Merge branch 'master' into 0.11
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 29 Aug 2011 11:43:59 +0000 (13:43 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 29 Aug 2011 11:43:59 +0000 (13:43 +0200)
Conflicts:
sys/v4l2/v4l2src_calls.c

383 files changed:
Makefile.am
REQUIREMENTS
common
configure.ac
docs/plugins/Makefile.am
docs/plugins/gst-plugins-good-plugins-docs.sgml
docs/plugins/gst-plugins-good-plugins-sections.txt
docs/plugins/inspect/plugin-esdsink.xml [deleted file]
docs/plugins/inspect/plugin-gconfelements.xml [deleted file]
ext/Makefile.am
ext/aalib/Makefile.am
ext/aalib/gstaasink.c
ext/aalib/gstaasink.h
ext/esd/Makefile.am [deleted file]
ext/esd/esdmon.c [deleted file]
ext/esd/esdmon.h [deleted file]
ext/esd/esdsink.c [deleted file]
ext/esd/esdsink.h [deleted file]
ext/esd/gstesd.c [deleted file]
ext/flac/gstflacdec.c
ext/flac/gstflacenc.c
ext/flac/gstflactag.c
ext/gconf/Makefile.am [deleted file]
ext/gconf/gstgconf.c [deleted file]
ext/gconf/gstgconf.h [deleted file]
ext/gconf/gstgconfaudiosink.c [deleted file]
ext/gconf/gstgconfaudiosink.h [deleted file]
ext/gconf/gstgconfaudiosrc.c [deleted file]
ext/gconf/gstgconfaudiosrc.h [deleted file]
ext/gconf/gstgconfelements.c [deleted file]
ext/gconf/gstgconfelements.h [deleted file]
ext/gconf/gstgconfvideosink.c [deleted file]
ext/gconf/gstgconfvideosink.h [deleted file]
ext/gconf/gstgconfvideosrc.c [deleted file]
ext/gconf/gstgconfvideosrc.h [deleted file]
ext/gconf/gstswitchsink.c [deleted file]
ext/gconf/gstswitchsink.h [deleted file]
ext/gconf/gstswitchsrc.c [deleted file]
ext/gconf/gstswitchsrc.h [deleted file]
ext/hal/Makefile.am [deleted file]
ext/hal/gsthalaudiosink.c [deleted file]
ext/hal/gsthalaudiosink.h [deleted file]
ext/hal/gsthalaudiosrc.c [deleted file]
ext/hal/gsthalaudiosrc.h [deleted file]
ext/hal/gsthalelements.c [deleted file]
ext/hal/gsthalelements.h [deleted file]
ext/hal/hal.c [deleted file]
ext/hal/hal.h [deleted file]
ext/jack/gstjack.h
ext/jack/gstjackaudiosink.c
ext/jack/gstjackaudiosrc.c
ext/jpeg/Makefile.am
ext/jpeg/gstjpeg.c
ext/jpeg/gstjpegdec.c
ext/jpeg/gstjpegdec.h
ext/jpeg/gstjpegenc.c
ext/jpeg/gstjpegenc.h
ext/libcaca/Makefile.am
ext/libcaca/gstcacasink.c
ext/libcaca/gstcacasink.h
ext/pulse/pulsemixer.c
ext/pulse/pulsesink.c
ext/pulse/pulsesrc.c
ext/pulse/pulsesrc.h
ext/pulse/pulseutil.c
ext/soup/gstsouphttpsrc.c
ext/speex/gstspeexdec.c
ext/speex/gstspeexenc.c
ext/taglib/gstid3v2mux.cc
gconf/.gitignore [deleted file]
gconf/Makefile.am [deleted file]
gconf/gstreamer.schemas.in [deleted file]
gst-plugins-good.spec.in
gst/alpha/gstalpha.c
gst/alpha/gstalpha.h
gst/alpha/gstalphacolor.c
gst/alpha/gstalphacolor.h
gst/apetag/gstapedemux.c
gst/audiofx/audioamplify.c
gst/audiofx/audioamplify.h
gst/audiofx/audiochebband.c
gst/audiofx/audiocheblimit.c
gst/audiofx/audiodynamic.c
gst/audiofx/audioecho.c
gst/audiofx/audiofirfilter.c
gst/audiofx/audiofirfilter.h
gst/audiofx/audiofxbasefirfilter.c
gst/audiofx/audiofxbaseiirfilter.c
gst/audiofx/audioiirfilter.c
gst/audiofx/audioiirfilter.h
gst/audiofx/audioinvert.c
gst/audiofx/audiokaraoke.c
gst/audiofx/audiokaraoke.h
gst/audiofx/audiopanorama.c
gst/audiofx/audiowsincband.c
gst/audiofx/audiowsincband.h
gst/audiofx/audiowsinclimit.c
gst/audioparsers/gstaacparse.c
gst/audioparsers/gstac3parse.c
gst/audioparsers/gstamrparse.c
gst/audioparsers/gstdcaparse.c
gst/audioparsers/gstflacparse.c
gst/audioparsers/gstmpegaudioparse.c
gst/auparse/Makefile.am
gst/auparse/gstauparse.c
gst/auparse/gstauparse.h
gst/autodetect/gstautoaudiosink.c
gst/autodetect/gstautoaudiosrc.c
gst/autodetect/gstautovideosink.c
gst/autodetect/gstautovideosrc.c
gst/avi/Makefile.am
gst/avi/gstavidemux.c
gst/avi/gstavidemux.h
gst/avi/gstavimux.c
gst/avi/gstavisubtitle.c
gst/cutter/gstcutter.c
gst/cutter/gstcutter.h
gst/debugutils/Makefile.am
gst/debugutils/breakmydata.c
gst/debugutils/cpureport.c
gst/debugutils/efence.c
gst/debugutils/gstcapsdebug.c
gst/debugutils/gstcapssetter.c
gst/debugutils/gstdebug.c
gst/debugutils/gstnavigationtest.c
gst/debugutils/gstnavigationtest.h
gst/debugutils/gstnavseek.c
gst/debugutils/gstpushfilesrc.c
gst/debugutils/gsttaginject.c
gst/debugutils/progressreport.c
gst/debugutils/rndbuffersize.c
gst/debugutils/testplugin.c
gst/debugutils/tests.c
gst/effectv/gstaging.c
gst/effectv/gstaging.h
gst/effectv/gstdice.c
gst/effectv/gstdice.h
gst/effectv/gstedge.c
gst/effectv/gstedge.h
gst/effectv/gstop.c
gst/effectv/gstop.h
gst/effectv/gstquark.c
gst/effectv/gstquark.h
gst/effectv/gstradioac.c
gst/effectv/gstradioac.h
gst/effectv/gstrev.c
gst/effectv/gstrev.h
gst/effectv/gstripple.c
gst/effectv/gstripple.h
gst/effectv/gstshagadelic.c
gst/effectv/gstshagadelic.h
gst/effectv/gststreak.c
gst/effectv/gststreak.h
gst/effectv/gstvertigo.c
gst/effectv/gstvertigo.h
gst/effectv/gstwarp.c
gst/effectv/gstwarp.h
gst/equalizer/gstiirequalizer.c
gst/equalizer/gstiirequalizer10bands.c
gst/equalizer/gstiirequalizer3bands.c
gst/equalizer/gstiirequalizernbands.c
gst/flv/gstflvdemux.c
gst/flv/gstflvdemux.h
gst/flv/gstflvmux.c
gst/goom/gstgoom.c
gst/goom/gstgoom.h
gst/imagefreeze/gstimagefreeze.c
gst/isomp4/Makefile.am
gst/isomp4/atoms.c
gst/isomp4/atoms.h
gst/isomp4/atomsrecovery.c
gst/isomp4/gstqtmoovrecover.c
gst/isomp4/gstqtmux.c
gst/isomp4/gstqtmux.h
gst/isomp4/gstqtmuxmap.c
gst/isomp4/gstrtpxqtdepay.c
gst/isomp4/qtdemux.c
gst/isomp4/qtdemux.h
gst/level/Makefile.am
gst/level/gstlevel.c
gst/level/gstlevel.h
gst/matroska/matroska-demux.c
gst/multifile/gstmultifilesink.c
gst/multifile/gstmultifilesrc.c
gst/multipart/multipartdemux.c
gst/multipart/multipartmux.c
gst/multipart/multipartmux.h
gst/replaygain/Makefile.am
gst/replaygain/gstrganalysis.c
gst/replaygain/gstrglimiter.c
gst/replaygain/gstrgvolume.c
gst/rtp/Makefile.am
gst/rtp/gstasteriskh263.c
gst/rtp/gstrtp.c
gst/rtp/gstrtpL16depay.c
gst/rtp/gstrtpL16pay.c
gst/rtp/gstrtpac3depay.c
gst/rtp/gstrtpac3pay.c
gst/rtp/gstrtpamrdepay.c
gst/rtp/gstrtpamrpay.c
gst/rtp/gstrtpbvdepay.c
gst/rtp/gstrtpbvpay.c
gst/rtp/gstrtpceltdepay.c
gst/rtp/gstrtpceltpay.c
gst/rtp/gstrtpdepay.c [deleted file]
gst/rtp/gstrtpdepay.h [deleted file]
gst/rtp/gstrtpdvdepay.c
gst/rtp/gstrtpdvpay.c
gst/rtp/gstrtpg722depay.c
gst/rtp/gstrtpg722pay.c
gst/rtp/gstrtpg723depay.c
gst/rtp/gstrtpg723pay.c
gst/rtp/gstrtpg726depay.c
gst/rtp/gstrtpg726pay.c
gst/rtp/gstrtpg729depay.c
gst/rtp/gstrtpg729pay.c
gst/rtp/gstrtpgsmdepay.c
gst/rtp/gstrtpgsmpay.c
gst/rtp/gstrtpgstdepay.c
gst/rtp/gstrtpgstpay.c
gst/rtp/gstrtph263depay.c
gst/rtp/gstrtph263pay.c
gst/rtp/gstrtph263pay.h
gst/rtp/gstrtph263pdepay.c
gst/rtp/gstrtph263ppay.c
gst/rtp/gstrtph264depay.c
gst/rtp/gstrtph264pay.c
gst/rtp/gstrtpilbcdepay.c
gst/rtp/gstrtpilbcpay.c
gst/rtp/gstrtpj2kdepay.c
gst/rtp/gstrtpj2kpay.c
gst/rtp/gstrtpjpegdepay.c
gst/rtp/gstrtpjpegpay.c
gst/rtp/gstrtpmp1sdepay.c
gst/rtp/gstrtpmp2tdepay.c
gst/rtp/gstrtpmp2tpay.c
gst/rtp/gstrtpmp4adepay.c
gst/rtp/gstrtpmp4apay.c
gst/rtp/gstrtpmp4gdepay.c
gst/rtp/gstrtpmp4gpay.c
gst/rtp/gstrtpmp4vdepay.c
gst/rtp/gstrtpmp4vpay.c
gst/rtp/gstrtpmpadepay.c
gst/rtp/gstrtpmpapay.c
gst/rtp/gstrtpmparobustdepay.c
gst/rtp/gstrtpmpvdepay.c
gst/rtp/gstrtpmpvpay.c
gst/rtp/gstrtppcmadepay.c
gst/rtp/gstrtppcmapay.c
gst/rtp/gstrtppcmudepay.c
gst/rtp/gstrtppcmupay.c
gst/rtp/gstrtpqcelpdepay.c
gst/rtp/gstrtpqdmdepay.c
gst/rtp/gstrtpsirendepay.c
gst/rtp/gstrtpsirenpay.c
gst/rtp/gstrtpspeexdepay.c
gst/rtp/gstrtpspeexpay.c
gst/rtp/gstrtpsv3vdepay.c
gst/rtp/gstrtptheoradepay.c
gst/rtp/gstrtptheorapay.c
gst/rtp/gstrtpvorbisdepay.c
gst/rtp/gstrtpvorbispay.c
gst/rtp/gstrtpvrawdepay.c
gst/rtp/gstrtpvrawdepay.h
gst/rtp/gstrtpvrawpay.c
gst/rtp/gstrtpvrawpay.h
gst/rtpmanager/gstrtpbin.c
gst/rtpmanager/gstrtpjitterbuffer.c
gst/rtpmanager/gstrtpptdemux.c
gst/rtpmanager/gstrtpsession.c
gst/rtpmanager/gstrtpssrcdemux.c
gst/rtpmanager/rtpjitterbuffer.c
gst/rtpmanager/rtpsession.c
gst/rtpmanager/rtpsource.c
gst/rtsp/gstrtpdec.c
gst/rtsp/gstrtspsrc.c
gst/rtsp/gstrtspsrc.h
gst/shapewipe/gstshapewipe.c
gst/spectrum/gstspectrum.c
gst/udp/gstdynudpsink.c
gst/udp/gstmultiudpsink.c
gst/udp/gstudp.c
gst/udp/gstudpsink.c
gst/udp/gstudpsrc.c
gst/videofilter/gstgamma.c
gst/videofilter/gstgamma.h
gst/videofilter/gstvideobalance.c
gst/videofilter/gstvideobalance.h
gst/videofilter/gstvideoflip.c
gst/videofilter/gstvideoflip.h
gst/videomixer/gstcollectpads2.c
gst/wavenc/gstwavenc.c
gst/wavparse/gstwavparse.c
gst/wavparse/gstwavparse.h
gst/y4m/Makefile.am
gst/y4m/gsty4mencode.c
gst/y4m/gsty4mencode.h
m4/Makefile.am
m4/as-arts.m4 [deleted file]
m4/esd.m4 [deleted file]
m4/gconf-2.m4 [deleted file]
po/POTFILES.in
po/af.po
po/az.po
po/bg.po
po/ca.po
po/cs.po
po/da.po
po/de.po
po/el.po
po/en_GB.po
po/es.po
po/eu.po
po/fi.po
po/fr.po
po/gl.po
po/hu.po
po/id.po
po/it.po
po/ja.po
po/lt.po
po/lv.po
po/mt.po
po/nb.po
po/nl.po
po/or.po
po/pl.po
po/pt_BR.po
po/ro.po
po/ru.po
po/sk.po
po/sl.po
po/sq.po
po/sr.po
po/sv.po
po/tr.po
po/uk.po
po/vi.po
po/zh_CN.po
po/zh_HK.po
po/zh_TW.po
sys/oss/gstosshelper.c
sys/oss/gstosssink.c
sys/oss/gstosssrc.c
sys/oss4/oss4-mixer-slider.c
sys/v4l2/Makefile.am
sys/v4l2/gstv4l2.c
sys/v4l2/gstv4l2bufferpool.c
sys/v4l2/gstv4l2bufferpool.h
sys/v4l2/gstv4l2colorbalance.c
sys/v4l2/gstv4l2object.c
sys/v4l2/gstv4l2object.h
sys/v4l2/gstv4l2radio.c
sys/v4l2/gstv4l2sink.c
sys/v4l2/gstv4l2sink.h
sys/v4l2/gstv4l2src.c
sys/v4l2/gstv4l2src.h
sys/v4l2/gstv4l2tuner.c
sys/v4l2/gstv4l2videooverlay.c [moved from sys/v4l2/gstv4l2xoverlay.c with 90% similarity]
sys/v4l2/gstv4l2videooverlay.h [moved from sys/v4l2/gstv4l2xoverlay.h with 60% similarity]
sys/v4l2/gstv4l2vidorient.c
sys/v4l2/v4l2_calls.c
sys/v4l2/v4l2_calls.h
sys/v4l2/v4l2src_calls.c [deleted file]
sys/v4l2/v4l2src_calls.h [deleted file]
sys/ximage/gstximagesrc.c
sys/ximage/gstximagesrc.h
sys/ximage/ximageutil.c
sys/ximage/ximageutil.h
tests/check/Makefile.am
tests/check/elements/audioinvert.c
tests/check/elements/autodetect.c
tests/check/elements/level.c
tests/check/elements/parser.c
tests/check/elements/rtp-payloading.c
tests/check/elements/rtpjitterbuffer.c
tests/examples/level/level-example.c
tests/examples/pulse/Makefile.am
tests/examples/spectrum/spectrum-example.c
tests/examples/v4l2/Makefile.am
tests/icles/Makefile.am
tests/icles/gdkpixbufsink-test.c
tests/icles/videocrop-test.c

index fb78f5d..0119fad 100644 (file)
@@ -1,11 +1,5 @@
 DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc
 
-if USE_GCONFTOOL
-GCONF_DIR = gconf
-else
-GCONF_DIR =
-endif
-
 ALWAYS_SUBDIRS =               \
        gst sys ext             \
        tests                   \
@@ -15,14 +9,9 @@ ALWAYS_SUBDIRS =              \
        m4                      \
        pkgconfig
 
-SUBDIRS =                      \
-       $(ALWAYS_SUBDIRS)       \
-       $(GCONF_DIR)
-
-DIST_SUBDIRS =                         \
-       $(ALWAYS_SUBDIRS)       \
-       gconf
+SUBDIRS = $(ALWAYS_SUBDIRS)
 
+DIST_SUBDIRS = $(ALWAYS_SUBDIRS)
 
 # include before EXTRA_DIST for win32 assignment
 include $(top_srcdir)/common/win32.mak
index 2b9b535..ddae38a 100644 (file)
@@ -89,22 +89,11 @@ Version:    >= 0.71
 Plugins:       cdio (cdiocddasrc)
 URL:           http://www.gnu.org/software/libcdio/
 
-Package:       ESound
-Version:       >= 0.2.12
-Plugins:       esdsink
-URL:           http://www.gnome.org/
-
 Package:       FLAC
 Version:       == 1.1.2
 Plugins:       flac (flacenc, flacdec)
 URL:           http://flac.sourceforge.net/
 
-Package:       GConf
-Version:       >= 2.0
-Plugins:       gconfelements (gconfvideosink, gconfvideosrc, gconfaudiosink,
-               gconfaudiosrc)
-URL:           http://www.gnome.org/
-
 Package:       HAL
 Version:       >= 0.5.6
 Plugins:       halelements (halaudiosink, halaudiosrc)
diff --git a/common b/common
index 605cd9a..50b34ab 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 605cd9a65ed61505f24b840d3fe8e252be72b151
+Subproject commit 50b34abb468b6572a92f6700552f6f541c655be8
index eab345d..1ca8435 100644 (file)
@@ -5,7 +5,7 @@ dnl please read gstreamer/docs/random/autotools before changing this file
 dnl initialize autoconf
 dnl releases only do -Wall, git and prerelease does -Werror too
 dnl use a three digit version number for releases, and four for git/pre
-AC_INIT(GStreamer Good Plug-ins, 0.10.30.1,
+AC_INIT(GStreamer Good Plug-ins, 0.11.0.1,
     http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer,
     gst-plugins-good)
 
@@ -40,7 +40,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],
 dnl our libraries and install dirs use major.minor as a version
 GST_MAJORMINOR=$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR
 dnl we override it here if we need to for the release candidate of new series
-GST_MAJORMINOR=0.10
+GST_MAJORMINOR=0.11
 AC_SUBST(GST_MAJORMINOR)
 
 AG_GST_LIBTOOL_PREPARE
@@ -54,8 +54,8 @@ AC_LIBTOOL_WIN32_DLL
 AM_PROG_LIBTOOL
 
 dnl *** required versions of GStreamer stuff ***
-GST_REQ=0.10.35.1
-GSTPB_REQ=0.10.35.1
+GST_REQ=0.11.0
+GSTPB_REQ=0.11.0
 
 dnl *** autotools stuff ****
 
@@ -130,10 +130,6 @@ AG_GST_CHECK_DOWHILE_MACROS
 AC_PATH_PROG(VALGRIND_PATH, valgrind, no)
 AM_CONDITIONAL(HAVE_VALGRIND, test ! "x$VALGRIND_PATH" = "xno")
 
-dnl check for gconftool-2
-dnl this macro defines an am conditional, so it needs to be run always
-AM_GCONF_SOURCE_2
-
 dnl check for documentation tools
 GTK_DOC_CHECK([1.3])
 AS_PATH_PYTHON([2.1])
@@ -266,19 +262,6 @@ fi
 AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes")
 AM_CONDITIONAL(HAVE_GTK_X11, test "x$HAVE_GTK_X11" = "xyes")
 
-dnl should we install schemas ?
-translit(dnm, m, l) AM_CONDITIONAL(USE_GCONFTOOL, true)
-AG_GST_CHECK_FEATURE(GCONFTOOL, [GConf schemas], , [
-  AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
-  if test x$GCONFTOOL = xno; then
-    AC_MSG_WARN(Not installing GConf schemas)
-    HAVE_GCONFTOOL="no"
-  else
-    HAVE_GCONFTOOL="yes"
-  fi
-  AC_SUBST(HAVE_GCONFTOOL)
-])
-
 dnl *** set variables based on configure arguments ***
 
 dnl set license and copyright notice
@@ -327,9 +310,18 @@ AG_GST_DEFAULT_ELEMENTS
 
 dnl *** plug-ins to include ***
 
+dnl Non ported plugins (non-dependant, then dependant)
+dnl Make sure you have a space before and after all plugins
+GST_PLUGINS_NONPORTED=" deinterlace flx goom2k1 icydemux id3demux \
+ imagefreeze interleave law matroska monoscope shapewipe smpte \
+ videobox videocrop videomixer \
+ annodex apetag cairo cairo_gobject dv1394 flac gdk_pixbuf libdv libpng \
+ oss oss4 shout2 \
+ soup taglib wavpack "
+AC_SUBST(GST_PLUGINS_NONPORTED)
+
 dnl these are all the gst plug-ins, compilable without additional libs
 dnl videofilter is at the top because others depend on it
-AG_GST_CHECK_PLUGIN(videofilter)
 AG_GST_CHECK_PLUGIN(alpha)
 AG_GST_CHECK_PLUGIN(apetag)
 AG_GST_CHECK_PLUGIN(audiofx)
@@ -343,13 +335,13 @@ AG_GST_CHECK_PLUGIN(deinterlace)
 AG_GST_CHECK_PLUGIN(effectv)
 AG_GST_CHECK_PLUGIN(equalizer)
 AG_GST_CHECK_PLUGIN(flv)
-AG_GST_CHECK_PLUGIN(id3demux)
-AG_GST_CHECK_PLUGIN(icydemux)
-AG_GST_CHECK_PLUGIN(interleave)
 AG_GST_CHECK_PLUGIN(flx)
 AG_GST_CHECK_PLUGIN(goom)
 AG_GST_CHECK_PLUGIN(goom2k1)
+AG_GST_CHECK_PLUGIN(icydemux)
+AG_GST_CHECK_PLUGIN(id3demux)
 AG_GST_CHECK_PLUGIN(imagefreeze)
+AG_GST_CHECK_PLUGIN(interleave)
 AG_GST_CHECK_PLUGIN(isomp4)
 AG_GST_CHECK_PLUGIN(law)
 AG_GST_CHECK_PLUGIN(level)
@@ -367,6 +359,7 @@ AG_GST_CHECK_PLUGIN(spectrum)
 AG_GST_CHECK_PLUGIN(udp)
 AG_GST_CHECK_PLUGIN(videobox)
 AG_GST_CHECK_PLUGIN(videocrop)
+AG_GST_CHECK_PLUGIN(videofilter)
 AG_GST_CHECK_PLUGIN(videomixer)
 AG_GST_CHECK_PLUGIN(wavenc)
 AG_GST_CHECK_PLUGIN(wavparse)
@@ -736,41 +729,18 @@ AG_GST_CHECK_FEATURE(CAIRO_GOBJECT,
   AG_GST_PKG_CHECK_MODULES(CAIRO_GOBJECT, cairo-gobject >= 1.10.0)
 ])
 
-dnl **** ESound ****
-translit(dnm, m, l) AM_CONDITIONAL(USE_ESD, true)
-AG_GST_CHECK_FEATURE(ESD, [ESounD sound daemon], esdsink, [
-  AG_GST_PKG_CHECK_MODULES(ESD, esound >= 0.2.12)
-  if test $HAVE_ESD = no
-  then
-    AM_PATH_ESD(0.2.12, HAVE_ESD="yes")
-    AS_SCRUB_INCLUDE(ESD_CFLAGS)
-  fi
-])
-
 dnl *** FLAC ***
 translit(dnm, m, l) AM_CONDITIONAL(USE_FLAC, true)
 AG_GST_CHECK_FEATURE(FLAC, [FLAC lossless audio], flac, [
   AG_GST_PKG_CHECK_MODULES(FLAC, flac >= 1.1.4)
 ])
 
-dnl *** GConf ***
-translit(dnm, m, l) AM_CONDITIONAL(USE_GCONF, true)
-AG_GST_CHECK_FEATURE(GCONF, [GConf libraries], gconfelements, [
-  AG_GST_PKG_CHECK_MODULES(GCONF, gconf-2.0)
-])
-
 dnl *** GDK pixbuf ***
 translit(dnm, m, l) AM_CONDITIONAL(USE_GDK_PIXBUF, true)
 AG_GST_CHECK_FEATURE(GDK_PIXBUF, [GDK pixbuf], gdkpixbuf, [
   AG_GST_PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0 >= 2.8.0)
 ])
 
-dnl *** HAL ***
-translit(dnm, m, l) AM_CONDITIONAL(USE_HAL, true)
-AG_GST_CHECK_FEATURE(HAL, [HAL libraries], halelements, [
-  AG_GST_PKG_CHECK_MODULES(HAL, [hal >= 0.5.6, dbus-1 >= 0.32])
-])
-
 dnl *** Jack ***
 translit(dnm, m, l) AM_CONDITIONAL(USE_JACK, true)
 AG_GST_CHECK_FEATURE(JACK, Jack, jack, [
@@ -1022,13 +992,9 @@ AM_CONDITIONAL(USE_CAIRO, false)
 AM_CONDITIONAL(USE_CAIRO_GOBJECT, false)
 AM_CONDITIONAL(USE_DIRECTSOUND, false)
 AM_CONDITIONAL(USE_DV1394, false)
-AM_CONDITIONAL(USE_ESD, false)
 AM_CONDITIONAL(USE_FLAC, false)
-AM_CONDITIONAL(USE_GCONF, false)
-AM_CONDITIONAL(USE_GCONFTOOL, false)
 AM_CONDITIONAL(USE_GDK_PIXBUF, false)
 AM_CONDITIONAL(USE_GST_V4L2, false)
-AM_CONDITIONAL(USE_HAL, false)
 AM_CONDITIONAL(USE_JACK, false)
 AM_CONDITIONAL(USE_JPEG, false)
 AM_CONDITIONAL(USE_LIBCACA, false)
@@ -1091,6 +1057,7 @@ dnl FIXME: do we want to rename to GST_ALL_* ?
 dnl prefer internal headers to already installed ones
 dnl also add builddir include for enumtypes and marshal
 dnl add ERROR_CFLAGS, but overridable
+GST_CFLAGS="$GST_CFLAGS -DGST_USE_UNSTABLE_API"
 GST_CXXFLAGS="-I\$(top_srcdir)/gst-libs $GST_CFLAGS $GLIB_EXTRA_CFLAGS \$(GST_OPTION_CXXFLAGS)"
 GST_CFLAGS="-I\$(top_srcdir)/gst-libs $GST_CFLAGS $GLIB_EXTRA_CFLAGS \$(GST_OPTION_CFLAGS)"
 AC_SUBST(GST_CFLAGS)
@@ -1160,11 +1127,8 @@ ext/aalib/Makefile
 ext/annodex/Makefile
 ext/cairo/Makefile
 ext/dv/Makefile
-ext/esd/Makefile
 ext/flac/Makefile
-ext/gconf/Makefile
 ext/gdk_pixbuf/Makefile
-ext/hal/Makefile
 ext/jack/Makefile
 ext/jpeg/Makefile
 ext/libcaca/Makefile
@@ -1202,8 +1166,6 @@ tests/examples/spectrum/Makefile
 tests/examples/v4l2/Makefile
 tests/files/Makefile
 tests/icles/Makefile
-gconf/Makefile
-gconf/gstreamer.schemas
 common/Makefile
 common/m4/Makefile
 m4/Makefile
@@ -1247,7 +1209,7 @@ sed \
     -e "s/.* PACKAGE_STRING$/#define PACKAGE_STRING \"$PACKAGE_STRING\"/" \
     -e 's/.* PACKAGE_TARNAME$/#define PACKAGE_TARNAME "'$PACKAGE_TARNAME'"/' \
     -e 's/.* PACKAGE_VERSION$/#define PACKAGE_VERSION "'$PACKAGE_VERSION'"/' \
-    -e 's/.* PLUGINDIR$/#ifdef _DEBUG\n#  define PLUGINDIR PREFIX "\\\\debug\\\\lib\\\\gstreamer-0.10"\n#else\n#  define PLUGINDIR PREFIX "\\\\lib\\\\gstreamer-0.10"\n#endif/' \
+    -e 's/.* PLUGINDIR$/#ifdef _DEBUG\n#  define PLUGINDIR PREFIX "\\\\debug\\\\lib\\\\gstreamer-0.11"\n#else\n#  define PLUGINDIR PREFIX "\\\\lib\\\\gstreamer-0.11"\n#endif/' \
     -e 's/.* USE_BINARY_REGISTRY$/#define USE_BINARY_REGISTRY/' \
     -e 's/.* VERSION$/#define VERSION "'$VERSION'"/' \
     -e "s/.* DEFAULT_AUDIOSINK$/#define DEFAULT_AUDIOSINK \"directsoundsink\"/" \
index 0219ecc..3702520 100644 (file)
@@ -84,17 +84,10 @@ EXTRA_HFILES = \
        $(top_srcdir)/ext/cairo/gstcairooverlay.h \
        $(top_srcdir)/ext/dv/gstdvdec.h \
        $(top_srcdir)/ext/dv/gstdvdemux.h \
-       $(top_srcdir)/ext/esd/esdsink.h \
        $(top_srcdir)/ext/flac/gstflacdec.h \
        $(top_srcdir)/ext/flac/gstflacenc.h \
        $(top_srcdir)/ext/flac/gstflactag.h \
-       $(top_srcdir)/ext/gconf/gstgconfaudiosrc.h \
-       $(top_srcdir)/ext/gconf/gstgconfaudiosink.h \
-       $(top_srcdir)/ext/gconf/gstgconfvideosrc.h \
-       $(top_srcdir)/ext/gconf/gstgconfvideosink.h \
        $(top_srcdir)/ext/gdk_pixbuf/gstgdkpixbufsink.h \
-       $(top_srcdir)/ext/hal/gsthalaudiosink.h \
-       $(top_srcdir)/ext/hal/gsthalaudiosrc.h \
        $(top_srcdir)/ext/jack/gstjackaudiosrc.h \
        $(top_srcdir)/ext/jack/gstjackaudiosink.h \
        $(top_srcdir)/ext/jpeg/gstjpegdec.h \
index 8b198ac..7d7fc9a 100644 (file)
@@ -72,7 +72,6 @@
     <xi:include href="xml/element-equalizer-10bands.xml" />
     <xi:include href="xml/element-equalizer-3bands.xml" />
     <xi:include href="xml/element-equalizer-nbands.xml" />
-    <xi:include href="xml/element-esdsink.xml" />
     <xi:include href="xml/element-flacdec.xml" />
     <xi:include href="xml/element-flacenc.xml" />
     <xi:include href="xml/element-flacparse.xml" />
     <xi:include href="xml/element-flvmux.xml" />
     <xi:include href="xml/element-flxdec.xml" />
     <xi:include href="xml/element-gamma.xml" />
-    <xi:include href="xml/element-gconfaudiosrc.xml" />
-    <xi:include href="xml/element-gconfaudiosink.xml" />
-    <xi:include href="xml/element-gconfvideosrc.xml" />
-    <xi:include href="xml/element-gconfvideosink.xml" />
     <xi:include href="xml/element-gdkpixbufsink.xml" />
     <xi:include href="xml/element-goom.xml" />
     <xi:include href="xml/element-goom2k1.xml" />
     <xi:include href="xml/plugin-efence.xml" />
     <xi:include href="xml/plugin-equalizer.xml" />
     <xi:include href="xml/plugin-effectv.xml" />
-    <xi:include href="xml/plugin-esdsink.xml" />
     <xi:include href="xml/plugin-flac.xml" />
     <xi:include href="xml/plugin-flv.xml" />
     <xi:include href="xml/plugin-flxdec.xml" />
-    <xi:include href="xml/plugin-gconfelements.xml" />
     <xi:include href="xml/plugin-gdkpixbuf.xml" />
     <xi:include href="xml/plugin-goom.xml" />
     <xi:include href="xml/plugin-goom2k1.xml" />
index f3b4cd3..0b21cb5 100644 (file)
@@ -798,20 +798,6 @@ ProcessFunc
 </SECTION>
 
 <SECTION>
-<FILE>element-esdsink</FILE>
-<TITLE>esdsink</TITLE>
-GstEsdSink
-<SUBSECTION Standard>
-GstEsdSinkClass
-GST_TYPE_ESDSINK
-GST_ESDSINK
-GST_ESDSINK_CLASS
-GST_IS_ESDSINK
-GST_IS_ESDSINK_CLASS
-gst_esdsink_get_type
-</SECTION>
-
-<SECTION>
 <FILE>element-flacdec</FILE>
 <TITLE>flacdec</TITLE>
 GstFlacDec
@@ -928,62 +914,6 @@ gst_gamma_get_type
 </SECTION>
 
 <SECTION>
-<FILE>element-gconfaudiosrc</FILE>
-<TITLE>gconfaudiosrc</TITLE>
-GstGConfAudioSrc
-<SUBSECTION Standard>
-GstGConfAudioSrcClass
-GST_GCONF_AUDIO_SRC
-GST_IS_GCONF_AUDIO_SRC
-GST_TYPE_GCONF_AUDIO_SRC
-GST_GCONF_AUDIO_SRC_CLASS
-GST_IS_GCONF_AUDIO_SRC_CLASS
-gst_gconf_audio_src_get_type
-</SECTION>
-
-<SECTION>
-<FILE>element-gconfaudiosink</FILE>
-<TITLE>gconfaudiosink</TITLE>
-GstGConfAudioSink
-<SUBSECTION Standard>
-GstGConfAudioSinkClass
-GST_GCONF_AUDIO_SINK
-GST_IS_GCONF_AUDIO_SINK
-GST_TYPE_GCONF_AUDIO_SINK
-GST_GCONF_AUDIO_SINK_CLASS
-GST_IS_GCONF_AUDIO_SINK_CLASS
-gst_gconf_audio_sink_get_type
-</SECTION>
-
-<SECTION>
-<FILE>element-gconfvideosrc</FILE>
-<TITLE>gconfvideosrc</TITLE>
-GstGConfVideoSrc
-<SUBSECTION Standard>
-GstGConfVideoSrcClass
-GST_GCONF_VIDEO_SRC
-GST_IS_GCONF_VIDEO_SRC
-GST_TYPE_GCONF_VIDEO_SRC
-GST_GCONF_VIDEO_SRC_CLASS
-GST_IS_GCONF_VIDEO_SRC_CLASS
-gst_gconf_video_src_get_type
-</SECTION>
-
-<SECTION>
-<FILE>element-gconfvideosink</FILE>
-<TITLE>gconfvideosink</TITLE>
-GstGConfVideoSink
-<SUBSECTION Standard>
-GstGConfVideoSinkClass
-GST_GCONF_VIDEO_SINK
-GST_IS_GCONF_VIDEO_SINK
-GST_TYPE_GCONF_VIDEO_SINK
-GST_GCONF_VIDEO_SINK_CLASS
-GST_IS_GCONF_VIDEO_SINK_CLASS
-gst_gconf_video_sink_get_type
-</SECTION>
-
-<SECTION>
 <FILE>element-gdkpixbufsink</FILE>
 <TITLE>gdkpixbufsink</TITLE>
 GstGdkPixbufSink
diff --git a/docs/plugins/inspect/plugin-esdsink.xml b/docs/plugins/inspect/plugin-esdsink.xml
deleted file mode 100644 (file)
index 13745b4..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<plugin>
-  <name>esdsink</name>
-  <description>ESD Element Plugins</description>
-  <filename>../../ext/esd/.libs/libgstesd.so</filename>
-  <basename>libgstesd.so</basename>
-  <version>0.10.30.1</version>
-  <license>LGPL</license>
-  <source>gst-plugins-good</source>
-  <package>GStreamer Good Plug-ins git</package>
-  <origin>Unknown package origin</origin>
-  <elements>
-    <element>
-      <name>esdsink</name>
-      <longname>Esound audio sink</longname>
-      <class>Sink/Audio</class>
-      <description>Plays audio to an esound server</description>
-      <author>Arwed von Merkatz &lt;v.merkatz@gmx.net&gt;</author>
-      <pads>
-        <caps>
-          <name>sink</name>
-          <direction>sink</direction>
-          <presence>always</presence>
-          <details>audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2 ]; audio/x-raw-int, signed=(boolean){ true, false }, width=(int)8, depth=(int)8, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2 ]</details>
-        </caps>
-      </pads>
-    </element>
-  </elements>
-</plugin>
diff --git a/docs/plugins/inspect/plugin-gconfelements.xml b/docs/plugins/inspect/plugin-gconfelements.xml
deleted file mode 100644 (file)
index f890dc6..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<plugin>
-  <name>gconfelements</name>
-  <description>elements wrapping the GStreamer/GConf audio/video output settings</description>
-  <filename>../../ext/gconf/.libs/libgstgconfelements.so</filename>
-  <basename>libgstgconfelements.so</basename>
-  <version>0.10.30.1</version>
-  <license>LGPL</license>
-  <source>gst-plugins-good</source>
-  <package>GStreamer Good Plug-ins git</package>
-  <origin>Unknown package origin</origin>
-  <elements>
-    <element>
-      <name>gconfaudiosink</name>
-      <longname>GConf audio sink</longname>
-      <class>Sink/Audio</class>
-      <description>Audio sink embedding the GConf-settings for audio output</description>
-      <author>Jan Schmidt &lt;thaytan@mad.scientist.com&gt;</author>
-      <pads>
-      </pads>
-    </element>
-    <element>
-      <name>gconfaudiosrc</name>
-      <longname>GConf audio source</longname>
-      <class>Source/Audio</class>
-      <description>Audio source embedding the GConf-settings for audio input</description>
-      <author>GStreamer maintainers &lt;gstreamer-devel@lists.sourceforge.net&gt;</author>
-      <pads>
-      </pads>
-    </element>
-    <element>
-      <name>gconfvideosink</name>
-      <longname>GConf video sink</longname>
-      <class>Sink/Video</class>
-      <description>Video sink embedding the GConf-settings for video output</description>
-      <author>GStreamer maintainers &lt;gstreamer-devel@lists.sourceforge.net&gt;</author>
-      <pads>
-      </pads>
-    </element>
-    <element>
-      <name>gconfvideosrc</name>
-      <longname>GConf video source</longname>
-      <class>Source/Video</class>
-      <description>Video source embedding the GConf-settings for video input</description>
-      <author>GStreamer maintainers &lt;gstreamer-devel@lists.sourceforge.net&gt;</author>
-      <pads>
-      </pads>
-    </element>
-  </elements>
-</plugin>
index 409408e..791fe00 100644 (file)
@@ -16,36 +16,18 @@ else
 CAIRO_DIR =
 endif
 
-if USE_ESD
-ESD_DIR = esd
-else
-ESD_DIR =
-endif
-
 if USE_FLAC
 FLAC_DIR = flac
 else
 FLAC_DIR =
 endif
 
-if USE_GCONF
-GCONF_DIR = gconf
-else
-GCONF_DIR =
-endif
-
 if USE_GDK_PIXBUF
 GDK_PIXBUF_DIR = gdk_pixbuf
 else
 GDK_PIXBUF_DIR =
 endif
 
-if USE_HAL
-HAL_DIR = hal
-else
-HAL_DIR =
-endif
-
 if USE_JACK
 JACK_DIR=jack
 else
@@ -136,11 +118,8 @@ SUBDIRS = \
        $(ANNODEX_DIR) \
        $(CAIRO_DIR) \
        $(DV1394_DIR) \
-       $(ESD_DIR) \
        $(FLAC_DIR) \
-       $(GCONF_DIR) \
        $(GDK_PIXBUF_DIR) \
-       $(HAL_DIR) \
        $(JACK_DIR) \
        $(JPEG_DIR) \
        $(LIBCACA_DIR) \
@@ -160,11 +139,8 @@ DIST_SUBDIRS = \
        annodex \
        cairo \
        dv \
-       esd \
        flac \
-       gconf \
        gdk_pixbuf \
-       hal \
        jack \
        jpeg \
        libcaca \
index 5820b24..8941704 100644 (file)
@@ -1,8 +1,8 @@
 plugin_LTLIBRARIES = libgstaasink.la
 
 libgstaasink_la_SOURCES = gstaasink.c
-libgstaasink_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(AALIB_CFLAGS)
-libgstaasink_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(AALIB_LIBS)
+libgstaasink_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AALIB_CFLAGS)
+libgstaasink_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) $(GST_BASE_LIBS) $(GST_LIBS) $(AALIB_LIBS)
 libgstaasink_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstaasink_la_LIBTOOLFLAGS = --tag=disable-static
 
index 06d3199..74cd068 100644 (file)
 #include <sys/time.h>
 
 #include "gstaasink.h"
-#include <gst/video/video.h>
 
 /* aasink signals and args */
 enum
 {
-  SIGNAL_FRAME_DISPLAYED,
-  SIGNAL_HAVE_SIZE,
   LAST_SIGNAL
 };
 
 
 enum
 {
-  ARG_0,
-  ARG_WIDTH,
-  ARG_HEIGHT,
-  ARG_DRIVER,
-  ARG_DITHER,
-  ARG_BRIGHTNESS,
-  ARG_CONTRAST,
-  ARG_GAMMA,
-  ARG_INVERSION,
-  ARG_RANDOMVAL,
-  ARG_FRAMES_DISPLAYED,
-  ARG_FRAME_TIME
+  PROP_0,
+  PROP_WIDTH,
+  PROP_HEIGHT,
+  PROP_DRIVER,
+  PROP_DITHER,
+  PROP_BRIGHTNESS,
+  PROP_CONTRAST,
+  PROP_GAMMA,
+  PROP_INVERSION,
+  PROP_RANDOMVAL,
+  PROP_FRAMES_DISPLAYED,
+  PROP_FRAME_TIME
 };
 
 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("I420"))
     );
 
-static void gst_aasink_base_init (gpointer g_class);
-static void gst_aasink_class_init (GstAASinkClass * klass);
-static void gst_aasink_init (GstAASink * aasink);
-
 static gboolean gst_aasink_setcaps (GstBaseSink * pad, GstCaps * caps);
 static void gst_aasink_get_times (GstBaseSink * sink, GstBuffer * buffer,
     GstClockTime * start, GstClockTime * end);
@@ -92,33 +85,8 @@ static void gst_aasink_get_property (GObject * object, guint prop_id,
 static GstStateChangeReturn gst_aasink_change_state (GstElement * element,
     GstStateChange transition);
 
-static GstElementClass *parent_class = NULL;
-static guint gst_aasink_signals[LAST_SIGNAL] = { 0 };
-
-GType
-gst_aasink_get_type (void)
-{
-  static GType aasink_type = 0;
-
-  if (!aasink_type) {
-    static const GTypeInfo aasink_info = {
-      sizeof (GstAASinkClass),
-      gst_aasink_base_init,
-      NULL,
-      (GClassInitFunc) gst_aasink_class_init,
-      NULL,
-      NULL,
-      sizeof (GstAASink),
-      0,
-      (GInstanceInitFunc) gst_aasink_init,
-    };
-
-    aasink_type =
-        g_type_register_static (GST_TYPE_BASE_SINK, "GstAASink", &aasink_info,
-        0);
-  }
-  return aasink_type;
-}
+#define gst_aasink_parent_class parent_class
+G_DEFINE_TYPE (GstAASink, gst_aasink, GST_TYPE_BASE_SINK);
 
 #define GST_TYPE_AADRIVERS (gst_aasink_drivers_get_type())
 static GType
@@ -186,18 +154,6 @@ gst_aasink_dither_get_type (void)
 }
 
 static void
-gst_aasink_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template));
-  gst_element_class_set_details_simple (element_class, "ASCII art video sink",
-      "Sink/Video",
-      "An ASCII art videosink", "Wim Taymans <wim.taymans@chello.be>");
-}
-
-static void
 gst_aasink_class_init (GstAASinkClass * klass)
 {
   GObjectClass *gobject_class;
@@ -208,55 +164,51 @@ gst_aasink_class_init (GstAASinkClass * klass)
   gstelement_class = (GstElementClass *) klass;
   gstbasesink_class = (GstBaseSinkClass *) klass;
 
-  parent_class = g_type_class_peek_parent (klass);
-
   gobject_class->set_property = gst_aasink_set_property;
   gobject_class->get_property = gst_aasink_get_property;
 
   /* FIXME: add long property descriptions */
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_WIDTH,
       g_param_spec_int ("width", "width", "width", G_MININT, G_MAXINT, 0,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_HEIGHT,
       g_param_spec_int ("height", "height", "height", G_MININT, G_MAXINT, 0,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DRIVER,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DRIVER,
       g_param_spec_enum ("driver", "driver", "driver", GST_TYPE_AADRIVERS, 0,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DITHER,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DITHER,
       g_param_spec_enum ("dither", "dither", "dither", GST_TYPE_AADITHER, 0,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BRIGHTNESS,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BRIGHTNESS,
       g_param_spec_int ("brightness", "brightness", "brightness", G_MININT,
           G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CONTRAST,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CONTRAST,
       g_param_spec_int ("contrast", "contrast", "contrast", G_MININT, G_MAXINT,
           0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GAMMA,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_GAMMA,
       g_param_spec_float ("gamma", "gamma", "gamma", 0.0, 5.0, 1.0,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_INVERSION,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_INVERSION,
       g_param_spec_boolean ("inversion", "inversion", "inversion", TRUE,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_RANDOMVAL,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_RANDOMVAL,
       g_param_spec_int ("randomval", "randomval", "randomval", G_MININT,
           G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FRAMES_DISPLAYED,
-      g_param_spec_int ("frames-displayed", "frames displayed",
-          "frames displayed", G_MININT, G_MAXINT, 0,
+  g_object_class_install_property (G_OBJECT_CLASS (klass),
+      PROP_FRAMES_DISPLAYED, g_param_spec_int ("frames-displayed",
+          "frames displayed", "frames displayed", G_MININT, G_MAXINT, 0,
           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FRAME_TIME,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FRAME_TIME,
       g_param_spec_int ("frame-time", "frame time", "frame time", G_MININT,
           G_MAXINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
-  gst_aasink_signals[SIGNAL_FRAME_DISPLAYED] =
-      g_signal_new ("frame-displayed", G_TYPE_FROM_CLASS (klass),
-      G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstAASinkClass, frame_displayed),
-      NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-  gst_aasink_signals[SIGNAL_HAVE_SIZE] =
-      g_signal_new ("have-size", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
-      G_STRUCT_OFFSET (GstAASinkClass, have_size), NULL, NULL,
-      gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "ASCII art video sink", "Sink/Video", "An ASCII art videosink",
+      "Wim Taymans <wim.taymans@chello.be>");
 
   gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_aasink_change_state);
 
@@ -282,24 +234,23 @@ static gboolean
 gst_aasink_setcaps (GstBaseSink * basesink, GstCaps * caps)
 {
   GstAASink *aasink;
-  GstStructure *structure;
+  GstVideoInfo info;
 
   aasink = GST_AASINK (basesink);
 
-  structure = gst_caps_get_structure (caps, 0);
-  gst_structure_get_int (structure, "width", &aasink->width);
-  gst_structure_get_int (structure, "height", &aasink->height);
-
-  /* FIXME aasink->format is never set */
-  g_print ("%d %d\n", aasink->width, aasink->height);
-
-  GST_DEBUG ("aasink: setting %08lx (%" GST_FOURCC_FORMAT ")",
-      aasink->format, GST_FOURCC_ARGS (aasink->format));
+  if (!gst_video_info_from_caps (&info, caps))
+    goto invalid_caps;
 
-  g_signal_emit (G_OBJECT (aasink), gst_aasink_signals[SIGNAL_HAVE_SIZE], 0,
-      aasink->width, aasink->height);
+  aasink->info = info;
 
   return TRUE;
+
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (aasink, "invalid caps");
+    return FALSE;
+  }
 }
 
 static void
@@ -319,10 +270,6 @@ gst_aasink_init (GstAASink * aasink)
   aasink->ascii_parms.inversion = 0;
   aasink->ascii_parms.randomval = 0;
   aasink->aa_driver = 0;
-
-  aasink->width = -1;
-  aasink->height = -1;
-
 }
 
 static void
@@ -367,22 +314,27 @@ gst_aasink_get_times (GstBaseSink * sink, GstBuffer * buffer,
     GstClockTime * start, GstClockTime * end)
 {
   *start = GST_BUFFER_TIMESTAMP (buffer);
-  *end = *start + GST_BUFFER_DURATION (buffer);
+  if (GST_BUFFER_DURATION_IS_VALID (buffer))
+    *end = *start + GST_BUFFER_DURATION (buffer);
 }
 
 static GstFlowReturn
 gst_aasink_render (GstBaseSink * basesink, GstBuffer * buffer)
 {
   GstAASink *aasink;
+  GstVideoFrame frame;
 
   aasink = GST_AASINK (basesink);
 
   GST_DEBUG ("render");
 
-  gst_aasink_scale (aasink, GST_BUFFER_DATA (buffer),   /* src */
+  if (!gst_video_frame_map (&frame, &aasink->info, buffer, GST_MAP_READ))
+    goto invalid_frame;
+
+  gst_aasink_scale (aasink, GST_VIDEO_FRAME_PLANE_DATA (&frame, 0),     /* src */
       aa_image (aasink->context),       /* dest */
-      aasink->width,            /* sw */
-      aasink->height,           /* sh */
+      GST_VIDEO_INFO_WIDTH (&aasink->info),     /* sw */
+      GST_VIDEO_INFO_HEIGHT (&aasink->info),    /* sh */
       aa_imgwidth (aasink->context),    /* dw */
       aa_imgheight (aasink->context));  /* dh */
 
@@ -390,8 +342,16 @@ gst_aasink_render (GstBaseSink * basesink, GstBuffer * buffer)
       0, 0, aa_imgwidth (aasink->context), aa_imgheight (aasink->context));
   aa_flush (aasink->context);
   aa_getevent (aasink->context, FALSE);
+  gst_video_frame_unmap (&frame);
 
   return GST_FLOW_OK;
+
+  /* ERRORS */
+invalid_frame:
+  {
+    GST_DEBUG_OBJECT (aasink, "invalid frame");
+    return GST_FLOW_ERROR;
+  }
 }
 
 
@@ -404,37 +364,37 @@ gst_aasink_set_property (GObject * object, guint prop_id, const GValue * value,
   aasink = GST_AASINK (object);
 
   switch (prop_id) {
-    case ARG_WIDTH:
+    case PROP_WIDTH:
       aasink->ascii_surf.width = g_value_get_int (value);
       break;
-    case ARG_HEIGHT:
+    case PROP_HEIGHT:
       aasink->ascii_surf.height = g_value_get_int (value);
       break;
-    case ARG_DRIVER:{
+    case PROP_DRIVER:{
       aasink->aa_driver = g_value_get_enum (value);
       break;
     }
-    case ARG_DITHER:{
+    case PROP_DITHER:{
       aasink->ascii_parms.dither = g_value_get_enum (value);
       break;
     }
-    case ARG_BRIGHTNESS:{
+    case PROP_BRIGHTNESS:{
       aasink->ascii_parms.bright = g_value_get_int (value);
       break;
     }
-    case ARG_CONTRAST:{
+    case PROP_CONTRAST:{
       aasink->ascii_parms.contrast = g_value_get_int (value);
       break;
     }
-    case ARG_GAMMA:{
+    case PROP_GAMMA:{
       aasink->ascii_parms.gamma = g_value_get_float (value);
       break;
     }
-    case ARG_INVERSION:{
+    case PROP_INVERSION:{
       aasink->ascii_parms.inversion = g_value_get_boolean (value);
       break;
     }
-    case ARG_RANDOMVAL:{
+    case PROP_RANDOMVAL:{
       aasink->ascii_parms.randomval = g_value_get_int (value);
       break;
     }
@@ -452,47 +412,47 @@ gst_aasink_get_property (GObject * object, guint prop_id, GValue * value,
   aasink = GST_AASINK (object);
 
   switch (prop_id) {
-    case ARG_WIDTH:{
+    case PROP_WIDTH:{
       g_value_set_int (value, aasink->ascii_surf.width);
       break;
     }
-    case ARG_HEIGHT:{
+    case PROP_HEIGHT:{
       g_value_set_int (value, aasink->ascii_surf.height);
       break;
     }
-    case ARG_DRIVER:{
+    case PROP_DRIVER:{
       g_value_set_enum (value, aasink->aa_driver);
       break;
     }
-    case ARG_DITHER:{
+    case PROP_DITHER:{
       g_value_set_enum (value, aasink->ascii_parms.dither);
       break;
     }
-    case ARG_BRIGHTNESS:{
+    case PROP_BRIGHTNESS:{
       g_value_set_int (value, aasink->ascii_parms.bright);
       break;
     }
-    case ARG_CONTRAST:{
+    case PROP_CONTRAST:{
       g_value_set_int (value, aasink->ascii_parms.contrast);
       break;
     }
-    case ARG_GAMMA:{
+    case PROP_GAMMA:{
       g_value_set_float (value, aasink->ascii_parms.gamma);
       break;
     }
-    case ARG_INVERSION:{
+    case PROP_INVERSION:{
       g_value_set_boolean (value, aasink->ascii_parms.inversion);
       break;
     }
-    case ARG_RANDOMVAL:{
+    case PROP_RANDOMVAL:{
       g_value_set_int (value, aasink->ascii_parms.randomval);
       break;
     }
-    case ARG_FRAMES_DISPLAYED:{
+    case PROP_FRAMES_DISPLAYED:{
       g_value_set_int (value, aasink->frames_displayed);
       break;
     }
-    case ARG_FRAME_TIME:{
+    case PROP_FRAME_TIME:{
       g_value_set_int (value, aasink->frame_time / 1000000);
       break;
     }
index 03bd2ea..e36e2a6 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <gst/gst.h>
 #include <gst/base/gstbasesink.h>
+#include <gst/video/video.h>
 
 #include <aalib.h>
 
@@ -48,8 +49,7 @@ typedef struct _GstAASinkClass GstAASinkClass;
 struct _GstAASink {
   GstBaseSink parent;
 
-  gulong format;
-  gint width, height;
+  GstVideoInfo info;
 
   gint frames_displayed;
   guint64 frame_time;
@@ -63,10 +63,6 @@ struct _GstAASink {
 
 struct _GstAASinkClass {
   GstBaseSinkClass parent_class;
-
-  /* signals */
-  void (*frame_displayed) (GstElement *element);
-  void (*have_size)       (GstElement *element, guint width, guint height);
 };
 
 GType gst_aasink_get_type(void);
diff --git a/ext/esd/Makefile.am b/ext/esd/Makefile.am
deleted file mode 100644 (file)
index a7a1464..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-plugin_LTLIBRARIES = libgstesd.la
-
-libgstesd_la_SOURCES = esdsink.c gstesd.c
-libgstesd_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(ESD_CFLAGS)
-libgstesd_la_LIBADD = \
-       $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) \
-       $(GST_BASE_LIBS) \
-       $(GST_LIBS) \
-       $(ESD_LIBS)
-libgstesd_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-libgstesd_la_LIBTOOLFLAGS = --tag=disable-static
-
-noinst_HEADERS = esdsink.h esdmon.h
-EXTRA_DIST =
diff --git a/ext/esd/esdmon.c b/ext/esd/esdmon.c
deleted file mode 100644 (file)
index 9cf9e7a..0000000
+++ /dev/null
@@ -1,466 +0,0 @@
-/* GStreamer
- * Copyright (C) <2001,2002> Richard Boulton <richard-gst@tartarus.org>
- *
- * Based on example.c:
- * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
- *
- * 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.
- */
-/**
- * SECTION:element-esdmon
- * @see_also: #GstAlsaSrc, #GstAutoAudioSrc
- *
- * This element records sound from an already-running Enlightened Sound Daemon
- * (ESound Daemon, esd). Note that a sound daemon will never be auto-spawned
- * through this element (regardless of the system configuration), since this
- * is actively prevented by the element. If you must use esd, you need to
- * make sure it is started automatically with your session or otherwise.
- *
- * TODO: insert some comments about how sucky esd is and that all the cool
- * kids use pulseaudio or whatever these days.
- * 
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch esdmon ! audioconvert ! waveenc ! filesink location=record.wav
- * ]| Record from audioinput
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "esdmon.h"
-#include <esd.h>
-#include <unistd.h>
-
-/* Signals and args */
-enum
-{
-  /* FILL ME */
-  LAST_SIGNAL
-};
-
-enum
-{
-  ARG_0,
-  ARG_DEPTH,
-  ARG_BYTESPERREAD,
-  ARG_CUROFFSET,
-  ARG_CHANNELS,
-  ARG_RATE,
-  ARG_HOST
-};
-
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
-    GST_PAD_SRC,
-    GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
-        "signed = (boolean) TRUE, "
-        "width = (int) 16, "
-        "depth = (int) 16, "
-        "rate = [ 8000, 96000 ], "
-        "channels = [ 1, 2 ]; "
-        "audio/x-raw-int, "
-        "signed = (boolean) FALSE, "
-        "width = (int) 8, "
-        "depth = (int) 8, " "rate = [ 8000, 96000 ], " "channels = [ 1, 2 ]")
-    );
-
-static void gst_esdmon_base_init (gpointer g_class);
-static void gst_esdmon_class_init (gpointer g_class, gpointer class_data);
-static void gst_esdmon_init (GTypeInstance * instance, gpointer g_class);
-
-static gboolean gst_esdmon_open_audio (GstEsdmon * src);
-static void gst_esdmon_close_audio (GstEsdmon * src);
-static GstStateChangeReturn gst_esdmon_change_state (GstElement * element,
-    GstStateChange transition);
-static gboolean gst_esdmon_sync_parms (GstEsdmon * esdmon);
-
-static GstData *gst_esdmon_get (GstPad * pad);
-
-static void gst_esdmon_set_property (GObject * object, guint prop_id,
-    const GValue * value, GParamSpec * pspec);
-static void gst_esdmon_get_property (GObject * object, guint prop_id,
-    GValue * value, GParamSpec * pspec);
-
-#define GST_TYPE_ESDMON_DEPTHS (gst_esdmon_depths_get_type())
-static GType
-gst_esdmon_depths_get_type (void)
-{
-  static GType esdmon_depths_type = 0;
-  static const GEnumValue esdmon_depths[] = {
-    {8, "8 Bits", "8"},
-    {16, "16 Bits", "16"},
-    {0, NULL, NULL},
-  };
-
-  if (!esdmon_depths_type) {
-    esdmon_depths_type =
-        g_enum_register_static ("GstEsdmonDepths", esdmon_depths);
-  }
-  return esdmon_depths_type;
-}
-
-#define GST_TYPE_ESDMON_CHANNELS (gst_esdmon_channels_get_type())
-static GType
-gst_esdmon_channels_get_type (void)
-{
-  static GType esdmon_channels_type = 0;
-  static const GEnumValue esdmon_channels[] = {
-    {1, "Mono", "mono"},
-    {2, "Stereo", "stereo"},
-    {0, NULL, NULL},
-  };
-
-  if (!esdmon_channels_type) {
-    esdmon_channels_type =
-        g_enum_register_static ("GstEsdmonChannels", esdmon_channels);
-  }
-  return esdmon_channels_type;
-}
-
-
-static GstElementClass *parent_class = NULL;
-
-/*static guint gst_esdmon_signals[LAST_SIGNAL] = { 0 }; */
-
-GType
-gst_esdmon_get_type (void)
-{
-  static GType esdmon_type = 0;
-
-  if (!esdmon_type) {
-    static const GTypeInfo esdmon_info = {
-      sizeof (GstEsdmonClass),
-      gst_esdmon_base_init,
-      NULL,
-      gst_esdmon_class_init,
-      NULL,
-      NULL,
-      sizeof (GstEsdmon),
-      0,
-      gst_esdmon_init,
-    };
-
-    esdmon_type =
-        g_type_register_static (GST_TYPE_ELEMENT, "GstEsdmon", &esdmon_info, 0);
-  }
-  return esdmon_type;
-}
-
-static void
-gst_esdmon_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_set_details_simple (element_class, "Esound audio monitor",
-      "Source/Audio",
-      "Monitors audio from an esound server",
-      "Richard Boulton <richard-gst@tartarus.org>");
-}
-
-static void
-gst_esdmon_class_init (gpointer g_class, gpointer class_data)
-{
-  GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
-  parent_class = g_type_class_peek_parent (g_class);
-
-  /* FIXME: add long property descriptions */
-  g_object_class_install_property (gobject_class, ARG_BYTESPERREAD,
-      g_param_spec_ulong ("bytes-per-read", "bytes per read", "bytes per read",
-          0, G_MAXULONG, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (gobject_class, ARG_CUROFFSET,
-      g_param_spec_ulong ("curoffset", "curoffset", "curoffset",
-          0, G_MAXULONG, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (gobject_class, ARG_DEPTH,
-      g_param_spec_enum ("depth", "depth", "depth", GST_TYPE_ESDMON_DEPTHS,
-          16, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (gobject_class, ARG_CHANNELS,
-      g_param_spec_enum ("channels", "channels", "channels",
-          GST_TYPE_ESDMON_CHANNELS, 2,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (gobject_class, ARG_RATE,
-      g_param_spec_int ("frequency", "frequency", "frequency",
-          G_MININT, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (gobject_class, ARG_HOST,
-      g_param_spec_string ("host", "host", "host", NULL,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
-  gobject_class->set_property = gst_esdmon_set_property;
-  gobject_class->get_property = gst_esdmon_get_property;
-
-  gstelement_class->change_state = gst_esdmon_change_state;
-}
-
-static void
-gst_esdmon_init (GTypeInstance * instance, gpointer g_class)
-{
-  GstEsdmon *esdmon = GST_ESDMON (instance);
-
-  esdmon->srcpad =
-      gst_pad_new_from_template (gst_element_class_get_pad_template
-      (GST_ELEMENT_GET_CLASS (esdmon), "src"), "src");
-  gst_pad_set_get_function (esdmon->srcpad, gst_esdmon_get);
-  gst_pad_use_explicit_caps (esdmon->srcpad);
-  gst_element_add_pad (GST_ELEMENT (esdmon), esdmon->srcpad);
-
-  esdmon->fd = -1;
-  /* FIXME: get default from somewhere better than just putting them inline. */
-  esdmon->depth = 16;
-  esdmon->channels = 2;
-  esdmon->frequency = 44100;
-  esdmon->host = NULL;
-  esdmon->bytes_per_read = 4096;
-  esdmon->curoffset = 0;
-  esdmon->basetime = 0;
-  esdmon->samples_since_basetime = 0;
-}
-
-static gboolean
-gst_esdmon_sync_parms (GstEsdmon * esdmon)
-{
-  g_return_val_if_fail (esdmon != NULL, FALSE);
-  g_return_val_if_fail (GST_IS_ESDMON (esdmon), FALSE);
-
-  if (esdmon->fd == -1)
-    return TRUE;
-
-  /* Need to set fd to use new parameters: only way to do this is to reopen. */
-  gst_esdmon_close_audio (esdmon);
-  return gst_esdmon_open_audio (esdmon);
-}
-
-static GstData *
-gst_esdmon_get (GstPad * pad)
-{
-  GstEsdmon *esdmon;
-  GstBuffer *buf;
-  glong readbytes;
-  glong readsamples;
-
-  g_return_val_if_fail (pad != NULL, NULL);
-  esdmon = GST_ESDMON (gst_pad_get_parent (pad));
-
-  GST_DEBUG ("attempting to read something from esdmon");
-
-  buf = gst_buffer_new ();
-  g_return_val_if_fail (buf, NULL);
-
-  GST_BUFFER_DATA (buf) = (gpointer) g_malloc (esdmon->bytes_per_read);
-
-  readbytes = read (esdmon->fd, GST_BUFFER_DATA (buf), esdmon->bytes_per_read);
-
-  if (readbytes == 0) {
-    gst_element_set_eos (GST_ELEMENT (esdmon));
-    return NULL;
-  }
-  if (!GST_PAD_CAPS (pad)) {
-    GstCaps *caps = gst_caps_new_simple ("audio/x-raw-int",
-        "endianness", G_TYPE_INT, G_BYTE_ORDER,
-        "signed", G_TYPE_BOOLEAN, esdmon->depth == 8 ? FALSE : TRUE,
-        "width", G_TYPE_INT, esdmon->depth,
-        "depth", G_TYPE_INT, esdmon->depth,
-        "rate", G_TYPE_INT, esdmon->frequency,
-        "channels", G_TYPE_INT, esdmon->channels,
-        NULL);
-
-    /* set caps on src pad */
-    if (gst_pad_set_explicit_caps (esdmon->srcpad, caps) <= 0) {
-      GST_ELEMENT_ERROR (esdmon, CORE, NEGOTIATION, (NULL), (NULL));
-      gst_caps_free (caps);
-      return NULL;
-    }
-    gst_caps_free (caps);
-  }
-
-  GST_BUFFER_SIZE (buf) = readbytes;
-  GST_BUFFER_OFFSET (buf) = esdmon->curoffset;
-  GST_BUFFER_TIMESTAMP (buf) = esdmon->basetime +
-      esdmon->samples_since_basetime * GST_SECOND / esdmon->frequency;
-
-  esdmon->curoffset += readbytes;
-  readsamples = readbytes / esdmon->channels;
-  if (esdmon->depth == 16)
-    readsamples /= 2;
-  esdmon->samples_since_basetime += readsamples;
-
-  GST_DEBUG ("pushed buffer from esdmon of %ld bytes, timestamp %"
-      G_GINT64_FORMAT, readbytes, GST_BUFFER_TIMESTAMP (buf));
-  gst_object_unref (esdmon);
-  return GST_DATA (buf);
-}
-
-static void
-gst_esdmon_set_property (GObject * object, guint prop_id, const GValue * value,
-    GParamSpec * pspec)
-{
-  GstEsdmon *esdmon;
-
-  g_return_if_fail (GST_IS_ESDMON (object));
-  esdmon = GST_ESDMON (object);
-
-  switch (prop_id) {
-    case ARG_BYTESPERREAD:
-      esdmon->bytes_per_read = g_value_get_ulong (value);
-      /* No need to sync params - will just happen on next read. */
-      break;
-    case ARG_DEPTH:
-      esdmon->depth = g_value_get_enum (value);
-      gst_esdmon_sync_parms (esdmon);
-      break;
-    case ARG_CHANNELS:
-      esdmon->channels = g_value_get_enum (value);
-      gst_esdmon_sync_parms (esdmon);
-      break;
-    case ARG_RATE:
-      /* Preserve the timestamps */
-      esdmon->basetime =
-          esdmon->samples_since_basetime * GST_SECOND / esdmon->frequency;
-      esdmon->samples_since_basetime = 0;
-
-      /* Set the new frequency */
-      esdmon->frequency = g_value_get_int (value);
-      gst_esdmon_sync_parms (esdmon);
-      break;
-    case ARG_HOST:
-      if (esdmon->host != NULL)
-        g_free (esdmon->host);
-      if (g_value_get_string (value) == NULL)
-        esdmon->host = NULL;
-      else
-        esdmon->host = g_strdup (g_value_get_string (value));
-      break;
-    default:
-      break;
-  }
-}
-
-static void
-gst_esdmon_get_property (GObject * object, guint prop_id, GValue * value,
-    GParamSpec * pspec)
-{
-  GstEsdmon *esdmon;
-
-  g_return_if_fail (GST_IS_ESDMON (object));
-  esdmon = GST_ESDMON (object);
-
-  switch (prop_id) {
-    case ARG_BYTESPERREAD:
-      g_value_set_ulong (value, esdmon->bytes_per_read);
-      break;
-    case ARG_CUROFFSET:
-      g_value_set_ulong (value, esdmon->curoffset);
-      break;
-    case ARG_DEPTH:
-      g_value_set_enum (value, esdmon->depth);
-      break;
-    case ARG_CHANNELS:
-      g_value_set_enum (value, esdmon->channels);
-      break;
-    case ARG_RATE:
-      g_value_set_int (value, esdmon->frequency);
-      break;
-    case ARG_HOST:
-      g_value_set_string (value, esdmon->host);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-  }
-}
-
-static gboolean
-gst_esdmon_open_audio (GstEsdmon * src)
-{
-  /* Name used by esound for this connection. */
-  const char connname[] = "GStreamer";
-
-  /* Bitmap describing audio format. */
-  esd_format_t esdformat = ESD_STREAM | ESD_PLAY;
-
-  g_return_val_if_fail (src->fd == -1, FALSE);
-
-  if (src->depth == 16)
-    esdformat |= ESD_BITS16;
-  else if (src->depth == 8)
-    esdformat |= ESD_BITS8;
-  else {
-    GST_DEBUG ("esdmon: invalid bit depth (%d)", src->depth);
-    return FALSE;
-  }
-
-  if (src->channels == 2)
-    esdformat |= ESD_STEREO;
-  else if (src->channels == 1)
-    esdformat |= ESD_MONO;
-  else {
-    GST_DEBUG ("esdmon: invalid number of channels (%d)", src->channels);
-    return FALSE;
-  }
-
-  GST_DEBUG ("esdmon: attempting to open connection to esound server");
-  src->fd = esd_monitor_stream (esdformat, src->frequency, src->host, connname);
-  if (src->fd < 0) {
-    GST_DEBUG ("esdmon: can't open connection to esound server");
-    return FALSE;
-  }
-
-  GST_OBJECT_FLAG_SET (src, GST_ESDMON_OPEN);
-
-  return TRUE;
-}
-
-static void
-gst_esdmon_close_audio (GstEsdmon * src)
-{
-  if (src->fd < 0)
-    return;
-
-  close (src->fd);
-  src->fd = -1;
-
-  GST_OBJECT_FLAG_UNSET (src, GST_ESDMON_OPEN);
-
-  GST_DEBUG ("esdmon: closed sound device");
-}
-
-static GstStateChangeReturn
-gst_esdmon_change_state (GstElement * element, GstStateChange transition)
-{
-  g_return_val_if_fail (GST_IS_ESDMON (element), FALSE);
-
-  /* if going down into NULL state, close the fd if it's open */
-  if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
-    if (GST_OBJECT_FLAG_IS_SET (element, GST_ESDMON_OPEN))
-      gst_esdmon_close_audio (GST_ESDMON (element));
-    /* otherwise (READY or higher) we need to open the fd */
-  } else {
-    if (!GST_OBJECT_FLAG_IS_SET (element, GST_ESDMON_OPEN)) {
-      if (!gst_esdmon_open_audio (GST_ESDMON (element)))
-        return GST_STATE_CHANGE_FAILURE;
-    }
-  }
-
-  if (GST_ELEMENT_CLASS (parent_class)->change_state)
-    return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
-  return GST_STATE_CHANGE_SUCCESS;
-}
diff --git a/ext/esd/esdmon.h b/ext/esd/esdmon.h
deleted file mode 100644 (file)
index 50fc7ee..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/* GStreamer
- * Copyright (C) <2001,2002> Richard Boulton <richard-gst@tartarus.org>
- *
- * Based on example.c:
- * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
- *
- * 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_ESDMON_H__
-#define __GST_ESDMON_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_ESDMON \
-  (gst_esdmon_get_type())
-#define GST_ESDMON(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ESDMON,GstEsdmon))
-#define GST_ESDMON_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ESDMON,GstEsdmonClass))
-#define GST_IS_ESDMON(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ESDMON))
-#define GST_IS_ESDMON_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ESDMON))
-
-typedef enum {
-  GST_ESDMON_OPEN            = (GST_ELEMENT_FLAG_LAST << 0),
-  GST_ESDMON_FLAG_LAST       = (GST_ELEMENT_FLAG_LAST << 2)
-} GstEsdSrcFlags;
-
-typedef struct _GstEsdmon GstEsdmon;
-typedef struct _GstEsdmonClass GstEsdmonClass;
-
-struct _GstEsdmon {
-  GstElement element;
-
-  GstPad *srcpad;
-
-  gchar* host;
-
-  int fd;
-
-  gint depth;
-  gint channels;
-  gint frequency;
-
-  guint64 basetime;
-  guint64 samples_since_basetime;
-  guint64 curoffset;
-  guint64 bytes_per_read;
-};
-
-struct _GstEsdmonClass {
-  GstElementClass parent_class;
-};
-
-GType gst_esdmon_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_ESDMON_H__ */
-
diff --git a/ext/esd/esdsink.c b/ext/esd/esdsink.c
deleted file mode 100644 (file)
index e6bc458..0000000
+++ /dev/null
@@ -1,469 +0,0 @@
-/* GStreamer
- * Copyright (C) <2005> Arwed v. Merkatz <v.merkatz@gmx.net>
- *
- * Roughly based on the gstreamer 0.8 esdsink plugin:
- * Copyright (C) <2001> Richard Boulton <richard-gst@tartarus.org>
- *
- * esdsink.c: an EsounD audio sink
- *
- * 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.
- */
-
-/**
- * SECTION:element-esdsink
- * @see_also: #GstAlsaSink, #GstAutoAudioSink
- *
- * This element outputs sound to an already-running Enlightened Sound Daemon
- * (ESound Daemon, esd). Note that a sound daemon will never be auto-spawned
- * through this element (regardless of the system configuration), since this
- * is actively prevented by the element. If you must use esd, you need to
- * make sure it is started automatically with your session or otherwise.
- *
- * TODO: insert some comments about how sucky esd is and that all the cool
- * kids use pulseaudio or whatever these days.
- *
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch -v filesrc location=foo.ogg ! decodebin ! audioconvert ! audioresample ! esdsink
- * ]| play an Ogg/Vorbis audio file via esd
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "esdsink.h"
-#include <esd.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <gst/gst-i18n-plugin.h>
-
-/* wtay: from my esd.h (debian unstable libesd0-dev 0.2.36-3) */
-#ifndef ESD_MAX_WRITE_SIZE
-#define ESD_MAX_WRITE_SIZE (21 * 4096)
-#endif
-
-GST_DEBUG_CATEGORY_EXTERN (esd_debug);
-#define GST_CAT_DEFAULT esd_debug
-
-enum
-{
-  PROP_0,
-  PROP_HOST
-};
-
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
-    GST_PAD_SINK,
-    GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "endianness = (int) BYTE_ORDER, "
-        "signed = (boolean) TRUE, "
-        "width = (int) 16, "
-        "depth = (int) 16, "
-        "rate = (int) [ 1, MAX ], "
-        "channels = (int) [ 1, 2 ]; "
-        "audio/x-raw-int, "
-        "signed = (boolean) { true, false }, "
-        "width = (int) 8, "
-        "depth = (int) 8, "
-        "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
-    );
-
-static void gst_esdsink_finalize (GObject * object);
-
-static GstCaps *gst_esdsink_getcaps (GstBaseSink * bsink);
-
-static gboolean gst_esdsink_open (GstAudioSink * asink);
-static gboolean gst_esdsink_close (GstAudioSink * asink);
-static gboolean gst_esdsink_prepare (GstAudioSink * asink,
-    GstRingBufferSpec * spec);
-static gboolean gst_esdsink_unprepare (GstAudioSink * asink);
-static guint gst_esdsink_write (GstAudioSink * asink, gpointer data,
-    guint length);
-static guint gst_esdsink_delay (GstAudioSink * asink);
-static void gst_esdsink_reset (GstAudioSink * asink);
-
-static void gst_esdsink_set_property (GObject * object, guint prop_id,
-    const GValue * value, GParamSpec * pspec);
-static void gst_esdsink_get_property (GObject * object, guint prop_id,
-    GValue * value, GParamSpec * pspec);
-
-GST_BOILERPLATE (GstEsdSink, gst_esdsink, GstAudioSink, GST_TYPE_AUDIO_SINK);
-
-static void
-gst_esdsink_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_factory));
-  gst_element_class_set_details_simple (element_class, "Esound audio sink",
-      "Sink/Audio",
-      "Plays audio to an esound server",
-      "Arwed von Merkatz <v.merkatz@gmx.net>");
-}
-
-static void
-gst_esdsink_class_init (GstEsdSinkClass * klass)
-{
-  GObjectClass *gobject_class;
-  GstBaseSinkClass *gstbasesink_class;
-  GstAudioSinkClass *gstaudiosink_class;
-
-  gobject_class = (GObjectClass *) klass;
-  gstbasesink_class = (GstBaseSinkClass *) klass;
-  gstaudiosink_class = (GstAudioSinkClass *) klass;
-
-  parent_class = g_type_class_peek_parent (klass);
-
-  gobject_class->finalize = gst_esdsink_finalize;
-
-  gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_esdsink_getcaps);
-
-  gstaudiosink_class->open = GST_DEBUG_FUNCPTR (gst_esdsink_open);
-  gstaudiosink_class->close = GST_DEBUG_FUNCPTR (gst_esdsink_close);
-  gstaudiosink_class->prepare = GST_DEBUG_FUNCPTR (gst_esdsink_prepare);
-  gstaudiosink_class->unprepare = GST_DEBUG_FUNCPTR (gst_esdsink_unprepare);
-  gstaudiosink_class->write = GST_DEBUG_FUNCPTR (gst_esdsink_write);
-  gstaudiosink_class->delay = GST_DEBUG_FUNCPTR (gst_esdsink_delay);
-  gstaudiosink_class->reset = GST_DEBUG_FUNCPTR (gst_esdsink_reset);
-
-  gobject_class->set_property = gst_esdsink_set_property;
-  gobject_class->get_property = gst_esdsink_get_property;
-
-  /* default value is filled in the _init method */
-  g_object_class_install_property (gobject_class, PROP_HOST,
-      g_param_spec_string ("host", "Host",
-          "The host running the esound daemon", NULL,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-static void
-gst_esdsink_init (GstEsdSink * esdsink, GstEsdSinkClass * klass)
-{
-  esdsink->fd = -1;
-  esdsink->ctrl_fd = -1;
-  esdsink->host = g_strdup (g_getenv ("ESPEAKER"));
-}
-
-static void
-gst_esdsink_finalize (GObject * object)
-{
-  GstEsdSink *esdsink = GST_ESDSINK (object);
-
-  gst_caps_replace (&esdsink->cur_caps, NULL);
-  g_free (esdsink->host);
-
-  G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static GstCaps *
-gst_esdsink_getcaps (GstBaseSink * bsink)
-{
-  GstEsdSink *esdsink;
-
-  esdsink = GST_ESDSINK (bsink);
-
-  /* no fd, we're done with the template caps */
-  if (esdsink->ctrl_fd < 0 || esdsink->cur_caps == NULL) {
-    GST_LOG_OBJECT (esdsink, "getcaps called, returning template caps");
-    return NULL;
-  }
-
-  GST_LOG_OBJECT (esdsink, "returning %" GST_PTR_FORMAT, esdsink->cur_caps);
-
-  return gst_caps_ref (esdsink->cur_caps);
-}
-
-static gboolean
-gst_esdsink_open (GstAudioSink * asink)
-{
-  esd_server_info_t *server_info;
-  GstPadTemplate *pad_template;
-  GstEsdSink *esdsink;
-  gchar *saved_env;
-  gint i;
-
-  esdsink = GST_ESDSINK (asink);
-
-  GST_DEBUG_OBJECT (esdsink, "open");
-
-  /* ensure libesd doesn't auto-spawn a sound daemon if none is running yet */
-  saved_env = g_strdup (g_getenv ("ESD_NO_SPAWN"));
-  g_setenv ("ESD_NO_SPAWN", "1", TRUE);
-
-  /* now try to connect to any existing/running sound daemons */
-  esdsink->ctrl_fd = esd_open_sound (esdsink->host);
-
-  /* and restore the previous state */
-  if (saved_env != NULL) {
-    g_setenv ("ESD_NO_SPAWN", saved_env, TRUE);
-  } else {
-    g_unsetenv ("ESD_NO_SPAWN");
-  }
-  g_free (saved_env);
-
-  if (esdsink->ctrl_fd < 0)
-    goto couldnt_connect;
-
-  /* get server info */
-  server_info = esd_get_server_info (esdsink->ctrl_fd);
-  if (!server_info)
-    goto no_server_info;
-
-  GST_INFO_OBJECT (esdsink, "got server info rate: %i", server_info->rate);
-
-  pad_template = gst_static_pad_template_get (&sink_factory);
-  esdsink->cur_caps = gst_caps_copy (gst_pad_template_get_caps (pad_template));
-  gst_object_unref (pad_template);
-
-  for (i = 0; i < esdsink->cur_caps->structs->len; i++) {
-    GstStructure *s;
-
-    s = gst_caps_get_structure (esdsink->cur_caps, i);
-    gst_structure_set (s, "rate", G_TYPE_INT, server_info->rate, NULL);
-  }
-
-  esd_free_server_info (server_info);
-
-  GST_INFO_OBJECT (esdsink, "server caps: %" GST_PTR_FORMAT, esdsink->cur_caps);
-
-  return TRUE;
-
-  /* ERRORS */
-couldnt_connect:
-  {
-    GST_ELEMENT_ERROR (esdsink, RESOURCE, OPEN_WRITE,
-        (_("Could not establish connection to sound server")),
-        ("can't open connection to esound server"));
-    return FALSE;
-  }
-no_server_info:
-  {
-    GST_ELEMENT_ERROR (esdsink, RESOURCE, OPEN_WRITE,
-        (_("Failed to query sound server capabilities")),
-        ("couldn't get server info!"));
-    return FALSE;
-  }
-}
-
-static gboolean
-gst_esdsink_close (GstAudioSink * asink)
-{
-  GstEsdSink *esdsink = GST_ESDSINK (asink);
-
-  GST_DEBUG_OBJECT (esdsink, "close");
-
-  gst_caps_replace (&esdsink->cur_caps, NULL);
-  esd_close (esdsink->ctrl_fd);
-  esdsink->ctrl_fd = -1;
-
-  return TRUE;
-}
-
-static gboolean
-gst_esdsink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
-{
-  GstEsdSink *esdsink = GST_ESDSINK (asink);
-  esd_format_t esdformat;
-
-  /* Name used by esound for this connection. */
-  const char connname[] = "GStreamer";
-
-  GST_DEBUG_OBJECT (esdsink, "prepare");
-
-  /* Bitmap describing audio format. */
-  esdformat = ESD_STREAM | ESD_PLAY;
-
-  switch (spec->depth) {
-    case 8:
-      esdformat |= ESD_BITS8;
-      break;
-    case 16:
-      esdformat |= ESD_BITS16;
-      break;
-    default:
-      goto unsupported_depth;
-  }
-
-  switch (spec->channels) {
-    case 1:
-      esdformat |= ESD_MONO;
-      break;
-    case 2:
-      esdformat |= ESD_STEREO;
-      break;
-    default:
-      goto unsupported_channels;
-  }
-
-  GST_INFO_OBJECT (esdsink,
-      "attempting to open data connection to esound server");
-
-  esdsink->fd =
-      esd_play_stream (esdformat, spec->rate, esdsink->host, connname);
-
-  if ((esdsink->fd < 0) || (esdsink->ctrl_fd < 0))
-    goto cannot_open;
-
-  esdsink->rate = spec->rate;
-
-  spec->segsize = ESD_BUF_SIZE;
-  spec->segtotal = (ESD_MAX_WRITE_SIZE / spec->segsize);
-
-  /* FIXME: this is wrong for signed ints (and the
-   * audioringbuffers should do it for us anyway) */
-  spec->silence_sample[0] = 0;
-  spec->silence_sample[1] = 0;
-  spec->silence_sample[2] = 0;
-  spec->silence_sample[3] = 0;
-
-  GST_INFO_OBJECT (esdsink, "successfully opened connection to esound server");
-
-  return TRUE;
-
-  /* ERRORS */
-unsupported_depth:
-  {
-    GST_ELEMENT_ERROR (esdsink, STREAM, WRONG_TYPE, (NULL),
-        ("can't handle sample depth of %d, only 8 or 16 supported",
-            spec->depth));
-    return FALSE;
-  }
-unsupported_channels:
-  {
-    GST_ELEMENT_ERROR (esdsink, STREAM, WRONG_TYPE, (NULL),
-        ("can't handle %d channels, only 1 or 2 supported", spec->channels));
-    return FALSE;
-  }
-cannot_open:
-  {
-    GST_ELEMENT_ERROR (esdsink, RESOURCE, OPEN_WRITE,
-        (_("Could not establish connection to sound server")),
-        ("can't open connection to esound server"));
-    return FALSE;
-  }
-}
-
-static gboolean
-gst_esdsink_unprepare (GstAudioSink * asink)
-{
-  GstEsdSink *esdsink = GST_ESDSINK (asink);
-
-  if ((esdsink->fd < 0) && (esdsink->ctrl_fd < 0))
-    return TRUE;
-
-  close (esdsink->fd);
-  esdsink->fd = -1;
-
-  GST_INFO_OBJECT (esdsink, "closed sound device");
-
-  return TRUE;
-}
-
-
-static guint
-gst_esdsink_write (GstAudioSink * asink, gpointer data, guint length)
-{
-  GstEsdSink *esdsink = GST_ESDSINK (asink);
-  gint to_write = 0;
-
-  to_write = length;
-
-  while (to_write > 0) {
-    int done;
-
-    done = write (esdsink->fd, data, to_write);
-
-    if (done < 0)
-      goto write_error;
-
-    to_write -= done;
-    data = (char *) data + done;
-  }
-  return length;
-
-  /* ERRORS */
-write_error:
-  {
-    GST_ELEMENT_ERROR (esdsink, RESOURCE, WRITE,
-        ("Failed to write data to the esound daemon"), GST_ERROR_SYSTEM);
-    return -1;
-  }
-}
-
-static guint
-gst_esdsink_delay (GstAudioSink * asink)
-{
-  GstEsdSink *esdsink = GST_ESDSINK (asink);
-  guint latency;
-
-  latency = esd_get_latency (esdsink->ctrl_fd);
-
-  if (latency == (guint) - 1) {
-    GST_WARNING_OBJECT (asink, "couldn't get latency");
-    return 0;
-  }
-
-  /* latency is measured in samples at a rate of 44100, this 
-   * cannot overflow. */
-  latency = latency * G_GINT64_CONSTANT (44100) / esdsink->rate;
-
-  GST_DEBUG_OBJECT (asink, "got latency: %u", latency);
-
-  return latency;
-}
-
-static void
-gst_esdsink_reset (GstAudioSink * asink)
-{
-  GST_DEBUG_OBJECT (asink, "reset called");
-}
-
-static void
-gst_esdsink_set_property (GObject * object, guint prop_id, const GValue * value,
-    GParamSpec * pspec)
-{
-  GstEsdSink *esdsink = GST_ESDSINK (object);
-
-  switch (prop_id) {
-    case PROP_HOST:
-      g_free (esdsink->host);
-      esdsink->host = g_value_dup_string (value);
-      break;
-    default:
-      break;
-  }
-}
-
-static void
-gst_esdsink_get_property (GObject * object, guint prop_id, GValue * value,
-    GParamSpec * pspec)
-{
-  GstEsdSink *esdsink = GST_ESDSINK (object);
-
-  switch (prop_id) {
-    case PROP_HOST:
-      g_value_set_string (value, esdsink->host);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-  }
-}
diff --git a/ext/esd/esdsink.h b/ext/esd/esdsink.h
deleted file mode 100644 (file)
index 2e69ea8..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* GStreamer
- * Copyright (C) <2005> Arwed v. Merkatz <v.merkatz@gmx.net>
- *
- * esdsink.h: an EsounD audio sink
- *
- * 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_ESDSINK_H__
-#define __GST_ESDSINK_H__
-
-#include <gst/gst.h>
-#include <gst/audio/gstaudiosink.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_ESDSINK \
-  (gst_esdsink_get_type())
-#define GST_ESDSINK(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ESDSINK,GstEsdSink))
-#define GST_ESDSINK_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ESDSINK,GstEsdSinkClass))
-#define GST_IS_ESDSINK(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ESDSINK))
-#define GST_IS_ESDSINK_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ESDSINK))
-
-typedef struct _GstEsdSink GstEsdSink;
-typedef struct _GstEsdSinkClass GstEsdSinkClass;
-
-struct _GstEsdSink {
-  GstAudioSink   sink;
-
-  int       fd;
-  int       ctrl_fd;
-  gchar    *host;
-
-  guint     rate;
-  GstCaps  *cur_caps;
-};
-
-struct _GstEsdSinkClass {
-  GstAudioSinkClass parent_class;
-};
-
-GType gst_esdsink_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_ESDSINK_H__ */
diff --git a/ext/esd/gstesd.c b/ext/esd/gstesd.c
deleted file mode 100644 (file)
index dc65001..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* GStreamer
- * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
- * Copyright (C) <2003> David A. 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 "esdsink.h"
-#if 0
-#include "esdmon.h"
-#endif
-
-#include "gst/gst-i18n-plugin.h"
-
-GST_DEBUG_CATEGORY (esd_debug);
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
-  if (!gst_element_register (plugin, "esdsink", GST_RANK_MARGINAL,
-          GST_TYPE_ESDSINK))
-    return FALSE;
-
-#if 0
-  if (!gst_element_register (plugin, "esdmon", GST_RANK_NONE, GST_TYPE_ESDMON))
-    return FALSE;
-#endif
-
-  GST_DEBUG_CATEGORY_INIT (esd_debug, "esd", 0, "ESounD elements");
-
-#ifdef ENABLE_NLS
-  setlocale (LC_ALL, "");
-  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-#endif /* ENABLE_NLS */
-
-  return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    "esdsink",
-    "ESD Element Plugins",
-    plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index 1e2ef5e..42b13c6 100644 (file)
@@ -147,7 +147,8 @@ static void gst_flac_dec_metadata_cb (const FLAC__StreamDecoder *
 static void gst_flac_dec_error_cb (const FLAC__StreamDecoder *
     decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
 
-GST_BOILERPLATE (GstFlacDec, gst_flac_dec, GstElement, GST_TYPE_ELEMENT);
+#define gst_flac_dec_parent_class parent_class
+G_DEFINE_TYPE (GstFlacDec, gst_flac_dec, GST_TYPE_ELEMENT);
 
 /* FIXME 0.11: Use width=32 for all depths and let audioconvert
  * handle the conversions instead of doing it ourself.
@@ -174,22 +175,6 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     );
 
 static void
-gst_flac_dec_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&flac_dec_src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&flac_dec_sink_factory));
-  gst_element_class_set_details_simple (element_class, "FLAC audio decoder",
-      "Codec/Decoder/Audio",
-      "Decodes FLAC lossless audio streams", "Wim Taymans <wim@fluendo.com>");
-
-  GST_DEBUG_CATEGORY_INIT (flacdec_debug, "flacdec", 0, "flac decoder");
-}
-
-static void
 gst_flac_dec_class_init (GstFlacDecClass * klass)
 {
   GstElementClass *gstelement_class;
@@ -198,14 +183,25 @@ gst_flac_dec_class_init (GstFlacDecClass * klass)
   gstelement_class = (GstElementClass *) klass;
   gobject_class = (GObjectClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (flacdec_debug, "flacdec", 0, "flac decoder");
+
   gobject_class->finalize = gst_flac_dec_finalize;
 
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_flac_dec_change_state);
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&flac_dec_src_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&flac_dec_sink_factory));
+
+  gst_element_class_set_details_simple (gstelement_class, "FLAC audio decoder",
+      "Codec/Decoder/Audio",
+      "Decodes FLAC lossless audio streams", "Wim Taymans <wim@fluendo.com>");
 }
 
 static void
-gst_flac_dec_init (GstFlacDec * flacdec, GstFlacDecClass * klass)
+gst_flac_dec_init (GstFlacDec * flacdec)
 {
   flacdec->sinkpad =
       gst_pad_new_from_static_template (&flac_dec_sink_factory, "sink");
@@ -505,8 +501,8 @@ gst_flac_dec_scan_for_last_block (GstFlacDec * flacdec, gint64 * samples)
   while (offset >= MAX (SCANBLOCK_SIZE / 2, file_size / 2)) {
     GstFlowReturn flow;
     GstBuffer *buf = NULL;
-    guint8 *data;
-    guint size;
+    guint8 *data, *ptr;
+    gsize size, left;
 
     /* divide by 2 = not very sophisticated way to deal with overlapping */
     offset -= SCANBLOCK_SIZE / 2;
@@ -519,20 +515,24 @@ gst_flac_dec_scan_for_last_block (GstFlacDec * flacdec, gint64 * samples)
       return;
     }
 
-    size = GST_BUFFER_SIZE (buf);
-    data = GST_BUFFER_DATA (buf);
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+
+    ptr = data;
+    left = size;
 
-    while (size > 16) {
-      if (gst_flac_dec_scan_got_frame (flacdec, data, size, samples)) {
+    while (left > 16) {
+      if (gst_flac_dec_scan_got_frame (flacdec, ptr, left, samples)) {
         GST_DEBUG_OBJECT (flacdec, "frame sync at offset %" G_GINT64_FORMAT,
-            offset + GST_BUFFER_SIZE (buf) - size);
+            offset + size - left);
+        gst_buffer_unmap (buf, data, size);
         gst_buffer_unref (buf);
         return;
       }
-      ++data;
-      --size;
+      ++ptr;
+      --left;
     }
 
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
   }
 }
@@ -781,10 +781,11 @@ gst_flac_dec_read_seekable (const FLAC__StreamDecoder * decoder,
       return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
   }
 
+  *bytes = gst_buffer_get_size (buf);
   GST_DEBUG_OBJECT (flacdec, "Read %d bytes at %" G_GUINT64_FORMAT,
-      GST_BUFFER_SIZE (buf), flacdec->offset);
-  memcpy (buffer, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
-  *bytes = GST_BUFFER_SIZE (buf);
+      *bytes, flacdec->offset);
+
+  gst_buffer_extract (buf, 0, buffer, *bytes);
   gst_buffer_unref (buf);
   flacdec->offset += *bytes;
 
@@ -828,6 +829,8 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
   guint samples = frame->header.blocksize;
   guint j, i;
   GstClockTime next;
+  gpointer data;
+  gsize size;
 
   GST_LOG_OBJECT (flacdec, "samples in frame header: %d", samples);
 
@@ -946,7 +949,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
      * downstream negotiation work on older basetransform */
     ret = gst_pad_alloc_buffer_and_set_caps (flacdec->srcpad,
         GST_BUFFER_OFFSET (flacdec->pending),
-        GST_BUFFER_SIZE (flacdec->pending),
+        gst_buffer_get_size (flacdec->pending),
         GST_BUFFER_CAPS (flacdec->pending), &outbuf);
     if (ret == GST_FLOW_OK) {
       gst_pad_push (flacdec->srcpad, flacdec->pending);
@@ -993,8 +996,9 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
 
   GST_BUFFER_DURATION (outbuf) = next - GST_BUFFER_TIMESTAMP (outbuf);
 
+  data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
   if (width == 8) {
-    gint8 *outbuffer = (gint8 *) GST_BUFFER_DATA (outbuf);
+    gint8 *outbuffer = (gint8 *) data;
 
     for (i = 0; i < samples; i++) {
       for (j = 0; j < channels; j++) {
@@ -1002,7 +1006,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
       }
     }
   } else if (width == 16) {
-    gint16 *outbuffer = (gint16 *) GST_BUFFER_DATA (outbuf);
+    gint16 *outbuffer = (gint16 *) data;
 
     for (i = 0; i < samples; i++) {
       for (j = 0; j < channels; j++) {
@@ -1010,7 +1014,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
       }
     }
   } else if (width == 32) {
-    gint32 *outbuffer = (gint32 *) GST_BUFFER_DATA (outbuf);
+    gint32 *outbuffer = (gint32 *) data;
 
     for (i = 0; i < samples; i++) {
       for (j = 0; j < channels; j++) {
@@ -1020,6 +1024,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
   } else {
     g_assert_not_reached ();
   }
+  gst_buffer_unmap (outbuf, data, size);
 
   if (!flacdec->seeking) {
     GST_DEBUG_OBJECT (flacdec, "pushing %d samples at offset %" G_GINT64_FORMAT
@@ -1030,7 +1035,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
 
     if (flacdec->discont) {
       GST_DEBUG_OBJECT (flacdec, "marking discont");
-      outbuf = gst_buffer_make_metadata_writable (outbuf);
+      outbuf = gst_buffer_make_writable (outbuf);
       GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
       flacdec->discont = FALSE;
     }
@@ -1393,9 +1398,9 @@ gst_flac_dec_chain (GstPad * pad, GstBuffer * buf)
 
   GST_LOG_OBJECT (dec,
       "buffer with ts=%" GST_TIME_FORMAT ", offset=%" G_GINT64_FORMAT
-      ", end_offset=%" G_GINT64_FORMAT ", size=%u",
+      ", end_offset=%" G_GINT64_FORMAT ", size=%" G_GSIZE_FORMAT,
       GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_BUFFER_OFFSET (buf),
-      GST_BUFFER_OFFSET_END (buf), GST_BUFFER_SIZE (buf));
+      GST_BUFFER_OFFSET_END (buf), gst_buffer_get_size (buf));
 
   if (dec->init) {
     GST_DEBUG_OBJECT (dec, "initializing decoder");
@@ -1417,10 +1422,13 @@ gst_flac_dec_chain (GstPad * pad, GstBuffer * buf)
 
   if (dec->framed) {
     gint64 unused;
+    guint8 *data;
+    gsize size;
 
     /* check if this is a flac audio frame (rather than a header or junk) */
-    got_audio_frame = gst_flac_dec_scan_got_frame (dec, GST_BUFFER_DATA (buf),
-        GST_BUFFER_SIZE (buf), &unused);
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+    got_audio_frame = gst_flac_dec_scan_got_frame (dec, data, size, &unused);
+    gst_buffer_unmap (buf, data, size);
 
     /* oggdemux will set granulepos in OFFSET_END instead of timestamp */
     if (G_LIKELY (got_audio_frame)) {
index a07fcdc..e72ce6b 100644 (file)
@@ -149,27 +149,10 @@ enum
 GST_DEBUG_CATEGORY_STATIC (flacenc_debug);
 #define GST_CAT_DEFAULT flacenc_debug
 
-
-#define _do_init(type)                                                          \
-  G_STMT_START{                                                                 \
-    static const GInterfaceInfo tag_setter_info = {                             \
-      NULL,                                                                     \
-      NULL,                                                                     \
-      NULL                                                                      \
-    };                                                                          \
-    static const GInterfaceInfo preset_info = {                                 \
-      NULL,                                                                     \
-      NULL,                                                                     \
-      NULL                                                                      \
-    };                                                                          \
-    g_type_add_interface_static (type, GST_TYPE_TAG_SETTER,                     \
-                                 &tag_setter_info);                             \
-    g_type_add_interface_static (type, GST_TYPE_PRESET,                         \
-                                 &preset_info);                                 \
-  }G_STMT_END
-
-GST_BOILERPLATE_FULL (GstFlacEnc, gst_flac_enc, GstElement, GST_TYPE_ELEMENT,
-    _do_init);
+#define gst_flac_enc_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstFlacEnc, gst_flac_enc, GST_TYPE_ELEMENT,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL));
 
 static void gst_flac_enc_finalize (GObject * object);
 
@@ -258,25 +241,6 @@ gst_flac_enc_quality_get_type (void)
 }
 
 static void
-gst_flac_enc_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_factory));
-
-  gst_element_class_set_details_simple (element_class, "FLAC audio encoder",
-      "Codec/Encoder/Audio",
-      "Encodes audio with the FLAC lossless audio encoder",
-      "Wim Taymans <wim.taymans@chello.be>");
-
-  GST_DEBUG_CATEGORY_INIT (flacenc_debug, "flacenc", 0,
-      "Flac encoding element");
-}
-
-static void
 gst_flac_enc_class_init (GstFlacEncClass * klass)
 {
   GObjectClass *gobject_class;
@@ -285,6 +249,9 @@ gst_flac_enc_class_init (GstFlacEncClass * klass)
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (flacenc_debug, "flacenc", 0,
+      "Flac encoding element");
+
   gobject_class->set_property = gst_flac_enc_set_property;
   gobject_class->get_property = gst_flac_enc_get_property;
   gobject_class->finalize = gst_flac_enc_finalize;
@@ -403,10 +370,20 @@ gst_flac_enc_class_init (GstFlacEncClass * klass)
           G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
 
   gstelement_class->change_state = gst_flac_enc_change_state;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_factory));
+
+  gst_element_class_set_details_simple (gstelement_class, "FLAC audio encoder",
+      "Codec/Encoder/Audio",
+      "Encodes audio with the FLAC lossless audio encoder",
+      "Wim Taymans <wim.taymans@chello.be>");
 }
 
 static void
-gst_flac_enc_init (GstFlacEnc * flacenc, GstFlacEncClass * klass)
+gst_flac_enc_init (GstFlacEnc * flacenc)
 {
   flacenc->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
   gst_pad_set_chain_function (flacenc->sinkpad,
@@ -505,6 +482,8 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
     GstStructure *structure;
     GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE;
     gint i;
+    guint8 *data;
+    gsize size;
 
     for (i = 0; i < n_images + n_preview_images; i++) {
       if (i < n_images) {
@@ -530,8 +509,11 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
       else
         image_type = image_type + 2;
 
+      data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
       FLAC__metadata_object_picture_set_data (flacenc->meta[entries],
-          GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer), TRUE);
+          data, size, TRUE);
+      gst_buffer_unmap (buffer, data, size);
+
       /* FIXME: There's no way to set the picture type in libFLAC */
       flacenc->meta[entries]->data.picture.type = image_type;
       FLAC__metadata_object_picture_set_mime_type (flacenc->meta[entries],
@@ -915,25 +897,29 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
       "rate", G_TYPE_INT, enc->sample_rate, NULL);
 
   for (l = enc->headers; l != NULL; l = l->next) {
-    const guint8 *data;
-    guint size;
+    GstBuffer *buf;
+    guint8 *data;
+    gsize size;
 
     /* mark buffers so oggmux will ignore them if it already muxed the
      * header buffers from the streamheaders field in the caps */
-    l->data = gst_buffer_make_metadata_writable (GST_BUFFER (l->data));
-    GST_BUFFER_FLAG_SET (GST_BUFFER (l->data), GST_BUFFER_FLAG_IN_CAPS);
+    l->data = gst_buffer_make_writable (GST_BUFFER_CAST (l->data));
 
-    data = GST_BUFFER_DATA (GST_BUFFER_CAST (l->data));
-    size = GST_BUFFER_SIZE (GST_BUFFER_CAST (l->data));
+    buf = GST_BUFFER_CAST (l->data);
+    GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
+
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
 
     /* find initial 4-byte marker which we need to skip later on */
     if (size == 4 && memcmp (data, "fLaC", 4) == 0) {
-      marker = GST_BUFFER_CAST (l->data);
+      marker = buf;
     } else if (size > 1 && (data[0] & 0x7f) == HDR_TYPE_STREAMINFO) {
-      streaminfo = GST_BUFFER_CAST (l->data);
+      streaminfo = buf;
     } else if (size > 1 && (data[0] & 0x7f) == HDR_TYPE_VORBISCOMMENT) {
-      vorbiscomment = GST_BUFFER_CAST (l->data);
+      vorbiscomment = buf;
     }
+
+    gst_buffer_unmap (buf, data, size);
   }
 
   if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) {
@@ -948,20 +934,26 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
   {
     GstBuffer *buf;
     guint16 num;
+    guint8 *bdata;
+    gsize bsize, slen;
 
     /* minus one for the marker that is merged with streaminfo here */
     num = g_list_length (enc->headers) - 1;
 
-    buf = gst_buffer_new_and_alloc (13 + GST_BUFFER_SIZE (streaminfo));
-    GST_BUFFER_DATA (buf)[0] = 0x7f;
-    memcpy (GST_BUFFER_DATA (buf) + 1, "FLAC", 4);
-    GST_BUFFER_DATA (buf)[5] = 0x01;    /* mapping version major */
-    GST_BUFFER_DATA (buf)[6] = 0x00;    /* mapping version minor */
-    GST_BUFFER_DATA (buf)[7] = (num & 0xFF00) >> 8;
-    GST_BUFFER_DATA (buf)[8] = (num & 0x00FF) >> 0;
-    memcpy (GST_BUFFER_DATA (buf) + 9, "fLaC", 4);
-    memcpy (GST_BUFFER_DATA (buf) + 13, GST_BUFFER_DATA (streaminfo),
-        GST_BUFFER_SIZE (streaminfo));
+    slen = gst_buffer_get_size (streaminfo);
+    buf = gst_buffer_new_and_alloc (13 + slen);
+
+    bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_WRITE);
+    bdata[0] = 0x7f;
+    memcpy (bdata + 1, "FLAC", 4);
+    bdata[5] = 0x01;            /* mapping version major */
+    bdata[6] = 0x00;            /* mapping version minor */
+    bdata[7] = (num & 0xFF00) >> 8;
+    bdata[8] = (num & 0x00FF) >> 0;
+    memcpy (bdata + 9, "fLaC", 4);
+    gst_buffer_extract (streaminfo, 0, bdata + 13, slen);
+    gst_buffer_unmap (buf, bdata, bsize);
+
     notgst_value_array_append_buffer (&array, buf);
     gst_buffer_unref (buf);
   }
@@ -971,10 +963,10 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
 
   /* add other headers, if there are any */
   for (l = enc->headers; l != NULL; l = l->next) {
-    if (GST_BUFFER_CAST (l->data) != marker &&
-        GST_BUFFER_CAST (l->data) != streaminfo &&
-        GST_BUFFER_CAST (l->data) != vorbiscomment) {
-      notgst_value_array_append_buffer (&array, GST_BUFFER_CAST (l->data));
+    GstBuffer *buf = GST_BUFFER_CAST (l->data);
+
+    if (buf != marker && buf != streaminfo && buf != vorbiscomment) {
+      notgst_value_array_append_buffer (&array, buf);
     }
   }
 
@@ -994,9 +986,11 @@ push_headers:
     buf = GST_BUFFER (l->data);
     gst_buffer_set_caps (buf, caps);
     GST_LOG_OBJECT (enc, "Pushing header buffer, size %u bytes",
-        GST_BUFFER_SIZE (buf));
+        gst_buffer_get_size (buf));
+#if 0
     GST_MEMDUMP_OBJECT (enc, "header buffer", GST_BUFFER_DATA (buf),
         GST_BUFFER_SIZE (buf));
+#endif
     (void) gst_pad_push (enc->srcpad, buf);
     l->data = NULL;
   }
@@ -1021,7 +1015,7 @@ gst_flac_enc_write_callback (const FLAC__StreamEncoder * encoder,
     return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
 
   outbuf = gst_buffer_new_and_alloc (bytes);
-  memcpy (GST_BUFFER_DATA (outbuf), buffer, bytes);
+  gst_buffer_fill (outbuf, 0, buffer, bytes);
 
   if (samples > 0 && flacenc->samples_written != (guint64) - 1) {
     guint64 granulepos;
@@ -1064,8 +1058,10 @@ gst_flac_enc_write_callback (const FLAC__StreamEncoder * encoder,
   } else if (flacenc->got_headers && samples == 0) {
     GST_DEBUG_OBJECT (flacenc, "Fixing up headers at pos=%" G_GUINT64_FORMAT
         ", size=%u", flacenc->offset, (guint) bytes);
+#if 0
     GST_MEMDUMP_OBJECT (flacenc, "Presumed header fragment",
         GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf));
+#endif
   } else {
     GST_LOG ("Pushing buffer: ts=%" GST_TIME_FORMAT ", samples=%u, size=%u, "
         "pos=%" G_GUINT64_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
@@ -1197,10 +1193,11 @@ gst_flac_enc_chain (GstPad * pad, GstBuffer * buffer)
 {
   GstFlacEnc *flacenc;
   FLAC__int32 *data;
-  gulong insize;
+  gsize bsize;
   gint samples, width;
   gulong i;
   FLAC__bool res;
+  gpointer bdata;
 
   flacenc = GST_FLAC_ENC (GST_PAD_PARENT (pad));
 
@@ -1238,30 +1235,30 @@ gst_flac_enc_chain (GstPad * pad, GstBuffer * buffer)
   else
     flacenc->next_ts = GST_CLOCK_TIME_NONE;
 
-  insize = GST_BUFFER_SIZE (buffer);
-  samples = insize / (width >> 3);
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
+  samples = bsize / (width >> 3);
 
   data = g_malloc (samples * sizeof (FLAC__int32));
 
   if (width == 8) {
-    gint8 *indata = (gint8 *) GST_BUFFER_DATA (buffer);
+    gint8 *indata = (gint8 *) bdata;
 
     for (i = 0; i < samples; i++)
       data[i] = (FLAC__int32) indata[i];
   } else if (width == 16) {
-    gint16 *indata = (gint16 *) GST_BUFFER_DATA (buffer);
+    gint16 *indata = (gint16 *) bdata;
 
     for (i = 0; i < samples; i++)
       data[i] = (FLAC__int32) indata[i];
   } else if (width == 32) {
-    gint32 *indata = (gint32 *) GST_BUFFER_DATA (buffer);
+    gint32 *indata = (gint32 *) bdata;
 
     for (i = 0; i < samples; i++)
       data[i] = (FLAC__int32) indata[i];
   } else {
     g_assert_not_reached ();
   }
-
+  gst_buffer_unmap (buffer, bdata, bsize);
   gst_buffer_unref (buffer);
 
   res = FLAC__stream_encoder_process_interleaved (flacenc->encoder,
index 682ceb8..3382999 100644 (file)
@@ -96,34 +96,10 @@ static GstStateChangeReturn gst_flac_tag_change_state (GstElement * element,
 
 static gboolean gst_flac_tag_sink_setcaps (GstPad * pad, GstCaps * caps);
 
-static void
-gst_flac_tag_setup_interfaces (GType flac_tag_type)
-{
-  static const GInterfaceInfo tag_setter_info = { NULL, NULL, NULL };
-
-  g_type_add_interface_static (flac_tag_type, GST_TYPE_TAG_SETTER,
-      &tag_setter_info);
-}
+#define gst_flac_tag_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstFlacTag, gst_flac_tag, GST_TYPE_ELEMENT,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
 
-GST_BOILERPLATE_FULL (GstFlacTag, gst_flac_tag, GstElement, GST_TYPE_ELEMENT,
-    gst_flac_tag_setup_interfaces);
-
-static void
-gst_flac_tag_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "FLAC tagger",
-      "Formatter/Metadata",
-      "Rewrite tags in a FLAC file", "Christophe Fergeau <teuf@gnome.org>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&flac_tag_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&flac_tag_src_template));
-
-  GST_DEBUG_CATEGORY_INIT (flactag_debug, "flactag", 0, "flac tag rewriter");
-}
 
 static void
 gst_flac_tag_class_init (GstFlacTagClass * klass)
@@ -131,13 +107,23 @@ gst_flac_tag_class_init (GstFlacTagClass * klass)
   GstElementClass *gstelement_class;
   GObjectClass *gobject_class;
 
+  GST_DEBUG_CATEGORY_INIT (flactag_debug, "flactag", 0, "flac tag rewriter");
+
   gstelement_class = (GstElementClass *) klass;
   gobject_class = (GObjectClass *) klass;
 
-  parent_class = g_type_class_peek_parent (klass);
-
   gobject_class->dispose = gst_flac_tag_dispose;
   gstelement_class->change_state = gst_flac_tag_change_state;
+
+  gst_element_class_set_details_simple (gstelement_class, "FLAC tagger",
+      "Formatter/Metadata",
+      "Rewrite tags in a FLAC file", "Christophe Fergeau <teuf@gnome.org>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&flac_tag_sink_template));
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&flac_tag_src_template));
 }
 
 static void
@@ -163,7 +149,7 @@ gst_flac_tag_dispose (GObject * object)
 
 
 static void
-gst_flac_tag_init (GstFlacTag * tag, GstFlacTagClass * klass)
+gst_flac_tag_init (GstFlacTag * tag)
 {
   /* create the sink and src pads */
   tag->sinkpad =
@@ -197,6 +183,8 @@ gst_flac_tag_chain (GstPad * pad, GstBuffer * buffer)
 {
   GstFlacTag *tag;
   GstFlowReturn ret;
+  guint8 *data;
+  gsize size;
 
   ret = GST_FLOW_OK;
   tag = GST_FLAC_TAG (gst_pad_get_parent (pad));
@@ -212,7 +200,7 @@ gst_flac_tag_chain (GstPad * pad, GstBuffer * buffer)
 
     id_buffer = gst_adapter_take_buffer (tag->adapter, FLAC_MAGIC_SIZE);
     GST_DEBUG_OBJECT (tag, "looking for " FLAC_MAGIC " identifier");
-    if (memcmp (GST_BUFFER_DATA (id_buffer), FLAC_MAGIC, FLAC_MAGIC_SIZE) == 0) {
+    if (gst_buffer_memcmp (id_buffer, 0, FLAC_MAGIC, FLAC_MAGIC_SIZE) == 0) {
 
       GST_DEBUG_OBJECT (tag, "pushing " FLAC_MAGIC " identifier buffer");
       gst_buffer_set_caps (id_buffer, GST_PAD_CAPS (tag->srcpad));
@@ -234,7 +222,6 @@ gst_flac_tag_chain (GstPad * pad, GstBuffer * buffer)
    * of a metadata block
    */
   if (tag->state == GST_FLAC_TAG_STATE_METADATA_BLOCKS) {
-    guint size;
     guint type;
     gboolean is_last;
     const guint8 *block_header;
@@ -250,13 +237,14 @@ gst_flac_tag_chain (GstPad * pad, GstBuffer * buffer)
     if (gst_adapter_available (tag->adapter) < 4)
       goto cleanup;
 
-    block_header = gst_adapter_peek (tag->adapter, 4);
+    block_header = gst_adapter_map (tag->adapter, 4);
 
     is_last = ((block_header[0] & 0x80) == 0x80);
     type = block_header[0] & 0x7F;
     size = (block_header[1] << 16)
         | (block_header[2] << 8)
         | block_header[3];
+    gst_adapter_unmap (tag->adapter, 0);
 
     /* The 4 bytes long header isn't included in the metadata size */
     tag->metadata_block_size = size + 4;
@@ -288,7 +276,9 @@ gst_flac_tag_chain (GstPad * pad, GstBuffer * buffer)
     /* clear the is-last flag, as the last metadata block will
      * be the vorbis comment block which we will build ourselves.
      */
-    GST_BUFFER_DATA (metadata_buffer)[0] &= (~0x80);
+    data = gst_buffer_map (metadata_buffer, &size, NULL, GST_MAP_READWRITE);
+    data[0] &= (~0x80);
+    gst_buffer_unmap (metadata_buffer, data, size);
 
     if (tag->state == GST_FLAC_TAG_STATE_WRITING_METADATA_BLOCK) {
       GST_DEBUG_OBJECT (tag, "pushing metadata block buffer");
@@ -312,12 +302,14 @@ gst_flac_tag_chain (GstPad * pad, GstBuffer * buffer)
      * block, and stop now if the user only wants to read tags
      */
     if (tag->vorbiscomment != NULL) {
+      guint8 id_data[4];
       /* We found some tags, try to parse them and notify the other elements
        * that we encountered some tags
        */
       GST_DEBUG_OBJECT (tag, "emitting vorbiscomment tags");
+      gst_buffer_extract (tag->vorbiscomment, 0, id_data, 4);
       tag->tags = gst_tag_list_from_vorbiscomment_buffer (tag->vorbiscomment,
-          GST_BUFFER_DATA (tag->vorbiscomment), 4, NULL);
+          id_data, 4, NULL);
       if (tag->tags != NULL) {
         gst_element_found_tags (GST_ELEMENT (tag),
             gst_tag_list_copy (tag->tags));
@@ -341,7 +333,6 @@ gst_flac_tag_chain (GstPad * pad, GstBuffer * buffer)
    */
   if (tag->state == GST_FLAC_TAG_STATE_ADD_VORBIS_COMMENT) {
     GstBuffer *buffer;
-    gint size;
     const GstTagList *user_tags;
     GstTagList *merged_tags;
 
@@ -361,68 +352,54 @@ gst_flac_tag_chain (GstPad * pad, GstBuffer * buffer)
        */
       GST_WARNING_OBJECT (tag, "No tags found");
       buffer = gst_buffer_new_and_alloc (12);
-      if (buffer == NULL) {
-        GST_ELEMENT_ERROR (tag, CORE, TOO_LAZY, (NULL),
-            ("Error creating 12-byte buffer for padding block"));
-        ret = GST_FLOW_ERROR;
-        goto cleanup;
-      }
-      memset (GST_BUFFER_DATA (buffer), 0, GST_BUFFER_SIZE (buffer));
-      GST_BUFFER_DATA (buffer)[0] = 0x81;       /* 0x80 = Last metadata block, 
-                                                 * 0x01 = padding block
-                                                 */
+      if (buffer == NULL)
+        goto no_buffer;
+
+      data = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE);
+      memset (data, 0, size);
+      data[0] = 0x81;           /* 0x80 = Last metadata block, 
+                                 * 0x01 = padding block */
+      gst_buffer_unmap (buffer, data, size);
     } else {
       guchar header[4];
+      guint8 fbit[1];
 
       memset (header, 0, sizeof (header));
       header[0] = 0x84;         /* 0x80 = Last metadata block, 
-                                 * 0x04 = vorbiscomment block
-                                 */
+                                 * 0x04 = vorbiscomment block */
       buffer = gst_tag_list_to_vorbiscomment_buffer (merged_tags, header,
           sizeof (header), NULL);
       GST_DEBUG_OBJECT (tag, "Writing tags %" GST_PTR_FORMAT, merged_tags);
       gst_tag_list_free (merged_tags);
-      if (buffer == NULL) {
-        GST_ELEMENT_ERROR (tag, CORE, TAG, (NULL),
-            ("Error converting tag list to vorbiscomment buffer"));
-        ret = GST_FLOW_ERROR;
-        goto cleanup;
-      }
-      size = GST_BUFFER_SIZE (buffer) - 4;
-      if ((size > 0xFFFFFF) || (size < 0)) {
-        /* FLAC vorbis comment blocks are limited to 2^24 bytes, 
-         * while the vorbis specs allow more than that. Shouldn't 
-         * be a real world problem though
-         */
-        GST_ELEMENT_ERROR (tag, CORE, TAG, (NULL),
-            ("Vorbis comment of size %d too long", size));
-        ret = GST_FLOW_ERROR;
-        goto cleanup;
-      }
+      if (buffer == NULL)
+        goto no_comment;
+
+      size = gst_buffer_get_size (buffer);
+      if ((size < 4) || ((size - 4) > 0xFFFFFF))
+        goto comment_too_long;
 
+      fbit[0] = 1;
       /* Get rid of the framing bit at the end of the vorbiscomment buffer 
        * if it exists since libFLAC seems to lose sync because of this
        * bit in gstflacdec
        */
-      if (GST_BUFFER_DATA (buffer)[GST_BUFFER_SIZE (buffer) - 1] == 1) {
-        GstBuffer *sub;
-
-        sub = gst_buffer_create_sub (buffer, 0, GST_BUFFER_SIZE (buffer) - 1);
-        gst_buffer_unref (buffer);
-        buffer = sub;
+      if (gst_buffer_memcmp (buffer, size - 1, fbit, 1) == 0) {
+        buffer = gst_buffer_make_writable (buffer);
+        gst_buffer_resize (buffer, 0, size - 1);
       }
     }
 
     /* The 4 byte metadata block header isn't accounted for in the total
      * size of the metadata block
      */
-    size = GST_BUFFER_SIZE (buffer) - 4;
+    data = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE);
+    data[1] = (((size - 4) & 0xFF0000) >> 16);
+    data[2] = (((size - 4) & 0x00FF00) >> 8);
+    data[3] = ((size - 4) & 0x0000FF);
+    gst_buffer_unmap (buffer, data, size);
+
+    GST_DEBUG_OBJECT (tag, "pushing %d byte vorbiscomment buffer", size);
 
-    GST_BUFFER_DATA (buffer)[1] = ((size & 0xFF0000) >> 16);
-    GST_BUFFER_DATA (buffer)[2] = ((size & 0x00FF00) >> 8);
-    GST_BUFFER_DATA (buffer)[3] = (size & 0x0000FF);
-    GST_DEBUG_OBJECT (tag, "pushing %d byte vorbiscomment buffer",
-        GST_BUFFER_SIZE (buffer));
     gst_buffer_set_caps (buffer, GST_PAD_CAPS (tag->srcpad));
     ret = gst_pad_push (tag->srcpad, buffer);
     if (ret != GST_FLOW_OK) {
@@ -448,8 +425,34 @@ cleanup:
   gst_object_unref (tag);
 
   return ret;
-}
 
+  /* ERRORS */
+no_buffer:
+  {
+    GST_ELEMENT_ERROR (tag, CORE, TOO_LAZY, (NULL),
+        ("Error creating 12-byte buffer for padding block"));
+    ret = GST_FLOW_ERROR;
+    goto cleanup;
+  }
+no_comment:
+  {
+    GST_ELEMENT_ERROR (tag, CORE, TAG, (NULL),
+        ("Error converting tag list to vorbiscomment buffer"));
+    ret = GST_FLOW_ERROR;
+    goto cleanup;
+  }
+comment_too_long:
+  {
+    /* FLAC vorbis comment blocks are limited to 2^24 bytes, 
+     * while the vorbis specs allow more than that. Shouldn't 
+     * be a real world problem though
+     */
+    GST_ELEMENT_ERROR (tag, CORE, TAG, (NULL),
+        ("Vorbis comment of size %d too long", size));
+    ret = GST_FLOW_ERROR;
+    goto cleanup;
+  }
+}
 
 static GstStateChangeReturn
 gst_flac_tag_change_state (GstElement * element, GstStateChange transition)
@@ -486,5 +489,5 @@ gst_flac_tag_change_state (GstElement * element, GstStateChange transition)
       break;
   }
 
-  return parent_class->change_state (element, transition);
+  return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
 }
diff --git a/ext/gconf/Makefile.am b/ext/gconf/Makefile.am
deleted file mode 100644 (file)
index 0f1cffb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-plugin_LTLIBRARIES = libgstgconfelements.la
-
-libgstgconfelements_la_SOURCES = \
-       gstgconfaudiosink.c \
-       gstgconfaudiosrc.c \
-       gstgconfelements.c \
-       gstgconfvideosink.c \
-       gstgconfvideosrc.c \
-       gstswitchsink.c \
-       gstswitchsrc.c \
-       gstgconf.c
-
-DIR_CFLAGS = -DGST_GCONF_DIR=\"/system/gstreamer/@GST_MAJORMINOR@\"
-libgstgconfelements_la_CFLAGS = $(GST_CFLAGS) $(GCONF_CFLAGS) $(DIR_CFLAGS)
-libgstgconfelements_la_LIBADD = $(GST_LIBS) $(GCONF_LIBS)
-libgstgconfelements_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-libgstgconfelements_la_LIBTOOLFLAGS = --tag=disable-static
-
-noinst_HEADERS = \
-       gstgconfaudiosink.h \
-       gstgconfaudiosrc.h \
-       gstgconfelements.h \
-       gstgconfvideosink.h \
-       gstgconfvideosrc.h \
-       gstswitchsink.h \
-       gstswitchsrc.h \
-       gstgconf.h
diff --git a/ext/gconf/gstgconf.c b/ext/gconf/gstgconf.c
deleted file mode 100644 (file)
index eee80c9..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-/* GStreamer
- * nf_get_default_audio_sink
- * Copyright (C) <2002> Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) <2006> Jürg Billeter <j@bitron.ch>
- *
- * 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.
- */
-
-/*
- * this library handles interaction with GConf
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-#include "gstgconf.h"
-#include "gstgconfelements.h"   /* for debug category */
-
-#ifndef GST_GCONF_DIR
-#error "GST_GCONF_DIR is not defined !"
-#endif
-
-static GConfClient *_gst_gconf_client = NULL;   /* GConf connection */
-
-
-/* internal functions */
-
-static GConfClient *
-gst_gconf_get_client (void)
-{
-  if (!_gst_gconf_client)
-    _gst_gconf_client = gconf_client_get_default ();
-
-  return _gst_gconf_client;
-}
-
-/* external functions */
-
-/**
- * gst_gconf_get_string:
- * @key: a #gchar corresponding to the key you want to get.
- *
- * Get GConf key @key's string value.
- *
- * Returns: a newly allocated #gchar string containing @key's value,
- * or NULL in the case of an error..
- */
-gchar *
-gst_gconf_get_string (const gchar * key)
-{
-  GError *error = NULL;
-  gchar *value = NULL;
-  gchar *full_key;
-
-  if (!g_str_has_prefix (key, GST_GCONF_DIR))
-    full_key = g_strdup_printf ("%s/%s", GST_GCONF_DIR, key);
-  else
-    full_key = g_strdup (key);
-
-  value = gconf_client_get_string (gst_gconf_get_client (), full_key, &error);
-  g_free (full_key);
-
-  if (error) {
-    g_warning ("gst_gconf_get_string: error: %s\n", error->message);
-    g_error_free (error);
-    return NULL;
-  }
-
-  return value;
-}
-
-const gchar *
-gst_gconf_get_key_for_sink_profile (GstGConfProfile profile)
-{
-  switch (profile) {
-    case GCONF_PROFILE_SOUNDS:
-      return GST_GCONF_DIR "/" GST_GCONF_AUDIOSINK_KEY;
-    case GCONF_PROFILE_MUSIC:
-      return GST_GCONF_DIR "/" GST_GCONF_MUSIC_AUDIOSINK_KEY;
-    case GCONF_PROFILE_CHAT:
-      return GST_GCONF_DIR "/" GST_GCONF_CHAT_AUDIOSINK_KEY;
-    default:
-      break;
-  }
-
-  g_return_val_if_reached (GST_GCONF_DIR "/" GST_GCONF_AUDIOSINK_KEY);
-}
-
-/**
- * gst_gconf_set_string:
- * @key: a #gchar corresponding to the key you want to set.
- * @value: a #gchar containing key value.
- *
- * Set GConf key @key to string value @value.
- */
-void
-gst_gconf_set_string (const gchar * key, const gchar * value)
-{
-  GError *error = NULL;
-  gchar *full_key;
-
-  if (!g_str_has_prefix (key, GST_GCONF_DIR))
-    full_key = g_strdup_printf ("%s/%s", GST_GCONF_DIR, key);
-  else
-    full_key = g_strdup (key);
-
-  gconf_client_set_string (gst_gconf_get_client (), full_key, value, &error);
-  if (error) {
-    GST_ERROR ("gst_gconf_set_string: error: %s\n", error->message);
-    g_error_free (error);
-  }
-  g_free (full_key);
-}
-
-/**
- * gst_gconf_render_bin_from_key:
- * @key: a #gchar string corresponding to a GConf key.
- *
- * Render bin from GConf key @key.
- *
- * Returns: a #GstElement containing the rendered bin.
- */
-GstElement *
-gst_gconf_render_bin_from_key (const gchar * key)
-{
-  GstElement *bin = NULL;
-  gchar *value;
-
-  value = gst_gconf_get_string (key);
-
-  GST_LOG ("%s = %s", GST_STR_NULL (key), GST_STR_NULL (value));
-
-  if (value) {
-    GError *err = NULL;
-
-    bin = gst_parse_bin_from_description (value, TRUE, &err);
-    if (err) {
-      GST_ERROR ("gconf: error creating bin '%s': %s", value, err->message);
-      g_error_free (err);
-    }
-
-    g_free (value);
-  }
-  return bin;
-}
-
-/**
- * gst_gconf_render_bin_with_default:
- * @bin: a #gchar string describing the pipeline to construct.
- * @default_sink: an element to use as default if the given pipeline fails to construct.
- *
- * Render bin from description @bin using @default_sink element as a fallback.
- *
- * Returns: a #GstElement containing the rendered bin.
- */
-GstElement *
-gst_gconf_render_bin_with_default (const gchar * bin,
-    const gchar * default_sink)
-{
-  GstElement *ret = NULL;
-  GError *err = NULL;
-
-  if (bin != NULL)
-    ret = gst_parse_bin_from_description (bin, TRUE, &err);
-
-  if (ret == NULL || err != NULL) {
-    if (err) {
-      GST_DEBUG ("Could not create audio sink from GConf settings: %s",
-          err->message);
-      g_error_free (err);
-    } else {
-      GST_DEBUG ("Could not create audio sink from GConf settings");
-    }
-
-    ret = gst_element_factory_make (default_sink, NULL);
-
-    if (!ret)
-      g_warning
-          ("Could not build GConf audio sink and the replacement %s doesn't work",
-          DEFAULT_AUDIOSINK);
-  }
-
-  return ret;
-}
-
-/**
- * gst_gconf_get_default_video_sink:
- *
- * Render video output bin from GStreamer GConf key : "default/videosink".
- * If key is invalid, the default video sink for the platform is used
- * (typically xvimagesink or ximagesink).
- *
- * Returns: a #GstElement containing the video output bin, or NULL if
- * everything failed.
- */
-GstElement *
-gst_gconf_get_default_video_sink (void)
-{
-  GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_VIDEOSINK_KEY);
-
-  if (!ret) {
-    ret = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL);
-
-    if (!ret)
-      g_warning ("No GConf default video sink key and %s doesn't work",
-          DEFAULT_VIDEOSINK);
-  }
-
-  return ret;
-}
-
-/**
- * gst_gconf_get_default_audio_src:
- *
- * Render audio acquisition bin from GStreamer GConf key : "default/audiosrc".
- * If key is invalid, the default audio source for the plaform is used.
- * (typically osssrc or sunaudiosrc).
- *
- * Returns: a #GstElement containing the audio source bin, or NULL if
- * everything failed.
- */
-GstElement *
-gst_gconf_get_default_audio_src (void)
-{
-  GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_AUDIOSRC_KEY);
-
-  if (!ret) {
-    ret = gst_element_factory_make (DEFAULT_AUDIOSRC, NULL);
-
-    if (!ret)
-      g_warning ("No GConf default audio src key and %s doesn't work",
-          DEFAULT_AUDIOSRC);
-  }
-
-  return ret;
-}
-
-/**
- * gst_gconf_get_default_video_src:
- *
- * Render video acquisition bin from GStreamer GConf key :
- * "default/videosrc". If key is invalid, the default video source
- * for the platform is used (typically videotestsrc).
- *
- * Returns: a #GstElement containing the video source bin, or NULL if
- * everything failed.
- */
-GstElement *
-gst_gconf_get_default_video_src (void)
-{
-  GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_VIDEOSRC_KEY);
-
-  if (!ret) {
-    ret = gst_element_factory_make (DEFAULT_VIDEOSRC, NULL);
-
-    if (!ret)
-      g_warning ("No GConf default video src key and %s doesn't work",
-          DEFAULT_VIDEOSRC);
-  }
-
-  return ret;
-}
-
-/**
- * gst_gconf_get_default_visualization_element:
- *
- * Render visualization bin from GStreamer GConf key : "default/visualization".
- * If key is invalid, the default visualization element is used.
- *
- * Returns: a #GstElement containing the visualization bin, or NULL if
- * everything failed.
- */
-GstElement *
-gst_gconf_get_default_visualization_element (void)
-{
-  GstElement *ret = gst_gconf_render_bin_from_key ("default/visualization");
-
-  if (!ret) {
-    ret = gst_element_factory_make (DEFAULT_VISUALIZER, NULL);
-
-    if (!ret)
-      g_warning
-          ("No GConf default visualization plugin key and %s doesn't work",
-          DEFAULT_VISUALIZER);
-  }
-
-  return ret;
-}
diff --git a/ext/gconf/gstgconf.h b/ext/gconf/gstgconf.h
deleted file mode 100644 (file)
index b1153e9..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* GStreamer
- * Copyright (C) <2002> Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) <2006> Jürg Billeter <j@bitron.ch>
- *
- * 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_GCONF_H
-#define GST_GCONF_H
-
-/*
- * this library handles interaction with GConf
- */
-
-#include <gst/gst.h>
-#include <gconf/gconf-client.h>
-
-G_BEGIN_DECLS
-
-#define GST_GCONF_AUDIOSRC_KEY        "default/audiosrc"
-#define GST_GCONF_AUDIOSINK_KEY       "default/audiosink"
-#define GST_GCONF_MUSIC_AUDIOSINK_KEY "default/musicaudiosink"
-#define GST_GCONF_CHAT_AUDIOSINK_KEY  "default/chataudiosink"
-#define GST_GCONF_VIDEOSRC_KEY        "default/videosrc"
-#define GST_GCONF_VIDEOSINK_KEY       "default/videosink"
-
-typedef enum
-{
-  GCONF_PROFILE_SOUNDS,
-  GCONF_PROFILE_MUSIC,
-  GCONF_PROFILE_CHAT,
-  GCONF_PROFILE_NONE /* Internal value only */
-} GstGConfProfile;
-
-gchar *         gst_gconf_get_string            (const gchar *key);
-void            gst_gconf_set_string            (const gchar *key, 
-                                                 const gchar *value);
-
-const gchar *   gst_gconf_get_key_for_sink_profile (GstGConfProfile profile);
-
-GstElement *    gst_gconf_render_bin_from_key           (const gchar *key);
-GstElement *    gst_gconf_render_bin_with_default       (const gchar *bin,
-    const gchar *default_sink);
-
-GstElement *    gst_gconf_get_default_video_sink (void);
-GstElement *    gst_gconf_get_default_audio_sink (int profile);
-GstElement *    gst_gconf_get_default_video_src (void);
-GstElement *    gst_gconf_get_default_audio_src (void);
-GstElement *    gst_gconf_get_default_visualization_element (void);
-
-G_END_DECLS
-
-#endif /* GST_GCONF_H */
diff --git a/ext/gconf/gstgconfaudiosink.c b/ext/gconf/gstgconfaudiosink.c
deleted file mode 100644 (file)
index d60f2be..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * (c) 2006 Jürg Billeter <j@bitron.ch>
- *
- * 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.
- */
-/**
- * SECTION:element-gconfaudiosink
- *
- * This element outputs sound to the audiosink that has been configured in
- * GConf by the user.
- * 
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch filesrc location=foo.ogg ! decodebin ! audioconvert ! audioresample ! gconfaudiosink
- * ]| Play on configured audiosink
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstgconfelements.h"
-#include "gstgconfaudiosink.h"
-
-static void gst_gconf_audio_sink_dispose (GObject * object);
-static void gst_gconf_audio_sink_finalize (GstGConfAudioSink * sink);
-static void cb_change_child (GConfClient * client,
-    guint connection_id, GConfEntry * entry, gpointer data);
-static GstStateChangeReturn
-gst_gconf_audio_sink_change_state (GstElement * element,
-    GstStateChange transition);
-static void gst_gconf_switch_profile (GstGConfAudioSink * sink,
-    GstGConfProfile profile);
-
-enum
-{
-  PROP_0,
-  PROP_PROFILE
-};
-
-GST_BOILERPLATE (GstGConfAudioSink, gst_gconf_audio_sink, GstSwitchSink,
-    GST_TYPE_SWITCH_SINK);
-
-static void gst_gconf_audio_sink_set_property (GObject * object, guint prop_id,
-    const GValue * value, GParamSpec * pspec);
-static void gst_gconf_audio_sink_get_property (GObject * object, guint prop_id,
-    GValue * value, GParamSpec * pspec);
-
-static void
-gst_gconf_audio_sink_base_init (gpointer klass)
-{
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_set_details_simple (eklass, "GConf audio sink",
-      "Sink/Audio",
-      "Audio sink embedding the GConf-settings for audio output",
-      "Jan Schmidt <thaytan@mad.scientist.com>");
-}
-
-#define GST_TYPE_GCONF_PROFILE (gst_gconf_profile_get_type())
-static GType
-gst_gconf_profile_get_type (void)
-{
-  static GType gconf_profile_type = 0;
-  static const GEnumValue gconf_profiles[] = {
-    {GCONF_PROFILE_SOUNDS, "Sound Events", "sounds"},
-    {GCONF_PROFILE_MUSIC, "Music and Movies", "music"},
-    {GCONF_PROFILE_CHAT, "Audio/Video Conferencing", "chat"},
-    {0, NULL, NULL}
-  };
-
-  if (!gconf_profile_type) {
-    gconf_profile_type =
-        g_enum_register_static ("GstGConfProfile", gconf_profiles);
-  }
-  return gconf_profile_type;
-}
-
-static void
-gst_gconf_audio_sink_class_init (GstGConfAudioSinkClass * klass)
-{
-  GObjectClass *oklass = G_OBJECT_CLASS (klass);
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  oklass->set_property = gst_gconf_audio_sink_set_property;
-  oklass->get_property = gst_gconf_audio_sink_get_property;
-  oklass->dispose = gst_gconf_audio_sink_dispose;
-  oklass->finalize = (GObjectFinalizeFunc) gst_gconf_audio_sink_finalize;
-  eklass->change_state = gst_gconf_audio_sink_change_state;
-
-  g_object_class_install_property (oklass, PROP_PROFILE,
-      g_param_spec_enum ("profile", "Profile", "Profile",
-          GST_TYPE_GCONF_PROFILE, GCONF_PROFILE_SOUNDS,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-static void
-gst_gconf_audio_sink_reset (GstGConfAudioSink * sink)
-{
-  gst_switch_sink_set_child (GST_SWITCH_SINK (sink), NULL);
-
-  g_free (sink->gconf_str);
-  sink->gconf_str = NULL;
-}
-
-static void
-gst_gconf_audio_sink_init (GstGConfAudioSink * sink,
-    GstGConfAudioSinkClass * g_class)
-{
-  gst_gconf_audio_sink_reset (sink);
-
-  sink->client = gconf_client_get_default ();
-  gconf_client_add_dir (sink->client, GST_GCONF_DIR "/default",
-      GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
-
-  gst_gconf_switch_profile (sink, GCONF_PROFILE_SOUNDS);
-}
-
-static void
-gst_gconf_audio_sink_dispose (GObject * object)
-{
-  GstGConfAudioSink *sink = GST_GCONF_AUDIO_SINK (object);
-
-  if (sink->client) {
-    gst_gconf_switch_profile (sink, GCONF_PROFILE_NONE);
-    g_object_unref (G_OBJECT (sink->client));
-    sink->client = NULL;
-  }
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static void
-gst_gconf_audio_sink_finalize (GstGConfAudioSink * sink)
-{
-  g_free (sink->gconf_str);
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, finalize, ((GObject *) (sink)));
-}
-
-static gboolean
-do_change_child (GstGConfAudioSink * sink)
-{
-  const gchar *key;
-  gchar *new_gconf_str;
-  GstElement *new_kid;
-
-  if (sink->profile == GCONF_PROFILE_NONE)
-    return FALSE;               /* Can't switch to a 'NONE' sink */
-
-  key = gst_gconf_get_key_for_sink_profile (sink->profile);
-  new_gconf_str = gst_gconf_get_string (key);
-
-  GST_LOG_OBJECT (sink, "old gconf string: %s", GST_STR_NULL (sink->gconf_str));
-  GST_LOG_OBJECT (sink, "new gconf string: %s", GST_STR_NULL (new_gconf_str));
-
-  if (new_gconf_str != NULL && sink->gconf_str != NULL &&
-      (strlen (new_gconf_str) == 0 ||
-          strcmp (sink->gconf_str, new_gconf_str) == 0)) {
-    g_free (new_gconf_str);
-    GST_DEBUG_OBJECT (sink,
-        "GConf key was updated, but it didn't change. Ignoring");
-    return TRUE;
-  }
-
-  GST_DEBUG_OBJECT (sink, "GConf key changed: '%s' to '%s'",
-      GST_STR_NULL (sink->gconf_str), GST_STR_NULL (new_gconf_str));
-
-  GST_DEBUG_OBJECT (sink, "Creating new child for profile %d", sink->profile);
-  new_kid =
-      gst_gconf_render_bin_with_default (new_gconf_str, DEFAULT_AUDIOSINK);
-
-  if (new_kid == NULL) {
-    GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
-        ("Failed to render audio sink from GConf"));
-    goto fail;
-  }
-
-  if (!gst_switch_sink_set_child (GST_SWITCH_SINK (sink), new_kid)) {
-    GST_WARNING_OBJECT (sink, "Failed to update child element");
-    goto fail;
-  }
-
-  g_free (sink->gconf_str);
-  sink->gconf_str = new_gconf_str;
-
-  GST_DEBUG_OBJECT (sink, "done changing gconf audio sink");
-
-  return TRUE;
-
-fail:
-  g_free (new_gconf_str);
-  return FALSE;
-}
-
-static void
-gst_gconf_switch_profile (GstGConfAudioSink * sink, GstGConfProfile profile)
-{
-  if (sink->client == NULL)
-    return;
-
-  if (sink->notify_id) {
-    GST_DEBUG_OBJECT (sink, "Unsubscribing old key %s for profile %d",
-        gst_gconf_get_key_for_sink_profile (sink->profile), sink->profile);
-    gconf_client_notify_remove (sink->client, sink->notify_id);
-    sink->notify_id = 0;
-  }
-
-  sink->profile = profile;
-  if (profile != GCONF_PROFILE_NONE) {
-    const gchar *key = gst_gconf_get_key_for_sink_profile (sink->profile);
-
-    GST_DEBUG_OBJECT (sink, "Subscribing to key %s for profile %d",
-        key, profile);
-    sink->notify_id = gconf_client_notify_add (sink->client, key,
-        cb_change_child, sink, NULL, NULL);
-  }
-}
-
-static void
-gst_gconf_audio_sink_set_property (GObject * object, guint prop_id,
-    const GValue * value, GParamSpec * pspec)
-{
-  GstGConfAudioSink *sink;
-
-  sink = GST_GCONF_AUDIO_SINK (object);
-
-  switch (prop_id) {
-    case PROP_PROFILE:
-      gst_gconf_switch_profile (sink, g_value_get_enum (value));
-      break;
-    default:
-      break;
-  }
-}
-
-static void
-gst_gconf_audio_sink_get_property (GObject * object, guint prop_id,
-    GValue * value, GParamSpec * pspec)
-{
-  GstGConfAudioSink *sink;
-
-  sink = GST_GCONF_AUDIO_SINK (object);
-
-  switch (prop_id) {
-    case PROP_PROFILE:
-      g_value_set_enum (value, sink->profile);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-  }
-}
-
-static void
-cb_change_child (GConfClient * client,
-    guint connection_id, GConfEntry * entry, gpointer data)
-{
-  do_change_child (GST_GCONF_AUDIO_SINK (data));
-}
-
-static GstStateChangeReturn
-gst_gconf_audio_sink_change_state (GstElement * element,
-    GstStateChange transition)
-{
-  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
-  GstGConfAudioSink *sink = GST_GCONF_AUDIO_SINK (element);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_NULL_TO_READY:
-      if (!do_change_child (sink)) {
-        gst_gconf_audio_sink_reset (sink);
-        return GST_STATE_CHANGE_FAILURE;
-      }
-      break;
-    default:
-      break;
-  }
-
-  ret = GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
-      (element, transition), GST_STATE_CHANGE_SUCCESS);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_READY_TO_NULL:
-      gst_gconf_audio_sink_reset (sink);
-      break;
-    default:
-      break;
-  }
-
-  return ret;
-}
diff --git a/ext/gconf/gstgconfaudiosink.h b/ext/gconf/gstgconfaudiosink.h
deleted file mode 100644 (file)
index 2d730f3..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.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_GCONF_AUDIO_SINK_H__
-#define __GST_GCONF_AUDIO_SINK_H__
-
-#include <gst/gst.h>
-#include <gconf/gconf-client.h>
-#include "gstswitchsink.h"
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GCONF_AUDIO_SINK \
-  (gst_gconf_audio_sink_get_type ())
-#define GST_GCONF_AUDIO_SINK(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GCONF_AUDIO_SINK, \
-                               GstGConfAudioSink))
-#define GST_GCONF_AUDIO_SINK_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GCONF_AUDIO_SINK, \
-                            GstGConfAudioSinkClass))
-#define GST_IS_GCONF_AUDIO_SINK(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GCONF_AUDIO_SINK))
-#define GST_IS_GCONF_AUDIO_SINK_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GCONF_AUDIO_SINK))
-
-typedef struct _GstGConfAudioSink {
-  GstSwitchSink parent;
-
-  /* explicit pointers to stuff used */
-  GConfClient *client;
-  GstGConfProfile profile;
-  guint notify_id;
-
-  /* Current gconf string */
-  gchar *gconf_str;
-} GstGConfAudioSink;
-
-typedef struct _GstGConfAudioSinkClass {
-  GstSwitchSinkClass parent_class;
-} GstGConfAudioSinkClass;
-
-GType   gst_gconf_audio_sink_get_type   (void);
-
-G_END_DECLS
-
-#endif /* __GST_GCONF_AUDIO_SINK_H__ */
diff --git a/ext/gconf/gstgconfaudiosrc.c b/ext/gconf/gstgconfaudiosrc.c
deleted file mode 100644 (file)
index 2fdd61f..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * (c) 2005 Tim-Philipp Müller <tim centricular 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.
- */
-/**
- * SECTION:element-gconfaudiosrc
- * @see_also: #GstAlsaSrc, #GstAutoAudioSrc
- *
- * This element records sound from the audiosink that has been configured in
- * GConf by the user.
- *
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch gconfaudiosrc ! audioconvert ! wavenc ! filesink location=record.wav
- * ]| Record from configured audioinput
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstgconfelements.h"
-#include "gstgconfaudiosrc.h"
-
-static void gst_gconf_audio_src_dispose (GObject * object);
-static void gst_gconf_audio_src_finalize (GstGConfAudioSrc * src);
-static void cb_toggle_element (GConfClient * client,
-    guint connection_id, GConfEntry * entry, gpointer data);
-static GstStateChangeReturn
-gst_gconf_audio_src_change_state (GstElement * element,
-    GstStateChange transition);
-
-GST_BOILERPLATE (GstGConfAudioSrc, gst_gconf_audio_src, GstSwitchSrc,
-    GST_TYPE_SWITCH_SRC);
-
-static void
-gst_gconf_audio_src_base_init (gpointer klass)
-{
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_set_details_simple (eklass, "GConf audio source",
-      "Source/Audio",
-      "Audio source embedding the GConf-settings for audio input",
-      "GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
-}
-
-static void
-gst_gconf_audio_src_class_init (GstGConfAudioSrcClass * klass)
-{
-  GObjectClass *oklass = G_OBJECT_CLASS (klass);
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  oklass->dispose = gst_gconf_audio_src_dispose;
-  oklass->finalize = (GObjectFinalizeFunc) gst_gconf_audio_src_finalize;
-  eklass->change_state = gst_gconf_audio_src_change_state;
-}
-
-/*
- * Hack to make negotiation work.
- */
-
-static gboolean
-gst_gconf_audio_src_reset (GstGConfAudioSrc * src)
-{
-  gst_switch_src_set_child (GST_SWITCH_SRC (src), NULL);
-
-  g_free (src->gconf_str);
-  src->gconf_str = NULL;
-  return TRUE;
-}
-
-static void
-gst_gconf_audio_src_init (GstGConfAudioSrc * src,
-    GstGConfAudioSrcClass * g_class)
-{
-  gst_gconf_audio_src_reset (src);
-
-  src->client = gconf_client_get_default ();
-  gconf_client_add_dir (src->client, GST_GCONF_DIR,
-      GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
-  src->gconf_notify_id = gconf_client_notify_add (src->client,
-      GST_GCONF_DIR "/" GST_GCONF_AUDIOSRC_KEY,
-      cb_toggle_element, src, NULL, NULL);
-}
-
-static void
-gst_gconf_audio_src_dispose (GObject * object)
-{
-  GstGConfAudioSrc *src = GST_GCONF_AUDIO_SRC (object);
-
-  if (src->client) {
-    if (src->gconf_notify_id) {
-      gconf_client_notify_remove (src->client, src->gconf_notify_id);
-      src->gconf_notify_id = 0;
-    }
-
-    g_object_unref (G_OBJECT (src->client));
-    src->client = NULL;
-  }
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static void
-gst_gconf_audio_src_finalize (GstGConfAudioSrc * src)
-{
-  g_free (src->gconf_str);
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, finalize, ((GObject *) (src)));
-}
-
-static gboolean
-do_toggle_element (GstGConfAudioSrc * src)
-{
-  GstElement *new_kid;
-  gchar *new_gconf_str;
-
-  new_gconf_str = gst_gconf_get_string (GST_GCONF_AUDIOSRC_KEY);
-  if (new_gconf_str != NULL && src->gconf_str != NULL &&
-      (strlen (new_gconf_str) == 0 ||
-          strcmp (src->gconf_str, new_gconf_str) == 0)) {
-    g_free (new_gconf_str);
-    GST_DEBUG_OBJECT (src, "GConf key was updated, but it didn't change");
-    return TRUE;
-  }
-
-  GST_DEBUG_OBJECT (src, "GConf key changed: '%s' to '%s'",
-      GST_STR_NULL (src->gconf_str), GST_STR_NULL (new_gconf_str));
-
-  GST_DEBUG_OBJECT (src, "Creating new kid");
-  if (!(new_kid = gst_gconf_get_default_audio_src ())) {
-    GST_ELEMENT_ERROR (src, LIBRARY, SETTINGS, (NULL),
-        ("Failed to render audio src from GConf"));
-    return FALSE;
-  }
-
-  if (!gst_switch_src_set_child (GST_SWITCH_SRC (src), new_kid)) {
-    GST_WARNING_OBJECT (src, "Failed to update child element");
-    goto fail;
-  }
-
-  g_free (src->gconf_str);
-  src->gconf_str = new_gconf_str;
-
-  GST_DEBUG_OBJECT (src, "done changing gconf audio src");
-
-  return TRUE;
-fail:
-  g_free (new_gconf_str);
-  return FALSE;
-}
-
-static void
-cb_toggle_element (GConfClient * client,
-    guint connection_id, GConfEntry * entry, gpointer data)
-{
-  do_toggle_element (GST_GCONF_AUDIO_SRC (data));
-}
-
-static GstStateChangeReturn
-gst_gconf_audio_src_change_state (GstElement * element,
-    GstStateChange transition)
-{
-  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
-  GstGConfAudioSrc *src = GST_GCONF_AUDIO_SRC (element);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_NULL_TO_READY:
-      if (!do_toggle_element (src)) {
-        gst_gconf_audio_src_reset (src);
-        return GST_STATE_CHANGE_FAILURE;
-      }
-      break;
-    default:
-      break;
-  }
-
-  ret = GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
-      (element, transition), GST_STATE_CHANGE_SUCCESS);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_READY_TO_NULL:
-      if (!gst_gconf_audio_src_reset (src))
-        ret = GST_STATE_CHANGE_FAILURE;
-      break;
-    default:
-      break;
-  }
-
-  return ret;
-}
diff --git a/ext/gconf/gstgconfaudiosrc.h b/ext/gconf/gstgconfaudiosrc.h
deleted file mode 100644 (file)
index 40fb94b..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * (c) 2005 Tim-Philipp Müller <tim centricular 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_GCONF_AUDIO_SRC_H__
-#define __GST_GCONF_AUDIO_SRC_H__
-
-#include <gst/gst.h>
-#include <gconf/gconf-client.h>
-
-#include "gstswitchsrc.h"
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GCONF_AUDIO_SRC            (gst_gconf_audio_src_get_type ())
-#define GST_GCONF_AUDIO_SRC(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GCONF_AUDIO_SRC, GstGConfAudioSrc))
-#define GST_GCONF_AUDIO_SRC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GCONF_AUDIO_SRC, GstGConfAudioSrcClass))
-#define GST_IS_GCONF_AUDIO_SRC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GCONF_AUDIO_SRC))
-#define GST_IS_GCONF_AUDIO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GCONF_AUDIO_SRC))
-
-typedef struct _GstGConfAudioSrc {
-  GstSwitchSrc parent;
-
-  /* explicit pointers to stuff used */
-  GConfClient *client;
-
-  guint gconf_notify_id;
-
-  /* Current gconf string */
-  gchar *gconf_str;
-} GstGConfAudioSrc;
-
-typedef struct _GstGConfAudioSrcClass {
-  GstSwitchSrcClass parent_class;
-} GstGConfAudioSrcClass;
-
-GType   gst_gconf_audio_src_get_type   (void);
-
-G_END_DECLS
-
-#endif /* __GST_GCONF_AUDIO_SRC_H__ */
diff --git a/ext/gconf/gstgconfelements.c b/ext/gconf/gstgconfelements.c
deleted file mode 100644 (file)
index 06f0113..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.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 <gst/gst.h>
-
-#include "gstgconfelements.h"
-
-#include "gstgconfaudiosink.h"
-#include "gstgconfaudiosrc.h"
-#include "gstgconfvideosink.h"
-#include "gstgconfvideosrc.h"
-
-GST_DEBUG_CATEGORY (gconf_debug);
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (gconf_debug, "gconf", 0,
-      "GConf/GStreamer audio/video output wrapper elements");
-
-  if (!gst_element_register (plugin, "gconfvideosink",
-          GST_RANK_NONE, GST_TYPE_GCONF_VIDEO_SINK) ||
-      !gst_element_register (plugin, "gconfvideosrc",
-          GST_RANK_NONE, GST_TYPE_GCONF_VIDEO_SRC) ||
-      !gst_element_register (plugin, "gconfaudiosink",
-          GST_RANK_NONE, GST_TYPE_GCONF_AUDIO_SINK) ||
-      !gst_element_register (plugin, "gconfaudiosrc",
-          GST_RANK_NONE, GST_TYPE_GCONF_AUDIO_SRC)) {
-    return FALSE;
-  }
-
-  return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    "gconfelements",
-    "elements wrapping the GStreamer/GConf audio/video output settings",
-    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/ext/gconf/gstgconfelements.h b/ext/gconf/gstgconfelements.h
deleted file mode 100644 (file)
index 872b2f2..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.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_GCONF_ELEMENTS_H__
-#define __GST_GCONF_ELEMENTS_H__
-
-#include "gstgconf.h"
-
-GST_DEBUG_CATEGORY_EXTERN (gconf_debug);
-#define GST_CAT_DEFAULT gconf_debug
-
-#endif /* __GST_GCONF_ELEMENTS_H__ */
diff --git a/ext/gconf/gstgconfvideosink.c b/ext/gconf/gstgconfvideosink.c
deleted file mode 100644 (file)
index 10fe90d..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.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.
- */
-/**
- * SECTION:element-gconfvideosink
- *
- * This element outputs video to the videosink that has been configured in
- * GConf by the user.
- * 
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch filesrc location=foo.ogg ! decodebin ! ffmpegcolorspace ! gconfvideosink
- * ]| Play on configured videosink
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstgconfelements.h"
-#include "gstgconfvideosink.h"
-
-static void gst_gconf_video_sink_dispose (GObject * object);
-static void gst_gconf_video_sink_finalize (GstGConfVideoSink * sink);
-static void cb_toggle_element (GConfClient * client,
-    guint connection_id, GConfEntry * entry, gpointer data);
-static GstStateChangeReturn
-gst_gconf_video_sink_change_state (GstElement * element,
-    GstStateChange transition);
-
-GST_BOILERPLATE (GstGConfVideoSink, gst_gconf_video_sink, GstSwitchSink,
-    GST_TYPE_SWITCH_SINK);
-
-static void
-gst_gconf_video_sink_base_init (gpointer klass)
-{
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_set_details_simple (eklass, "GConf video sink",
-      "Sink/Video",
-      "Video sink embedding the GConf-settings for video output",
-      "GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
-}
-
-static void
-gst_gconf_video_sink_class_init (GstGConfVideoSinkClass * klass)
-{
-  GObjectClass *oklass = G_OBJECT_CLASS (klass);
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  oklass->dispose = gst_gconf_video_sink_dispose;
-  oklass->finalize = (GObjectFinalizeFunc) gst_gconf_video_sink_finalize;
-  eklass->change_state = gst_gconf_video_sink_change_state;
-}
-
-/*
- * Hack to make negotiation work.
- */
-
-static void
-gst_gconf_video_sink_reset (GstGConfVideoSink * sink)
-{
-  gst_switch_sink_set_child (GST_SWITCH_SINK (sink), NULL);
-
-  g_free (sink->gconf_str);
-  sink->gconf_str = NULL;
-}
-
-static void
-gst_gconf_video_sink_init (GstGConfVideoSink * sink,
-    GstGConfVideoSinkClass * g_class)
-{
-  gst_gconf_video_sink_reset (sink);
-
-  sink->client = gconf_client_get_default ();
-  gconf_client_add_dir (sink->client, GST_GCONF_DIR,
-      GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
-  sink->notify_id = gconf_client_notify_add (sink->client,
-      GST_GCONF_DIR "/" GST_GCONF_VIDEOSINK_KEY,
-      cb_toggle_element, sink, NULL, NULL);
-}
-
-static void
-gst_gconf_video_sink_dispose (GObject * object)
-{
-  GstGConfVideoSink *sink = GST_GCONF_VIDEO_SINK (object);
-
-  if (sink->client) {
-    if (sink->notify_id != 0)
-      gconf_client_notify_remove (sink->client, sink->notify_id);
-
-    g_object_unref (G_OBJECT (sink->client));
-    sink->client = NULL;
-  }
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static void
-gst_gconf_video_sink_finalize (GstGConfVideoSink * sink)
-{
-  g_free (sink->gconf_str);
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, finalize, ((GObject *) (sink)));
-}
-
-static gboolean
-do_change_child (GstGConfVideoSink * sink)
-{
-  gchar *new_gconf_str;
-  GstElement *new_kid;
-
-  new_gconf_str = gst_gconf_get_string (GST_GCONF_VIDEOSINK_KEY);
-
-  GST_LOG_OBJECT (sink, "old gconf string: %s", GST_STR_NULL (sink->gconf_str));
-  GST_LOG_OBJECT (sink, "new gconf string: %s", GST_STR_NULL (new_gconf_str));
-
-  if (new_gconf_str != NULL && sink->gconf_str != NULL &&
-      (strlen (new_gconf_str) == 0 ||
-          strcmp (sink->gconf_str, new_gconf_str) == 0)) {
-    g_free (new_gconf_str);
-    GST_DEBUG_OBJECT (sink,
-        "GConf key was updated, but it didn't change. Ignoring");
-    return TRUE;
-  }
-
-  GST_DEBUG_OBJECT (sink, "GConf key changed: '%s' to '%s'",
-      GST_STR_NULL (sink->gconf_str), GST_STR_NULL (new_gconf_str));
-
-  GST_DEBUG_OBJECT (sink, "Creating new kid");
-  if (!(new_kid = gst_gconf_get_default_video_sink ())) {
-    GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
-        ("Failed to render video sink from GConf"));
-    return FALSE;
-  }
-
-  if (!gst_switch_sink_set_child (GST_SWITCH_SINK (sink), new_kid)) {
-    GST_WARNING_OBJECT (sink, "Failed to update child element");
-    goto fail;
-  }
-
-  g_free (sink->gconf_str);
-  sink->gconf_str = new_gconf_str;
-
-  GST_DEBUG_OBJECT (sink, "done changing gconf video sink");
-
-  return TRUE;
-
-fail:
-  g_free (new_gconf_str);
-  return FALSE;
-}
-
-static void
-cb_toggle_element (GConfClient * client,
-    guint connection_id, GConfEntry * entry, gpointer data)
-{
-  do_change_child (GST_GCONF_VIDEO_SINK (data));
-}
-
-static GstStateChangeReturn
-gst_gconf_video_sink_change_state (GstElement * element,
-    GstStateChange transition)
-{
-  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
-  GstGConfVideoSink *sink = GST_GCONF_VIDEO_SINK (element);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_NULL_TO_READY:
-      if (!do_change_child (sink)) {
-        gst_gconf_video_sink_reset (sink);
-        return GST_STATE_CHANGE_FAILURE;
-      }
-      break;
-    default:
-      break;
-  }
-
-  ret = GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
-      (element, transition), GST_STATE_CHANGE_SUCCESS);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_READY_TO_NULL:
-      gst_gconf_video_sink_reset (sink);
-      break;
-    default:
-      break;
-  }
-
-  return ret;
-}
diff --git a/ext/gconf/gstgconfvideosink.h b/ext/gconf/gstgconfvideosink.h
deleted file mode 100644 (file)
index faaa0a8..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.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_GCONF_VIDEO_SINK_H__
-#define __GST_GCONF_VIDEO_SINK_H__
-
-#include <gst/gst.h>
-#include <gconf/gconf-client.h>
-
-#include "gstswitchsink.h"
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GCONF_VIDEO_SINK \
-  (gst_gconf_video_sink_get_type ())
-#define GST_GCONF_VIDEO_SINK(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GCONF_VIDEO_SINK, \
-                               GstGConfVideoSink))
-#define GST_GCONF_VIDEO_SINK_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GCONF_VIDEO_SINK, \
-                            GstGConfVideoSinkClass))
-#define GST_IS_GCONF_VIDEO_SINK(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GCONF_VIDEO_SINK))
-#define GST_IS_GCONF_VIDEO_SINK_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GCONF_VIDEO_SINK))
-
-typedef struct _GstGConfVideoSink {
-  GstSwitchSink parent;
-
-  /* explicit pointers to stuff used */
-  GConfClient *client;
-
-  /* gconf notify id */
-  guint notify_id;
-
-  /* Current gconf string */
-  gchar *gconf_str;
-} GstGConfVideoSink;
-
-typedef struct _GstGConfVideoSinkClass {
-  GstSwitchSinkClass parent_class;
-} GstGConfVideoSinkClass;
-
-GType   gst_gconf_video_sink_get_type   (void);
-
-G_END_DECLS
-
-#endif /* __GST_GCONF_VIDEO_SINK_H__ */
diff --git a/ext/gconf/gstgconfvideosrc.c b/ext/gconf/gstgconfvideosrc.c
deleted file mode 100644 (file)
index 2d9d5df..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * (c) 2005 Tim-Philipp Müller <tim centricular 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.
- */
-/**
- * SECTION:element-gconfvideosrc
- * @see_also: #GstAlsaSrc, #GstAutoVideoSrc
- *
- * This element records video from the videosink that has been configured in
- * GConf by the user.
- *
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch gconfvideosrc ! theoraenc ! oggmux ! filesink location=record.ogg
- * ]| Record from configured videoinput
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "gstgconfelements.h"
-#include "gstgconfvideosrc.h"
-
-static void gst_gconf_video_src_dispose (GObject * object);
-static void gst_gconf_video_src_finalize (GstGConfVideoSrc * src);
-static void cb_toggle_element (GConfClient * client,
-    guint connection_id, GConfEntry * entry, gpointer data);
-static GstStateChangeReturn
-gst_gconf_video_src_change_state (GstElement * element,
-    GstStateChange transition);
-
-GST_BOILERPLATE (GstGConfVideoSrc, gst_gconf_video_src, GstSwitchSrc,
-    GST_TYPE_SWITCH_SRC);
-
-static void
-gst_gconf_video_src_base_init (gpointer klass)
-{
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_set_details_simple (eklass, "GConf video source",
-      "Source/Video",
-      "Video source embedding the GConf-settings for video input",
-      "GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
-}
-
-static void
-gst_gconf_video_src_class_init (GstGConfVideoSrcClass * klass)
-{
-  GObjectClass *oklass = G_OBJECT_CLASS (klass);
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  oklass->dispose = gst_gconf_video_src_dispose;
-  oklass->finalize = (GObjectFinalizeFunc) gst_gconf_video_src_finalize;
-  eklass->change_state = gst_gconf_video_src_change_state;
-}
-
-/*
- * Hack to make negotiation work.
- */
-
-static gboolean
-gst_gconf_video_src_reset (GstGConfVideoSrc * src)
-{
-  gst_switch_src_set_child (GST_SWITCH_SRC (src), NULL);
-
-  g_free (src->gconf_str);
-  src->gconf_str = NULL;
-
-  return TRUE;
-}
-
-static void
-gst_gconf_video_src_init (GstGConfVideoSrc * src,
-    GstGConfVideoSrcClass * g_class)
-{
-  gst_gconf_video_src_reset (src);
-
-  src->client = gconf_client_get_default ();
-  gconf_client_add_dir (src->client, GST_GCONF_DIR,
-      GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
-  src->notify_id = gconf_client_notify_add (src->client,
-      GST_GCONF_DIR "/" GST_GCONF_VIDEOSRC_KEY,
-      cb_toggle_element, src, NULL, NULL);
-}
-
-static void
-gst_gconf_video_src_dispose (GObject * object)
-{
-  GstGConfVideoSrc *src = GST_GCONF_VIDEO_SRC (object);
-
-  if (src->client) {
-    if (src->notify_id != 0)
-      gconf_client_notify_remove (src->client, src->notify_id);
-
-    g_object_unref (G_OBJECT (src->client));
-    src->client = NULL;
-  }
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static void
-gst_gconf_video_src_finalize (GstGConfVideoSrc * src)
-{
-  g_free (src->gconf_str);
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, finalize, ((GObject *) (src)));
-}
-
-static gboolean
-do_toggle_element (GstGConfVideoSrc * src)
-{
-  GstElement *new_kid;
-  gchar *new_gconf_str;
-
-  new_gconf_str = gst_gconf_get_string (GST_GCONF_VIDEOSRC_KEY);
-  if (new_gconf_str != NULL && src->gconf_str != NULL &&
-      (strlen (new_gconf_str) == 0 ||
-          strcmp (src->gconf_str, new_gconf_str) == 0)) {
-    g_free (new_gconf_str);
-    GST_DEBUG_OBJECT (src, "GConf key was updated, but it didn't change");
-    return TRUE;
-  }
-
-  GST_DEBUG_OBJECT (src, "GConf key changed: '%s' to '%s'",
-      GST_STR_NULL (src->gconf_str), GST_STR_NULL (new_gconf_str));
-
-  GST_DEBUG_OBJECT (src, "Creating new kid");
-  if (!(new_kid = gst_gconf_get_default_video_src ())) {
-    GST_ELEMENT_ERROR (src, LIBRARY, SETTINGS, (NULL),
-        ("Failed to render video src from GConf"));
-    return FALSE;
-  }
-
-  if (!gst_switch_src_set_child (GST_SWITCH_SRC (src), new_kid)) {
-    GST_WARNING_OBJECT (src, "Failed to update child element");
-    goto fail;
-  }
-
-  g_free (src->gconf_str);
-  src->gconf_str = new_gconf_str;
-
-  GST_DEBUG_OBJECT (src, "done changing gconf video src");
-
-  return TRUE;
-fail:
-  g_free (new_gconf_str);
-  return FALSE;
-}
-
-static void
-cb_toggle_element (GConfClient * client,
-    guint connection_id, GConfEntry * entry, gpointer data)
-{
-  do_toggle_element (GST_GCONF_VIDEO_SRC (data));
-}
-
-static GstStateChangeReturn
-gst_gconf_video_src_change_state (GstElement * element,
-    GstStateChange transition)
-{
-  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
-  GstGConfVideoSrc *src = GST_GCONF_VIDEO_SRC (element);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_NULL_TO_READY:
-      if (!do_toggle_element (src)) {
-        gst_gconf_video_src_reset (src);
-        return GST_STATE_CHANGE_FAILURE;
-      }
-      break;
-    default:
-      break;
-  }
-
-  ret = GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
-      (element, transition), GST_STATE_CHANGE_SUCCESS);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_READY_TO_NULL:
-      if (!gst_gconf_video_src_reset (src))
-        ret = GST_STATE_CHANGE_FAILURE;
-      break;
-    default:
-      break;
-  }
-
-  return ret;
-}
diff --git a/ext/gconf/gstgconfvideosrc.h b/ext/gconf/gstgconfvideosrc.h
deleted file mode 100644 (file)
index 5c8300d..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * (c) 2005 Tim-Philipp Müller <tim centricular 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_GCONF_VIDEO_SRC_H__
-#define __GST_GCONF_VIDEO_SRC_H__
-
-#include <gst/gst.h>
-#include <gconf/gconf-client.h>
-
-#include "gstswitchsrc.h"
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_GCONF_VIDEO_SRC            (gst_gconf_video_src_get_type ())
-#define GST_GCONF_VIDEO_SRC(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GCONF_VIDEO_SRC, GstGConfVideoSrc))
-#define GST_GCONF_VIDEO_SRC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GCONF_VIDEO_SRC, GstGConfVideoSrcClass))
-#define GST_IS_GCONF_VIDEO_SRC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GCONF_VIDEO_SRC))
-#define GST_IS_GCONF_VIDEO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GCONF_VIDEO_SRC))
-
-typedef struct _GstGConfVideoSrc {
-  GstSwitchSrc parent;
-
-  /* explicit pointers to stuff used */
-  GConfClient *client;
-
-  /* gconf key notification id */
-  guint notify_id;
-
-  /* Current gconf string */
-  gchar *gconf_str;
-} GstGConfVideoSrc;
-
-typedef struct _GstGConfVideoSrcClass {
-  GstSwitchSrcClass parent_class;
-} GstGConfVideoSrcClass;
-
-GType   gst_gconf_video_src_get_type   (void);
-
-G_END_DECLS
-
-#endif /* __GST_GCONF_VIDEO_SRC_H__ */
diff --git a/ext/gconf/gstswitchsink.c b/ext/gconf/gstswitchsink.c
deleted file mode 100644 (file)
index 1fccf68..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-/* GStreamer
- * Copyright (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (c) 2006 Jürg Billeter <j@bitron.ch>
- * Copyright (c) 2007 Jan Schmidt <thaytan@noraisin.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 <string.h>
-
-#include "gstswitchsink.h"
-
-GST_DEBUG_CATEGORY_STATIC (switch_debug);
-#define GST_CAT_DEFAULT switch_debug
-
-static void gst_switch_sink_dispose (GObject * object);
-static GstStateChangeReturn
-gst_switch_sink_change_state (GstElement * element, GstStateChange transition);
-
-enum
-{
-  PROP_0
-};
-
-GST_BOILERPLATE (GstSwitchSink, gst_switch_sink, GstBin, GST_TYPE_BIN);
-
-static void
-gst_switch_sink_base_init (gpointer klass)
-{
-  GST_DEBUG_CATEGORY_INIT (switch_debug, "switchsink", 0, "switchsink element");
-}
-
-static void
-gst_switch_sink_class_init (GstSwitchSinkClass * klass)
-{
-  GObjectClass *oklass = G_OBJECT_CLASS (klass);
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-  static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
-      GST_PAD_SINK,
-      GST_PAD_ALWAYS,
-      GST_STATIC_CAPS_ANY);
-  GstPadTemplate *child_pad_templ;
-
-  oklass->dispose = gst_switch_sink_dispose;
-  eklass->change_state = gst_switch_sink_change_state;
-
-  /* Provide a default pad template if the child didn't */
-  child_pad_templ = gst_element_class_get_pad_template (eklass, "sink");
-  if (child_pad_templ == NULL) {
-    gst_element_class_add_pad_template (eklass,
-        gst_static_pad_template_get (&sink_template));
-  }
-}
-
-static gboolean
-gst_switch_sink_reset (GstSwitchSink * sink)
-{
-  /* this will install fakesink if no other child has been set,
-   * otherwise we rely on the subclass to know when to unset its
-   * custom kid */
-  if (sink->kid == NULL) {
-    return gst_switch_sink_set_child (sink, NULL);
-  }
-
-  return TRUE;
-}
-
-static void
-gst_switch_sink_init (GstSwitchSink * sink, GstSwitchSinkClass * g_class)
-{
-  GstElementClass *eklass = GST_ELEMENT_GET_CLASS (sink);
-  GstPadTemplate *templ;
-
-  templ = gst_element_class_get_pad_template (eklass, "sink");
-  sink->pad = gst_ghost_pad_new_no_target_from_template ("sink", templ);
-  gst_element_add_pad (GST_ELEMENT (sink), sink->pad);
-
-  gst_switch_sink_reset (sink);
-
-  GST_OBJECT_FLAG_SET (sink, GST_ELEMENT_IS_SINK);
-}
-
-static void
-gst_switch_sink_dispose (GObject * object)
-{
-  GstSwitchSink *sink = GST_SWITCH_SINK (object);
-  GstObject *new_kid, *kid;
-
-  GST_OBJECT_LOCK (sink);
-  new_kid = GST_OBJECT_CAST (sink->new_kid);
-  sink->new_kid = NULL;
-
-  kid = GST_OBJECT_CAST (sink->kid);
-  sink->kid = NULL;
-  GST_OBJECT_UNLOCK (sink);
-
-  gst_object_replace (&new_kid, NULL);
-  gst_object_replace (&kid, NULL);
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static gboolean
-gst_switch_sink_commit_new_kid (GstSwitchSink * sink)
-{
-  GstPad *targetpad;
-  GstState kid_state;
-  GstElement *new_kid, *old_kid;
-  gboolean is_fakesink = FALSE;
-  GstBus *bus;
-
-  /* need locking around member accesses */
-  GST_OBJECT_LOCK (sink);
-  /* If we're currently changing state, set the child to the next state
-   * we're transitioning too, rather than our current state which is 
-   * about to change */
-  if (GST_STATE_NEXT (sink) != GST_STATE_VOID_PENDING)
-    kid_state = GST_STATE_NEXT (sink);
-  else
-    kid_state = GST_STATE (sink);
-
-  new_kid = sink->new_kid ? gst_object_ref (sink->new_kid) : NULL;
-  sink->new_kid = NULL;
-  GST_OBJECT_UNLOCK (sink);
-
-  /* Fakesink by default if NULL is passed as the new child */
-  if (new_kid == NULL) {
-    GST_DEBUG_OBJECT (sink, "Replacing kid with fakesink");
-    new_kid = gst_element_factory_make ("fakesink", "testsink");
-    if (new_kid == NULL) {
-      GST_ERROR_OBJECT (sink, "Failed to create fakesink");
-      return FALSE;
-    }
-    /* Add a reference, as it would if the element came from sink->new_kid */
-    gst_object_ref (new_kid);
-    g_object_set (new_kid, "sync", TRUE, NULL);
-    is_fakesink = TRUE;
-  } else {
-    GST_DEBUG_OBJECT (sink, "Setting new kid");
-  }
-
-  /* set temporary bus of our own to catch error messages from the child
-   * (could we just set our own bus on it, or would the state change messages
-   * from the not-yet-added element confuse the state change algorithm? Let's
-   * play it safe for now) */
-  bus = gst_bus_new ();
-  gst_element_set_bus (new_kid, bus);
-  gst_object_unref (bus);
-
-  if (gst_element_set_state (new_kid, kid_state) == GST_STATE_CHANGE_FAILURE) {
-    GstMessage *msg;
-
-    /* check if child posted an error message and if so re-post it on our bus
-     * so that the application gets to see a decent error and not our generic
-     * fallback error message which is completely indecipherable to the user */
-    msg = gst_bus_pop_filtered (GST_ELEMENT_BUS (new_kid), GST_MESSAGE_ERROR);
-    if (msg) {
-      GST_INFO_OBJECT (sink, "Forwarding kid error: %" GST_PTR_FORMAT, msg);
-      gst_element_post_message (GST_ELEMENT (sink), msg);
-    }
-    GST_ELEMENT_ERROR (sink, CORE, STATE_CHANGE, (NULL),
-        ("Failed to set state on new child."));
-    gst_element_set_bus (new_kid, NULL);
-    gst_object_unref (new_kid);
-    return FALSE;
-  }
-  gst_element_set_bus (new_kid, NULL);
-  gst_bin_add (GST_BIN (sink), new_kid);
-
-  /* Now, replace the existing child */
-  GST_OBJECT_LOCK (sink);
-  old_kid = sink->kid;
-  sink->kid = new_kid;
-  /* Mark whether a custom kid or fakesink has been installed */
-  sink->have_kid = !is_fakesink;
-  GST_OBJECT_UNLOCK (sink);
-
-  /* kill old element */
-  if (old_kid) {
-    GST_DEBUG_OBJECT (sink, "Removing old kid %" GST_PTR_FORMAT, old_kid);
-    gst_element_set_state (old_kid, GST_STATE_NULL);
-    gst_bin_remove (GST_BIN (sink), old_kid);
-    gst_object_unref (old_kid);
-    /* Don't lose the SINK flag */
-    GST_OBJECT_FLAG_SET (sink, GST_ELEMENT_IS_SINK);
-  }
-
-  /* re-attach ghostpad */
-  GST_DEBUG_OBJECT (sink, "Creating new ghostpad");
-  targetpad = gst_element_get_static_pad (sink->kid, "sink");
-  gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad);
-  gst_object_unref (targetpad);
-  GST_DEBUG_OBJECT (sink, "done changing child of switchsink");
-
-  /* FIXME: Push new-segment info and pre-roll buffer(s) into the kid */
-
-  return TRUE;
-}
-
-gboolean
-gst_switch_sink_set_child (GstSwitchSink * sink, GstElement * new_kid)
-{
-  GstState cur, next;
-  GstElement **p_kid;
-
-  /* Nothing to do if clearing the child and we've already installed fakesink */
-  if (new_kid == NULL && sink->kid != NULL && sink->have_kid == FALSE)
-    return TRUE;
-
-  /* Store the new kid to be committed later */
-  GST_OBJECT_LOCK (sink);
-  cur = GST_STATE (sink);
-  next = GST_STATE_NEXT (sink);
-  p_kid = &sink->new_kid;
-  gst_object_replace ((GstObject **) p_kid, (GstObject *) new_kid);
-  GST_OBJECT_UNLOCK (sink);
-  if (new_kid)
-    gst_object_unref (new_kid);
-
-  /* Sometime, it would be lovely to allow sink changes even when
-   * already running, but this involves sending an appropriate new-segment
-   * and possibly prerolling etc */
-  /* FIXME: Block the pad and replace the kid when it completes */
-  if (cur > GST_STATE_READY || next == GST_STATE_PAUSED) {
-    GST_DEBUG_OBJECT (sink,
-        "Switch-sink is already running. Ignoring change of child.");
-    gst_object_unref (new_kid);
-    return TRUE;
-  }
-
-  return gst_switch_sink_commit_new_kid (sink);
-}
-
-static GstStateChangeReturn
-gst_switch_sink_change_state (GstElement * element, GstStateChange transition)
-{
-  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
-  GstSwitchSink *sink = GST_SWITCH_SINK (element);
-
-  ret = GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
-      (element, transition), GST_STATE_CHANGE_SUCCESS);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_READY_TO_NULL:
-      if (!gst_switch_sink_reset (sink))
-        ret = GST_STATE_CHANGE_FAILURE;
-      break;
-    default:
-      break;
-  }
-
-  return ret;
-}
diff --git a/ext/gconf/gstswitchsink.h b/ext/gconf/gstswitchsink.h
deleted file mode 100644 (file)
index 556e755..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* GStreamer
- * Copyright (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (c) 2007 Jan Schmidt <thaytan@mad.scientist.com>
- *
- * 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_SWITCH_SINK_H__
-#define __GST_SWITCH_SINK_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_SWITCH_SINK \
-  (gst_switch_sink_get_type ())
-#define GST_SWITCH_SINK(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SWITCH_SINK, \
-                               GstSwitchSink))
-#define GST_SWITCH_SINK_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SWITCH_SINK, \
-                            GstSwitchSinkClass))
-#define GST_IS_SWITCH_SINK(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SWITCH_SINK))
-#define GST_IS_SWITCH_SINK_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SWITCH_SINK))
-
-typedef struct _GstSwitchSink {
-  GstBin parent;
-
-  GstElement *kid;
-  GstElement *new_kid;
-  GstPad *pad;
-
-  /* If a custom child has been set... */
-  gboolean have_kid;
-} GstSwitchSink;
-
-typedef struct _GstSwitchSinkClass {
-  GstBinClass parent_class;
-} GstSwitchSinkClass;
-
-GType   gst_switch_sink_get_type   (void);
-
-gboolean gst_switch_sink_set_child (GstSwitchSink *ssink, GstElement *new_kid);
-
-G_END_DECLS
-
-#endif /* __GST_SWITCH_SINK_H__ */
diff --git a/ext/gconf/gstswitchsrc.c b/ext/gconf/gstswitchsrc.c
deleted file mode 100644 (file)
index 0136e4a..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/* GStreamer
- * Copyright (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (c) 2006 Jürg Billeter <j@bitron.ch>
- * Copyright (c) 2007 Jan Schmidt <thaytan@noraisin.net>
- * Copyright (c) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
- *
- * 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 <string.h>
-
-#include "gstswitchsrc.h"
-
-GST_DEBUG_CATEGORY_STATIC (switch_debug);
-#define GST_CAT_DEFAULT switch_debug
-
-static void gst_switch_src_dispose (GObject * object);
-static GstStateChangeReturn
-gst_switch_src_change_state (GstElement * element, GstStateChange transition);
-
-GST_BOILERPLATE (GstSwitchSrc, gst_switch_src, GstBin, GST_TYPE_BIN);
-
-static void
-gst_switch_src_base_init (gpointer klass)
-{
-  GST_DEBUG_CATEGORY_INIT (switch_debug, "switchsrc", 0, "switchsrc element");
-}
-
-static void
-gst_switch_src_class_init (GstSwitchSrcClass * klass)
-{
-  GObjectClass *oklass = G_OBJECT_CLASS (klass);
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-  static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
-      GST_PAD_SRC,
-      GST_PAD_ALWAYS,
-      GST_STATIC_CAPS_ANY);
-  GstPadTemplate *child_pad_templ;
-
-  oklass->dispose = gst_switch_src_dispose;
-  eklass->change_state = gst_switch_src_change_state;
-
-  /* Provide a default pad template if the child didn't */
-  child_pad_templ = gst_element_class_get_pad_template (eklass, "src");
-  if (child_pad_templ == NULL) {
-    gst_element_class_add_pad_template (eklass,
-        gst_static_pad_template_get (&src_template));
-  }
-}
-
-static gboolean
-gst_switch_src_reset (GstSwitchSrc * src)
-{
-  /* this will install fakesrc if no other child has been set,
-   * otherwise we rely on the subclass to know when to unset its
-   * custom kid */
-  if (src->kid == NULL) {
-    return gst_switch_src_set_child (src, NULL);
-  }
-
-  return TRUE;
-}
-
-static void
-gst_switch_src_init (GstSwitchSrc * src, GstSwitchSrcClass * g_class)
-{
-  GstElementClass *eklass = GST_ELEMENT_GET_CLASS (src);
-  GstPadTemplate *templ;
-
-  templ = gst_element_class_get_pad_template (eklass, "src");
-  src->pad = gst_ghost_pad_new_no_target_from_template ("src", templ);
-  gst_element_add_pad (GST_ELEMENT (src), src->pad);
-
-  gst_switch_src_reset (src);
-
-  GST_OBJECT_FLAG_SET (src, GST_ELEMENT_IS_SOURCE);
-}
-
-static void
-gst_switch_src_dispose (GObject * object)
-{
-  GstSwitchSrc *src = GST_SWITCH_SRC (object);
-  GstObject *new_kid, *kid;
-
-  GST_OBJECT_LOCK (src);
-  new_kid = GST_OBJECT_CAST (src->new_kid);
-  src->new_kid = NULL;
-
-  kid = GST_OBJECT_CAST (src->kid);
-  src->kid = NULL;
-  GST_OBJECT_UNLOCK (src);
-
-  gst_object_replace (&new_kid, NULL);
-  gst_object_replace (&kid, NULL);
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static gboolean
-gst_switch_src_commit_new_kid (GstSwitchSrc * src)
-{
-  GstPad *targetpad;
-  GstState kid_state;
-  GstElement *new_kid, *old_kid;
-  gboolean is_fakesrc = FALSE;
-  GstBus *bus;
-
-  /* need locking around member accesses */
-  GST_OBJECT_LOCK (src);
-  /* If we're currently changing state, set the child to the next state
-   * we're transitioning too, rather than our current state which is 
-   * about to change */
-  if (GST_STATE_NEXT (src) != GST_STATE_VOID_PENDING)
-    kid_state = GST_STATE_NEXT (src);
-  else
-    kid_state = GST_STATE (src);
-
-  new_kid = src->new_kid ? gst_object_ref (src->new_kid) : NULL;
-  src->new_kid = NULL;
-  GST_OBJECT_UNLOCK (src);
-
-  /* Fakesrc by default if NULL is passed as the new child */
-  if (new_kid == NULL) {
-    GST_DEBUG_OBJECT (src, "Replacing kid with fakesrc");
-    new_kid = gst_element_factory_make ("fakesrc", "testsrc");
-    if (new_kid == NULL) {
-      GST_ERROR_OBJECT (src, "Failed to create fakesrc");
-      return FALSE;
-    }
-    /* Add a reference, as it would if the element came from src->new_kid */
-    gst_object_ref (new_kid);
-    is_fakesrc = TRUE;
-  } else {
-    GST_DEBUG_OBJECT (src, "Setting new kid");
-  }
-
-  /* set temporary bus of our own to catch error messages from the child
-   * (could we just set our own bus on it, or would the state change messages
-   * from the not-yet-added element confuse the state change algorithm? Let's
-   * play it safe for now) */
-  bus = gst_bus_new ();
-  gst_element_set_bus (new_kid, bus);
-  gst_object_unref (bus);
-
-  if (gst_element_set_state (new_kid, kid_state) == GST_STATE_CHANGE_FAILURE) {
-    GstMessage *msg;
-
-    /* check if child posted an error message and if so re-post it on our bus
-     * so that the application gets to see a decent error and not our generic
-     * fallback error message which is completely indecipherable to the user */
-    msg = gst_bus_pop_filtered (GST_ELEMENT_BUS (new_kid), GST_MESSAGE_ERROR);
-    if (msg) {
-      GST_INFO_OBJECT (src, "Forwarding kid error: %" GST_PTR_FORMAT, msg);
-      gst_element_post_message (GST_ELEMENT (src), msg);
-    }
-    GST_ELEMENT_ERROR (src, CORE, STATE_CHANGE, (NULL),
-        ("Failed to set state on new child."));
-    gst_element_set_bus (new_kid, NULL);
-    gst_object_unref (new_kid);
-    return FALSE;
-  }
-  gst_element_set_bus (new_kid, NULL);
-  gst_bin_add (GST_BIN (src), new_kid);
-
-  /* Now, replace the existing child */
-  GST_OBJECT_LOCK (src);
-  old_kid = src->kid;
-  src->kid = new_kid;
-  /* Mark whether a custom kid or fakesrc has been installed */
-  src->have_kid = !is_fakesrc;
-  GST_OBJECT_UNLOCK (src);
-
-  /* kill old element */
-  if (old_kid) {
-    GST_DEBUG_OBJECT (src, "Removing old kid %" GST_PTR_FORMAT, old_kid);
-    gst_element_set_state (old_kid, GST_STATE_NULL);
-    gst_bin_remove (GST_BIN (src), old_kid);
-    gst_object_unref (old_kid);
-    /* Don't lose the SOURCE flag */
-    GST_OBJECT_FLAG_SET (src, GST_ELEMENT_IS_SOURCE);
-  }
-
-  /* re-attach ghostpad */
-  GST_DEBUG_OBJECT (src, "Creating new ghostpad");
-  targetpad = gst_element_get_static_pad (src->kid, "src");
-  gst_ghost_pad_set_target (GST_GHOST_PAD (src->pad), targetpad);
-  gst_object_unref (targetpad);
-  GST_DEBUG_OBJECT (src, "done changing child of switchsrc");
-
-  return TRUE;
-}
-
-gboolean
-gst_switch_src_set_child (GstSwitchSrc * src, GstElement * new_kid)
-{
-  GstState cur, next;
-  GstElement **p_kid;
-
-  /* Nothing to do if clearing the child and we've already installed fakesrc */
-  if (new_kid == NULL && src->kid != NULL && src->have_kid == FALSE)
-    return TRUE;
-
-  /* Store the new kid to be committed later */
-  GST_OBJECT_LOCK (src);
-  cur = GST_STATE (src);
-  next = GST_STATE_NEXT (src);
-  p_kid = &src->new_kid;
-  gst_object_replace ((GstObject **) p_kid, (GstObject *) new_kid);
-  GST_OBJECT_UNLOCK (src);
-  if (new_kid)
-    gst_object_unref (new_kid);
-
-  /* Sometime, it would be lovely to allow src changes even when
-   * already running */
-  /* FIXME: Block the pad and replace the kid when it completes */
-  if (cur > GST_STATE_READY || next == GST_STATE_PAUSED) {
-    GST_DEBUG_OBJECT (src,
-        "Switch-src is already running. Ignoring change of child.");
-    gst_object_unref (new_kid);
-    return TRUE;
-  }
-
-  return gst_switch_src_commit_new_kid (src);
-}
-
-static GstStateChangeReturn
-gst_switch_src_change_state (GstElement * element, GstStateChange transition)
-{
-  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
-  GstSwitchSrc *src = GST_SWITCH_SRC (element);
-
-  ret = GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
-      (element, transition), GST_STATE_CHANGE_SUCCESS);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_READY_TO_NULL:
-      if (!gst_switch_src_reset (src))
-        ret = GST_STATE_CHANGE_FAILURE;
-      break;
-    default:
-      break;
-  }
-
-  return ret;
-}
diff --git a/ext/gconf/gstswitchsrc.h b/ext/gconf/gstswitchsrc.h
deleted file mode 100644 (file)
index 6c550ad..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* GStreamer
- *
- * Copyright (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (c) 2005 Tim-Philipp Müller <tim centricular net>
- * Copyright (c) 2007 Jan Schmidt <thaytan@mad.scientist.com>
- * Copyright (c) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
- *
- * 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_SWITCH_SRC_H__
-#define __GST_SWITCH_SRC_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_SWITCH_SRC            (gst_switch_src_get_type ())
-#define GST_SWITCH_SRC(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SWITCH_SRC, GstSwitchSrc))
-#define GST_SWITCH_SRC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SWITCH_SRC, GstSwitchSrcClass))
-#define GST_IS_SWITCH_SRC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SWITCH_SRC))
-#define GST_IS_SWITCH_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SWITCH_SRC))
-
-typedef struct _GstSwitchSrc {
-  GstBin parent;
-
-  GstElement *kid;
-  GstElement *new_kid;
-  GstPad *pad;
-
-  /* If a custom child has been set... */
-  gboolean have_kid;
-} GstSwitchSrc;
-
-typedef struct _GstSwitchSrcClass {
-  GstBinClass parent_class;
-} GstSwitchSrcClass;
-
-GType     gst_switch_src_get_type   (void);
-gboolean  gst_switch_src_set_child  (GstSwitchSrc *ssrc, GstElement *new_kid);
-
-G_END_DECLS
-
-#endif /* __GST_SWITCH_SRC_H__ */
diff --git a/ext/hal/Makefile.am b/ext/hal/Makefile.am
deleted file mode 100644 (file)
index 8862aeb..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-plugin_LTLIBRARIES = libgsthalelements.la
-
-libgsthalelements_la_SOURCES = \
-       gsthalaudiosink.c \
-       gsthalaudiosrc.c \
-       gsthalelements.c \
-       hal.c
-
-libgsthalelements_la_CFLAGS = $(GST_CFLAGS) $(HAL_CFLAGS)
-libgsthalelements_la_LIBADD = $(GST_LIBS) $(HAL_LIBS)
-libgsthalelements_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-libgsthalelements_la_LIBTOOLFLAGS = --tag=disable-static
-
-noinst_HEADERS = \
-       gsthalaudiosink.h \
-       gsthalaudiosrc.h \
-       gsthalelements.h \
-       hal.h
diff --git a/ext/hal/gsthalaudiosink.c b/ext/hal/gsthalaudiosink.c
deleted file mode 100644 (file)
index 24b29da..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * (c) 2006 Jürg Billeter <j@bitron.ch>
- *
- * 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.
- */
-
-/**
- * SECTION:element-halaudiosink
- *
- * HalAudioSink allows access to output of sound devices by specifying the
- * corresponding persistent Unique Device Id (UDI) from the Hardware Abstraction
- * Layer (HAL) in the #GstHalAudioSink:udi property.
- * It currently always embeds alsasink or osssink as HAL doesn't support other
- * sound systems yet. You can also specify the UDI of a device that has ALSA or
- * OSS subdevices. If both are present ALSA is preferred.
- *
- * <refsect2>
- * <title>Examples</title>
- * |[
- * hal-find-by-property --key alsa.type --string playback
- * ]| list the UDIs of all your ALSA output devices
- * |[
- * gst-launch -v audiotestsrc ! halaudiosink udi=/org/freedesktop/Hal/devices/pci_8086_27d8_alsa_playback_0
- * ]| test your soundcard by playing a test signal on the specified sound device.
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gsthalelements.h"
-#include "gsthalaudiosink.h"
-
-static void gst_hal_audio_sink_dispose (GObject * object);
-static GstStateChangeReturn
-gst_hal_audio_sink_change_state (GstElement * element,
-    GstStateChange transition);
-
-enum
-{
-  PROP_0,
-  PROP_UDI
-};
-
-GST_BOILERPLATE (GstHalAudioSink, gst_hal_audio_sink, GstBin, GST_TYPE_BIN);
-
-static void gst_hal_audio_sink_set_property (GObject * object, guint prop_id,
-    const GValue * value, GParamSpec * pspec);
-static void gst_hal_audio_sink_get_property (GObject * object, guint prop_id,
-    GValue * value, GParamSpec * pspec);
-
-static void
-gst_hal_audio_sink_base_init (gpointer klass)
-{
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
-      GST_PAD_SINK,
-      GST_PAD_ALWAYS,
-      GST_STATIC_CAPS_ANY);
-
-  gst_element_class_add_pad_template (eklass,
-      gst_static_pad_template_get (&sink_template));
-  gst_element_class_set_details_simple (eklass, "HAL audio sink",
-      "Sink/Audio",
-      "Audio sink for sound device access via HAL",
-      "Jürg Billeter <j@bitron.ch>");
-}
-
-static void
-gst_hal_audio_sink_class_init (GstHalAudioSinkClass * klass)
-{
-  GObjectClass *oklass = G_OBJECT_CLASS (klass);
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  oklass->set_property = gst_hal_audio_sink_set_property;
-  oklass->get_property = gst_hal_audio_sink_get_property;
-  oklass->dispose = gst_hal_audio_sink_dispose;
-  eklass->change_state = gst_hal_audio_sink_change_state;
-
-  g_object_class_install_property (oklass, PROP_UDI,
-      g_param_spec_string ("udi",
-          "UDI", "Unique Device Id", NULL,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-/*
- * Hack to make negotiation work.
- */
-
-static void
-gst_hal_audio_sink_reset (GstHalAudioSink * sink)
-{
-  GstPad *targetpad;
-
-  /* fakesink */
-  if (sink->kid) {
-    gst_element_set_state (sink->kid, GST_STATE_NULL);
-    gst_bin_remove (GST_BIN (sink), sink->kid);
-  }
-  sink->kid = gst_element_factory_make ("fakesink", "testsink");
-  gst_bin_add (GST_BIN (sink), sink->kid);
-
-  targetpad = gst_element_get_static_pad (sink->kid, "sink");
-  gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad);
-  gst_object_unref (targetpad);
-}
-
-static void
-gst_hal_audio_sink_init (GstHalAudioSink * sink, GstHalAudioSinkClass * g_class)
-{
-  sink->pad = gst_ghost_pad_new_no_target ("sink", GST_PAD_SINK);
-  gst_element_add_pad (GST_ELEMENT (sink), sink->pad);
-
-  gst_hal_audio_sink_reset (sink);
-}
-
-static void
-gst_hal_audio_sink_dispose (GObject * object)
-{
-  GstHalAudioSink *sink = GST_HAL_AUDIO_SINK (object);
-
-  if (sink->udi) {
-    g_free (sink->udi);
-    sink->udi = NULL;
-  }
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static gboolean
-do_toggle_element (GstHalAudioSink * sink)
-{
-  GstPad *targetpad;
-
-  /* kill old element */
-  if (sink->kid) {
-    GST_DEBUG_OBJECT (sink, "Removing old kid");
-    gst_element_set_state (sink->kid, GST_STATE_NULL);
-    gst_bin_remove (GST_BIN (sink), sink->kid);
-    sink->kid = NULL;
-  }
-
-  GST_DEBUG_OBJECT (sink, "Creating new kid");
-  if (!sink->udi)
-    GST_INFO_OBJECT (sink, "No UDI set for device, using default one");
-
-  if (!(sink->kid = gst_hal_get_audio_sink (sink->udi))) {
-    GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
-        ("Failed to render audio sink from Hal"));
-    return FALSE;
-  }
-  gst_element_set_state (sink->kid, GST_STATE (sink));
-  gst_bin_add (GST_BIN (sink), sink->kid);
-
-  /* re-attach ghostpad */
-  GST_DEBUG_OBJECT (sink, "Creating new ghostpad");
-  targetpad = gst_element_get_static_pad (sink->kid, "sink");
-  gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad);
-  gst_object_unref (targetpad);
-  GST_DEBUG_OBJECT (sink, "done changing hal audio sink");
-
-  return TRUE;
-}
-
-static void
-gst_hal_audio_sink_set_property (GObject * object, guint prop_id,
-    const GValue * value, GParamSpec * pspec)
-{
-  GstHalAudioSink *this = GST_HAL_AUDIO_SINK (object);
-
-  GST_OBJECT_LOCK (this);
-
-  switch (prop_id) {
-    case PROP_UDI:
-      if (this->udi)
-        g_free (this->udi);
-      this->udi = g_value_dup_string (value);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-  }
-
-  GST_OBJECT_UNLOCK (this);
-}
-
-static void
-gst_hal_audio_sink_get_property (GObject * object, guint prop_id,
-    GValue * value, GParamSpec * pspec)
-{
-  GstHalAudioSink *this = GST_HAL_AUDIO_SINK (object);
-
-  GST_OBJECT_LOCK (this);
-
-  switch (prop_id) {
-    case PROP_UDI:
-      g_value_set_string (value, this->udi);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-  }
-
-  GST_OBJECT_UNLOCK (this);
-}
-
-static GstStateChangeReturn
-gst_hal_audio_sink_change_state (GstElement * element,
-    GstStateChange transition)
-{
-  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
-  GstHalAudioSink *sink = GST_HAL_AUDIO_SINK (element);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_NULL_TO_READY:
-      if (!do_toggle_element (sink))
-        return GST_STATE_CHANGE_FAILURE;
-      break;
-    default:
-      break;
-  }
-
-  ret = GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
-      (element, transition), GST_STATE_CHANGE_SUCCESS);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_READY_TO_NULL:
-      gst_hal_audio_sink_reset (sink);
-      break;
-    default:
-      break;
-  }
-
-  return ret;
-}
diff --git a/ext/hal/gsthalaudiosink.h b/ext/hal/gsthalaudiosink.h
deleted file mode 100644 (file)
index 3f07fde..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * (c) 2006 Jürg Billeter <j@bitron.ch>
- *
- * 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_HAL_AUDIO_SINK_H__
-#define __GST_HAL_AUDIO_SINK_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_HAL_AUDIO_SINK \
-  (gst_hal_audio_sink_get_type ())
-#define GST_HAL_AUDIO_SINK(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_HAL_AUDIO_SINK, \
-                               GstHalAudioSink))
-#define GST_HAL_AUDIO_SINK_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_HAL_AUDIO_SINK, \
-                            GstHalAudioSinkClass))
-#define GST_IS_HAL_AUDIO_SINK(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_HAL_AUDIO_SINK))
-#define GST_IS_HAL_AUDIO_SINK_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_HAL_AUDIO_SINK))
-
-typedef struct _GstHalAudioSink {
-  GstBin parent;
-
-  /* explicit pointers to stuff used */
-  gchar *udi;
-  GstElement *kid;
-  GstPad *pad;
-} GstHalAudioSink;
-
-typedef struct _GstHalAudioSinkClass {
-  GstBinClass parent_class;
-} GstHalAudioSinkClass;
-
-GType   gst_hal_audio_sink_get_type   (void);
-
-G_END_DECLS
-
-#endif /* __GST_HAL_AUDIO_SINK_H__ */
diff --git a/ext/hal/gsthalaudiosrc.c b/ext/hal/gsthalaudiosrc.c
deleted file mode 100644 (file)
index de87848..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * (c) 2005 Tim-Philipp Müller <tim centricular net>
- * (c) 2006 Jürg Billeter <j@bitron.ch>
- *
- * 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.
- */
-
-/**
- * SECTION:element-halaudiosrc
- *
- * HalAudioSrc allows access to input of sound devices by specifying the
- * corresponding persistent Unique Device Id (UDI) from the Hardware Abstraction
- * Layer (HAL) in the #GstHalAudioSrc:udi property.
- * It currently always embeds alsasrc or osssrc as HAL doesn't support other
- * sound systems yet. You can also specify the UDI of a device that has ALSA or
- * OSS subdevices. If both are present ALSA is preferred.
- *
- * <refsect2>
- * <title>Examples</title>
- * |[
- * hal-find-by-property --key alsa.type --string capture
- * ]| list the UDIs of all your ALSA input devices
- * |[
- * gst-launch -v halaudiosrc udi=/org/freedesktop/Hal/devices/pci_8086_27d8_alsa_capture_0 ! autoaudiosink
- * ]| You should now hear yourself with a small delay if you have a microphone
- * connected to the specified sound device.
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gsthalelements.h"
-#include "gsthalaudiosrc.h"
-
-static void gst_hal_audio_src_dispose (GObject * object);
-static GstStateChangeReturn
-gst_hal_audio_src_change_state (GstElement * element,
-    GstStateChange transition);
-
-enum
-{
-  PROP_0,
-  PROP_UDI
-};
-
-GST_BOILERPLATE (GstHalAudioSrc, gst_hal_audio_src, GstBin, GST_TYPE_BIN);
-
-static void gst_hal_audio_src_set_property (GObject * object, guint prop_id,
-    const GValue * value, GParamSpec * pspec);
-static void gst_hal_audio_src_get_property (GObject * object, guint prop_id,
-    GValue * value, GParamSpec * pspec);
-
-static void
-gst_hal_audio_src_base_init (gpointer klass)
-{
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
-      GST_PAD_SRC,
-      GST_PAD_ALWAYS,
-      GST_STATIC_CAPS_ANY);
-
-  gst_element_class_add_pad_template (eklass,
-      gst_static_pad_template_get (&src_template));
-  gst_element_class_set_details_simple (eklass, "HAL audio source",
-      "Source/Audio",
-      "Audio source for sound device access via HAL",
-      "Jürg Billeter <j@bitron.ch>");
-}
-
-static void
-gst_hal_audio_src_class_init (GstHalAudioSrcClass * klass)
-{
-  GObjectClass *oklass = G_OBJECT_CLASS (klass);
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  oklass->set_property = gst_hal_audio_src_set_property;
-  oklass->get_property = gst_hal_audio_src_get_property;
-  oklass->dispose = gst_hal_audio_src_dispose;
-  eklass->change_state = gst_hal_audio_src_change_state;
-
-  g_object_class_install_property (oklass, PROP_UDI,
-      g_param_spec_string ("udi",
-          "UDI", "Unique Device Id", NULL,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-/*
- * Hack to make negotiation work.
- */
-
-static void
-gst_hal_audio_src_reset (GstHalAudioSrc * src)
-{
-  GstPad *targetpad;
-
-  /* fakesrc */
-  if (src->kid) {
-    gst_element_set_state (src->kid, GST_STATE_NULL);
-    gst_bin_remove (GST_BIN (src), src->kid);
-  }
-  src->kid = gst_element_factory_make ("fakesrc", "testsrc");
-  gst_bin_add (GST_BIN (src), src->kid);
-
-  targetpad = gst_element_get_static_pad (src->kid, "src");
-  gst_ghost_pad_set_target (GST_GHOST_PAD (src->pad), targetpad);
-  gst_object_unref (targetpad);
-}
-
-static void
-gst_hal_audio_src_init (GstHalAudioSrc * src, GstHalAudioSrcClass * g_class)
-{
-  src->pad = gst_ghost_pad_new_no_target ("src", GST_PAD_SRC);
-  gst_element_add_pad (GST_ELEMENT (src), src->pad);
-
-  gst_hal_audio_src_reset (src);
-}
-
-static void
-gst_hal_audio_src_dispose (GObject * object)
-{
-  GstHalAudioSrc *src = GST_HAL_AUDIO_SRC (object);
-
-  if (src->udi) {
-    g_free (src->udi);
-    src->udi = NULL;
-  }
-
-  GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
-}
-
-static gboolean
-do_toggle_element (GstHalAudioSrc * src)
-{
-  GstPad *targetpad;
-
-  /* kill old element */
-  if (src->kid) {
-    GST_DEBUG_OBJECT (src, "Removing old kid");
-    gst_element_set_state (src->kid, GST_STATE_NULL);
-    gst_bin_remove (GST_BIN (src), src->kid);
-    src->kid = NULL;
-  }
-
-  GST_DEBUG_OBJECT (src, "Creating new kid");
-  if (!src->udi)
-    GST_INFO_OBJECT (src, "No UDI set for device, using default one");
-
-  if (!(src->kid = gst_hal_get_audio_src (src->udi))) {
-    GST_ELEMENT_ERROR (src, LIBRARY, SETTINGS, (NULL),
-        ("Failed to render audio source from Hal"));
-    return FALSE;
-  }
-  gst_element_set_state (src->kid, GST_STATE (src));
-  gst_bin_add (GST_BIN (src), src->kid);
-
-  /* re-attach ghostpad */
-  GST_DEBUG_OBJECT (src, "Creating new ghostpad");
-  targetpad = gst_element_get_static_pad (src->kid, "src");
-  gst_ghost_pad_set_target (GST_GHOST_PAD (src->pad), targetpad);
-  gst_object_unref (targetpad);
-  GST_DEBUG_OBJECT (src, "done changing hal audio source");
-
-  return TRUE;
-}
-
-static void
-gst_hal_audio_src_set_property (GObject * object, guint prop_id,
-    const GValue * value, GParamSpec * pspec)
-{
-  GstHalAudioSrc *this = GST_HAL_AUDIO_SRC (object);
-
-  GST_OBJECT_LOCK (this);
-
-  switch (prop_id) {
-    case PROP_UDI:
-      if (this->udi)
-        g_free (this->udi);
-      this->udi = g_value_dup_string (value);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-  }
-
-  GST_OBJECT_UNLOCK (this);
-}
-
-static void
-gst_hal_audio_src_get_property (GObject * object, guint prop_id,
-    GValue * value, GParamSpec * pspec)
-{
-  GstHalAudioSrc *this = GST_HAL_AUDIO_SRC (object);
-
-  GST_OBJECT_LOCK (this);
-
-  switch (prop_id) {
-    case PROP_UDI:
-      g_value_set_string (value, this->udi);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-  }
-
-  GST_OBJECT_UNLOCK (this);
-}
-
-static GstStateChangeReturn
-gst_hal_audio_src_change_state (GstElement * element, GstStateChange transition)
-{
-  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
-  GstHalAudioSrc *src = GST_HAL_AUDIO_SRC (element);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_NULL_TO_READY:
-      if (!do_toggle_element (src))
-        return GST_STATE_CHANGE_FAILURE;
-      break;
-    default:
-      break;
-  }
-
-  ret = GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
-      (element, transition), GST_STATE_CHANGE_SUCCESS);
-
-  switch (transition) {
-    case GST_STATE_CHANGE_READY_TO_NULL:
-      gst_hal_audio_src_reset (src);
-      break;
-    default:
-      break;
-  }
-
-  return ret;
-}
diff --git a/ext/hal/gsthalaudiosrc.h b/ext/hal/gsthalaudiosrc.h
deleted file mode 100644 (file)
index 7afdadd..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * (c) 2005 Tim-Philipp Müller <tim centricular net>
- * (c) 2006 Jürg Billeter <j@bitron.ch>
- *
- * 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_HAL_AUDIO_SRC_H__
-#define __GST_HAL_AUDIO_SRC_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_HAL_AUDIO_SRC            (gst_hal_audio_src_get_type ())
-#define GST_HAL_AUDIO_SRC(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_HAL_AUDIO_SRC, GstHalAudioSrc))
-#define GST_HAL_AUDIO_SRC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_HAL_AUDIO_SRC, GstHalAudioSrcClass))
-#define GST_IS_HAL_AUDIO_SRC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_HAL_AUDIO_SRC))
-#define GST_IS_HAL_AUDIO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_HAL_AUDIO_SRC))
-
-typedef struct _GstHalAudioSrc {
-  GstBin parent;
-
-  /* explicit pointers to stuff used */
-  gchar *udi;
-  GstElement *kid;
-  GstPad *pad;
-} GstHalAudioSrc;
-
-typedef struct _GstHalAudioSrcClass {
-  GstBinClass parent_class;
-} GstHalAudioSrcClass;
-
-GType   gst_hal_audio_src_get_type   (void);
-
-G_END_DECLS
-
-#endif /* __GST_HAL_AUDIO_SRC_H__ */
diff --git a/ext/hal/gsthalelements.c b/ext/hal/gsthalelements.c
deleted file mode 100644 (file)
index dd5122a..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * (c) 2006 Jürg Billeter <j@bitron.ch>
- *
- * 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 "gsthalelements.h"
-
-#include "gsthalaudiosink.h"
-#include "gsthalaudiosrc.h"
-
-GST_DEBUG_CATEGORY (hal_debug);
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
-  GST_DEBUG_CATEGORY_INIT (hal_debug, "hal", 0,
-      "HAL/GStreamer audio input/output wrapper elements");
-
-  if (!gst_element_register (plugin, "halaudiosink",
-          GST_RANK_NONE, GST_TYPE_HAL_AUDIO_SINK) ||
-      !gst_element_register (plugin, "halaudiosrc",
-          GST_RANK_NONE, GST_TYPE_HAL_AUDIO_SRC)) {
-    return FALSE;
-  }
-
-  return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    "halelements",
-    "elements wrapping the GStreamer/HAL audio input/output devices",
-    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/ext/hal/gsthalelements.h b/ext/hal/gsthalelements.h
deleted file mode 100644 (file)
index 6a9462f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* GStreamer
- * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * (c) 2006 Ronald S. Bultje <rbultje@ronald.bitfreak.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_HAL_ELEMENTS_H__
-#define __GST_HAL_ELEMENTS_H__
-
-#include <hal.h>
-
-GST_DEBUG_CATEGORY_EXTERN (hal_debug);
-#define GST_CAT_DEFAULT hal_debug
-
-#endif /* __GST_HAL_ELEMENTS_H__ */
diff --git a/ext/hal/hal.c b/ext/hal/hal.c
deleted file mode 100644 (file)
index 6957f56..0000000
+++ /dev/null
@@ -1,397 +0,0 @@
-/* GStreamer
- * Copyright (C) <2002> Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) <2006> Jürg Billeter <j@bitron.ch>
- * Copyright (C) <2007> Sebastian Dröge <slomo@circular-chaos.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.
- */
-
-/*
- * this library handles interaction with Hal
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <glib.h>
-#include "hal.h"
-
-GST_DEBUG_CATEGORY_EXTERN (hal_debug);
-
-#define GST_CAT_DEFAULT hal_debug
-
-/* compat for older libhal */
-#ifndef LIBHAL_FREE_DBUS_ERROR
-#define LIBHAL_FREE_DBUS_ERROR(e) dbus_error_free (e)
-#endif
-
-/*
- * gst_hal_get_alsa_element:
- * @ctx: a #LibHalContext which should be used for querying HAL.
- * @udi: a #gchar corresponding to the UDI you want to get.
- * @device_type: a #GstHalDeviceType specifying the wanted device type.
- *
- * Get Hal UDI @udi's string value.
- *
- * Returns: a newly allocated #gchar string containing the appropriate pipeline
- * for UDI @udi, or NULL in the case of an error..
- */
-static gchar *
-gst_hal_get_alsa_element (LibHalContext * ctx, const gchar * udi,
-    GstHalDeviceType device_type)
-{
-  char *type, *string = NULL;
-  const char *element = NULL;
-  DBusError error;
-
-  dbus_error_init (&error);
-
-  if (!libhal_device_query_capability (ctx, udi, "alsa", &error)) {
-    if (dbus_error_is_set (&error)) {
-      GST_DEBUG ("Failed querying %s for alsa capability: %s: %s",
-          udi, error.name, error.message);
-      LIBHAL_FREE_DBUS_ERROR (&error);
-    } else {
-      GST_DEBUG ("UDI %s has no alsa capability", udi);
-    }
-    return NULL;
-  }
-
-  type = libhal_device_get_property_string (ctx, udi, "alsa.type", &error);
-
-  if (dbus_error_is_set (&error)) {
-    GST_DEBUG ("UDI %s has alsa capabilities but no alsa.type property: %s, %s",
-        udi, error.name, error.message);
-    LIBHAL_FREE_DBUS_ERROR (&error);
-    return NULL;
-  } else if (!type) {
-    GST_DEBUG ("UDI %s has empty alsa.type property", udi);
-    return NULL;
-  }
-
-  if (strcmp (type, "playback") == 0 && device_type == GST_HAL_AUDIOSINK)
-    element = "alsasink";
-  else if (strcmp (type, "capture") == 0 && device_type == GST_HAL_AUDIOSRC)
-    element = "alsasrc";
-
-  libhal_free_string (type);
-
-  if (element) {
-    int card, device;
-
-    card = libhal_device_get_property_int (ctx, udi, "alsa.card", &error);
-    if (dbus_error_is_set (&error)) {
-      GST_DEBUG ("UDI %s has no alsa.card property: %s: %s", udi, error.name,
-          error.message);
-      LIBHAL_FREE_DBUS_ERROR (&error);
-      return NULL;
-    } else if (card == -1) {
-      GST_DEBUG ("UDI %s has no alsa.card property", udi);
-      return NULL;
-    }
-
-    device = libhal_device_get_property_int (ctx, udi, "alsa.device", &error);
-    if (dbus_error_is_set (&error)) {
-      GST_DEBUG ("UDI %s has no alsa.device property: %s: %s", udi, error.name,
-          error.message);
-      LIBHAL_FREE_DBUS_ERROR (&error);
-      return NULL;
-    } else if (device == -1) {
-      GST_DEBUG ("UDI %s has no alsa.device property", udi);
-      return NULL;
-    }
-
-    /* This is a bit dodgy, since it makes lots of assumptions about the way
-     * alsa is set up. In any case, only munge the device string for playback */
-    if (strcmp (element, "alsasink") == 0 && device == 0) {
-      /* handle default device specially to use
-       * dmix, dsnoop, and softvol if appropriate */
-      string = g_strdup_printf ("%s device=default:%d", element, card);
-    } else {
-      string =
-          g_strdup_printf ("%s device=plughw:%d,%d", element, card, device);
-    }
-  }
-
-  return string;
-}
-
-/*
- * gst_hal_get_oss_element:
- * @ctx: a #LibHalContext which should be used for querying HAL.
- * @udi: a #gchar corresponding to the UDI you want to get.
- * @device_type: a #GstHalDeviceType specifying the wanted device type.
- *
- * Get Hal UDI @udi's string value.
- *
- * Returns: a newly allocated #gchar string containing the appropriate pipeline
- * for UDI @udi, or NULL in the case of an error..
- */
-static gchar *
-gst_hal_get_oss_element (LibHalContext * ctx, const gchar * udi,
-    GstHalDeviceType device_type)
-{
-  char *type, *string = NULL;
-  const char *element = NULL;
-  DBusError error;
-
-  dbus_error_init (&error);
-
-  if (!libhal_device_query_capability (ctx, udi, "oss", &error)) {
-    if (dbus_error_is_set (&error)) {
-      GST_DEBUG ("Failed querying %s for oss capability: %s: %s", udi,
-          error.name, error.message);
-      LIBHAL_FREE_DBUS_ERROR (&error);
-    } else {
-      GST_DEBUG ("UDI %s has no oss capability", udi);
-    }
-    return NULL;
-  }
-
-  type = libhal_device_get_property_string (ctx, udi, "oss.type", &error);
-  if (dbus_error_is_set (&error)) {
-    GST_DEBUG ("UDI %s has oss capabilities but no oss.type property: %s, %s",
-        udi, error.name, error.message);
-    LIBHAL_FREE_DBUS_ERROR (&error);
-    return NULL;
-  } else if (!type) {
-    GST_DEBUG ("UDI %s has empty oss.type property", udi);
-    return NULL;
-  }
-
-  if (strcmp (type, "pcm") == 0) {
-    if (device_type == GST_HAL_AUDIOSINK)
-      element = "osssink";
-    else if (device_type == GST_HAL_AUDIOSRC)
-      element = "osssrc";
-  }
-  libhal_free_string (type);
-
-  if (element) {
-    char *device = NULL;
-
-    device =
-        libhal_device_get_property_string (ctx, udi, "oss.device_file", &error);
-    if (dbus_error_is_set (&error)) {
-      GST_DEBUG
-          ("UDI %s has oss capabilities but no oss.device_file property: %s, %s",
-          udi, error.name, error.message);
-      LIBHAL_FREE_DBUS_ERROR (&error);
-      return NULL;
-    } else if (!device) {
-      GST_DEBUG ("UDI %s has empty oss.device_file property", udi);
-      return NULL;
-    }
-
-    string = g_strdup_printf ("%s device=%s", element, device);
-    libhal_free_string (device);
-  }
-
-  return string;
-}
-
-/*
- * gst_hal_get_string:
- * @udi: a #gchar corresponding to the UDI you want to get.
- * @device_type: a #GstHalDeviceType specifying the wanted device type.
- *
- * Get Hal UDI @udi's string value.
- *
- * Returns: a newly allocated #gchar string containing the appropriate pipeline
- * for UDI @udi, or NULL in the case of an error..
- */
-static gchar *
-gst_hal_get_string (const gchar * udi, GstHalDeviceType device_type)
-{
-  DBusError error;
-  LibHalContext *ctx;
-  char *string = NULL;
-
-  /* Don't query HAL for NULL UDIs. Passing NULL as UDI to HAL gives
-   * an assertion failure in D-Bus when running with
-   * DBUS_FATAL_WARNINGS=1. */
-  if (!udi)
-    return NULL;
-
-  dbus_error_init (&error);
-
-  ctx = libhal_ctx_new ();
-  /* Should only happen on OOM */
-  g_return_val_if_fail (ctx != NULL, NULL);
-
-  if (!libhal_ctx_set_dbus_connection (ctx, dbus_bus_get (DBUS_BUS_SYSTEM,
-              &error))) {
-    GST_DEBUG ("Unable to set DBus connection: %s: %s", error.name,
-        error.message);
-    LIBHAL_FREE_DBUS_ERROR (&error);
-    goto ctx_free;
-  }
-
-  if (!libhal_ctx_init (ctx, &error)) {
-    GST_DEBUG ("Unable to set init HAL context: %s: %s", error.name,
-        error.message);
-    LIBHAL_FREE_DBUS_ERROR (&error);
-    goto ctx_free;
-  }
-
-  /* Now first check if UDI is an alsa device, then oss and then
-   * check the childs of the given device. If there are alsa and oss
-   * children the first alsa one is used. */
-
-  string = gst_hal_get_alsa_element (ctx, udi, device_type);
-
-  if (!string)
-    string = gst_hal_get_oss_element (ctx, udi, device_type);
-
-  if (!string) {
-    int num_childs;
-    char **childs = NULL;
-
-    /* now try if one of the direct subdevices supports ALSA or OSS */
-    childs =
-        libhal_manager_find_device_string_match (ctx, "info.parent", udi,
-        &num_childs, &error);
-    if (dbus_error_is_set (&error)) {
-      GST_DEBUG ("Unable to retrieve childs of %s: %s: %s", udi, error.name,
-          error.message);
-      LIBHAL_FREE_DBUS_ERROR (&error);
-      goto ctx_shutdown;
-    }
-
-    if (childs && num_childs > 0) {
-      int i;
-      char *alsa_string = NULL, *oss_string = NULL;
-
-      for (i = 0; i < num_childs && !alsa_string; i++) {
-        alsa_string = gst_hal_get_alsa_element (ctx, childs[i], device_type);
-
-        if (!oss_string)
-          oss_string = gst_hal_get_oss_element (ctx, childs[i], device_type);
-      }
-
-      if (alsa_string) {
-        string = alsa_string;
-        g_free (oss_string);
-      } else if (oss_string) {
-        string = oss_string;
-      }
-    }
-    libhal_free_string_array (childs);
-  }
-
-ctx_shutdown:
-  if (!libhal_ctx_shutdown (ctx, &error)) {
-    GST_DEBUG ("Closing connection to HAL failed: %s: %s", error.name,
-        error.message);
-    LIBHAL_FREE_DBUS_ERROR (&error);
-  }
-
-ctx_free:
-  libhal_ctx_free (ctx);
-
-  if (string == NULL) {
-    GST_WARNING ("Problem finding a HAL audio device for udi %s", udi);
-  } else {
-    GST_INFO ("Using %s", string);
-  }
-
-  return string;
-}
-
-/* external functions */
-
-/**
- * gst_hal_render_bin_from_udi:
- * @udi: a #gchar string corresponding to a Hal UDI.
- *
- * Render bin from Hal UDI @udi.
- *
- * Returns: a #GstElement containing the rendered bin.
- */
-GstElement *
-gst_hal_render_bin_from_udi (const gchar * udi, GstHalDeviceType type)
-{
-  GstElement *bin = NULL;
-  gchar *value;
-
-  value = gst_hal_get_string (udi, type);
-  if (value)
-    bin = gst_parse_bin_from_description (value, TRUE, NULL);
-  g_free (value);
-  return bin;
-}
-
-/**
- * gst_hal_get_audio_sink:
- * @udi: a #gchar string corresponding to a Hal UDI.
- *
- * Render audio output bin from GStreamer Hal UDI.
- * If no device with the specified UDI exists or @udi is NULL,
- * the default audio sink for the  platform is used
- * (typically alsasink, osssink or sunaudiosink).
- *
- * Returns: a #GstElement containing the audio output bin, or NULL if
- * everything failed.
- */
-GstElement *
-gst_hal_get_audio_sink (const gchar * udi)
-{
-  GstElement *ret = NULL;
-
-  if (udi)
-    ret = gst_hal_render_bin_from_udi (udi, GST_HAL_AUDIOSINK);
-
-  if (!ret) {
-    ret = gst_element_factory_make (DEFAULT_AUDIOSINK, NULL);
-
-    if (!ret)
-      GST_ERROR ("Hal audio sink and %s don't work", DEFAULT_AUDIOSINK);
-  }
-
-  return ret;
-}
-
-/**
- * gst_hal_get_audio_src:
- * @udi: a #gchar string corresponding to a Hal UDI.
- *
- * Render audio acquisition bin from GStreamer Hal UDI.
- * If no device with the specified UDI exists or @udi is NULL,
- * the default audio source for the  plaform is used
- * (typically alsasrc, osssrc or sunaudiosrc).
- *
- * Returns: a #GstElement containing the audio source bin, or NULL if
- * everything failed.
- */
-GstElement *
-gst_hal_get_audio_src (const gchar * udi)
-{
-  GstElement *ret = NULL;
-
-  if (udi)
-    ret = gst_hal_render_bin_from_udi (udi, GST_HAL_AUDIOSRC);
-
-  if (!ret) {
-    ret = gst_element_factory_make (DEFAULT_AUDIOSRC, NULL);
-
-    if (!ret)
-      GST_ERROR ("Hal audio src and %s don't work", DEFAULT_AUDIOSRC);
-  }
-
-  return ret;
-}
diff --git a/ext/hal/hal.h b/ext/hal/hal.h
deleted file mode 100644 (file)
index 9cc5aed..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/* GStreamer
- * Copyright (C) <2002> Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) <2006> Jürg Billeter <j@bitron.ch>
- *
- * 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_HAL_H
-#define GST_HAL_H
-
-/*
- * this library handles interaction with Hal
- */
-
-#include <gst/gst.h>
-#include <dbus/dbus.h>
-#include <libhal.h>
-
-G_BEGIN_DECLS
-
-typedef enum
-{
-  GST_HAL_AUDIOSINK,
-  GST_HAL_AUDIOSRC
-} GstHalDeviceType;
-
-GstElement *gst_hal_render_bin_from_udi (const gchar * udi,
-    GstHalDeviceType type);
-
-GstElement *gst_hal_get_audio_sink (const gchar * udi);
-GstElement *gst_hal_get_audio_src (const gchar * udi);
-
-G_END_DECLS
-
-#endif /* GST_HAL_H */
index d923866..9724cc0 100644 (file)
@@ -49,6 +49,12 @@ typedef jack_default_audio_sample_t sample_t;
 #define GST_TYPE_JACK_CONNECT (gst_jack_connect_get_type())
 #define GST_TYPE_JACK_CLIENT  (gst_jack_client_get_type ())
 
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define GST_JACK_FORMAT_STR "F32_LE"
+#else
+#define GST_JACK_FORMAT_STR "F32_BE"
+#endif
+
 GType gst_jack_client_get_type(void);
 GType gst_jack_connect_get_type(void);
 
index 0aa578b..0434089 100644 (file)
@@ -195,7 +195,7 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
   buf = GST_RING_BUFFER_CAST (arg);
   sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
 
-  channels = buf->spec.channels;
+  channels = GST_AUDIO_INFO_CHANNELS (&buf->spec.info);
 
   /* get target buffers */
   for (i = 0; i < channels; i++) {
@@ -396,7 +396,7 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
   GstJackRingBuffer *abuf;
   const char **ports;
   gint sample_rate, buffer_size;
-  gint i, channels, res;
+  gint i, rate, bpf, channels, res;
   jack_client_t *client;
 
   sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
@@ -406,12 +406,15 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
 
   client = gst_jack_audio_client_get_client (sink->client);
 
+  rate = GST_AUDIO_INFO_RATE (&spec->info);
+
   /* sample rate must be that of the server */
   sample_rate = jack_get_sample_rate (client);
-  if (sample_rate != spec->rate)
+  if (sample_rate != rate)
     goto wrong_samplerate;
 
-  channels = spec->channels;
+  channels = GST_AUDIO_INFO_CHANNELS (&spec->info);
+  bpf = GST_AUDIO_INFO_BPF (&spec->info);
 
   if (!gst_jack_audio_sink_allocate_channels (sink, channels))
     goto out_of_ports;
@@ -422,7 +425,7 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
    * for all channels  */
   spec->segsize = buffer_size * sizeof (gfloat) * channels;
   spec->latency_time = gst_util_uint64_scale (spec->segsize,
-      (GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample);
+      (GST_SECOND / GST_USECOND), rate * bpf);
   /* segtotal based on buffer-time latency */
   spec->segtotal = spec->buffer_time / spec->latency_time;
   if (spec->segtotal < 2) {
@@ -438,8 +441,8 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
       buffer_size, spec->segsize, spec->segtotal);
 
   /* allocate the ringbuffer memory now */
-  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);
 
   if ((res = gst_jack_audio_client_set_active (sink->client, TRUE)))
     goto could_not_activate;
@@ -482,7 +485,7 @@ done:
 
   abuf->sample_rate = sample_rate;
   abuf->buffer_size = buffer_size;
-  abuf->channels = spec->channels;
+  abuf->channels = channels;
 
   return TRUE;
 
@@ -491,7 +494,7 @@ wrong_samplerate:
   {
     GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL),
         ("Wrong samplerate, server is running at %d and we received %d",
-            sample_rate, spec->rate));
+            sample_rate, rate));
     return FALSE;
   }
 out_of_ports:
@@ -541,8 +544,8 @@ gst_jack_ring_buffer_release (GstRingBuffer * buf)
   abuf->sample_rate = -1;
 
   /* free the buffer */
-  gst_buffer_unref (buf->data);
-  buf->data = NULL;
+  g_free (buf->memory);
+  buf->memory = NULL;
 
   return TRUE;
 }
@@ -631,9 +634,8 @@ static GstStaticPadTemplate jackaudiosink_sink_factory =
 GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-float, "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) 32, "
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " GST_JACK_FORMAT_STR ", "
         "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
     );
 
@@ -656,11 +658,8 @@ enum
   PROP_LAST
 };
 
-#define _do_init(bla) \
-    GST_DEBUG_CATEGORY_INIT (gst_jack_audio_sink_debug, "jacksink", 0, "jacksink element");
-
-GST_BOILERPLATE_FULL (GstJackAudioSink, gst_jack_audio_sink, GstBaseAudioSink,
-    GST_TYPE_BASE_AUDIO_SINK, _do_init);
+#define gst_jack_audio_sink_parent_class parent_class
+G_DEFINE_TYPE (GstJackAudioSink, gst_jack_audio_sink, GST_TYPE_BASE_AUDIO_SINK);
 
 static void gst_jack_audio_sink_dispose (GObject * object);
 static void gst_jack_audio_sink_set_property (GObject * object, guint prop_id,
@@ -668,31 +667,24 @@ static void gst_jack_audio_sink_set_property (GObject * object, guint prop_id,
 static void gst_jack_audio_sink_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-static GstCaps *gst_jack_audio_sink_getcaps (GstBaseSink * bsink);
+static GstCaps *gst_jack_audio_sink_getcaps (GstBaseSink * bsink,
+    GstCaps * filter);
 static GstRingBuffer *gst_jack_audio_sink_create_ringbuffer (GstBaseAudioSink *
     sink);
 
 static void
-gst_jack_audio_sink_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "Audio Sink (Jack)",
-      "Sink/Audio", "Output audio to a JACK server",
-      "Wim Taymans <wim.taymans@gmail.com>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&jackaudiosink_sink_factory));
-}
-
-static void
 gst_jack_audio_sink_class_init (GstJackAudioSinkClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseSinkClass *gstbasesink_class;
   GstBaseAudioSinkClass *gstbaseaudiosink_class;
 
+  GST_DEBUG_CATEGORY_INIT (gst_jack_audio_sink_debug, "jacksink", 0,
+      "jacksink element");
+
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasesink_class = (GstBaseSinkClass *) klass;
   gstbaseaudiosink_class = (GstBaseAudioSinkClass *) klass;
 
@@ -717,6 +709,13 @@ gst_jack_audio_sink_class_init (GstJackAudioSinkClass * klass)
           GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE |
           G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "Audio Sink (Jack)",
+      "Sink/Audio", "Output audio to a JACK server",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&jackaudiosink_sink_factory));
+
   gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_jack_audio_sink_getcaps);
 
   gstbaseaudiosink_class->create_ringbuffer =
@@ -730,8 +729,7 @@ gst_jack_audio_sink_class_init (GstJackAudioSinkClass * klass)
 }
 
 static void
-gst_jack_audio_sink_init (GstJackAudioSink * sink,
-    GstJackAudioSinkClass * g_class)
+gst_jack_audio_sink_init (GstJackAudioSink * sink)
 {
   sink->connect = DEFAULT_PROP_CONNECT;
   sink->server = g_strdup (DEFAULT_PROP_SERVER);
@@ -803,7 +801,7 @@ gst_jack_audio_sink_get_property (GObject * object, guint prop_id,
 }
 
 static GstCaps *
-gst_jack_audio_sink_getcaps (GstBaseSink * bsink)
+gst_jack_audio_sink_getcaps (GstBaseSink * bsink, GstCaps * filter)
 {
   GstJackAudioSink *sink = GST_JACK_AUDIO_SINK (bsink);
   const char **ports;
@@ -839,9 +837,8 @@ gst_jack_audio_sink_getcaps (GstBaseSink * bsink)
   GST_DEBUG_OBJECT (sink, "got %d-%d ports, samplerate: %d", min, max, rate);
 
   if (!sink->caps) {
-    sink->caps = gst_caps_new_simple ("audio/x-raw-float",
-        "endianness", G_TYPE_INT, G_BYTE_ORDER,
-        "width", G_TYPE_INT, 32,
+    sink->caps = gst_caps_new_simple ("audio/x-raw",
+        "format", G_TYPE_STRING, GST_JACK_FORMAT_STR,
         "rate", G_TYPE_INT, rate,
         "channels", GST_TYPE_INT_RANGE, min, max, NULL);
   }
index 3aa6e93..12c2768 100644 (file)
@@ -215,7 +215,7 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
   buf = GST_RING_BUFFER_CAST (arg);
   src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
 
-  channels = buf->spec.channels;
+  channels = GST_AUDIO_INFO_CHANNELS (&buf->spec.info);
 
   /* get input buffers */
   for (i = 0; i < channels; i++)
@@ -404,7 +404,7 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
   GstJackRingBuffer *abuf;
   const char **ports;
   gint sample_rate, buffer_size;
-  gint i, channels, res;
+  gint i, bpf, rate, channels, res;
   jack_client_t *client;
 
   src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
@@ -414,12 +414,15 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
 
   client = gst_jack_audio_client_get_client (src->client);
 
+  rate = GST_AUDIO_INFO_RATE (&spec->info);
+
   /* sample rate must be that of the server */
   sample_rate = jack_get_sample_rate (client);
-  if (sample_rate != spec->rate)
+  if (sample_rate != rate)
     goto wrong_samplerate;
 
-  channels = spec->channels;
+  bpf = GST_AUDIO_INFO_BPF (&spec->info);
+  channels = GST_AUDIO_INFO_CHANNELS (&spec->info);
 
   if (!gst_jack_audio_src_allocate_channels (src, channels))
     goto out_of_ports;
@@ -432,7 +435,7 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
    * for all channels  */
   spec->segsize = buffer_size * sizeof (gfloat) * channels;
   spec->latency_time = gst_util_uint64_scale (spec->segsize,
-      (GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample);
+      (GST_SECOND / GST_USECOND), rate * bpf);
   /* segtotal based on buffer-time latency */
   spec->segtotal = spec->buffer_time / spec->latency_time;
   if (spec->segtotal < 2) {
@@ -448,8 +451,8 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
       buffer_size, spec->segsize, spec->segtotal);
 
   /* allocate the ringbuffer memory now */
-  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);
 
   if ((res = gst_jack_audio_client_set_active (src->client, TRUE)))
     goto could_not_activate;
@@ -494,7 +497,7 @@ done:
 
   abuf->sample_rate = sample_rate;
   abuf->buffer_size = buffer_size;
-  abuf->channels = spec->channels;
+  abuf->channels = channels;
 
   return TRUE;
 
@@ -503,7 +506,7 @@ wrong_samplerate:
   {
     GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL),
         ("Wrong samplerate, server is running at %d and we received %d",
-            sample_rate, spec->rate));
+            sample_rate, rate));
     return FALSE;
   }
 out_of_ports:
@@ -553,8 +556,8 @@ gst_jack_ring_buffer_release (GstRingBuffer * buf)
   abuf->sample_rate = -1;
 
   /* free the buffer */
-  gst_buffer_unref (buf->data);
-  buf->data = NULL;
+  g_free (buf->memory);
+  buf->memory = NULL;
 
   return TRUE;
 }
@@ -668,17 +671,13 @@ enum
 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-float, "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) 32, "
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " GST_JACK_FORMAT_STR ", "
         "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
     );
 
-#define _do_init(bla) \
-  GST_DEBUG_CATEGORY_INIT(gst_jack_audio_src_debug, "jacksrc", 0, "jacksrc element");
-
-GST_BOILERPLATE_FULL (GstJackAudioSrc, gst_jack_audio_src, GstBaseAudioSrc,
-    GST_TYPE_BASE_AUDIO_SRC, _do_init);
+#define gst_jack_audio_src_parent_class parent_class
+G_DEFINE_TYPE (GstJackAudioSrc, gst_jack_audio_src, GST_TYPE_BASE_AUDIO_SRC);
 
 static void gst_jack_audio_src_dispose (GObject * object);
 static void gst_jack_audio_src_set_property (GObject * object, guint prop_id,
@@ -686,34 +685,27 @@ static void gst_jack_audio_src_set_property (GObject * object, guint prop_id,
 static void gst_jack_audio_src_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-static GstCaps *gst_jack_audio_src_getcaps (GstBaseSrc * bsrc);
+static GstCaps *gst_jack_audio_src_getcaps (GstBaseSrc * bsrc,
+    GstCaps * filter);
 static GstRingBuffer *gst_jack_audio_src_create_ringbuffer (GstBaseAudioSrc *
     src);
 
 /* GObject vmethod implementations */
 
-static void
-gst_jack_audio_src_base_init (gpointer gclass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_set_details_simple (element_class, "Audio Source (Jack)",
-      "Source/Audio", "Captures audio from a JACK server",
-      "Tristan Matthews <tristan@sat.qc.ca>");
-}
-
 /* initialize the jack_audio_src's class */
 static void
 gst_jack_audio_src_class_init (GstJackAudioSrcClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseSrcClass *gstbasesrc_class;
   GstBaseAudioSrcClass *gstbaseaudiosrc_class;
 
-  gobject_class = (GObjectClass *) klass;
+  GST_DEBUG_CATEGORY_INIT (gst_jack_audio_src_debug, "jacksrc", 0,
+      "jacksrc element");
 
+  gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasesrc_class = (GstBaseSrcClass *) klass;
   gstbaseaudiosrc_class = (GstBaseAudioSrcClass *) klass;
 
@@ -738,6 +730,13 @@ gst_jack_audio_src_class_init (GstJackAudioSrcClass * klass)
           GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE |
           G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_factory));
+
+  gst_element_class_set_details_simple (gstelement_class, "Audio Source (Jack)",
+      "Source/Audio", "Captures audio from a JACK server",
+      "Tristan Matthews <tristan@sat.qc.ca>");
+
   gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_jack_audio_src_getcaps);
   gstbaseaudiosrc_class->create_ringbuffer =
       GST_DEBUG_FUNCPTR (gst_jack_audio_src_create_ringbuffer);
@@ -755,7 +754,7 @@ gst_jack_audio_src_class_init (GstJackAudioSrcClass * klass)
  * initialize instance structure
  */
 static void
-gst_jack_audio_src_init (GstJackAudioSrc * src, GstJackAudioSrcClass * gclass)
+gst_jack_audio_src_init (GstJackAudioSrc * src)
 {
   //gst_base_src_set_live(GST_BASE_SRC (src), TRUE);
   src->connect = DEFAULT_PROP_CONNECT;
@@ -824,7 +823,7 @@ gst_jack_audio_src_get_property (GObject * object, guint prop_id,
 }
 
 static GstCaps *
-gst_jack_audio_src_getcaps (GstBaseSrc * bsrc)
+gst_jack_audio_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
 {
   GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (bsrc);
   const char **ports;
@@ -861,9 +860,8 @@ gst_jack_audio_src_getcaps (GstBaseSrc * bsrc)
   GST_DEBUG_OBJECT (src, "got %d-%d ports, samplerate: %d", min, max, rate);
 
   if (!src->caps) {
-    src->caps = gst_caps_new_simple ("audio/x-raw-float",
-        "endianness", G_TYPE_INT, G_BYTE_ORDER,
-        "width", G_TYPE_INT, 32,
+    src->caps = gst_caps_new_simple ("audio/x-raw",
+        "format", G_TYPE_STRING, GST_JACK_FORMAT_STR,
         "rate", G_TYPE_INT, rate,
         "channels", GST_TYPE_INT_RANGE, min, max, NULL);
   }
index a72f12f..eb581e1 100644 (file)
@@ -3,10 +3,8 @@ plugin_LTLIBRARIES = libgstjpeg.la
 libgstjpeg_la_SOURCES = \
        gstjpeg.c \
        gstjpegenc.c \
-       gstjpegdec.c \
-       gstsmokeenc.c \
-       smokecodec.c \
-       gstsmokedec.c
+       gstjpegdec.c
+# deprected gstsmokeenc.c smokecodec.c gstsmokedec.c
 
 libgstjpeg_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
 libgstjpeg_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) -lgstvideo-$(GST_MAJORMINOR) \
@@ -16,6 +14,5 @@ libgstjpeg_la_LIBTOOLFLAGS = --tag=disable-static
 
 noinst_HEADERS = \
        gstjpeg.h \
-       gstjpegdec.h gstjpegenc.h \
-       gstsmokeenc.h gstsmokedec.h \
-       smokecodec.h smokeformat.h
+       gstjpegdec.h gstjpegenc.h
+# deprecated gstsmokeenc.h gstsmokedec.h smokecodec.h smokeformat.h
index b9d6e04..1a7006b 100644 (file)
 #include "gstjpeg.h"
 #include "gstjpegdec.h"
 #include "gstjpegenc.h"
+#if 0
 #include "gstsmokeenc.h"
 #include "gstsmokedec.h"
+#endif
 
 GType
 gst_idct_method_get_type (void)
@@ -59,6 +61,7 @@ plugin_init (GstPlugin * plugin)
           GST_TYPE_JPEG_DEC))
     return FALSE;
 
+#if 0
   if (!gst_element_register (plugin, "smokeenc", GST_RANK_PRIMARY,
           GST_TYPE_SMOKEENC))
     return FALSE;
@@ -66,6 +69,7 @@ plugin_init (GstPlugin * plugin)
   if (!gst_element_register (plugin, "smokedec", GST_RANK_PRIMARY,
           GST_TYPE_SMOKEDEC))
     return FALSE;
+#endif
 
   return TRUE;
 }
index 23e8f23..13a78ff 100644 (file)
@@ -66,12 +66,10 @@ static GstStaticPadTemplate gst_jpeg_dec_src_pad_template =
 GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420") "; "
-        GST_VIDEO_CAPS_RGB "; " GST_VIDEO_CAPS_BGR "; "
-        GST_VIDEO_CAPS_RGBx "; " GST_VIDEO_CAPS_xRGB "; "
-        GST_VIDEO_CAPS_BGRx "; " GST_VIDEO_CAPS_xBGR "; "
-        GST_VIDEO_CAPS_GRAY8)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
+        ("{ I420, RGB, BGR, RGBx, xRGB, BGRx, xBGR, GRAY8 }"))
     );
+
 /* *INDENT-ON* */
 
 static GstStaticPadTemplate gst_jpeg_dec_sink_pad_template =
@@ -88,31 +86,12 @@ GST_DEBUG_CATEGORY_STATIC (jpeg_dec_debug);
 #define GST_CAT_DEFAULT jpeg_dec_debug
 GST_DEBUG_CATEGORY_STATIC (GST_CAT_PERFORMANCE);
 
-/* These macros are adapted from videotestsrc.c 
- *  and/or gst-plugins/gst/games/gstvideoimage.c */
-#define I420_Y_ROWSTRIDE(width) (GST_ROUND_UP_4(width))
-#define I420_U_ROWSTRIDE(width) (GST_ROUND_UP_8(width)/2)
-#define I420_V_ROWSTRIDE(width) ((GST_ROUND_UP_8(I420_Y_ROWSTRIDE(width)))/2)
-
-#define I420_Y_OFFSET(w,h) (0)
-#define I420_U_OFFSET(w,h) (I420_Y_OFFSET(w,h)+(I420_Y_ROWSTRIDE(w)*GST_ROUND_UP_2(h)))
-#define I420_V_OFFSET(w,h) (I420_U_OFFSET(w,h)+(I420_U_ROWSTRIDE(w)*GST_ROUND_UP_2(h)/2))
-
-#define I420_SIZE(w,h)     (I420_V_OFFSET(w,h)+(I420_V_ROWSTRIDE(w)*GST_ROUND_UP_2(h)/2))
-
-static GstElementClass *parent_class;   /* NULL */
-
-static void gst_jpeg_dec_base_init (gpointer g_class);
-static void gst_jpeg_dec_class_init (GstJpegDecClass * klass);
-static void gst_jpeg_dec_init (GstJpegDec * jpegdec);
-
 static void gst_jpeg_dec_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
 static void gst_jpeg_dec_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
 static GstFlowReturn gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buffer);
-static gboolean gst_jpeg_dec_setcaps (GstPad * pad, GstCaps * caps);
 static gboolean gst_jpeg_dec_sink_event (GstPad * pad, GstEvent * event);
 static gboolean gst_jpeg_dec_src_event (GstPad * pad, GstEvent * event);
 static GstStateChangeReturn gst_jpeg_dec_change_state (GstElement * element,
@@ -123,29 +102,8 @@ static void gst_jpeg_dec_reset_qos (GstJpegDec * dec);
 static void gst_jpeg_dec_read_qos (GstJpegDec * dec, gdouble * proportion,
     GstClockTime * time);
 
-GType
-gst_jpeg_dec_get_type (void)
-{
-  static GType type = 0;
-
-  if (!type) {
-    static const GTypeInfo jpeg_dec_info = {
-      sizeof (GstJpegDecClass),
-      (GBaseInitFunc) gst_jpeg_dec_base_init,
-      NULL,
-      (GClassInitFunc) gst_jpeg_dec_class_init,
-      NULL,
-      NULL,
-      sizeof (GstJpegDec),
-      0,
-      (GInstanceInitFunc) gst_jpeg_dec_init,
-    };
-
-    type = g_type_register_static (GST_TYPE_ELEMENT, "GstJpegDec",
-        &jpeg_dec_info, 0);
-  }
-  return type;
-}
+#define gst_jpeg_dec_parent_class parent_class
+G_DEFINE_TYPE (GstJpegDec, gst_jpeg_dec, GST_TYPE_ELEMENT);
 
 static void
 gst_jpeg_dec_finalize (GObject * object)
@@ -160,20 +118,6 @@ gst_jpeg_dec_finalize (GObject * object)
 }
 
 static void
-gst_jpeg_dec_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_jpeg_dec_src_pad_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_jpeg_dec_sink_pad_template));
-  gst_element_class_set_details_simple (element_class, "JPEG image decoder",
-      "Codec/Decoder/Image",
-      "Decode images from JPEG format", "Wim Taymans <wim@fluendo.com>");
-}
-
-static void
 gst_jpeg_dec_class_init (GstJpegDecClass * klass)
 {
   GstElementClass *gstelement_class;
@@ -209,6 +153,14 @@ gst_jpeg_dec_class_init (GstJpegDecClass * klass)
           -1, G_MAXINT, JPEG_DEFAULT_MAX_ERRORS,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_jpeg_dec_src_pad_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_jpeg_dec_sink_pad_template));
+  gst_element_class_set_details_simple (gstelement_class, "JPEG image decoder",
+      "Codec/Decoder/Image",
+      "Decode images from JPEG format", "Wim Taymans <wim@fluendo.com>");
+
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_jpeg_dec_change_state);
 
@@ -404,8 +356,6 @@ gst_jpeg_dec_init (GstJpegDec * dec)
       gst_pad_new_from_static_template (&gst_jpeg_dec_sink_pad_template,
       "sink");
   gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
-  gst_pad_set_setcaps_function (dec->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_jpeg_dec_setcaps));
   gst_pad_set_chain_function (dec->sinkpad,
       GST_DEBUG_FUNCPTR (gst_jpeg_dec_chain));
   gst_pad_set_event_function (dec->sinkpad,
@@ -743,21 +693,19 @@ guarantee_huff_tables (j_decompress_ptr dinfo)
 }
 
 static gboolean
-gst_jpeg_dec_setcaps (GstPad * pad, GstCaps * caps)
+gst_jpeg_dec_setcaps (GstJpegDec * dec, GstCaps * caps)
 {
   GstStructure *s;
-  GstJpegDec *dec;
   const GValue *framerate;
 
-  dec = GST_JPEG_DEC (GST_OBJECT_PARENT (pad));
   s = gst_caps_get_structure (caps, 0);
 
   if ((framerate = gst_structure_get_value (s, "framerate")) != NULL) {
-    dec->framerate_numerator = gst_value_get_fraction_numerator (framerate);
-    dec->framerate_denominator = gst_value_get_fraction_denominator (framerate);
+    dec->in_fps_n = gst_value_get_fraction_numerator (framerate);
+    dec->in_fps_d = gst_value_get_fraction_denominator (framerate);
     dec->packetized = TRUE;
     GST_DEBUG ("got framerate of %d/%d fps => packetized mode",
-        dec->framerate_numerator, dec->framerate_denominator);
+        dec->in_fps_n, dec->in_fps_d);
   }
 
   /* do not extract width/height here. we do that in the chain
@@ -806,7 +754,7 @@ gst_jpeg_dec_ensure_buffers (GstJpegDec * dec, guint maxrowbytes)
 {
   gint i;
 
-  if (G_LIKELY (dec->idr_width_allocated == maxrowbytes))
+  if (G_LIKELY (dec->idr_width_allocated >= maxrowbytes))
     return TRUE;
 
   /* FIXME: maybe just alloc one or three blocks altogether? */
@@ -827,19 +775,28 @@ gst_jpeg_dec_ensure_buffers (GstJpegDec * dec, guint maxrowbytes)
 }
 
 static void
-gst_jpeg_dec_decode_grayscale (GstJpegDec * dec, guchar * base[1],
-    guint width, guint height, guint pstride, guint rstride)
+gst_jpeg_dec_decode_grayscale (GstJpegDec * dec, GstVideoFrame * frame)
 {
   guchar *rows[16];
   guchar **scanarray[1] = { rows };
   gint i, j, k;
   gint lines;
+  guint8 *base[1];
+  gint width, height;
+  gint pstride, rstride;
 
   GST_DEBUG_OBJECT (dec, "indirect decoding of grayscale");
 
+  width = GST_VIDEO_FRAME_WIDTH (frame);
+  height = GST_VIDEO_FRAME_HEIGHT (frame);
+
   if (G_UNLIKELY (!gst_jpeg_dec_ensure_buffers (dec, GST_ROUND_UP_32 (width))))
     return;
 
+  base[0] = GST_VIDEO_FRAME_COMP_DATA (frame, 0);
+  pstride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0);
+  rstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0);
+
   memcpy (rows, dec->idr_y, 16 * sizeof (gpointer));
 
   i = 0;
@@ -863,19 +820,30 @@ gst_jpeg_dec_decode_grayscale (GstJpegDec * dec, guchar * base[1],
 }
 
 static void
-gst_jpeg_dec_decode_rgb (GstJpegDec * dec, guchar * base[3],
-    guint width, guint height, guint pstride, guint rstride)
+gst_jpeg_dec_decode_rgb (GstJpegDec * dec, GstVideoFrame * frame)
 {
   guchar *r_rows[16], *g_rows[16], *b_rows[16];
   guchar **scanarray[3] = { r_rows, g_rows, b_rows };
   gint i, j, k;
   gint lines;
+  guint8 *base[3];
+  guint pstride, rstride;
+  gint width, height;
 
   GST_DEBUG_OBJECT (dec, "indirect decoding of RGB");
 
+  width = GST_VIDEO_FRAME_WIDTH (frame);
+  height = GST_VIDEO_FRAME_HEIGHT (frame);
+
   if (G_UNLIKELY (!gst_jpeg_dec_ensure_buffers (dec, GST_ROUND_UP_32 (width))))
     return;
 
+  for (i = 0; i < 3; i++)
+    base[i] = GST_VIDEO_FRAME_COMP_DATA (frame, i);
+
+  pstride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0);
+  rstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0);
+
   memcpy (r_rows, dec->idr_y, 16 * sizeof (gpointer));
   memcpy (g_rows, dec->idr_u, 16 * sizeof (gpointer));
   memcpy (b_rows, dec->idr_v, 16 * sizeof (gpointer));
@@ -905,20 +873,35 @@ gst_jpeg_dec_decode_rgb (GstJpegDec * dec, guchar * base[3],
 }
 
 static void
-gst_jpeg_dec_decode_indirect (GstJpegDec * dec, guchar * base[3],
-    guchar * last[3], guint width, guint height, gint r_v, gint r_h, gint comp)
+gst_jpeg_dec_decode_indirect (GstJpegDec * dec, GstVideoFrame * frame,
+    gint r_v, gint r_h, gint comp)
 {
   guchar *y_rows[16], *u_rows[16], *v_rows[16];
   guchar **scanarray[3] = { y_rows, u_rows, v_rows };
   gint i, j, k;
   gint lines;
+  guchar *base[3], *last[3];
+  gint stride[3];
+  gint width, height;
 
   GST_DEBUG_OBJECT (dec,
       "unadvantageous width or r_h, taking slow route involving memcpy");
 
+  width = GST_VIDEO_FRAME_WIDTH (frame);
+  height = GST_VIDEO_FRAME_HEIGHT (frame);
+
   if (G_UNLIKELY (!gst_jpeg_dec_ensure_buffers (dec, GST_ROUND_UP_32 (width))))
     return;
 
+  for (i = 0; i < 3; i++) {
+    base[i] = GST_VIDEO_FRAME_COMP_DATA (frame, i);
+    stride[i] = GST_VIDEO_FRAME_COMP_STRIDE (frame, i);
+    /* make sure we don't make jpeglib write beyond our buffer,
+     * which might happen if (height % (r_v*DCTSIZE)) != 0 */
+    last[i] = base[i] + (GST_VIDEO_FRAME_COMP_STRIDE (frame, i) *
+        (GST_VIDEO_FRAME_COMP_HEIGHT (frame, i) - 1));
+  }
+
   memcpy (y_rows, dec->idr_y, 16 * sizeof (gpointer));
   memcpy (u_rows, dec->idr_u, 16 * sizeof (gpointer));
   memcpy (v_rows, dec->idr_v, 16 * sizeof (gpointer));
@@ -937,30 +920,30 @@ gst_jpeg_dec_decode_indirect (GstJpegDec * dec, guchar * base[3],
     if (G_LIKELY (lines > 0)) {
       for (j = 0, k = 0; j < (r_v * DCTSIZE); j += r_v, k++) {
         if (G_LIKELY (base[0] <= last[0])) {
-          memcpy (base[0], y_rows[j], I420_Y_ROWSTRIDE (width));
-          base[0] += I420_Y_ROWSTRIDE (width);
+          memcpy (base[0], y_rows[j], stride[0]);
+          base[0] += stride[0];
         }
         if (r_v == 2) {
           if (G_LIKELY (base[0] <= last[0])) {
-            memcpy (base[0], y_rows[j + 1], I420_Y_ROWSTRIDE (width));
-            base[0] += I420_Y_ROWSTRIDE (width);
+            memcpy (base[0], y_rows[j + 1], stride[0]);
+            base[0] += stride[0];
           }
         }
         if (G_LIKELY (base[1] <= last[1] && base[2] <= last[2])) {
           if (r_h == 2) {
-            memcpy (base[1], u_rows[k], I420_U_ROWSTRIDE (width));
-            memcpy (base[2], v_rows[k], I420_V_ROWSTRIDE (width));
+            memcpy (base[1], u_rows[k], stride[1]);
+            memcpy (base[2], v_rows[k], stride[2]);
           } else if (r_h == 1) {
-            hresamplecpy1 (base[1], u_rows[k], I420_U_ROWSTRIDE (width));
-            hresamplecpy1 (base[2], v_rows[k], I420_V_ROWSTRIDE (width));
+            hresamplecpy1 (base[1], u_rows[k], stride[1]);
+            hresamplecpy1 (base[2], v_rows[k], stride[2]);
           } else {
             /* FIXME: implement (at least we avoid crashing by doing nothing) */
           }
         }
 
         if (r_v == 2 || (k & 1) != 0) {
-          base[1] += I420_U_ROWSTRIDE (width);
-          base[2] += I420_V_ROWSTRIDE (width);
+          base[1] += stride[1];
+          base[2] += stride[2];
         }
       }
     } else {
@@ -969,27 +952,8 @@ gst_jpeg_dec_decode_indirect (GstJpegDec * dec, guchar * base[3],
   }
 }
 
-#ifndef GST_DISABLE_GST_DEBUG
-static inline void
-dump_lines (guchar * base[3], guchar ** line[3], int v_samp0, int width)
-{
-  int j;
-
-  for (j = 0; j < (v_samp0 * DCTSIZE); ++j) {
-    GST_LOG ("[%02d]  %5d  %5d  %5d", j,
-        (line[0][j] >= base[0]) ?
-        (int) (line[0][j] - base[0]) / I420_Y_ROWSTRIDE (width) : -1,
-        (line[1][j] >= base[1]) ?
-        (int) (line[1][j] - base[1]) / I420_U_ROWSTRIDE (width) : -1,
-        (line[2][j] >= base[2]) ?
-        (int) (line[2][j] - base[2]) / I420_V_ROWSTRIDE (width) : -1);
-  }
-}
-#endif
-
 static GstFlowReturn
-gst_jpeg_dec_decode_direct (GstJpegDec * dec, guchar * base[3],
-    guchar * last[3], guint width, guint height)
+gst_jpeg_dec_decode_direct (GstJpegDec * dec, GstVideoFrame * frame)
 {
   guchar **line[3];             /* the jpeg line buffer         */
   guchar *y[4 * DCTSIZE] = { NULL, };   /* alloc enough for the lines   */
@@ -997,6 +961,9 @@ gst_jpeg_dec_decode_direct (GstJpegDec * dec, guchar * base[3],
   guchar *v[4 * DCTSIZE] = { NULL, };
   gint i, j;
   gint lines, v_samp[3];
+  guchar *base[3], *last[3];
+  gint stride[3];
+  guint width, height;
 
   line[0] = y;
   line[1] = u;
@@ -1009,35 +976,45 @@ gst_jpeg_dec_decode_direct (GstJpegDec * dec, guchar * base[3],
   if (G_UNLIKELY (v_samp[0] > 2 || v_samp[1] > 2 || v_samp[2] > 2))
     goto format_not_supported;
 
+  width = GST_VIDEO_FRAME_WIDTH (frame);
+  height = GST_VIDEO_FRAME_HEIGHT (frame);
+
+  for (i = 0; i < 3; i++) {
+    base[i] = GST_VIDEO_FRAME_COMP_DATA (frame, i);
+    stride[i] = GST_VIDEO_FRAME_COMP_STRIDE (frame, i);
+    /* make sure we don't make jpeglib write beyond our buffer,
+     * which might happen if (height % (r_v*DCTSIZE)) != 0 */
+    last[i] = base[i] + (GST_VIDEO_FRAME_COMP_STRIDE (frame, i) *
+        (GST_VIDEO_FRAME_COMP_HEIGHT (frame, i) - 1));
+  }
+
   /* let jpeglib decode directly into our final buffer */
   GST_DEBUG_OBJECT (dec, "decoding directly into output buffer");
 
   for (i = 0; i < height; i += v_samp[0] * DCTSIZE) {
     for (j = 0; j < (v_samp[0] * DCTSIZE); ++j) {
       /* Y */
-      line[0][j] = base[0] + (i + j) * I420_Y_ROWSTRIDE (width);
+      line[0][j] = base[0] + (i + j) * stride[0];
       if (G_UNLIKELY (line[0][j] > last[0]))
         line[0][j] = last[0];
       /* U */
       if (v_samp[1] == v_samp[0]) {
-        line[1][j] = base[1] + ((i + j) / 2) * I420_U_ROWSTRIDE (width);
+        line[1][j] = base[1] + ((i + j) / 2) * stride[1];
       } else if (j < (v_samp[1] * DCTSIZE)) {
-        line[1][j] = base[1] + ((i / 2) + j) * I420_U_ROWSTRIDE (width);
+        line[1][j] = base[1] + ((i / 2) + j) * stride[1];
       }
       if (G_UNLIKELY (line[1][j] > last[1]))
         line[1][j] = last[1];
       /* V */
       if (v_samp[2] == v_samp[0]) {
-        line[2][j] = base[2] + ((i + j) / 2) * I420_V_ROWSTRIDE (width);
+        line[2][j] = base[2] + ((i + j) / 2) * stride[2];
       } else if (j < (v_samp[2] * DCTSIZE)) {
-        line[2][j] = base[2] + ((i / 2) + j) * I420_V_ROWSTRIDE (width);
+        line[2][j] = base[2] + ((i / 2) + j) * stride[2];
       }
       if (G_UNLIKELY (line[2][j] > last[2]))
         line[2][j] = last[2];
     }
 
-    /* dump_lines (base, line, v_samp[0], width); */
-
     lines = jpeg_read_raw_data (&dec->cinfo, line, v_samp[0] * DCTSIZE);
     if (G_UNLIKELY (!lines)) {
       GST_INFO_OBJECT (dec, "jpeg_read_raw_data() returned 0");
@@ -1061,7 +1038,7 @@ gst_jpeg_dec_update_qos (GstJpegDec * dec, gdouble proportion,
   GST_OBJECT_LOCK (dec);
   dec->proportion = proportion;
   if (G_LIKELY (ts != GST_CLOCK_TIME_NONE)) {
-    if (G_UNLIKELY (diff > 0))
+    if (G_UNLIKELY (diff > dec->qos_duration))
       dec->earliest_time = ts + 2 * diff + dec->qos_duration;
     else
       dec->earliest_time = ts + diff;
@@ -1127,38 +1104,96 @@ gst_jpeg_dec_do_qos (GstJpegDec * dec, GstClockTime timestamp)
   return TRUE;
 }
 
-static void
+static gboolean
+gst_jpeg_dec_buffer_pool (GstJpegDec * dec, GstCaps * caps)
+{
+  GstQuery *query;
+  GstBufferPool *pool = NULL;
+  guint size, min, max, prefix, alignment;
+  GstStructure *config;
+
+  GST_DEBUG_OBJECT (dec, "setting up bufferpool");
+
+  /* find a pool for the negotiated caps now */
+  query = gst_query_new_allocation (caps, TRUE);
+
+  if (gst_pad_peer_query (dec->srcpad, query)) {
+    /* we got configuration from our peer, parse them */
+    gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
+        &alignment, &pool);
+    size = MAX (size, dec->info.size);
+  } else {
+    GST_DEBUG_OBJECT (dec, "peer query failed, using defaults");
+    size = dec->info.size;
+    min = max = 0;
+    prefix = 0;
+    alignment = 15;
+  }
+  gst_query_unref (query);
+
+  if (pool == NULL) {
+    /* we did not get a pool, make one ourselves then */
+    pool = gst_buffer_pool_new ();
+  }
+
+  config = gst_buffer_pool_get_config (pool);
+  gst_buffer_pool_config_set (config, caps, size, min, max, prefix,
+      alignment | 15);
+  /* and store */
+  gst_buffer_pool_set_config (pool, config);
+
+  if (dec->pool) {
+    gst_buffer_pool_set_active (dec->pool, FALSE);
+    gst_object_unref (dec->pool);
+  }
+  dec->pool = pool;
+
+  /* and activate */
+  gst_buffer_pool_set_active (pool, TRUE);
+
+  return TRUE;
+}
+
+static gboolean
 gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc)
 {
   GstCaps *caps;
   GstVideoFormat format;
+  GstVideoInfo info;
 
-  if (G_UNLIKELY (width == dec->caps_width && height == dec->caps_height &&
-          dec->framerate_numerator == dec->caps_framerate_numerator &&
-          dec->framerate_denominator == dec->caps_framerate_denominator &&
-          clrspc == dec->clrspc))
-    return;
+  if (G_UNLIKELY (width == dec->info.width && height == dec->info.height &&
+          dec->in_fps_n == dec->info.fps_n && dec->in_fps_d == dec->info.fps_d
+          && clrspc == dec->clrspc))
+    return TRUE;
+
+  gst_video_info_init (&info);
 
   /* framerate == 0/1 is a still frame */
-  if (dec->framerate_denominator == 0) {
-    dec->framerate_numerator = 0;
-    dec->framerate_denominator = 1;
+  if (dec->in_fps_d == 0) {
+    info.fps_n = 0;
+    info.fps_d = 1;
+  } else {
+    info.fps_n = dec->in_fps_n;
+    info.fps_d = dec->in_fps_d;
   }
 
   /* calculate or assume an average frame duration for QoS purposes */
   GST_OBJECT_LOCK (dec);
-  if (dec->framerate_numerator != 0) {
-    dec->qos_duration = gst_util_uint64_scale (GST_SECOND,
-        dec->framerate_denominator, dec->framerate_numerator);
+  if (info.fps_n != 0) {
+    dec->qos_duration =
+        gst_util_uint64_scale (GST_SECOND, info.fps_d, info.fps_n);
+    dec->duration = dec->qos_duration;
   } else {
     /* if not set just use 25fps */
     dec->qos_duration = gst_util_uint64_scale (GST_SECOND, 1, 25);
+    dec->duration = GST_CLOCK_TIME_NONE;
   }
   GST_OBJECT_UNLOCK (dec);
 
   if (dec->cinfo.jpeg_color_space == JCS_RGB) {
     gint i;
     GstCaps *allowed_caps;
+    GstVideoInfo tmpinfo;
 
     GST_DEBUG_OBJECT (dec, "selecting RGB format");
     /* retrieve allowed caps, and find the first one that reasonably maps
@@ -1170,7 +1205,7 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc)
        * and get_pad_template_caps doesn't */
       caps = gst_caps_copy (gst_pad_get_pad_template_caps (dec->srcpad));
     }
-    /* avoid lists of fourcc, etc */
+    /* avoid lists of formats, etc */
     allowed_caps = gst_caps_normalize (caps);
     gst_caps_unref (caps);
     caps = NULL;
@@ -1183,10 +1218,11 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc)
       /* sigh, ds and _parse_caps need fixed caps for parsing, fixate */
       gst_pad_fixate_caps (dec->srcpad, caps);
       GST_LOG_OBJECT (dec, "checking caps %" GST_PTR_FORMAT, caps);
-      if (!gst_video_format_parse_caps (caps, &format, NULL, NULL))
+
+      if (!gst_video_info_from_caps (&tmpinfo, caps))
         continue;
       /* we'll settle for the first (preferred) downstream rgb format */
-      if (gst_video_format_is_rgb (format))
+      if (GST_VIDEO_INFO_IS_RGB (&tmpinfo))
         break;
       /* default fall-back */
       format = GST_VIDEO_FORMAT_RGB;
@@ -1194,51 +1230,31 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc)
     if (caps)
       gst_caps_unref (caps);
     gst_caps_unref (allowed_caps);
-    caps = gst_video_format_new_caps (format, width, height,
-        dec->framerate_numerator, dec->framerate_denominator, 1, 1);
-    dec->outsize = gst_video_format_get_size (format, width, height);
-    /* some format info */
-    dec->offset[0] =
-        gst_video_format_get_component_offset (format, 0, width, height);
-    dec->offset[1] =
-        gst_video_format_get_component_offset (format, 1, width, height);
-    dec->offset[2] =
-        gst_video_format_get_component_offset (format, 2, width, height);
-    /* equal for all components */
-    dec->stride = gst_video_format_get_row_stride (format, 0, width);
-    dec->inc = gst_video_format_get_pixel_stride (format, 0);
   } else if (dec->cinfo.jpeg_color_space == JCS_GRAYSCALE) {
     /* TODO is anything else then 8bit supported in jpeg? */
     format = GST_VIDEO_FORMAT_GRAY8;
-    caps = gst_video_format_new_caps (format, width, height,
-        dec->framerate_numerator, dec->framerate_denominator, 1, 1);
-    dec->outsize = gst_video_format_get_size (format, width, height);
-    dec->offset[0] =
-        gst_video_format_get_component_offset (format, 0, width, height);
-    dec->stride = gst_video_format_get_row_stride (format, 0, width);
-    dec->inc = gst_video_format_get_pixel_stride (format, 0);
   } else {
     /* go for plain and simple I420 */
     /* TODO other YUV cases ? */
-    caps = gst_caps_new_simple ("video/x-raw-yuv",
-        "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
-        "width", G_TYPE_INT, width, "height", G_TYPE_INT, height,
-        "framerate", GST_TYPE_FRACTION, dec->framerate_numerator,
-        dec->framerate_denominator, NULL);
-    dec->outsize = I420_SIZE (width, height);
+    format = GST_VIDEO_FORMAT_I420;
   }
 
+  gst_video_info_set_format (&info, format, width, height);
+  caps = gst_video_info_to_caps (&info);
+
   GST_DEBUG_OBJECT (dec, "setting caps %" GST_PTR_FORMAT, caps);
   GST_DEBUG_OBJECT (dec, "max_v_samp_factor=%d", dec->cinfo.max_v_samp_factor);
   GST_DEBUG_OBJECT (dec, "max_h_samp_factor=%d", dec->cinfo.max_h_samp_factor);
 
   gst_pad_set_caps (dec->srcpad, caps);
+
+  dec->info = info;
+  dec->clrspc = clrspc;
+
+  gst_jpeg_dec_buffer_pool (dec, caps);
   gst_caps_unref (caps);
 
-  dec->caps_width = width;
-  dec->caps_height = height;
-  dec->caps_framerate_numerator = dec->framerate_numerator;
-  dec->caps_framerate_denominator = dec->framerate_denominator;
+  return TRUE;
 }
 
 static GstFlowReturn
@@ -1247,17 +1263,12 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
   GstFlowReturn ret = GST_FLOW_OK;
   GstJpegDec *dec;
   GstBuffer *outbuf = NULL;
-#ifndef GST_DISABLE_GST_DEBUG
-  guchar *data;
-#endif
-  guchar *outdata;
-  guchar *base[3], *last[3];
   gint img_len;
-  guint outsize;
   gint width, height;
   gint r_h, r_v;
   guint code, hdr_ok;
   GstClockTime timestamp, duration;
+  GstVideoFrame frame;
 
   dec = GST_JPEG_DEC (GST_PAD_PARENT (pad));
 
@@ -1323,9 +1334,13 @@ again:
     goto skip_decoding;
 
 #ifndef GST_DISABLE_GST_DEBUG
-  data = (guint8 *) gst_adapter_peek (dec->adapter, 4);
-  GST_LOG_OBJECT (dec, "reading header %02x %02x %02x %02x", data[0], data[1],
-      data[2], data[3]);
+  {
+    guchar data[4];
+
+    gst_adapter_copy (dec->adapter, data, 0, 4);
+    GST_LOG_OBJECT (dec, "reading header %02x %02x %02x %02x", data[0], data[1],
+        data[2], data[3]);
+  }
 #endif
 
   gst_jpeg_dec_fill_input_buffer (&dec->cinfo);
@@ -1425,16 +1440,14 @@ again:
 
   gst_jpeg_dec_negotiate (dec, width, height, dec->cinfo.jpeg_color_space);
 
-  ret = gst_pad_alloc_buffer_and_set_caps (dec->srcpad, GST_BUFFER_OFFSET_NONE,
-      dec->outsize, GST_PAD_CAPS (dec->srcpad), &outbuf);
+  ret = gst_buffer_pool_acquire_buffer (dec->pool, &outbuf, NULL);
   if (G_UNLIKELY (ret != GST_FLOW_OK))
     goto alloc_failed;
 
-  outdata = GST_BUFFER_DATA (outbuf);
-  outsize = GST_BUFFER_SIZE (outbuf);
+  if (!gst_video_frame_map (&frame, &dec->info, outbuf, GST_MAP_READWRITE))
+    goto invalid_frame;
 
-  GST_LOG_OBJECT (dec, "width %d, height %d, buffer size %d, required size %d",
-      width, height, outsize, dec->outsize);
+  GST_LOG_OBJECT (dec, "width %d, height %d", width, height);
 
   GST_BUFFER_TIMESTAMP (outbuf) = dec->next_ts;
 
@@ -1442,10 +1455,9 @@ again:
     if (GST_CLOCK_TIME_IS_VALID (duration)) {
       /* use duration from incoming buffer for outgoing buffer */
       dec->next_ts += duration;
-    } else if (dec->framerate_numerator != 0) {
-      duration = gst_util_uint64_scale (GST_SECOND,
-          dec->framerate_denominator, dec->framerate_numerator);
-      dec->next_ts += duration;
+    } else if (GST_CLOCK_TIME_IS_VALID (dec->duration)) {
+      duration = dec->duration;
+      dec->next_ts += dec->duration;
     } else {
       duration = GST_CLOCK_TIME_NONE;
       dec->next_ts = GST_CLOCK_TIME_NONE;
@@ -1457,32 +1469,10 @@ again:
   GST_BUFFER_DURATION (outbuf) = duration;
 
   if (dec->cinfo.jpeg_color_space == JCS_RGB) {
-    base[0] = outdata + dec->offset[0];
-    base[1] = outdata + dec->offset[1];
-    base[2] = outdata + dec->offset[2];
-    gst_jpeg_dec_decode_rgb (dec, base, width, height, dec->inc, dec->stride);
+    gst_jpeg_dec_decode_rgb (dec, &frame);
   } else if (dec->cinfo.jpeg_color_space == JCS_GRAYSCALE) {
-    base[0] = outdata + dec->offset[0];
-    gst_jpeg_dec_decode_grayscale (dec, base, width, height, dec->inc,
-        dec->stride);
+    gst_jpeg_dec_decode_grayscale (dec, &frame);
   } else {
-    /* mind the swap, jpeglib outputs blue chroma first
-     * ensonic: I see no swap?
-     */
-    base[0] = outdata + I420_Y_OFFSET (width, height);
-    base[1] = outdata + I420_U_OFFSET (width, height);
-    base[2] = outdata + I420_V_OFFSET (width, height);
-
-    /* make sure we don't make jpeglib write beyond our buffer,
-     * which might happen if (height % (r_v*DCTSIZE)) != 0 */
-    last[0] = base[0] + (I420_Y_ROWSTRIDE (width) * (height - 1));
-    last[1] =
-        base[1] + (I420_U_ROWSTRIDE (width) * ((GST_ROUND_UP_2 (height) / 2) -
-            1));
-    last[2] =
-        base[2] + (I420_V_ROWSTRIDE (width) * ((GST_ROUND_UP_2 (height) / 2) -
-            1));
-
     GST_LOG_OBJECT (dec, "decompressing (reqired scanline buffer height = %u)",
         dec->cinfo.rec_outbuf_height);
 
@@ -1497,11 +1487,10 @@ again:
             || dec->cinfo.comp_info[2].h_samp_factor != 1)) {
       GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, dec,
           "indirect decoding using extra buffer copy");
-      gst_jpeg_dec_decode_indirect (dec, base, last, width, height, r_v, r_h,
+      gst_jpeg_dec_decode_indirect (dec, &frame, r_v, r_h,
           dec->cinfo.num_components);
     } else {
-      ret = gst_jpeg_dec_decode_direct (dec, base, last, width, height);
-
+      ret = gst_jpeg_dec_decode_direct (dec, &frame);
       if (G_UNLIKELY (ret != GST_FLOW_OK))
         goto decode_direct_failed;
     }
@@ -1510,9 +1499,11 @@ again:
   GST_LOG_OBJECT (dec, "decompressing finished");
   jpeg_finish_decompress (&dec->cinfo);
 
+  gst_video_frame_unmap (&frame);
+
   /* Clipping */
   if (dec->segment.format == GST_FORMAT_TIME) {
-    gint64 start, stop, clip_start, clip_stop;
+    guint64 start, stop, clip_start, clip_stop;
 
     GST_LOG_OBJECT (dec, "Attempting clipping");
 
@@ -1618,6 +1609,13 @@ alloc_failed:
     }
     goto exit;
   }
+invalid_frame:
+  {
+    jpeg_abort_decompress (&dec->cinfo);
+    gst_buffer_unref (outbuf);
+    ret = GST_FLOW_OK;
+    goto exit;
+  }
 drop_buffer:
   {
     GST_WARNING_OBJECT (dec, "Outgoing buffer is outside configured segment");
@@ -1663,11 +1661,12 @@ gst_jpeg_dec_src_event (GstPad * pad, GstEvent * event)
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_QOS:{
+      GstQOSType type;
       GstClockTimeDiff diff;
       GstClockTime timestamp;
       gdouble proportion;
 
-      gst_event_parse_qos (event, &proportion, &diff, &timestamp);
+      gst_event_parse_qos (event, &type, &proportion, &diff, &timestamp);
       gst_jpeg_dec_update_qos (dec, proportion, diff, timestamp);
       break;
     }
@@ -1684,7 +1683,7 @@ gst_jpeg_dec_src_event (GstPad * pad, GstEvent * event)
 static gboolean
 gst_jpeg_dec_sink_event (GstPad * pad, GstEvent * event)
 {
-  gboolean ret = TRUE;
+  gboolean ret = TRUE, forward = TRUE;
   GstJpegDec *dec = GST_JPEG_DEC (GST_OBJECT_PARENT (pad));
 
   GST_DEBUG_OBJECT (dec, "event : %s", GST_EVENT_TYPE_NAME (event));
@@ -1702,30 +1701,28 @@ gst_jpeg_dec_sink_event (GstPad * pad, GstEvent * event)
       dec->parse_resync = FALSE;
       gst_jpeg_dec_reset_qos (dec);
       break;
-    case GST_EVENT_NEWSEGMENT:{
-      gboolean update;
-      gdouble rate, applied_rate;
-      GstFormat format;
-      gint64 start, stop, position;
-
-      gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate,
-          &format, &start, &stop, &position);
-
-      GST_DEBUG_OBJECT (dec, "Got NEWSEGMENT [%" GST_TIME_FORMAT
-          " - %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "]",
-          GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
-          GST_TIME_ARGS (position));
-
-      gst_segment_set_newsegment_full (&dec->segment, update, rate,
-          applied_rate, format, start, stop, position);
+    case GST_EVENT_SEGMENT:
+      gst_event_copy_segment (event, &dec->segment);
+      GST_DEBUG_OBJECT (dec, "Got NEWSEGMENT %" GST_SEGMENT_FORMAT,
+          &dec->segment);
+      break;
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
 
+      gst_event_parse_caps (event, &caps);
+      ret = gst_jpeg_dec_setcaps (dec, caps);
+      forward = FALSE;
       break;
     }
     default:
       break;
   }
 
-  ret = gst_pad_push_event (dec->srcpad, event);
+  if (forward)
+    ret = gst_pad_push_event (dec->srcpad, event);
+  else
+    gst_event_unref (event);
 
   return ret;
 }
@@ -1786,11 +1783,9 @@ gst_jpeg_dec_change_state (GstElement * element, GstStateChange transition)
     case GST_STATE_CHANGE_READY_TO_PAUSED:
       dec->error_count = 0;
       dec->good_count = 0;
-      dec->framerate_numerator = 0;
-      dec->framerate_denominator = 1;
-      dec->caps_framerate_numerator = dec->caps_framerate_denominator = 0;
-      dec->caps_width = -1;
-      dec->caps_height = -1;
+      dec->in_fps_n = 0;
+      dec->in_fps_d = 1;
+      gst_video_info_init (&dec->info);
       dec->clrspc = -1;
       dec->packetized = FALSE;
       dec->next_ts = 0;
@@ -1815,6 +1810,11 @@ gst_jpeg_dec_change_state (GstElement * element, GstStateChange transition)
       g_free (dec->cur_buf);
       dec->cur_buf = NULL;
       gst_jpeg_dec_free_buffers (dec);
+      if (dec->pool) {
+        gst_buffer_pool_set_active (dec->pool, FALSE);
+        gst_object_unref (dec->pool);
+      }
+      dec->pool = NULL;
       break;
     default:
       break;
index 7daf7b6..4946ee5 100644 (file)
@@ -90,21 +90,16 @@ struct _GstJpegDec {
   GstClockTime earliest_time;
   GstClockTime qos_duration;
 
-  /* video state */
-  gint framerate_numerator;
-  gint framerate_denominator;
-
-  /* negotiated state */
-  gint     caps_framerate_numerator;
-  gint     caps_framerate_denominator;
-  gint     caps_width;
-  gint     caps_height;
-  gint     outsize;
-  gint     clrspc;
+  /* input state */
+  gint in_fps_n;
+  gint in_fps_d;
+
+  /* negotiated output state */
+  GstBufferPool *pool;
+  GstVideoInfo info;
+  GstClockTime duration;
 
-  gint     offset[3];
-  gint     stride;
-  gint     inc;
+  gint     clrspc;
 
   /* parse state */
   gint     parse_offset;
index e631be6..80993e9 100644 (file)
@@ -54,7 +54,6 @@ GST_DEBUG_CATEGORY_STATIC (jpegenc_debug);
 /* JpegEnc signals and args */
 enum
 {
-  FRAME_ENCODED,
   /* FILL ME */
   LAST_SIGNAL
 };
@@ -68,14 +67,11 @@ enum
 };
 
 static void gst_jpegenc_reset (GstJpegEnc * enc);
-static void gst_jpegenc_base_init (gpointer g_class);
-static void gst_jpegenc_class_init (GstJpegEnc * klass);
-static void gst_jpegenc_init (GstJpegEnc * jpegenc);
 static void gst_jpegenc_finalize (GObject * object);
 
 static GstFlowReturn gst_jpegenc_chain (GstPad * pad, GstBuffer * buf);
-static gboolean gst_jpegenc_setcaps (GstPad * pad, GstCaps * caps);
-static GstCaps *gst_jpegenc_getcaps (GstPad * pad);
+static gboolean gst_jpegenc_sink_event (GstPad * pad, GstEvent * event);
+static GstCaps *gst_jpegenc_getcaps (GstPad * pad, GstCaps * filter);
 
 static void gst_jpegenc_resync (GstJpegEnc * jpegenc);
 static void gst_jpegenc_set_property (GObject * object, guint prop_id,
@@ -85,46 +81,17 @@ static void gst_jpegenc_get_property (GObject * object, guint prop_id,
 static GstStateChangeReturn gst_jpegenc_change_state (GstElement * element,
     GstStateChange transition);
 
-
-static GstElementClass *parent_class = NULL;
-static guint gst_jpegenc_signals[LAST_SIGNAL] = { 0 };
-
-GType
-gst_jpegenc_get_type (void)
-{
-  static GType jpegenc_type = 0;
-
-  if (!jpegenc_type) {
-    static const GTypeInfo jpegenc_info = {
-      sizeof (GstJpegEnc),
-      (GBaseInitFunc) gst_jpegenc_base_init,
-      NULL,
-      (GClassInitFunc) gst_jpegenc_class_init,
-      NULL,
-      NULL,
-      sizeof (GstJpegEnc),
-      0,
-      (GInstanceInitFunc) gst_jpegenc_init,
-    };
-
-    jpegenc_type =
-        g_type_register_static (GST_TYPE_ELEMENT, "GstJpegEnc", &jpegenc_info,
-        0);
-  }
-  return jpegenc_type;
-}
+#define gst_jpegenc_parent_class parent_class
+G_DEFINE_TYPE (GstJpegEnc, gst_jpegenc, GST_TYPE_ELEMENT);
 
 /* *INDENT-OFF* */
 static GstStaticPadTemplate gst_jpegenc_sink_pad_template =
 GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV
-        ("{ I420, YV12, YUY2, UYVY, Y41B, Y42B, YVYU, Y444 }") "; "
-        GST_VIDEO_CAPS_RGB "; " GST_VIDEO_CAPS_BGR "; "
-        GST_VIDEO_CAPS_RGBx "; " GST_VIDEO_CAPS_xRGB "; "
-        GST_VIDEO_CAPS_BGRx "; " GST_VIDEO_CAPS_xBGR "; "
-        GST_VIDEO_CAPS_GRAY8)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
+        ("{ I420, YV12, YUY2, UYVY, Y41B, Y42B, YVYU, Y444, "
+         "RGB, BGR, RGBx, xRGB, BGRx, xBGR, GRAY8 }"))
     );
 /* *INDENT-ON* */
 
@@ -137,22 +104,9 @@ GST_STATIC_PAD_TEMPLATE ("src",
         "height = (int) [ 16, 65535 ], " "framerate = (fraction) [ 0/1, MAX ]")
     );
 
-static void
-gst_jpegenc_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_jpegenc_sink_pad_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_jpegenc_src_pad_template));
-  gst_element_class_set_details_simple (element_class, "JPEG image encoder",
-      "Codec/Encoder/Image",
-      "Encode images in JPEG format", "Wim Taymans <wim.taymans@tvd.be>");
-}
 
 static void
-gst_jpegenc_class_init (GstJpegEnc * klass)
+gst_jpegenc_class_init (GstJpegEncClass * klass)
 {
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
@@ -160,17 +114,10 @@ gst_jpegenc_class_init (GstJpegEnc * klass)
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
 
-  parent_class = g_type_class_peek_parent (klass);
-
-  gst_jpegenc_signals[FRAME_ENCODED] =
-      g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS (klass),
-      G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstJpegEncClass, frame_encoded), NULL,
-      NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-
+  gobject_class->finalize = gst_jpegenc_finalize;
   gobject_class->set_property = gst_jpegenc_set_property;
   gobject_class->get_property = gst_jpegenc_get_property;
 
-
   g_object_class_install_property (gobject_class, PROP_QUALITY,
       g_param_spec_int ("quality", "Quality", "Quality of encoding",
           0, 100, JPEG_DEFAULT_QUALITY,
@@ -192,13 +139,55 @@ gst_jpegenc_class_init (GstJpegEnc * klass)
 
   gstelement_class->change_state = gst_jpegenc_change_state;
 
-  gobject_class->finalize = gst_jpegenc_finalize;
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_jpegenc_sink_pad_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_jpegenc_src_pad_template));
+  gst_element_class_set_details_simple (gstelement_class, "JPEG image encoder",
+      "Codec/Encoder/Image",
+      "Encode images in JPEG format", "Wim Taymans <wim.taymans@tvd.be>");
 
   GST_DEBUG_CATEGORY_INIT (jpegenc_debug, "jpegenc", 0,
       "JPEG encoding element");
 }
 
 static void
+ensure_memory (GstJpegEnc * jpegenc)
+{
+  GstMemory *new_memory;
+  gsize old_size, desired_size, new_size;
+  guint8 *new_data;
+
+  old_size = jpegenc->output_size;
+  if (old_size == 0)
+    desired_size = jpegenc->bufsize;
+  else
+    desired_size = old_size * 2;
+
+  /* Our output memory wasn't big enough.
+   * Make a new memory that's twice the size, */
+  new_memory = gst_allocator_alloc (NULL, desired_size, 3);
+  new_data = gst_memory_map (new_memory, &new_size, NULL, GST_MAP_READWRITE);
+
+  /* copy previous data if any */
+  if (jpegenc->output_mem) {
+    memcpy (new_data, jpegenc->output_data, old_size);
+    gst_memory_unmap (jpegenc->output_mem, jpegenc->output_data,
+        jpegenc->output_size);
+    gst_memory_unref (jpegenc->output_mem);
+  }
+
+  /* drop it into place, */
+  jpegenc->output_mem = new_memory;
+  jpegenc->output_data = new_data;
+  jpegenc->output_size = new_size;
+
+  /* and last, update libjpeg on where to work. */
+  jpegenc->jdest.next_output_byte = new_data + old_size;
+  jpegenc->jdest.free_in_buffer = new_size - old_size;
+}
+
+static void
 gst_jpegenc_init_destination (j_compress_ptr cinfo)
 {
   GST_DEBUG ("gst_jpegenc_chain: init_destination");
@@ -207,33 +196,12 @@ gst_jpegenc_init_destination (j_compress_ptr cinfo)
 static boolean
 gst_jpegenc_flush_destination (j_compress_ptr cinfo)
 {
-  GstBuffer *overflow_buffer;
-  guint32 old_buffer_size;
   GstJpegEnc *jpegenc = (GstJpegEnc *) (cinfo->client_data);
+
   GST_DEBUG_OBJECT (jpegenc,
       "gst_jpegenc_chain: flush_destination: buffer too small");
 
-  /* Our output buffer wasn't big enough.
-   * Make a new buffer that's twice the size, */
-  old_buffer_size = GST_BUFFER_SIZE (jpegenc->output_buffer);
-  gst_pad_alloc_buffer_and_set_caps (jpegenc->srcpad,
-      GST_BUFFER_OFFSET_NONE, old_buffer_size * 2,
-      GST_PAD_CAPS (jpegenc->srcpad), &overflow_buffer);
-  memcpy (GST_BUFFER_DATA (overflow_buffer),
-      GST_BUFFER_DATA (jpegenc->output_buffer), old_buffer_size);
-
-  gst_buffer_copy_metadata (overflow_buffer, jpegenc->output_buffer,
-      GST_BUFFER_COPY_TIMESTAMPS);
-
-  /* drop it into place, */
-  gst_buffer_unref (jpegenc->output_buffer);
-  jpegenc->output_buffer = overflow_buffer;
-
-  /* and last, update libjpeg on where to work. */
-  jpegenc->jdest.next_output_byte =
-      GST_BUFFER_DATA (jpegenc->output_buffer) + old_buffer_size;
-  jpegenc->jdest.free_in_buffer =
-      GST_BUFFER_SIZE (jpegenc->output_buffer) - old_buffer_size;
+  ensure_memory (jpegenc);
 
   return TRUE;
 }
@@ -244,14 +212,11 @@ gst_jpegenc_term_destination (j_compress_ptr cinfo)
   GstJpegEnc *jpegenc = (GstJpegEnc *) (cinfo->client_data);
   GST_DEBUG_OBJECT (jpegenc, "gst_jpegenc_chain: term_source");
 
-  /* Trim the buffer size and push it. */
-  GST_BUFFER_SIZE (jpegenc->output_buffer) =
-      GST_BUFFER_SIZE (jpegenc->output_buffer) - jpegenc->jdest.free_in_buffer;
-
-  g_signal_emit (G_OBJECT (jpegenc), gst_jpegenc_signals[FRAME_ENCODED], 0);
-
-  jpegenc->last_ret = gst_pad_push (jpegenc->srcpad, jpegenc->output_buffer);
-  jpegenc->output_buffer = NULL;
+  /* Trim the buffer size. we will push it in the chain function */
+  gst_memory_unmap (jpegenc->output_mem, jpegenc->output_data,
+      jpegenc->output_size - jpegenc->jdest.free_in_buffer);
+  jpegenc->output_data = NULL;
+  jpegenc->output_size = 0;
 }
 
 static void
@@ -264,8 +229,8 @@ gst_jpegenc_init (GstJpegEnc * jpegenc)
       GST_DEBUG_FUNCPTR (gst_jpegenc_chain));
   gst_pad_set_getcaps_function (jpegenc->sinkpad,
       GST_DEBUG_FUNCPTR (gst_jpegenc_getcaps));
-  gst_pad_set_setcaps_function (jpegenc->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_jpegenc_setcaps));
+  gst_pad_set_event_function (jpegenc->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_jpegenc_sink_event));
   gst_element_add_pad (GST_ELEMENT (jpegenc), jpegenc->sinkpad);
 
   jpegenc->srcpad =
@@ -274,8 +239,7 @@ gst_jpegenc_init (GstJpegEnc * jpegenc)
   gst_element_add_pad (GST_ELEMENT (jpegenc), jpegenc->srcpad);
 
   /* reset the initial video state */
-  jpegenc->width = -1;
-  jpegenc->height = -1;
+  gst_video_info_init (&jpegenc->info);
 
   /* setup jpeglib */
   memset (&jpegenc->cinfo, 0, sizeof (jpegenc->cinfo));
@@ -315,11 +279,7 @@ gst_jpegenc_reset (GstJpegEnc * enc)
     }
   }
 
-  enc->width = -1;
-  enc->height = -1;
-  enc->format = GST_VIDEO_FORMAT_UNKNOWN;
-  enc->fps_den = enc->par_den = 0;
-  enc->height = enc->width = 0;
+  gst_video_info_init (&enc->info);
 }
 
 static void
@@ -333,7 +293,7 @@ gst_jpegenc_finalize (GObject * object)
 }
 
 static GstCaps *
-gst_jpegenc_getcaps (GstPad * pad)
+gst_jpegenc_getcaps (GstPad * pad, GstCaps * filter)
 {
   GstJpegEnc *jpegenc = GST_JPEGENC (gst_pad_get_parent (pad));
   GstCaps *caps, *othercaps;
@@ -344,7 +304,7 @@ gst_jpegenc_getcaps (GstPad * pad)
   /* we want to proxy properties like width, height and framerate from the
      other end of the element */
 
-  othercaps = gst_pad_peer_get_caps_reffed (jpegenc->srcpad);
+  othercaps = gst_pad_peer_get_caps (jpegenc->srcpad, filter);
   if (othercaps == NULL ||
       gst_caps_is_empty (othercaps) || gst_caps_is_any (othercaps)) {
     caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
@@ -381,59 +341,41 @@ done:
 }
 
 static gboolean
-gst_jpegenc_setcaps (GstPad * pad, GstCaps * caps)
+gst_jpegenc_setcaps (GstJpegEnc * enc, GstCaps * caps)
 {
-  GstJpegEnc *enc = GST_JPEGENC (gst_pad_get_parent (pad));
-  GstVideoFormat format;
-  gint width, height;
-  gint fps_num, fps_den;
-  gint par_num, par_den;
+  GstVideoInfo info;
   gint i;
   GstCaps *othercaps;
   gboolean ret;
+  const GstVideoFormatInfo *vinfo;
 
   /* get info from caps */
-  if (!gst_video_format_parse_caps (caps, &format, &width, &height))
+  if (!gst_video_info_from_caps (&info, caps))
     goto refuse_caps;
-  /* optional; pass along if present */
-  fps_num = fps_den = -1;
-  par_num = par_den = -1;
-  gst_video_parse_caps_framerate (caps, &fps_num, &fps_den);
-  gst_video_parse_caps_pixel_aspect_ratio (caps, &par_num, &par_den);
-
-  if (width == enc->width && height == enc->height && enc->format == format
-      && fps_num == enc->fps_num && fps_den == enc->fps_den
-      && par_num == enc->par_num && par_den == enc->par_den)
-    return TRUE;
 
   /* store input description */
-  enc->format = format;
-  enc->width = width;
-  enc->height = height;
-  enc->fps_num = fps_num;
-  enc->fps_den = fps_den;
-  enc->par_num = par_num;
-  enc->par_den = par_den;
+  enc->info = info;
+
+  vinfo = info.finfo;
 
   /* prepare a cached image description  */
-  enc->channels = 3 + (gst_video_format_has_alpha (format) ? 1 : 0);
+  enc->channels = 3 + (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (vinfo) ? 1 : 0);
   /* ... but any alpha is disregarded in encoding */
-  if (gst_video_format_is_gray (format))
+  if (GST_VIDEO_FORMAT_INFO_IS_GRAY (vinfo))
     enc->channels = 1;
   else
     enc->channels = 3;
+
   enc->h_max_samp = 0;
   enc->v_max_samp = 0;
   for (i = 0; i < enc->channels; ++i) {
-    enc->cwidth[i] = gst_video_format_get_component_width (format, i, width);
-    enc->cheight[i] = gst_video_format_get_component_height (format, i, height);
-    enc->offset[i] = gst_video_format_get_component_offset (format, i, width,
-        height);
-    enc->stride[i] = gst_video_format_get_row_stride (format, i, width);
-    enc->inc[i] = gst_video_format_get_pixel_stride (format, i);
-    enc->h_samp[i] = GST_ROUND_UP_4 (width) / enc->cwidth[i];
+    enc->cwidth[i] = GST_VIDEO_INFO_COMP_WIDTH (&info, i);
+    enc->cheight[i] = GST_VIDEO_INFO_COMP_HEIGHT (&info, i);
+    enc->inc[i] = GST_VIDEO_INFO_COMP_PSTRIDE (&info, i);
+
+    enc->h_samp[i] = GST_ROUND_UP_4 (info.width) / enc->cwidth[i];
     enc->h_max_samp = MAX (enc->h_max_samp, enc->h_samp[i]);
-    enc->v_samp[i] = GST_ROUND_UP_4 (height) / enc->cheight[i];
+    enc->v_samp[i] = GST_ROUND_UP_4 (info.height) / enc->cheight[i];
     enc->v_max_samp = MAX (enc->v_max_samp, enc->v_samp[i]);
   }
   /* samp should only be 1, 2 or 4 */
@@ -449,14 +391,13 @@ gst_jpegenc_setcaps (GstPad * pad, GstCaps * caps)
 
   othercaps = gst_caps_copy (gst_pad_get_pad_template_caps (enc->srcpad));
   gst_caps_set_simple (othercaps,
-      "width", G_TYPE_INT, enc->width, "height", G_TYPE_INT, enc->height, NULL);
-  if (enc->fps_den > 0)
+      "width", G_TYPE_INT, info.width, "height", G_TYPE_INT, info.height, NULL);
+  if (info.fps_d > 0)
     gst_caps_set_simple (othercaps,
-        "framerate", GST_TYPE_FRACTION, enc->fps_num, enc->fps_den, NULL);
-  if (enc->par_den > 0)
+        "framerate", GST_TYPE_FRACTION, info.fps_n, info.fps_d, NULL);
+  if (info.par_d > 0)
     gst_caps_set_simple (othercaps,
-        "pixel-aspect-ratio", GST_TYPE_FRACTION, enc->par_num, enc->par_den,
-        NULL);
+        "pixel-aspect-ratio", GST_TYPE_FRACTION, info.par_n, info.par_d, NULL);
 
   ret = gst_pad_set_caps (enc->srcpad, othercaps);
   gst_caps_unref (othercaps);
@@ -464,38 +405,64 @@ gst_jpegenc_setcaps (GstPad * pad, GstCaps * caps)
   if (ret)
     gst_jpegenc_resync (enc);
 
-  gst_object_unref (enc);
-
   return ret;
 
   /* ERRORS */
 refuse_caps:
   {
     GST_WARNING_OBJECT (enc, "refused caps %" GST_PTR_FORMAT, caps);
-    gst_object_unref (enc);
     return FALSE;
   }
 }
 
+static gboolean
+gst_jpegenc_sink_event (GstPad * pad, GstEvent * event)
+{
+  gboolean res;
+  GstJpegEnc *enc = GST_JPEGENC (gst_pad_get_parent (pad));
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+
+      gst_event_parse_caps (event, &caps);
+      res = gst_jpegenc_setcaps (enc, caps);
+      break;
+    }
+    default:
+      res = gst_pad_event_default (pad, event);
+      break;
+  }
+
+  gst_object_unref (enc);
+
+  return res;
+}
+
 static void
 gst_jpegenc_resync (GstJpegEnc * jpegenc)
 {
   gint width, height;
   gint i, j;
+  const GstVideoFormatInfo *finfo;
 
   GST_DEBUG_OBJECT (jpegenc, "resync");
 
-  jpegenc->cinfo.image_width = width = jpegenc->width;
-  jpegenc->cinfo.image_height = height = jpegenc->height;
+  finfo = jpegenc->info.finfo;
+
+  jpegenc->cinfo.image_width = width = GST_VIDEO_INFO_WIDTH (&jpegenc->info);
+  jpegenc->cinfo.image_height = height = GST_VIDEO_INFO_HEIGHT (&jpegenc->info);
   jpegenc->cinfo.input_components = jpegenc->channels;
 
   GST_DEBUG_OBJECT (jpegenc, "width %d, height %d", width, height);
-  GST_DEBUG_OBJECT (jpegenc, "format %d", jpegenc->format);
+  GST_DEBUG_OBJECT (jpegenc, "format %d",
+      GST_VIDEO_INFO_FORMAT (&jpegenc->info));
 
-  if (gst_video_format_is_rgb (jpegenc->format)) {
+  if (GST_VIDEO_FORMAT_INFO_IS_RGB (finfo)) {
     GST_DEBUG_OBJECT (jpegenc, "RGB");
     jpegenc->cinfo.in_color_space = JCS_RGB;
-  } else if (gst_video_format_is_gray (jpegenc->format)) {
+  } else if (GST_VIDEO_FORMAT_INFO_IS_GRAY (finfo)) {
     GST_DEBUG_OBJECT (jpegenc, "gray");
     jpegenc->cinfo.in_color_space = JCS_GRAYSCALE;
   } else {
@@ -504,7 +471,7 @@ gst_jpegenc_resync (GstJpegEnc * jpegenc)
   }
 
   /* input buffer size as max output */
-  jpegenc->bufsize = gst_video_format_get_size (jpegenc->format, width, height);
+  jpegenc->bufsize = GST_VIDEO_INFO_SIZE (&jpegenc->info);
   jpeg_set_defaults (&jpegenc->cinfo);
   jpegenc->cinfo.raw_data_in = TRUE;
   /* duh, libjpeg maps RGB to YUV ... and don't expect some conversion */
@@ -544,42 +511,41 @@ gst_jpegenc_chain (GstPad * pad, GstBuffer * buf)
 {
   GstFlowReturn ret;
   GstJpegEnc *jpegenc;
-  guchar *data;
-  gulong size;
-  guint height;
+  guint height, width;
   guchar *base[3], *end[3];
+  guint stride[3];
   gint i, j, k;
+  GstBuffer *outbuf;
+  GstVideoFrame frame;
 
   jpegenc = GST_JPEGENC (GST_OBJECT_PARENT (pad));
 
-  if (G_UNLIKELY (jpegenc->width <= 0 || jpegenc->height <= 0))
+  if (G_UNLIKELY (GST_VIDEO_INFO_FORMAT (&jpegenc->info) ==
+          GST_VIDEO_FORMAT_UNKNOWN))
     goto not_negotiated;
 
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
-
-  GST_LOG_OBJECT (jpegenc, "got buffer of %lu bytes", size);
+  if (!gst_video_frame_map (&frame, &jpegenc->info, buf, GST_MAP_READ))
+    goto invalid_frame;
 
-  ret =
-      gst_pad_alloc_buffer_and_set_caps (jpegenc->srcpad,
-      GST_BUFFER_OFFSET_NONE, jpegenc->bufsize, GST_PAD_CAPS (jpegenc->srcpad),
-      &jpegenc->output_buffer);
-
-  if (ret != GST_FLOW_OK)
-    goto done;
+  height = GST_VIDEO_FRAME_HEIGHT (&frame);
+  width = GST_VIDEO_FRAME_WIDTH (&frame);
 
-  gst_buffer_copy_metadata (jpegenc->output_buffer, buf,
-      GST_BUFFER_COPY_TIMESTAMPS);
-
-  height = jpegenc->height;
+  GST_LOG_OBJECT (jpegenc, "got buffer of %lu bytes",
+      gst_buffer_get_size (buf));
 
   for (i = 0; i < jpegenc->channels; i++) {
-    base[i] = data + jpegenc->offset[i];
-    end[i] = base[i] + jpegenc->cheight[i] * jpegenc->stride[i];
+    base[i] = GST_VIDEO_FRAME_COMP_DATA (&frame, i);
+    stride[i] = GST_VIDEO_FRAME_COMP_STRIDE (&frame, i);
+    end[i] = base[i] + GST_VIDEO_FRAME_COMP_HEIGHT (&frame, i) * stride[i];
   }
 
-  jpegenc->jdest.next_output_byte = GST_BUFFER_DATA (jpegenc->output_buffer);
-  jpegenc->jdest.free_in_buffer = GST_BUFFER_SIZE (jpegenc->output_buffer);
+  jpegenc->output_mem = gst_allocator_alloc (NULL, jpegenc->bufsize, 3);
+  jpegenc->output_data =
+      gst_memory_map (jpegenc->output_mem, &jpegenc->output_size, NULL,
+      GST_MAP_READWRITE);
+
+  jpegenc->jdest.next_output_byte = jpegenc->output_data;
+  jpegenc->jdest.free_in_buffer = jpegenc->output_size;
 
   /* prepare for raw input */
 #if JPEG_LIB_VERSION >= 70
@@ -597,8 +563,8 @@ gst_jpegenc_chain (GstPad * pad, GstBuffer * buf)
       for (k = 0; k < jpegenc->channels; k++) {
         for (j = 0; j < jpegenc->v_samp[k] * DCTSIZE; j++) {
           jpegenc->line[k][j] = base[k];
-          if (base[k] + jpegenc->stride[k] < end[k])
-            base[k] += jpegenc->stride[k];
+          if (base[k] + stride[k] < end[k])
+            base[k] += stride[k];
         }
       }
       jpeg_write_raw_data (&jpegenc->cinfo, jpegenc->line,
@@ -619,8 +585,8 @@ gst_jpegenc_chain (GstPad * pad, GstBuffer * buf)
             src += jpegenc->inc[k];
             dst++;
           }
-          if (base[k] + jpegenc->stride[k] < end[k])
-            base[k] += jpegenc->stride[k];
+          if (base[k] + stride[k] < end[k])
+            base[k] += stride[k];
         }
       }
       jpeg_write_raw_data (&jpegenc->cinfo, jpegenc->line,
@@ -628,22 +594,34 @@ gst_jpegenc_chain (GstPad * pad, GstBuffer * buf)
     }
   }
 
-  /* This will ensure that gst_jpegenc_term_destination is called; we push
-     the final output buffer from there */
+  /* This will ensure that gst_jpegenc_term_destination is called */
   jpeg_finish_compress (&jpegenc->cinfo);
   GST_LOG_OBJECT (jpegenc, "compressing done");
 
-done:
+  outbuf = gst_buffer_new ();
+  gst_buffer_copy_into (outbuf, buf, GST_BUFFER_COPY_METADATA, 0, -1);
+  gst_buffer_take_memory (outbuf, -1, jpegenc->output_mem);
+  jpegenc->output_mem = NULL;
+
+  ret = gst_pad_push (jpegenc->srcpad, outbuf);
+
+  gst_video_frame_unmap (&frame);
   gst_buffer_unref (buf);
 
   return ret;
 
-/* ERRORS */
+  /* ERRORS */
 not_negotiated:
   {
     GST_WARNING_OBJECT (jpegenc, "no input format set (no caps on buffer)");
-    ret = GST_FLOW_NOT_NEGOTIATED;
-    goto done;
+    gst_buffer_unref (buf);
+    return GST_FLOW_NOT_NEGOTIATED;
+  }
+invalid_frame:
+  {
+    GST_WARNING_OBJECT (jpegenc, "invalid frame received");
+    gst_buffer_unref (buf);
+    return GST_FLOW_OK;
   }
 }
 
index f7a3ef0..f677887 100644 (file)
@@ -46,8 +46,6 @@ G_BEGIN_DECLS
 typedef struct _GstJpegEnc GstJpegEnc;
 typedef struct _GstJpegEncClass GstJpegEncClass;
 
-#define GST_JPEG_ENC_MAX_COMPONENT  4
-
 struct _GstJpegEnc
 {
   GstElement element;
@@ -56,20 +54,15 @@ struct _GstJpegEnc
   GstPad *sinkpad, *srcpad;
 
   /* stream/image properties */
-  GstVideoFormat format;
-  gint width;
-  gint height;
+  GstVideoInfo info;
   gint channels;
-  gint fps_num, fps_den;
-  gint par_num, par_den;
+
   /* standard video_format indexed */
-  gint stride[GST_JPEG_ENC_MAX_COMPONENT];
-  gint offset[GST_JPEG_ENC_MAX_COMPONENT];
-  gint inc[GST_JPEG_ENC_MAX_COMPONENT];
-  gint cwidth[GST_JPEG_ENC_MAX_COMPONENT];
-  gint cheight[GST_JPEG_ENC_MAX_COMPONENT];
-  gint h_samp[GST_JPEG_ENC_MAX_COMPONENT];
-  gint v_samp[GST_JPEG_ENC_MAX_COMPONENT];
+  gint inc[GST_VIDEO_MAX_COMPONENTS];
+  gint cwidth[GST_VIDEO_MAX_COMPONENTS];
+  gint cheight[GST_VIDEO_MAX_COMPONENTS];
+  gint h_samp[GST_VIDEO_MAX_COMPONENTS];
+  gint v_samp[GST_VIDEO_MAX_COMPONENTS];
   gint h_max_samp;
   gint v_max_samp;
   gboolean planar;
@@ -92,15 +85,14 @@ struct _GstJpegEnc
   /* cached return state for any problems that may occur in callbacks */
   GstFlowReturn last_ret;
 
-  GstBuffer *output_buffer;
+  GstMemory *output_mem;
+  gpointer output_data;
+  gsize output_size;
 };
 
 struct _GstJpegEncClass
 {
   GstElementClass parent_class;
-
-  /* signals */
-  void (*frame_encoded) (GstElement * element);
 };
 
 GType gst_jpegenc_get_type (void);
index e44c048..9443f84 100644 (file)
@@ -7,6 +7,7 @@ libgstcacasink_la_CFLAGS = \
        $(GST_CFLAGS) \
        $(LIBCACA_CFLAGS)
 libgstcacasink_la_LIBADD = \
+       -lgstvideo-$(GST_MAJORMINOR) \
        $(GST_BASE_LIBS) \
        $(GST_LIBS) \
        $(LIBCACA_LIBS)
index 1846c26..668013c 100644 (file)
 
 #include "gstcacasink.h"
 
-#define GST_CACA_DEFAULT_SCREEN_WIDTH 80
-#define GST_CACA_DEFAULT_SCREEN_HEIGHT 25
-#define GST_CACA_DEFAULT_BPP 24
-#define GST_CACA_DEFAULT_RED_MASK GST_VIDEO_BYTE1_MASK_32_INT
-#define GST_CACA_DEFAULT_GREEN_MASK GST_VIDEO_BYTE2_MASK_32_INT
-#define GST_CACA_DEFAULT_BLUE_MASK GST_VIDEO_BYTE3_MASK_32_INT
 
 //#define GST_CACA_DEFAULT_RED_MASK R_MASK_32_REVERSE_INT
 //#define GST_CACA_DEFAULT_GREEN_MASK G_MASK_32_REVERSE_INT
@@ -60,27 +54,26 @@ enum
   LAST_SIGNAL
 };
 
+#define GST_CACA_DEFAULT_SCREEN_WIDTH 80
+#define GST_CACA_DEFAULT_SCREEN_HEIGHT 25
+#define GST_CACA_DEFAULT_DITHER CACA_DITHERING_NONE
+#define GST_CACA_DEFAULT_ANTIALIASING TRUE
 
 enum
 {
-  ARG_0,
-  ARG_SCREEN_WIDTH,
-  ARG_SCREEN_HEIGHT,
-  ARG_DITHER,
-  ARG_ANTIALIASING
+  PROP_0,
+  PROP_SCREEN_WIDTH,
+  PROP_SCREEN_HEIGHT,
+  PROP_DITHER,
+  PROP_ANTIALIASING
 };
 
 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_RGBx ";"
-        GST_VIDEO_CAPS_RGB_16 ";" GST_VIDEO_CAPS_RGB_15)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ RGB, RGBx, RGB16, RGB15 }"))
     );
 
-static void gst_cacasink_base_init (gpointer g_class);
-static void gst_cacasink_class_init (GstCACASinkClass * klass);
-static void gst_cacasink_init (GstCACASink * cacasink);
-
 static gboolean gst_cacasink_setcaps (GstBaseSink * pad, GstCaps * caps);
 static void gst_cacasink_get_times (GstBaseSink * sink, GstBuffer * buffer,
     GstClockTime * start, GstClockTime * end);
@@ -95,32 +88,8 @@ static void gst_cacasink_get_property (GObject * object, guint prop_id,
 static GstStateChangeReturn gst_cacasink_change_state (GstElement * element,
     GstStateChange transition);
 
-static GstElementClass *parent_class = NULL;
-
-GType
-gst_cacasink_get_type (void)
-{
-  static GType cacasink_type = 0;
-
-  if (!cacasink_type) {
-    static const GTypeInfo cacasink_info = {
-      sizeof (GstCACASinkClass),
-      gst_cacasink_base_init,
-      NULL,
-      (GClassInitFunc) gst_cacasink_class_init,
-      NULL,
-      NULL,
-      sizeof (GstCACASink),
-      0,
-      (GInstanceInitFunc) gst_cacasink_init,
-    };
-
-    cacasink_type =
-        g_type_register_static (GST_TYPE_BASE_SINK, "GstCACASink",
-        &cacasink_info, 0);
-  }
-  return cacasink_type;
-}
+#define gst_cacasink_parent_class parent_class
+G_DEFINE_TYPE (GstCACASink, gst_cacasink, GST_TYPE_BASE_SINK);
 
 #define GST_TYPE_CACADITHER (gst_cacasink_dither_get_type())
 static GType
@@ -144,18 +113,6 @@ gst_cacasink_dither_get_type (void)
 }
 
 static void
-gst_cacasink_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class,
-      "A colored ASCII art video sink", "Sink/Video",
-      "A colored ASCII art videosink", "Zeeshan Ali <zak147@yahoo.com>");
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template));
-}
-
-static void
 gst_cacasink_class_init (GstCACASinkClass * klass)
 {
   GObjectClass *gobject_class;
@@ -170,26 +127,33 @@ gst_cacasink_class_init (GstCACASinkClass * klass)
 
   gobject_class->set_property = gst_cacasink_set_property;
   gobject_class->get_property = gst_cacasink_get_property;
-  gstelement_class->change_state = gst_cacasink_change_state;
 
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SCREEN_WIDTH,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SCREEN_WIDTH,
       g_param_spec_int ("screen-width", "Screen Width",
           "The width of the screen", 0, G_MAXINT, GST_CACA_DEFAULT_SCREEN_WIDTH,
           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SCREEN_HEIGHT,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SCREEN_HEIGHT,
       g_param_spec_int ("screen-height", "Screen Height",
           "The height of the screen", 0, G_MAXINT,
           GST_CACA_DEFAULT_SCREEN_HEIGHT,
           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DITHER,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DITHER,
       g_param_spec_enum ("dither", "Dither Type", "Set type of Dither",
-          GST_TYPE_CACADITHER, CACA_DITHERING_NONE,
+          GST_TYPE_CACADITHER, GST_CACA_DEFAULT_DITHER,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ANTIALIASING,
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_ANTIALIASING,
       g_param_spec_boolean ("anti-aliasing", "Anti Aliasing",
-          "Enables Anti-Aliasing", TRUE,
+          "Enables Anti-Aliasing", GST_CACA_DEFAULT_ANTIALIASING,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gstelement_class->change_state = gst_cacasink_change_state;
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "A colored ASCII art video sink", "Sink/Video",
+      "A colored ASCII art videosink", "Zeeshan Ali <zak147@yahoo.com>");
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_template));
+
   gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_cacasink_setcaps);
   gstbasesink_class->get_times = GST_DEBUG_FUNCPTR (gst_cacasink_get_times);
   gstbasesink_class->preroll = GST_DEBUG_FUNCPTR (gst_cacasink_render);
@@ -208,60 +172,75 @@ static gboolean
 gst_cacasink_setcaps (GstBaseSink * basesink, GstCaps * caps)
 {
   GstCACASink *cacasink;
-  GstStructure *structure;
-  gint endianness;
+  GstVideoInfo info;
+  guint bpp, red_mask, green_mask, blue_mask;
 
   cacasink = GST_CACASINK (basesink);
 
-  structure = gst_caps_get_structure (caps, 0);
-  gst_structure_get_int (structure, "width", &(cacasink->width));
-  gst_structure_get_int (structure, "height", &(cacasink->height));
-  gst_structure_get_int (structure, "endianness", &endianness);
-  gst_structure_get_int (structure, "bpp", (int *) &cacasink->bpp);
-  gst_structure_get_int (structure, "red_mask", (int *) &cacasink->red_mask);
-  gst_structure_get_int (structure, "green_mask",
-      (int *) &cacasink->green_mask);
-  gst_structure_get_int (structure, "blue_mask", (int *) &cacasink->blue_mask);
-
-  if (cacasink->bpp == 24) {
-    cacasink->red_mask = GUINT32_FROM_BE (cacasink->red_mask) >> 8;
-    cacasink->green_mask = GUINT32_FROM_BE (cacasink->green_mask) >> 8;
-    cacasink->blue_mask = GUINT32_FROM_BE (cacasink->blue_mask) >> 8;
-  }
+  if (!gst_video_info_from_caps (&info, caps))
+    goto caps_error;
 
-  else if (cacasink->bpp == 32) {
-    cacasink->red_mask = GUINT32_FROM_BE (cacasink->red_mask);
-    cacasink->green_mask = GUINT32_FROM_BE (cacasink->green_mask);
-    cacasink->blue_mask = GUINT32_FROM_BE (cacasink->blue_mask);
-  }
 
-  else if (cacasink->bpp == 16) {
-    if (endianness == G_BIG_ENDIAN) {
-      cacasink->red_mask = GUINT16_FROM_BE (cacasink->red_mask);
-      cacasink->green_mask = GUINT16_FROM_BE (cacasink->green_mask);
-      cacasink->blue_mask = GUINT16_FROM_BE (cacasink->blue_mask);
-    } else {
-      cacasink->red_mask = GUINT16_FROM_LE (cacasink->red_mask);
-      cacasink->green_mask = GUINT16_FROM_LE (cacasink->green_mask);
-      cacasink->blue_mask = GUINT16_FROM_LE (cacasink->blue_mask);
-    }
+  switch (GST_VIDEO_INFO_FORMAT (&info)) {
+    case GST_VIDEO_FORMAT_RGB:
+      bpp = 24;
+      red_mask = 0xff0000;
+      green_mask = 0x00ff00;
+      blue_mask = 0x0000ff;
+      break;
+    case GST_VIDEO_FORMAT_RGBx:
+      bpp = 32;
+      red_mask = 0xff000000;
+      green_mask = 0x00ff0000;
+      blue_mask = 0x0000ff00;
+      break;
+    case GST_VIDEO_FORMAT_RGB16:
+      bpp = 16;
+      red_mask = 0xf800;
+      green_mask = 0x07e0;
+      blue_mask = 0x001f;
+      break;
+    case GST_VIDEO_FORMAT_RGB15:
+      bpp = 16;
+      red_mask = 0x7c00;
+      green_mask = 0x03e0;
+      blue_mask = 0x001f;
+      break;
+    default:
+      goto invalid_format;
   }
 
   if (cacasink->bitmap) {
     caca_free_bitmap (cacasink->bitmap);
   }
+  cacasink->bitmap = caca_create_bitmap (bpp,
+      GST_VIDEO_INFO_WIDTH (&info),
+      GST_VIDEO_INFO_HEIGHT (&info),
+      GST_ROUND_UP_4 (GST_VIDEO_INFO_WIDTH (&info) * bpp / 8),
+      red_mask, green_mask, blue_mask, 0);
+  if (!cacasink->bitmap)
+    goto no_bitmap;
+
+  cacasink->info = info;
 
-  cacasink->bitmap = caca_create_bitmap (cacasink->bpp,
-      cacasink->width,
-      cacasink->height,
-      GST_ROUND_UP_4 (cacasink->width * cacasink->bpp / 8),
-      cacasink->red_mask, cacasink->green_mask, cacasink->blue_mask, 0);
+  return TRUE;
 
-  if (!cacasink->bitmap) {
+  /* ERROS */
+caps_error:
+  {
+    GST_ERROR_OBJECT (cacasink, "error parsing caps");
+    return FALSE;
+  }
+invalid_format:
+  {
+    GST_ERROR_OBJECT (cacasink, "invalid format");
+    return FALSE;
+  }
+no_bitmap:
+  {
+    GST_ERROR_OBJECT (cacasink, "could not create bitmap");
     return FALSE;
   }
-
-  return TRUE;
 }
 
 static void
@@ -269,25 +248,38 @@ gst_cacasink_init (GstCACASink * cacasink)
 {
   cacasink->screen_width = GST_CACA_DEFAULT_SCREEN_WIDTH;
   cacasink->screen_height = GST_CACA_DEFAULT_SCREEN_HEIGHT;
-  cacasink->bpp = GST_CACA_DEFAULT_BPP;
-  cacasink->red_mask = GST_CACA_DEFAULT_RED_MASK;
-  cacasink->green_mask = GST_CACA_DEFAULT_GREEN_MASK;
-  cacasink->blue_mask = GST_CACA_DEFAULT_BLUE_MASK;
+
+  cacasink->dither = GST_CACA_DEFAULT_DITHER;
+  cacasink->antialiasing = GST_CACA_DEFAULT_ANTIALIASING;
 }
 
 static GstFlowReturn
 gst_cacasink_render (GstBaseSink * basesink, GstBuffer * buffer)
 {
   GstCACASink *cacasink = GST_CACASINK (basesink);
+  GstVideoFrame frame;
 
   GST_DEBUG ("render");
 
+  if (!gst_video_frame_map (&frame, &cacasink->info, buffer, GST_MAP_READ))
+    goto invalid_frame;
+
   caca_clear ();
   caca_draw_bitmap (0, 0, cacasink->screen_width - 1,
-      cacasink->screen_height - 1, cacasink->bitmap, GST_BUFFER_DATA (buffer));
+      cacasink->screen_height - 1, cacasink->bitmap,
+      GST_VIDEO_FRAME_PLANE_DATA (&frame, 0));
   caca_refresh ();
 
+  gst_video_frame_unmap (&frame);
+
   return GST_FLOW_OK;
+
+  /* ERRORS */
+invalid_frame:
+  {
+    GST_ERROR_OBJECT (cacasink, "invalid frame received");
+    return GST_FLOW_ERROR;
+  }
 }
 
 static void
@@ -301,12 +293,12 @@ gst_cacasink_set_property (GObject * object, guint prop_id,
   cacasink = GST_CACASINK (object);
 
   switch (prop_id) {
-    case ARG_DITHER:{
+    case PROP_DITHER:{
       cacasink->dither = g_value_get_enum (value);
       caca_set_dithering (cacasink->dither + CACA_DITHERING_NONE);
       break;
     }
-    case ARG_ANTIALIASING:{
+    case PROP_ANTIALIASING:{
       cacasink->antialiasing = g_value_get_boolean (value);
       if (cacasink->antialiasing) {
         caca_set_feature (CACA_ANTIALIASING_MAX);
@@ -329,19 +321,19 @@ gst_cacasink_get_property (GObject * object, guint prop_id, GValue * value,
   cacasink = GST_CACASINK (object);
 
   switch (prop_id) {
-    case ARG_SCREEN_WIDTH:{
+    case PROP_SCREEN_WIDTH:{
       g_value_set_int (value, cacasink->screen_width);
       break;
     }
-    case ARG_SCREEN_HEIGHT:{
+    case PROP_SCREEN_HEIGHT:{
       g_value_set_int (value, cacasink->screen_height);
       break;
     }
-    case ARG_DITHER:{
+    case PROP_DITHER:{
       g_value_set_enum (value, cacasink->dither);
       break;
     }
-    case ARG_ANTIALIASING:{
+    case PROP_ANTIALIASING:{
       g_value_set_boolean (value, cacasink->antialiasing);
       break;
     }
@@ -357,11 +349,8 @@ gst_cacasink_open (GstCACASink * cacasink)
 {
   cacasink->bitmap = NULL;
 
-  if (caca_init () < 0) {
-    GST_ELEMENT_ERROR (cacasink, RESOURCE, OPEN_WRITE, (NULL),
-        ("caca_init() failed"));
-    return FALSE;
-  }
+  if (caca_init () < 0)
+    goto init_failed;
 
   cacasink->screen_width = caca_get_width ();
   cacasink->screen_height = caca_get_height ();
@@ -371,6 +360,14 @@ gst_cacasink_open (GstCACASink * cacasink)
   caca_set_dithering (CACA_DITHERING_NONE);
 
   return TRUE;
+
+  /* ERRORS */
+init_failed:
+  {
+    GST_ELEMENT_ERROR (cacasink, RESOURCE, OPEN_WRITE, (NULL),
+        ("caca_init() failed"));
+    return FALSE;
+  }
 }
 
 static void
index 580567a..db041d9 100644 (file)
@@ -49,12 +49,11 @@ typedef struct _GstCACASinkClass GstCACASinkClass;
 struct _GstCACASink {
   GstBaseSink parent;
 
-  gint width, height;
+  GstVideoInfo info;
   gint screen_width, screen_height;
-  guint bpp;
+
   guint dither;
   gboolean antialiasing;
-  guint red_mask, green_mask, blue_mask;
 
   struct caca_bitmap *bitmap;
 };
index 96468ce..2a479cd 100644 (file)
@@ -64,69 +64,15 @@ static void gst_pulsemixer_finalize (GObject * object);
 static GstStateChangeReturn gst_pulsemixer_change_state (GstElement * element,
     GstStateChange transition);
 
-static void gst_pulsemixer_init_interfaces (GType type);
-
 GST_IMPLEMENT_PULSEMIXER_CTRL_METHODS (GstPulseMixer, gst_pulsemixer);
 GST_IMPLEMENT_PULSEPROBE_METHODS (GstPulseMixer, gst_pulsemixer);
-GST_BOILERPLATE_FULL (GstPulseMixer, gst_pulsemixer, GstElement,
-    GST_TYPE_ELEMENT, gst_pulsemixer_init_interfaces);
-
-static gboolean
-gst_pulsemixer_interface_supported (GstImplementsInterface
-    * iface, GType interface_type)
-{
-  GstPulseMixer *this = GST_PULSEMIXER (iface);
-
-  if (interface_type == GST_TYPE_MIXER && this->mixer)
-    return TRUE;
-
-  if (interface_type == GST_TYPE_PROPERTY_PROBE && this->probe)
-    return TRUE;
-
-  return FALSE;
-}
 
-static void
-gst_pulsemixer_implements_interface_init (GstImplementsInterfaceClass * klass)
-{
-  klass->supported = gst_pulsemixer_interface_supported;
-}
-
-static void
-gst_pulsemixer_init_interfaces (GType type)
-{
-  static const GInterfaceInfo implements_iface_info = {
-    (GInterfaceInitFunc) gst_pulsemixer_implements_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo mixer_iface_info = {
-    (GInterfaceInitFunc) gst_pulsemixer_mixer_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo probe_iface_info = {
-    (GInterfaceInitFunc) gst_pulsemixer_property_probe_interface_init,
-    NULL,
-    NULL,
-  };
-
-  g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE,
-      &implements_iface_info);
-  g_type_add_interface_static (type, GST_TYPE_MIXER, &mixer_iface_info);
-  g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE,
-      &probe_iface_info);
-}
 
-static void
-gst_pulsemixer_base_init (gpointer g_class)
-{
-  gst_element_class_set_details_simple (GST_ELEMENT_CLASS (g_class),
-      "PulseAudio Mixer",
-      "Generic/Audio",
-      "Control sound input and output levels for PulseAudio",
-      "Lennart Poettering");
-}
+#define gst_pulsemixer_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstPulseMixer, gst_pulsemixer, GST_TYPE_ELEMENT,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_MIXER, gst_pulsemixer_mixer_interface_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_PROPERTY_PROBE,
+        gst_pulsemixer_property_probe_interface_init));
 
 static void
 gst_pulsemixer_class_init (GstPulseMixerClass * g_class)
@@ -158,10 +104,16 @@ gst_pulsemixer_class_init (GstPulseMixerClass * g_class)
       g_param_spec_string ("device-name", "Device name",
           "Human-readable name of the sound device", NULL,
           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_set_details_simple (GST_ELEMENT_CLASS (g_class),
+      "PulseAudio Mixer",
+      "Generic/Audio",
+      "Control sound input and output levels for PulseAudio",
+      "Lennart Poettering");
 }
 
 static void
-gst_pulsemixer_init (GstPulseMixer * this, GstPulseMixerClass * g_class)
+gst_pulsemixer_init (GstPulseMixer * this)
 {
   this->mixer = NULL;
   this->server = NULL;
index 51f60be..dd89f99 100644 (file)
@@ -1147,8 +1147,7 @@ gst_pulseringbuffer_start (GstRingBuffer * buf)
 
   /* EOS needs running clock */
   if (GST_BASE_SINK_CAST (psink)->eos ||
-      g_atomic_int_get (&GST_BASE_AUDIO_SINK (psink)->abidata.ABI.
-          eos_rendering))
+      g_atomic_int_get (&GST_BASE_AUDIO_SINK (psink)->eos_rendering))
     gst_pulsering_set_corked (pbuf, FALSE, FALSE);
 
   pa_threaded_mainloop_unlock (mainloop);
@@ -1275,16 +1274,16 @@ server_dead:
 G_STMT_START {                                  \
   guint8 *sb = s, *db = d;                      \
   while (s <= se && d < de) {                   \
-    memcpy (d, s, bps);                         \
-    s += bps;                                   \
+    memcpy (d, s, bpf);                         \
+    s += bpf;                                   \
     *accum += outr;                             \
     if ((*accum << 1) >= inr) {                 \
       *accum -= inr;                            \
-      d += bps;                                 \
+      d += bpf;                                 \
     }                                           \
   }                                             \
-  in_samples -= (s - sb)/bps;                   \
-  out_samples -= (d - db)/bps;                  \
+  in_samples -= (s - sb)/bpf;                   \
+  out_samples -= (d - db)/bpf;                  \
   GST_DEBUG ("fwd_up end %d/%d",*accum,*toprocess);     \
 } G_STMT_END
 
@@ -1293,16 +1292,16 @@ G_STMT_START {                                  \
 G_STMT_START {                                  \
   guint8 *sb = s, *db = d;                      \
   while (s <= se && d < de) {                   \
-    memcpy (d, s, bps);                         \
-    d += bps;                                   \
+    memcpy (d, s, bpf);                         \
+    d += bpf;                                   \
     *accum += inr;                              \
     if ((*accum << 1) >= outr) {                \
       *accum -= outr;                           \
-      s += bps;                                 \
+      s += bpf;                                 \
     }                                           \
   }                                             \
-  in_samples -= (s - sb)/bps;                   \
-  out_samples -= (d - db)/bps;                  \
+  in_samples -= (s - sb)/bpf;                   \
+  out_samples -= (d - db)/bpf;                  \
   GST_DEBUG ("fwd_down end %d/%d",*accum,*toprocess);   \
 } G_STMT_END
 
@@ -1310,16 +1309,16 @@ G_STMT_START {                                  \
 G_STMT_START {                                  \
   guint8 *sb = se, *db = d;                     \
   while (s <= se && d < de) {                   \
-    memcpy (d, se, bps);                        \
-    se -= bps;                                  \
+    memcpy (d, se, bpf);                        \
+    se -= bpf;                                  \
     *accum += outr;                             \
     while (d < de && (*accum << 1) >= inr) {    \
       *accum -= inr;                            \
-      d += bps;                                 \
+      d += bpf;                                 \
     }                                           \
   }                                             \
-  in_samples -= (sb - se)/bps;                  \
-  out_samples -= (d - db)/bps;                  \
+  in_samples -= (sb - se)/bpf;                  \
+  out_samples -= (d - db)/bpf;                  \
   GST_DEBUG ("rev_up end %d/%d",*accum,*toprocess);     \
 } G_STMT_END
 
@@ -1327,16 +1326,16 @@ G_STMT_START {                                  \
 G_STMT_START {                                  \
   guint8 *sb = se, *db = d;                     \
   while (s <= se && d < de) {                   \
-    memcpy (d, se, bps);                        \
-    d += bps;                                   \
+    memcpy (d, se, bpf);                        \
+    d += bpf;                                   \
     *accum += inr;                              \
     while (s <= se && (*accum << 1) >= outr) {  \
       *accum -= outr;                           \
-      se -= bps;                                \
+      se -= bpf;                                \
     }                                           \
   }                                             \
-  in_samples -= (sb - se)/bps;                  \
-  out_samples -= (d - db)/bps;                  \
+  in_samples -= (sb - se)/bpf;                  \
+  out_samples -= (d - db)/bpf;                  \
   GST_DEBUG ("rev_down end %d/%d",*accum,*toprocess);   \
 } G_STMT_END
 
@@ -1352,7 +1351,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
   guint8 *data_end;
   gboolean reverse;
   gint *toprocess;
-  gint inr, outr, bps;
+  gint inr, outr, bpf;
   gint64 offset;
   guint bufsize;
 
@@ -1369,7 +1368,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
   if (G_UNLIKELY (g_atomic_int_get (&buf->state) !=
           GST_RING_BUFFER_STATE_STARTED)) {
     /* see if we are allowed to start it */
-    if (G_UNLIKELY (g_atomic_int_get (&buf->abidata.ABI.may_start) == FALSE))
+    if (G_UNLIKELY (g_atomic_int_get (&buf->may_start) == FALSE))
       goto no_start;
 
     GST_DEBUG_OBJECT (buf, "start!");
@@ -1382,7 +1381,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
   GST_DEBUG_OBJECT (psink, "entering commit");
   pbuf->in_commit = TRUE;
 
-  bps = buf->spec.bytes_per_sample;
+  bpf = GST_AUDIO_INFO_BPF (&buf->spec.info);
   bufsize = buf->spec.segsize * buf->spec.segtotal;
 
   /* our toy resampler for trick modes */
@@ -1401,7 +1400,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
 
   /* data_end points to the last sample we have to write, not past it. This is
    * needed to properly handle reverse playback: it points to the last sample. */
-  data_end = data + (bps * inr);
+  data_end = data + (bpf * inr);
 
 #ifdef HAVE_PULSE_1_0
   if (g_atomic_int_get (&psink->format_lost)) {
@@ -1414,7 +1413,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
     goto was_paused;
 
   /* offset is in bytes */
-  offset = *sample * bps;
+  offset = *sample * bpf;
 
   while (*toprocess > 0) {
     size_t avail;
@@ -1428,7 +1427,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
       GST_LOG_OBJECT (psink, "discontinuity, offset is %" G_GINT64_FORMAT ", "
           "last offset was %" G_GINT64_FORMAT, offset, pbuf->m_lastoffset);
 
-    towrite = out_samples * bps;
+    towrite = out_samples * bpf;
 
     /* Wait for at least segsize bytes to become available */
     if (towrite > buf->spec.segsize)
@@ -1443,7 +1442,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
 
         GST_LOG_OBJECT (psink,
             "flushing %u samples at offset %" G_GINT64_FORMAT,
-            (guint) pbuf->m_towrite / bps, pbuf->m_offset);
+            (guint) pbuf->m_towrite / bpf, pbuf->m_offset);
 
         if (pa_stream_write (pbuf->stream, (uint8_t *) pbuf->m_data,
                 pbuf->m_towrite, NULL, pbuf->m_offset, PA_SEEK_ABSOLUTE) < 0) {
@@ -1467,8 +1466,8 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
         if (pbuf->m_writable == (size_t) - 1)
           goto writable_size_failed;
 
-        pbuf->m_writable /= bps;
-        pbuf->m_writable *= bps;        /* handle only complete samples */
+        pbuf->m_writable /= bpf;
+        pbuf->m_writable *= bpf;        /* handle only complete samples */
 
         if (pbuf->m_writable >= towrite)
           break;
@@ -1488,7 +1487,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
       }
 
       /* Recalculate what we can write in the next chunk */
-      towrite = out_samples * bps;
+      towrite = out_samples * bpf;
       if (pbuf->m_writable > towrite)
         pbuf->m_writable = towrite;
 
@@ -1508,7 +1507,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
 
     if (towrite > pbuf->m_writable)
       towrite = pbuf->m_writable;
-    avail = towrite / bps;
+    avail = towrite / bpf;
 
     GST_LOG_OBJECT (psink, "writing %u samples at offset %" G_GUINT64_FORMAT,
         (guint) avail, offset);
@@ -1559,14 +1558,14 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
       pbuf->m_towrite += towrite;
       pbuf->m_writable -= towrite;
 
-      avail = towrite / bps;
+      avail = towrite / bpf;
     }
 
     /* flush the buffer if it's full */
     if ((pbuf->m_data != NULL) && (pbuf->m_towrite > 0)
         && (pbuf->m_writable == 0)) {
       GST_LOG_OBJECT (psink, "flushing %u samples at offset %" G_GINT64_FORMAT,
-          (guint) pbuf->m_towrite / bps, pbuf->m_offset);
+          (guint) pbuf->m_towrite / bpf, pbuf->m_offset);
 
       if (pa_stream_write (pbuf->stream, (uint8_t *) pbuf->m_data,
               pbuf->m_towrite, NULL, pbuf->m_offset, PA_SEEK_ABSOLUTE) < 0) {
@@ -1577,7 +1576,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
     }
 
     *sample += avail;
-    offset += avail * bps;
+    offset += avail * bpf;
     pbuf->m_lastoffset = offset;
 
     /* check if we need to uncork after writing the samples */
@@ -1605,13 +1604,13 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
 fake_done:
 #endif
   /* we consumed all samples here */
-  data = data_end + bps;
+  data = data_end + bpf;
 
   pbuf->in_commit = FALSE;
   pa_threaded_mainloop_unlock (mainloop);
 
 done:
-  result = inr - ((data_end - data) / bps);
+  result = inr - ((data_end - data) / bpf);
   GST_LOG_OBJECT (psink, "wrote %d samples", result);
 
   return result;
@@ -1676,12 +1675,12 @@ gst_pulsering_flush (GstPulseRingBuffer * pbuf)
   /* flush the buffer if possible */
   if (pbuf->stream && (pbuf->m_data != NULL) && (pbuf->m_towrite > 0)) {
 #ifndef GST_DISABLE_GST_DEBUG
-    gint bps;
+    gint bpf;
 
-    bps = (GST_RING_BUFFER_CAST (pbuf))->spec.bytes_per_sample;
+    bpf = (GST_RING_BUFFER_CAST (pbuf))->spec.info.bpf;
     GST_LOG_OBJECT (psink,
         "flushing %u samples at offset %" G_GINT64_FORMAT,
-        (guint) pbuf->m_towrite / bps, pbuf->m_offset);
+        (guint) pbuf->m_towrite / bpf, pbuf->m_offset);
 #endif
 
     if (pa_stream_write (pbuf->stream, (uint8_t *) pbuf->m_data,
@@ -1717,133 +1716,45 @@ static gboolean gst_pulsesink_event (GstBaseSink * sink, GstEvent * event);
 static GstStateChangeReturn gst_pulsesink_change_state (GstElement * element,
     GstStateChange transition);
 
-static void gst_pulsesink_init_interfaces (GType type);
-
 #if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
-# define ENDIANNESS   "LITTLE_ENDIAN, BIG_ENDIAN"
+# define FORMATS   "{ S16_LE, S16_BE, F32_LE, F32_BE, S32_LE, S32_BE, " \
+                     "S24_3LE, S24_3BE, S24_LE, S24_BE, S8 }"
 #else
-# define ENDIANNESS   "BIG_ENDIAN, LITTLE_ENDIAN"
+# define FORMATS   "{ S16_BE, S16_LE, F32_BE, F32_LE, S32_BE, S32_LE, " \
+                     "S24_3BE, S24_3LE, S24_BE, S24_LE, S8 }"
 #endif
 
-GST_IMPLEMENT_PULSEPROBE_METHODS (GstPulseSink, gst_pulsesink);
-
-#define _do_init(type) \
-  gst_pulsesink_init_contexts (); \
-  gst_pulsesink_init_interfaces (type);
-
-GST_BOILERPLATE_FULL (GstPulseSink, gst_pulsesink, GstBaseAudioSink,
-    GST_TYPE_BASE_AUDIO_SINK, _do_init);
-
-static gboolean
-gst_pulsesink_interface_supported (GstImplementsInterface *
-    iface, GType interface_type)
-{
-  GstPulseSink *this = GST_PULSESINK_CAST (iface);
-
-  if (interface_type == GST_TYPE_PROPERTY_PROBE && this->probe)
-    return TRUE;
-  if (interface_type == GST_TYPE_STREAM_VOLUME)
-    return TRUE;
-
-  return FALSE;
-}
-
-static void
-gst_pulsesink_implements_interface_init (GstImplementsInterfaceClass * klass)
-{
-  klass->supported = gst_pulsesink_interface_supported;
-}
-
-static void
-gst_pulsesink_init_interfaces (GType type)
-{
-  static const GInterfaceInfo implements_iface_info = {
-    (GInterfaceInitFunc) gst_pulsesink_implements_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo probe_iface_info = {
-    (GInterfaceInitFunc) gst_pulsesink_property_probe_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo svol_iface_info = {
-    NULL, NULL, NULL
-  };
-
-  g_type_add_interface_static (type, GST_TYPE_STREAM_VOLUME, &svol_iface_info);
-  g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE,
-      &implements_iface_info);
-  g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE,
-      &probe_iface_info);
-}
-
-static void
-gst_pulsesink_base_init (gpointer g_class)
-{
-  static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("sink",
-      GST_PAD_SINK,
-      GST_PAD_ALWAYS,
-      GST_STATIC_CAPS ("audio/x-raw-int, "
-          "endianness = (int) { " ENDIANNESS " }, "
-          "signed = (boolean) TRUE, "
-          "width = (int) 16, "
-          "depth = (int) 16, "
-          "rate = (int) [ 1, MAX ], "
-          "channels = (int) [ 1, 32 ];"
-          "audio/x-raw-float, "
-          "endianness = (int) { " ENDIANNESS " }, "
-          "width = (int) 32, "
-          "rate = (int) [ 1, MAX ], "
-          "channels = (int) [ 1, 32 ];"
-          "audio/x-raw-int, "
-          "endianness = (int) { " ENDIANNESS " }, "
-          "signed = (boolean) TRUE, "
-          "width = (int) 32, "
-          "depth = (int) 32, "
-          "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 32 ];"
-          "audio/x-raw-int, "
-          "endianness = (int) { " ENDIANNESS " }, "
-          "signed = (boolean) TRUE, "
-          "width = (int) 24, "
-          "depth = (int) 24, "
-          "rate = (int) [ 1, MAX ], "
-          "channels = (int) [ 1, 32 ];"
-          "audio/x-raw-int, "
-          "endianness = (int) { " ENDIANNESS " }, "
-          "signed = (boolean) TRUE, "
-          "width = (int) 32, "
-          "depth = (int) 24, "
-          "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 32 ];"
-          "audio/x-raw-int, "
-          "signed = (boolean) FALSE, "
-          "width = (int) 8, "
-          "depth = (int) 8, "
-          "rate = (int) [ 1, MAX ], "
-          "channels = (int) [ 1, 32 ];"
-          "audio/x-alaw, "
-          "rate = (int) [ 1, MAX], "
-          "channels = (int) [ 1, 32 ];"
-          "audio/x-mulaw, "
-          "rate = (int) [ 1, MAX], " "channels = (int) [ 1, 32 ];"
+static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " FORMATS ", "
+        "rate = (int) [ 1, MAX ], "
+        "channels = (int) [ 1, 32 ];"
+        "audio/x-alaw, "
+        "rate = (int) [ 1, MAX], "
+        "channels = (int) [ 1, 32 ];"
+        "audio/x-mulaw, "
+        "rate = (int) [ 1, MAX], " "channels = (int) [ 1, 32 ];"
 #ifdef HAVE_PULSE_1_0
-          "audio/x-ac3, framed = (boolean) true;"
-          "audio/x-eac3, framed = (boolean) true; "
-          "audio/x-dts, framed = (boolean) true, "
-          "  block_size = (int) { 512, 1024, 2048 }; "
-          "audio/mpeg, mpegversion = (int)1, "
-          "  mpegaudioversion = (int) [ 1, 2 ], parsed = (boolean) true; "
+        "audio/x-ac3, framed = (boolean) true;"
+        "audio/x-eac3, framed = (boolean) true; "
+        "audio/x-dts, framed = (boolean) true, "
+        "  block_size = (int) { 512, 1024, 2048 }; "
+        "audio/mpeg, mpegversion = (int)1, "
+        "  mpegaudioversion = (int) [ 1, 2 ], parsed = (boolean) true; "
 #endif
-      ));
+    ));
 
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+GST_IMPLEMENT_PULSEPROBE_METHODS (GstPulseSink, gst_pulsesink);
 
-  gst_element_class_set_details_simple (element_class,
-      "PulseAudio Audio Sink",
-      "Sink/Audio", "Plays audio to a PulseAudio server", "Lennart Poettering");
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&pad_template));
-}
+#define gst_pulsesink_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstPulseSink, gst_pulsesink, GST_TYPE_BASE_AUDIO_SINK,
+    gst_pulsesink_init_contexts ();
+    G_IMPLEMENT_INTERFACE (GST_TYPE_PROPERTY_PROBE,
+        gst_pulsesink_property_probe_interface_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_STREAM_VOLUME, NULL)
+    );
 
 static GstRingBuffer *
 gst_pulsesink_create_ringbuffer (GstBaseAudioSink * sink)
@@ -1869,20 +1780,30 @@ gst_pulsesink_payload (GstBaseAudioSink * sink, GstBuffer * buf)
       /* FIXME: alloc memory from PA if possible */
       gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
       GstBuffer *out;
+      guint8 *indata, *outdata;
+      gsize insize, outsize;
+      gboolean res;
 
       if (framesize <= 0)
         return NULL;
 
       out = gst_buffer_new_and_alloc (framesize);
 
-      if (!gst_audio_iec61937_payload (GST_BUFFER_DATA (buf),
-              GST_BUFFER_SIZE (buf), GST_BUFFER_DATA (out),
-              GST_BUFFER_SIZE (out), &sink->ringbuffer->spec)) {
+      indata = gst_buffer_map (buf, &insize, NULL, GST_MAP_READ);
+      outdata = gst_buffer_map (out, &outsize, NULL, GST_MAP_WRITE);
+
+      res = gst_audio_iec61937_payload (indata, insize,
+          outdata, outsize, &sink->ringbuffer->spec);
+
+      gst_buffer_unmap (buf, indata, insize);
+      gst_buffer_unmap (out, outdata, outsize);
+
+      if (!res) {
         gst_buffer_unref (out);
         return NULL;
       }
 
-      gst_buffer_copy_metadata (out, buf, GST_BUFFER_COPY_ALL);
+      gst_buffer_copy_into (out, buf, GST_BUFFER_COPY_METADATA, 0, -1);
       return out;
     }
 
@@ -1982,6 +1903,12 @@ gst_pulsesink_class_init (GstPulseSinkClass * klass)
       g_param_spec_boxed ("stream-properties", "stream properties",
           "list of pulseaudio stream properties",
           GST_TYPE_STRUCTURE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "PulseAudio Audio Sink",
+      "Sink/Audio", "Plays audio to a PulseAudio server", "Lennart Poettering");
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&pad_template));
 }
 
 /* returns the current time of the sink ringbuffer */
@@ -2210,7 +2137,7 @@ info_failed:
 #endif
 
 static void
-gst_pulsesink_init (GstPulseSink * pulsesink, GstPulseSinkClass * klass)
+gst_pulsesink_init (GstPulseSink * pulsesink)
 {
   pulsesink->server = NULL;
   pulsesink->device = NULL;
index da3ae24..e0c1134 100644 (file)
@@ -76,6 +76,8 @@ static void gst_pulsesrc_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 static void gst_pulsesrc_finalize (GObject * object);
 
+static gboolean gst_pulsesrc_set_corked (GstPulseSrc * psrc, gboolean corked,
+    gboolean wait);
 static gboolean gst_pulsesrc_open (GstAudioSrc * asrc);
 
 static gboolean gst_pulsesrc_close (GstAudioSrc * asrc);
@@ -96,114 +98,35 @@ static gboolean gst_pulsesrc_negotiate (GstBaseSrc * basesrc);
 static GstStateChangeReturn gst_pulsesrc_change_state (GstElement *
     element, GstStateChange transition);
 
-static void gst_pulsesrc_init_interfaces (GType type);
-
 #if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
-# define ENDIANNESS   "LITTLE_ENDIAN, BIG_ENDIAN"
+# define FORMATS "{ S16_LE, S16_BE, F32_LE, F32_BE, S32_LE, S32_BE, U8 }"
 #else
-# define ENDIANNESS   "BIG_ENDIAN, LITTLE_ENDIAN"
+# define FORMATS "{ S16_BE, S16_LE, F32_BE, F32_LE, S32_BE, S32_LE, U8 }"
 #endif
 
-GST_IMPLEMENT_PULSEMIXER_CTRL_METHODS (GstPulseSrc, gst_pulsesrc);
-GST_IMPLEMENT_PULSEPROBE_METHODS (GstPulseSrc, gst_pulsesrc);
-GST_BOILERPLATE_FULL (GstPulseSrc, gst_pulsesrc, GstAudioSrc,
-    GST_TYPE_AUDIO_SRC, gst_pulsesrc_init_interfaces);
-
-static gboolean
-gst_pulsesrc_interface_supported (GstImplementsInterface *
-    iface, GType interface_type)
-{
-  GstPulseSrc *this = GST_PULSESRC_CAST (iface);
-
-  if (interface_type == GST_TYPE_MIXER && this->mixer)
-    return TRUE;
+static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " FORMATS ", "
+        "rate = (int) [ 1, MAX ], "
+        "channels = (int) [ 1, 32 ];"
+        "audio/x-alaw, "
+        "rate = (int) [ 1, MAX], "
+        "channels = (int) [ 1, 32 ];"
+        "audio/x-mulaw, "
+        "rate = (int) [ 1, MAX], " "channels = (int) [ 1, 32 ]")
+    );
 
-  if (interface_type == GST_TYPE_PROPERTY_PROBE && this->probe)
-    return TRUE;
 
-  return FALSE;
-}
-
-static void
-gst_pulsesrc_implements_interface_init (GstImplementsInterfaceClass * klass)
-{
-  klass->supported = gst_pulsesrc_interface_supported;
-}
+GST_IMPLEMENT_PULSEMIXER_CTRL_METHODS (GstPulseSrc, gst_pulsesrc);
+GST_IMPLEMENT_PULSEPROBE_METHODS (GstPulseSrc, gst_pulsesrc);
 
-static void
-gst_pulsesrc_init_interfaces (GType type)
-{
-  static const GInterfaceInfo implements_iface_info = {
-    (GInterfaceInitFunc) gst_pulsesrc_implements_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo mixer_iface_info = {
-    (GInterfaceInitFunc) gst_pulsesrc_mixer_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo probe_iface_info = {
-    (GInterfaceInitFunc) gst_pulsesrc_property_probe_interface_init,
-    NULL,
-    NULL,
-  };
-
-  g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE,
-      &implements_iface_info);
-  g_type_add_interface_static (type, GST_TYPE_MIXER, &mixer_iface_info);
-  g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE,
-      &probe_iface_info);
-}
-
-static void
-gst_pulsesrc_base_init (gpointer g_class)
-{
-
-  static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("src",
-      GST_PAD_SRC,
-      GST_PAD_ALWAYS,
-      GST_STATIC_CAPS ("audio/x-raw-int, "
-          "endianness = (int) { " ENDIANNESS " }, "
-          "signed = (boolean) TRUE, "
-          "width = (int) 16, "
-          "depth = (int) 16, "
-          "rate = (int) [ 1, MAX ], "
-          "channels = (int) [ 1, 32 ];"
-          "audio/x-raw-float, "
-          "endianness = (int) { " ENDIANNESS " }, "
-          "width = (int) 32, "
-          "rate = (int) [ 1, MAX ], "
-          "channels = (int) [ 1, 32 ];"
-          "audio/x-raw-int, "
-          "endianness = (int) { " ENDIANNESS " }, "
-          "signed = (boolean) TRUE, "
-          "width = (int) 32, "
-          "depth = (int) 32, "
-          "rate = (int) [ 1, MAX ], "
-          "channels = (int) [ 1, 32 ];"
-          "audio/x-raw-int, "
-          "signed = (boolean) FALSE, "
-          "width = (int) 8, "
-          "depth = (int) 8, "
-          "rate = (int) [ 1, MAX ], "
-          "channels = (int) [ 1, 32 ];"
-          "audio/x-alaw, "
-          "rate = (int) [ 1, MAX], "
-          "channels = (int) [ 1, 32 ];"
-          "audio/x-mulaw, "
-          "rate = (int) [ 1, MAX], " "channels = (int) [ 1, 32 ]")
-      );
-
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class,
-      "PulseAudio Audio Source",
-      "Source/Audio",
-      "Captures audio from a PulseAudio server", "Lennart Poettering");
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&pad_template));
-}
+#define gst_pulsesrc_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstPulseSrc, gst_pulsesrc, GST_TYPE_AUDIO_SRC,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_MIXER, gst_pulsesrc_mixer_interface_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_PROPERTY_PROBE,
+        gst_pulsesrc_property_probe_interface_init));
 
 static void
 gst_pulsesrc_class_init (GstPulseSrcClass * klass)
@@ -287,7 +210,6 @@ gst_pulsesrc_class_init (GstPulseSrcClass * klass)
       g_param_spec_boxed ("stream-properties", "stream properties",
           "list of pulseaudio stream properties",
           GST_TYPE_STRUCTURE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
   /**
    * GstPulseSrc:source-output-index
    *
@@ -301,10 +223,17 @@ gst_pulsesrc_class_init (GstPulseSrcClass * klass)
           "The index of the PulseAudio source output corresponding to this "
           "record stream", 0, G_MAXUINT, PA_INVALID_INDEX,
           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "PulseAudio Audio Source",
+      "Source/Audio",
+      "Captures audio from a PulseAudio server", "Lennart Poettering");
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&pad_template));
 }
 
 static void
-gst_pulsesrc_init (GstPulseSrc * pulsesrc, GstPulseSrcClass * klass)
+gst_pulsesrc_init (GstPulseSrc * pulsesrc)
 {
   pulsesrc->server = NULL;
   pulsesrc->device = NULL;
@@ -313,6 +242,7 @@ gst_pulsesrc_init (GstPulseSrc * pulsesrc, GstPulseSrcClass * klass)
 
   pulsesrc->context = NULL;
   pulsesrc->stream = NULL;
+  pulsesrc->stream_connected = FALSE;
   pulsesrc->source_output_idx = PA_INVALID_INDEX;
 
   pulsesrc->read_buffer = NULL;
@@ -321,7 +251,7 @@ gst_pulsesrc_init (GstPulseSrc * pulsesrc, GstPulseSrcClass * klass)
   pa_sample_spec_init (&pulsesrc->sample_spec);
 
   pulsesrc->operation_success = FALSE;
-  pulsesrc->paused = FALSE;
+  pulsesrc->paused = TRUE;
   pulsesrc->in_read = FALSE;
 
   pulsesrc->mixer = NULL;
@@ -343,6 +273,7 @@ gst_pulsesrc_destroy_stream (GstPulseSrc * pulsesrc)
     pa_stream_disconnect (pulsesrc->stream);
     pa_stream_unref (pulsesrc->stream);
     pulsesrc->stream = NULL;
+    pulsesrc->stream_connected = FALSE;
     pulsesrc->source_output_idx = PA_INVALID_INDEX;
     g_object_notify (G_OBJECT (pulsesrc), "source-output-index");
   }
@@ -884,33 +815,26 @@ gst_pulsesrc_create_stream (GstPulseSrc * pulsesrc, GstCaps * caps)
 
   memset (&spec, 0, sizeof (GstRingBufferSpec));
   spec.latency_time = GST_SECOND;
-  if (!gst_ring_buffer_parse_caps (&spec, caps)) {
-    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, SETTINGS,
-        ("Can't parse caps."), (NULL));
-    goto fail;
-  }
+  if (!gst_ring_buffer_parse_caps (&spec, caps))
+    goto invalid_caps;
+
   /* Keep the refcount of the caps at 1 to make them writable */
   gst_caps_unref (spec.caps);
 
-  if (!gst_pulse_fill_sample_spec (&spec, &pulsesrc->sample_spec)) {
-    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, SETTINGS,
-        ("Invalid sample specification."), (NULL));
-    goto fail;
-  }
+  if (!gst_pulse_fill_sample_spec (&spec, &pulsesrc->sample_spec))
+    goto invalid_spec;
 
   pa_threaded_mainloop_lock (pulsesrc->mainloop);
 
-  if (!pulsesrc->context) {
-    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED, ("Bad context"), (NULL));
-    goto unlock_and_fail;
-  }
+  if (!pulsesrc->context)
+    goto bad_context;
 
   s = gst_caps_get_structure (caps, 0);
   if (!gst_structure_has_field (s, "channel-layout") ||
       !gst_pulse_gst_to_channel_map (&channel_map, &spec)) {
-    if (spec.channels == 1)
+    if (spec.info.channels == 1)
       pa_channel_map_init_mono (&channel_map);
-    else if (spec.channels == 2)
+    else if (spec.info.channels == 2)
       pa_channel_map_init_stereo (&channel_map);
     else
       need_channel_layout = TRUE;
@@ -921,20 +845,13 @@ gst_pulsesrc_create_stream (GstPulseSrc * pulsesrc, GstCaps * caps)
     if (!(pulsesrc->stream = pa_stream_new_with_proplist (pulsesrc->context,
                 name, &pulsesrc->sample_spec,
                 (need_channel_layout) ? NULL : &channel_map,
-                pulsesrc->proplist))) {
-      GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED,
-          ("Failed to create stream: %s",
-              pa_strerror (pa_context_errno (pulsesrc->context))), (NULL));
-      goto unlock_and_fail;
-    }
+                pulsesrc->proplist)))
+      goto create_failed;
+
   } else if (!(pulsesrc->stream = pa_stream_new (pulsesrc->context,
               name, &pulsesrc->sample_spec,
-              (need_channel_layout) ? NULL : &channel_map))) {
-    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED,
-        ("Failed to create stream: %s",
-            pa_strerror (pa_context_errno (pulsesrc->context))), (NULL));
-    goto unlock_and_fail;
-  }
+              (need_channel_layout) ? NULL : &channel_map)))
+    goto create_failed;
 
   if (need_channel_layout) {
     const pa_channel_map *m = pa_stream_get_channel_map (pulsesrc->stream);
@@ -960,13 +877,40 @@ gst_pulsesrc_create_stream (GstPulseSrc * pulsesrc, GstCaps * caps)
 
   return TRUE;
 
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, SETTINGS,
+        ("Can't parse caps."), (NULL));
+    goto fail;
+  }
+invalid_spec:
+  {
+    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, SETTINGS,
+        ("Invalid sample specification."), (NULL));
+    goto fail;
+  }
+bad_context:
+  {
+    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED, ("Bad context"), (NULL));
+    goto unlock_and_fail;
+  }
+create_failed:
+  {
+    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED,
+        ("Failed to create stream: %s",
+            pa_strerror (pa_context_errno (pulsesrc->context))), (NULL));
+    goto unlock_and_fail;
+  }
 unlock_and_fail:
-  gst_pulsesrc_destroy_stream (pulsesrc);
+  {
+    gst_pulsesrc_destroy_stream (pulsesrc);
 
-  pa_threaded_mainloop_unlock (pulsesrc->mainloop);
+    pa_threaded_mainloop_unlock (pulsesrc->mainloop);
 
-fail:
-  return FALSE;
+  fail:
+    return FALSE;
+  }
 }
 
 /* This is essentially gst_base_src_negotiate_default() but the caps
@@ -975,20 +919,21 @@ fail:
 static gboolean
 gst_pulsesrc_negotiate (GstBaseSrc * basesrc)
 {
+  GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (basesrc);
   GstCaps *thiscaps;
   GstCaps *caps = NULL;
   GstCaps *peercaps = NULL;
   gboolean result = FALSE;
 
   /* first see what is possible on our source pad */
-  thiscaps = gst_pad_get_caps_reffed (GST_BASE_SRC_PAD (basesrc));
+  thiscaps = gst_pad_get_caps (GST_BASE_SRC_PAD (basesrc), NULL);
   GST_DEBUG_OBJECT (basesrc, "caps of src: %" GST_PTR_FORMAT, thiscaps);
   /* nothing or anything is allowed, we're done */
   if (thiscaps == NULL || gst_caps_is_any (thiscaps))
     goto no_nego_needed;
 
   /* get the peer caps */
-  peercaps = gst_pad_peer_get_caps_reffed (GST_BASE_SRC_PAD (basesrc));
+  peercaps = gst_pad_peer_get_caps (GST_BASE_SRC_PAD (basesrc), NULL);
   GST_DEBUG_OBJECT (basesrc, "caps of peer: %" GST_PTR_FORMAT, peercaps);
   if (peercaps) {
     /* get intersection */
@@ -1016,9 +961,9 @@ gst_pulsesrc_negotiate (GstBaseSrc * basesrc)
         result = TRUE;
       } else if (gst_caps_is_fixed (caps)) {
         /* yay, fixed caps, use those then */
-        result = gst_pulsesrc_create_stream (GST_PULSESRC_CAST (basesrc), caps);
+        result = gst_pulsesrc_create_stream (pulsesrc, caps);
         if (result)
-          result = gst_pad_set_caps (GST_BASE_SRC_PAD (basesrc), caps);
+          result = gst_base_src_set_caps (basesrc, caps);
       }
     }
     gst_caps_unref (caps);
@@ -1058,12 +1003,8 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
   if (pa_stream_connect_record (pulsesrc->stream, pulsesrc->device, &wanted,
           PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE |
           PA_STREAM_NOT_MONOTONIC | PA_STREAM_ADJUST_LATENCY |
-          PA_STREAM_START_CORKED) < 0) {
-    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED,
-        ("Failed to connect stream: %s",
-            pa_strerror (pa_context_errno (pulsesrc->context))), (NULL));
-    goto unlock_and_fail;
-  }
+          PA_STREAM_START_CORKED) < 0)
+    goto connect_failed;
 
   pulsesrc->corked = TRUE;
 
@@ -1072,12 +1013,8 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
 
     state = pa_stream_get_state (pulsesrc->stream);
 
-    if (!PA_STREAM_IS_GOOD (state)) {
-      GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED,
-          ("Failed to connect stream: %s",
-              pa_strerror (pa_context_errno (pulsesrc->context))), (NULL));
-      goto unlock_and_fail;
-    }
+    if (!PA_STREAM_IS_GOOD (state))
+      goto stream_is_bad;
 
     if (state == PA_STREAM_READY)
       break;
@@ -1085,6 +1022,7 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
     /* Wait until the stream is ready */
     pa_threaded_mainloop_wait (pulsesrc->mainloop);
   }
+  pulsesrc->stream_connected = TRUE;
 
   /* store the source output index so it can be accessed via a property */
   pulsesrc->source_output_idx = pa_stream_get_index (pulsesrc->stream);
@@ -1109,10 +1047,29 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
   }
   spec->segtotal = actual->maxlength / spec->segsize;
 
+  if (!pulsesrc->paused) {
+    GST_DEBUG_OBJECT (pulsesrc, "uncorking because we are playing");
+    gst_pulsesrc_set_corked (pulsesrc, FALSE, FALSE);
+  }
   pa_threaded_mainloop_unlock (pulsesrc->mainloop);
 
   return TRUE;
 
+  /* ERRORS */
+connect_failed:
+  {
+    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED,
+        ("Failed to connect stream: %s",
+            pa_strerror (pa_context_errno (pulsesrc->context))), (NULL));
+    goto unlock_and_fail;
+  }
+stream_is_bad:
+  {
+    GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED,
+        ("Failed to connect stream: %s",
+            pa_strerror (pa_context_errno (pulsesrc->context))), (NULL));
+    goto unlock_and_fail;
+  }
 unlock_and_fail:
   {
     gst_pulsesrc_destroy_stream (pulsesrc);
@@ -1192,6 +1149,9 @@ gst_pulsesrc_set_corked (GstPulseSrc * psrc, gboolean corked, gboolean wait)
   gboolean res = FALSE;
 
   GST_DEBUG_OBJECT (psrc, "setting corked state to %d", corked);
+  if (!psrc->stream_connected)
+    return TRUE;
+
   if (psrc->corked != corked) {
     if (!(o = pa_stream_cork (psrc->stream, corked,
                 gst_pulsesrc_success_cb, psrc)))
index a308afd..f62f733 100644 (file)
@@ -73,6 +73,7 @@ struct _GstPulseSrc
   GstPulseProbe *probe;
 
   gboolean corked:1;
+  gboolean stream_connected:1;
   gboolean operation_success:1;
   gboolean paused:1;
   gboolean in_read:1;
index 0d8af79..196e39c 100644 (file)
@@ -49,6 +49,19 @@ static const pa_channel_position_t gst_pos_to_pa[GST_AUDIO_CHANNEL_POSITION_NUM]
       PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
   [GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT] = PA_CHANNEL_POSITION_SIDE_LEFT,
   [GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT] = PA_CHANNEL_POSITION_SIDE_RIGHT,
+  [GST_AUDIO_CHANNEL_POSITION_TOP_CENTER] = PA_CHANNEL_POSITION_TOP_CENTER,
+  [GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT] =
+      PA_CHANNEL_POSITION_TOP_FRONT_LEFT,
+  [GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT] =
+      PA_CHANNEL_POSITION_TOP_FRONT_RIGHT,
+  [GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_CENTER] =
+      PA_CHANNEL_POSITION_TOP_FRONT_CENTER,
+  [GST_AUDIO_CHANNEL_POSITION_TOP_REAR_LEFT] =
+      PA_CHANNEL_POSITION_TOP_REAR_LEFT,
+  [GST_AUDIO_CHANNEL_POSITION_TOP_REAR_RIGHT] =
+      PA_CHANNEL_POSITION_TOP_REAR_RIGHT,
+  [GST_AUDIO_CHANNEL_POSITION_TOP_REAR_CENTER] =
+      PA_CHANNEL_POSITION_TOP_REAR_CENTER,
   [GST_AUDIO_CHANNEL_POSITION_NONE] = PA_CHANNEL_POSITION_INVALID
 };
 
@@ -80,37 +93,53 @@ gboolean
 gst_pulse_fill_sample_spec (GstRingBufferSpec * spec, pa_sample_spec * ss)
 {
 
-  if (spec->format == GST_MU_LAW && spec->width == 8)
+  if (spec->type == GST_BUFTYPE_RAW) {
+    switch (GST_AUDIO_INFO_FORMAT (&spec->info)) {
+      case GST_AUDIO_FORMAT_U8:
+        ss->format = PA_SAMPLE_U8;
+        break;
+      case GST_AUDIO_FORMAT_S16_LE:
+        ss->format = PA_SAMPLE_S16LE;
+        break;
+      case GST_AUDIO_FORMAT_S16_BE:
+        ss->format = PA_SAMPLE_S16BE;
+        break;
+      case GST_AUDIO_FORMAT_F32_LE:
+        ss->format = PA_SAMPLE_FLOAT32LE;
+        break;
+      case GST_AUDIO_FORMAT_F32_BE:
+        ss->format = PA_SAMPLE_FLOAT32BE;
+        break;
+      case GST_AUDIO_FORMAT_S32_LE:
+        ss->format = PA_SAMPLE_S32LE;
+        break;
+      case GST_AUDIO_FORMAT_S32_BE:
+        ss->format = PA_SAMPLE_S32BE;
+        break;
+      case GST_AUDIO_FORMAT_S24_3LE:
+        ss->format = PA_SAMPLE_S24LE;
+        break;
+      case GST_AUDIO_FORMAT_S24_3BE:
+        ss->format = PA_SAMPLE_S24BE;
+        break;
+      case GST_AUDIO_FORMAT_S24_LE:
+        ss->format = PA_SAMPLE_S24_32LE;
+        break;
+      case GST_AUDIO_FORMAT_S24_BE:
+        ss->format = PA_SAMPLE_S24_32BE;
+        break;
+      default:
+        return FALSE;
+    }
+  } else if (spec->type == GST_BUFTYPE_MU_LAW) {
     ss->format = PA_SAMPLE_ULAW;
-  else if (spec->format == GST_A_LAW && spec->width == 8)
+  } else if (spec->type == GST_BUFTYPE_A_LAW) {
     ss->format = PA_SAMPLE_ALAW;
-  else if (spec->format == GST_U8 && spec->width == 8)
-    ss->format = PA_SAMPLE_U8;
-  else if (spec->format == GST_S16_LE && spec->width == 16)
-    ss->format = PA_SAMPLE_S16LE;
-  else if (spec->format == GST_S16_BE && spec->width == 16)
-    ss->format = PA_SAMPLE_S16BE;
-  else if (spec->format == GST_FLOAT32_LE && spec->width == 32)
-    ss->format = PA_SAMPLE_FLOAT32LE;
-  else if (spec->format == GST_FLOAT32_BE && spec->width == 32)
-    ss->format = PA_SAMPLE_FLOAT32BE;
-  else if (spec->format == GST_S32_LE && spec->width == 32)
-    ss->format = PA_SAMPLE_S32LE;
-  else if (spec->format == GST_S32_BE && spec->width == 32)
-    ss->format = PA_SAMPLE_S32BE;
-  else if (spec->format == GST_S24_3LE && spec->width == 24)
-    ss->format = PA_SAMPLE_S24LE;
-  else if (spec->format == GST_S24_3BE && spec->width == 24)
-    ss->format = PA_SAMPLE_S24BE;
-  else if (spec->format == GST_S24_LE && spec->width == 32)
-    ss->format = PA_SAMPLE_S24_32LE;
-  else if (spec->format == GST_S24_BE && spec->width == 32)
-    ss->format = PA_SAMPLE_S24_32BE;
-  else
+  } else
     return FALSE;
 
-  ss->channels = spec->channels;
-  ss->rate = spec->rate;
+  ss->channels = GST_AUDIO_INFO_CHANNELS (&spec->info);
+  ss->rate = GST_AUDIO_INFO_RATE (&spec->info);
 
   if (!pa_sample_spec_valid (ss))
     return FALSE;
@@ -236,7 +265,7 @@ gst_pulse_gst_to_channel_map (pa_channel_map * map,
     return NULL;
   }
 
-  for (i = 0; i < spec->channels; i++) {
+  for (i = 0; i < spec->info.channels; i++) {
     if (pos[i] == GST_AUDIO_CHANNEL_POSITION_NONE) {
       /* no valid mappings for these channels */
       g_free (pos);
@@ -248,7 +277,7 @@ gst_pulse_gst_to_channel_map (pa_channel_map * map,
   }
 
   g_free (pos);
-  map->channels = spec->channels;
+  map->channels = spec->info.channels;
 
   if (!pa_channel_map_valid (map)) {
     return NULL;
@@ -264,12 +293,15 @@ gst_pulse_channel_map_to_gst (const pa_channel_map * map,
   int i;
   GstAudioChannelPosition *pos;
   gboolean invalid = FALSE;
+  gint channels;
+
+  channels = GST_AUDIO_INFO_CHANNELS (&spec->info);
 
-  g_return_val_if_fail (map->channels == spec->channels, NULL);
+  g_return_val_if_fail (map->channels == channels, NULL);
 
-  pos = g_new0 (GstAudioChannelPosition, spec->channels + 1);
+  pos = g_new0 (GstAudioChannelPosition, channels + 1);
 
-  for (i = 0; i < spec->channels; i++) {
+  for (i = 0; i < channels; i++) {
     if (map->map[i] == PA_CHANNEL_POSITION_INVALID) {
       invalid = TRUE;
       break;
@@ -281,11 +313,11 @@ gst_pulse_channel_map_to_gst (const pa_channel_map * map,
     }
   }
 
-  if (!invalid && !gst_audio_check_channel_positions (pos, spec->channels))
+  if (!invalid && !gst_audio_check_channel_positions (pos, channels))
     invalid = TRUE;
 
   if (invalid) {
-    for (i = 0; i < spec->channels; i++)
+    for (i = 0; i < channels; i++)
       pos[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
   }
 
index 131fe74..e73ef51 100644 (file)
@@ -802,13 +802,9 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
       if (param != NULL)
         rate = atol (param);
 
-      src->src_caps = gst_caps_new_simple ("audio/x-raw-int",
-          "channels", G_TYPE_INT, channels,
-          "rate", G_TYPE_INT, rate,
-          "width", G_TYPE_INT, 16,
-          "depth", G_TYPE_INT, 16,
-          "signed", G_TYPE_BOOLEAN, TRUE,
-          "endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL);
+      src->src_caps = gst_caps_new_simple ("audio/x-raw",
+          "format", G_TYPE_STRING, "S16_BE",
+          "channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL);
     } else {
       /* Set the Content-Type field on the caps */
       if (src->src_caps)
index 46f774b..c5add82 100644 (file)
@@ -46,6 +46,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <gst/tag/tag.h>
+#include <gst/audio/audio.h>
 
 GST_DEBUG_CATEGORY_STATIC (speexdec_debug);
 #define GST_CAT_DEFAULT speexdec_debug
@@ -58,15 +59,15 @@ enum
   ARG_ENH
 };
 
+#define FORMAT_STR GST_AUDIO_NE(S16)
+
 static GstStaticPadTemplate speex_dec_src_factory =
 GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "rate = (int) [ 6000, 48000 ], "
-        "channels = (int) [ 1, 2 ], "
-        "endianness = (int) BYTE_ORDER, "
-        "signed = (boolean) true, " "width = (int) 16, " "depth = (int) 16")
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " FORMAT_STR ", "
+        "rate = (int) [ 6000, 48000 ], " "channels = (int) [ 1, 2 ]")
     );
 
 static GstStaticPadTemplate speex_dec_sink_factory =
@@ -76,7 +77,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     GST_STATIC_CAPS ("audio/x-speex")
     );
 
-GST_BOILERPLATE (GstSpeexDec, gst_speex_dec, GstElement, GST_TYPE_ELEMENT);
+#define gst_speex_dec_parent_class parent_class
+G_DEFINE_TYPE (GstSpeexDec, gst_speex_dec, GST_TYPE_ELEMENT);
 
 static gboolean speex_dec_sink_event (GstPad * pad, GstEvent * event);
 static GstFlowReturn speex_dec_chain (GstPad * pad, GstBuffer * buf);
@@ -86,7 +88,6 @@ static GstStateChangeReturn speex_dec_change_state (GstElement * element,
 static gboolean speex_dec_src_event (GstPad * pad, GstEvent * event);
 static gboolean speex_dec_src_query (GstPad * pad, GstQuery * query);
 static gboolean speex_dec_sink_query (GstPad * pad, GstQuery * query);
-static gboolean speex_dec_sink_setcaps (GstPad * pad, GstCaps * caps);
 static const GstQueryType *speex_get_src_query_types (GstPad * pad);
 static const GstQueryType *speex_get_sink_query_types (GstPad * pad);
 static gboolean speex_dec_convert (GstPad * pad,
@@ -107,20 +108,6 @@ static GstFlowReturn speex_dec_chain_parse_comments (GstSpeexDec * dec,
     GstBuffer * buf);
 
 static void
-gst_speex_dec_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&speex_dec_src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&speex_dec_sink_factory));
-  gst_element_class_set_details_simple (element_class, "Speex audio decoder",
-      "Codec/Decoder/Audio",
-      "decode speex streams to audio", "Wim Taymans <wim@fluendo.com>");
-}
-
-static void
 gst_speex_dec_class_init (GstSpeexDecClass * klass)
 {
   GObjectClass *gobject_class;
@@ -138,6 +125,14 @@ gst_speex_dec_class_init (GstSpeexDecClass * klass)
 
   gstelement_class->change_state = GST_DEBUG_FUNCPTR (speex_dec_change_state);
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&speex_dec_src_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&speex_dec_sink_factory));
+  gst_element_class_set_details_simple (gstelement_class, "Speex audio decoder",
+      "Codec/Decoder/Audio",
+      "decode speex streams to audio", "Wim Taymans <wim@fluendo.com>");
+
   GST_DEBUG_CATEGORY_INIT (speexdec_debug, "speexdec", 0,
       "speex decoding element");
 }
@@ -169,7 +164,7 @@ gst_speex_dec_reset (GstSpeexDec * dec)
 }
 
 static void
-gst_speex_dec_init (GstSpeexDec * dec, GstSpeexDecClass * g_class)
+gst_speex_dec_init (GstSpeexDec * dec)
 {
   dec->sinkpad =
       gst_pad_new_from_static_template (&speex_dec_sink_factory, "sink");
@@ -181,8 +176,6 @@ gst_speex_dec_init (GstSpeexDec * dec, GstSpeexDecClass * g_class)
       GST_DEBUG_FUNCPTR (speex_get_sink_query_types));
   gst_pad_set_query_function (dec->sinkpad,
       GST_DEBUG_FUNCPTR (speex_dec_sink_query));
-  gst_pad_set_setcaps_function (dec->sinkpad,
-      GST_DEBUG_FUNCPTR (speex_dec_sink_setcaps));
   gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
 
   dec->srcpad =
@@ -384,6 +377,7 @@ speex_dec_src_query (GstPad * pad, GstQuery * query)
 
   dec = GST_SPEEX_DEC (gst_pad_get_parent (pad));
 
+  /* FIXME: why not just pass position/duration queries upstream to demuxer? */
   switch (GST_QUERY_TYPE (query)) {
     case GST_QUERY_POSITION:{
       GstSegment segment;
@@ -402,17 +396,17 @@ speex_dec_src_query (GstPad * pad, GstQuery * query)
       }
 
       if ((res = speex_dec_convert (dec->srcpad, GST_FORMAT_TIME,
-                  segment.last_stop, &format, &cur))) {
+                  segment.position, &format, &cur))) {
         gst_query_set_position (query, format, cur);
       }
       break;
     }
     case GST_QUERY_DURATION:{
-      GstFormat format = GST_FORMAT_TIME;
+      GstFormat format;
       gint64 dur;
 
       /* get duration from demuxer */
-      if (!gst_pad_query_peer_duration (dec->sinkpad, &format, &dur))
+      if (!gst_pad_query_peer_duration (dec->sinkpad, GST_FORMAT_TIME, &dur))
         break;
 
       gst_query_parse_duration (query, &format, NULL);
@@ -496,43 +490,44 @@ speex_dec_sink_event (GstPad * pad, GstEvent * event)
   GST_LOG_OBJECT (dec, "handling %s event", GST_EVENT_TYPE_NAME (event));
 
   switch (GST_EVENT_TYPE (event)) {
-    case GST_EVENT_NEWSEGMENT:{
-      GstFormat format;
-      gdouble rate, arate;
-      gint64 start, stop, time;
-      gboolean update;
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
 
-      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
-          &start, &stop, &time);
+      gst_event_parse_caps (event, &caps);
+      ret = speex_dec_sink_setcaps (pad, caps);
+      gst_event_unref (event);
+      break;
+    }
+    case GST_EVENT_SEGMENT:{
+      GstSegment segment;
+
+      gst_event_copy_segment (event, &segment);
 
-      if (format != GST_FORMAT_TIME)
+      if (segment.format != GST_FORMAT_TIME)
         goto newseg_wrong_format;
 
-      if (rate <= 0.0)
+      if (segment.rate <= 0.0)
         goto newseg_wrong_rate;
 
+#if 0
       if (update) {
         /* time progressed without data, see if we can fill the gap with
          * some concealment data */
-        if (dec->segment.last_stop < start) {
+        if (dec->segment.position < start) {
           GstClockTime duration;
 
-          duration = start - dec->segment.last_stop;
-          speex_dec_chain_parse_data (dec, NULL, dec->segment.last_stop,
+          duration = start - dec->segment.position;
+          speex_dec_chain_parse_data (dec, NULL, dec->segment.position,
               duration);
         }
       }
+#endif
 
       /* now configure the values */
-      gst_segment_set_newsegment_full (&dec->segment, update,
-          rate, arate, GST_FORMAT_TIME, start, stop, time);
-
-      GST_DEBUG_OBJECT (dec, "segment now: cur = %" GST_TIME_FORMAT " [%"
-          GST_TIME_FORMAT " - %" GST_TIME_FORMAT "]",
-          GST_TIME_ARGS (dec->segment.last_stop),
-          GST_TIME_ARGS (dec->segment.start),
-          GST_TIME_ARGS (dec->segment.stop));
+      dec->segment = segment;
 
+      GST_DEBUG_OBJECT (dec, "segment now: %" GST_SEGMENT_FORMAT, &segment);
       ret = gst_pad_push_event (dec->srcpad, event);
       break;
     }
@@ -563,10 +558,13 @@ static GstFlowReturn
 speex_dec_chain_parse_header (GstSpeexDec * dec, GstBuffer * buf)
 {
   GstCaps *caps;
+  char *data;
+  gsize size;
 
   /* get the header */
-  dec->header = speex_packet_to_header ((char *) GST_BUFFER_DATA (buf),
-      GST_BUFFER_SIZE (buf));
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  dec->header = speex_packet_to_header (data, size);
+  gst_buffer_unmap (buf, data, size);
 
   if (!dec->header)
     goto no_header;
@@ -600,12 +598,10 @@ speex_dec_chain_parse_header (GstSpeexDec * dec, GstBuffer * buf)
   speex_bits_init (&dec->bits);
 
   /* set caps */
-  caps = gst_caps_new_simple ("audio/x-raw-int",
+  caps = gst_caps_new_simple ("audio/x-raw",
+      "format", G_TYPE_STRING, FORMAT_STR,
       "rate", G_TYPE_INT, dec->header->rate,
-      "channels", G_TYPE_INT, dec->header->nb_channels,
-      "signed", G_TYPE_BOOLEAN, TRUE,
-      "endianness", G_TYPE_INT, G_BYTE_ORDER,
-      "width", G_TYPE_INT, 16, "depth", G_TYPE_INT, 16, NULL);
+      "channels", G_TYPE_INT, dec->header->nb_channels, NULL);
 
   if (!gst_pad_set_caps (dec->srcpad, caps))
     goto nego_failed;
@@ -693,25 +689,24 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf,
 {
   GstFlowReturn res = GST_FLOW_OK;
   gint i, fpp;
-  guint size;
-  guint8 *data;
   SpeexBits *bits;
+  gsize size;
+  char *data;
 
   if (!dec->frame_duration)
     goto not_negotiated;
 
   if (timestamp != -1) {
-    dec->segment.last_stop = timestamp;
+    dec->segment.position = timestamp;
   } else {
-    timestamp = dec->segment.last_stop;
+    timestamp = dec->segment.position;
   }
 
   if (buf) {
-    data = GST_BUFFER_DATA (buf);
-    size = GST_BUFFER_SIZE (buf);
-
     /* send data to the bitstream */
-    speex_bits_read_from (&dec->bits, (char *) data, size);
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+    speex_bits_read_from (&dec->bits, data, size);
+    gst_buffer_unmap (buf, data, size);
 
     fpp = dec->header->frames_per_packet;
     bits = &dec->bits;
@@ -734,7 +729,7 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf,
 
     GST_LOG_OBJECT (dec, "decoding frame %d/%d, %d bits remaining", i, fpp,
         bits ? speex_bits_remaining (bits) : -1);
-
+#if 0
     res = gst_pad_alloc_buffer_and_set_caps (dec->srcpad,
         GST_BUFFER_OFFSET_NONE, dec->frame_size * dec->header->nb_channels * 2,
         GST_PAD_CAPS (dec->srcpad), &outbuf);
@@ -743,10 +738,17 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf,
       GST_DEBUG_OBJECT (dec, "buf alloc flow: %s", gst_flow_get_name (res));
       return res;
     }
+#endif
+    /* FIXME, we can use a bufferpool because we have fixed size buffers. We
+     * could also use an allocator */
+    outbuf =
+        gst_buffer_new_allocate (NULL,
+        dec->frame_size * dec->header->nb_channels * 2, 0);
 
-    out_data = (gint16 *) GST_BUFFER_DATA (outbuf);
-
+    out_data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
     ret = speex_decode_int (dec->state, bits, out_data);
+    gst_buffer_unmap (outbuf, out_data, size);
+
     if (ret == -1) {
       /* uh? end of stream */
       if (fpp == 0 && speex_bits_remaining (bits) < 8) {
@@ -777,8 +779,8 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf,
     GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
     GST_BUFFER_DURATION (outbuf) = dec->frame_duration;
 
-    dec->segment.last_stop += dec->frame_duration;
-    timestamp = dec->segment.last_stop;
+    dec->segment.position += dec->frame_duration;
+    timestamp = dec->segment.position;
 
     GST_LOG_OBJECT (dec, "pushing buffer with ts=%" GST_TIME_FORMAT ", dur=%"
         GST_TIME_FORMAT, GST_TIME_ARGS (timestamp),
@@ -803,6 +805,26 @@ not_negotiated:
   }
 }
 
+static gboolean
+memcmp_buffers (GstBuffer * buf1, GstBuffer * buf2)
+{
+  gsize size1, size2;
+  gpointer data1;
+  gboolean res;
+
+  size1 = gst_buffer_get_size (buf1);
+  size2 = gst_buffer_get_size (buf2);
+
+  if (size1 != size2)
+    return FALSE;
+
+  data1 = gst_buffer_map (buf1, NULL, NULL, GST_MAP_READ);
+  res = gst_buffer_memcmp (buf2, 0, data1, size1) == 0;
+  gst_buffer_unmap (buf1, data1, size1);
+
+  return res;
+}
+
 static GstFlowReturn
 speex_dec_chain (GstPad * pad, GstBuffer * buf)
 {
@@ -814,13 +836,9 @@ speex_dec_chain (GstPad * pad, GstBuffer * buf)
   /* If we have the streamheader and vorbiscomment from the caps already
    * ignore them here */
   if (dec->streamheader && dec->vorbiscomment) {
-    if (GST_BUFFER_SIZE (dec->streamheader) == GST_BUFFER_SIZE (buf)
-        && memcmp (GST_BUFFER_DATA (dec->streamheader), GST_BUFFER_DATA (buf),
-            GST_BUFFER_SIZE (buf)) == 0) {
+    if (memcmp_buffers (dec->streamheader, buf)) {
       res = GST_FLOW_OK;
-    } else if (GST_BUFFER_SIZE (dec->vorbiscomment) == GST_BUFFER_SIZE (buf)
-        && memcmp (GST_BUFFER_DATA (dec->vorbiscomment), GST_BUFFER_DATA (buf),
-            GST_BUFFER_SIZE (buf)) == 0) {
+    } else if (memcmp_buffers (dec->vorbiscomment, buf)) {
       res = GST_FLOW_OK;
     } else {
       res =
@@ -904,7 +922,7 @@ speex_dec_change_state (GstElement * element, GstStateChange transition)
       break;
   }
 
-  ret = parent_class->change_state (element, transition);
+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
   if (ret != GST_STATE_CHANGE_SUCCESS)
     return ret;
 
index 6ace2da..3b26866 100644 (file)
 GST_DEBUG_CATEGORY_STATIC (speexenc_debug);
 #define GST_CAT_DEFAULT speexenc_debug
 
+#define FORMAT_STR GST_AUDIO_NE(S16)
+
 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "rate = (int) [ 6000, 48000 ], "
-        "channels = (int) [ 1, 2 ], "
-        "endianness = (int) BYTE_ORDER, "
-        "signed = (boolean) TRUE, " "width = (int) 16, " "depth = (int) 16")
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " FORMAT_STR ", "
+        "rate = (int) [ 6000, 48000 ], " "channels = (int) [ 1, 2 ]")
     );
 
 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
@@ -135,7 +135,7 @@ gst_speex_enc_get_formats (GstPad * pad)
 
 static void gst_speex_enc_finalize (GObject * object);
 
-static gboolean gst_speex_enc_sinkevent (GstPad * pad, GstEvent * event);
+static gboolean gst_speex_enc_sink_event (GstPad * pad, GstEvent * event);
 static GstFlowReturn gst_speex_enc_chain (GstPad * pad, GstBuffer * buf);
 static gboolean gst_speex_enc_setup (GstSpeexEnc * enc);
 
@@ -148,40 +148,10 @@ static GstStateChangeReturn gst_speex_enc_change_state (GstElement * element,
 
 static GstFlowReturn gst_speex_enc_encode (GstSpeexEnc * enc, gboolean flush);
 
-static void
-gst_speex_enc_setup_interfaces (GType speexenc_type)
-{
-  static const GInterfaceInfo tag_setter_info = { NULL, NULL, NULL };
-  const GInterfaceInfo preset_interface_info = {
-    NULL,                       /* interface_init */
-    NULL,                       /* interface_finalize */
-    NULL                        /* interface_data */
-  };
-
-  g_type_add_interface_static (speexenc_type, GST_TYPE_TAG_SETTER,
-      &tag_setter_info);
-  g_type_add_interface_static (speexenc_type, GST_TYPE_PRESET,
-      &preset_interface_info);
-
-  GST_DEBUG_CATEGORY_INIT (speexenc_debug, "speexenc", 0, "Speex encoder");
-}
-
-GST_BOILERPLATE_FULL (GstSpeexEnc, gst_speex_enc, GstElement, GST_TYPE_ELEMENT,
-    gst_speex_enc_setup_interfaces);
-
-static void
-gst_speex_enc_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_factory));
-  gst_element_class_set_details_simple (element_class, "Speex audio encoder",
-      "Codec/Encoder/Audio",
-      "Encodes audio in Speex format", "Wim Taymans <wim@fluendo.com>");
-}
+#define gst_speex_enc_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstSpeexEnc, gst_speex_enc, GST_TYPE_ELEMENT,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL));
 
 static void
 gst_speex_enc_class_init (GstSpeexEncClass * klass)
@@ -192,6 +162,7 @@ gst_speex_enc_class_init (GstSpeexEncClass * klass)
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
 
+  gobject_class->finalize = gst_speex_enc_finalize;
   gobject_class->set_property = gst_speex_enc_set_property;
   gobject_class->get_property = gst_speex_enc_get_property;
 
@@ -240,10 +211,18 @@ gst_speex_enc_class_init (GstSpeexEncClass * klass)
           "The last status message", NULL,
           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
-  gobject_class->finalize = gst_speex_enc_finalize;
-
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_speex_enc_change_state);
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_factory));
+  gst_element_class_set_details_simple (gstelement_class, "Speex audio encoder",
+      "Codec/Encoder/Audio",
+      "Encodes audio in Speex format", "Wim Taymans <wim@fluendo.com>");
+
+  GST_DEBUG_CATEGORY_INIT (speexenc_debug, "speexenc", 0, "Speex encoder");
 }
 
 static void
@@ -279,13 +258,13 @@ gst_speex_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
 
 
 static GstCaps *
-gst_speex_enc_sink_getcaps (GstPad * pad)
+gst_speex_enc_sink_getcaps (GstPad * pad, GstCaps * filter)
 {
   GstCaps *caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
   GstCaps *peercaps = NULL;
   GstSpeexEnc *enc = GST_SPEEX_ENC (gst_pad_get_parent_element (pad));
 
-  peercaps = gst_pad_peer_get_caps (enc->srcpad);
+  peercaps = gst_pad_peer_get_caps (enc->srcpad, filter);
 
   if (peercaps) {
     if (!gst_caps_is_empty (peercaps) && !gst_caps_is_any (peercaps)) {
@@ -312,7 +291,7 @@ gst_speex_enc_sink_getcaps (GstPad * pad)
 
 static gboolean
 gst_speex_enc_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
-    GstFormat dest_format, gint64 * dest_value)
+    GstFormat dest_format, gint64 * dest_value)
 {
   gboolean res = TRUE;
   GstSpeexEnc *enc;
@@ -327,7 +306,7 @@ gst_speex_enc_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
 
   switch (src_format) {
     case GST_FORMAT_BYTES:
-      switch (*dest_format) {
+      switch (dest_format) {
         case GST_FORMAT_TIME:
           *dest_value = src_value * GST_SECOND / avg;
           break;
@@ -336,7 +315,7 @@ gst_speex_enc_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
       }
       break;
     case GST_FORMAT_TIME:
-      switch (*dest_format) {
+      switch (dest_format) {
         case GST_FORMAT_BYTES:
           *dest_value = src_value * avg / GST_SECOND;
           break;
@@ -451,44 +430,44 @@ gst_speex_enc_src_query (GstPad * pad, GstQuery * query)
   switch (GST_QUERY_TYPE (query)) {
     case GST_QUERY_POSITION:
     {
-      GstFormat fmt, req_fmt;
+      GstFormat req_fmt;
       gint64 pos, val;
 
       gst_query_parse_position (query, &req_fmt, NULL);
-      if ((res = gst_pad_query_peer_position (enc->sinkpad, &req_fmt, &val))) {
+      if ((res = gst_pad_query_peer_position (enc->sinkpad, req_fmt, &val))) {
         gst_query_set_position (query, req_fmt, val);
         break;
       }
 
-      fmt = GST_FORMAT_TIME;
-      if (!(res = gst_pad_query_peer_position (enc->sinkpad, &fmt, &pos)))
+      res = gst_pad_query_peer_position (enc->sinkpad, GST_FORMAT_TIME, &pos);
+      if (!res)
         break;
 
       if ((res =
-              gst_pad_query_peer_convert (enc->sinkpad, fmt, pos, &req_fmt,
-                  &val)))
+              gst_pad_query_peer_convert (enc->sinkpad, GST_FORMAT_TIME, pos,
+                  req_fmt, &val))) {
         gst_query_set_position (query, req_fmt, val);
-
+      }
       break;
     }
     case GST_QUERY_DURATION:
     {
-      GstFormat fmt, req_fmt;
+      GstFormat req_fmt;
       gint64 dur, val;
 
       gst_query_parse_duration (query, &req_fmt, NULL);
-      if ((res = gst_pad_query_peer_duration (enc->sinkpad, &req_fmt, &val))) {
+      if ((res = gst_pad_query_peer_duration (enc->sinkpad, req_fmt, &val))) {
         gst_query_set_duration (query, req_fmt, val);
         break;
       }
 
-      fmt = GST_FORMAT_TIME;
-      if (!(res = gst_pad_query_peer_duration (enc->sinkpad, &fmt, &dur)))
+      res = gst_pad_query_peer_duration (enc->sinkpad, GST_FORMAT_TIME, &dur);
+      if (!res)
         break;
 
       if ((res =
-              gst_pad_query_peer_convert (enc->sinkpad, fmt, dur, &req_fmt,
-                  &val))) {
+              gst_pad_query_peer_convert (enc->sinkpad, GST_FORMAT_TIME, dur,
+                  req_fmt, &val))) {
         gst_query_set_duration (query, req_fmt, val);
       }
       break;
@@ -499,7 +478,7 @@ gst_speex_enc_src_query (GstPad * pad, GstQuery * query)
       gint64 src_val, dest_val;
 
       gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
-      if (!(res = gst_speex_enc_convert_src (pad, src_fmt, src_val, &dest_fmt,
+      if (!(res = gst_speex_enc_convert_src (pad, src_fmt, src_val, dest_fmt,
                   &dest_val)))
         goto error;
       gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
@@ -568,16 +547,14 @@ error:
 }
 
 static void
-gst_speex_enc_init (GstSpeexEnc * enc, GstSpeexEncClass * klass)
+gst_speex_enc_init (GstSpeexEnc * enc)
 {
   enc->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
   gst_element_add_pad (GST_ELEMENT (enc), enc->sinkpad);
   gst_pad_set_event_function (enc->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_speex_enc_sinkevent));
+      GST_DEBUG_FUNCPTR (gst_speex_enc_sink_event));
   gst_pad_set_chain_function (enc->sinkpad,
       GST_DEBUG_FUNCPTR (gst_speex_enc_chain));
-  gst_pad_set_setcaps_function (enc->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_speex_enc_sink_setcaps));
   gst_pad_set_getcaps_function (enc->sinkpad,
       GST_DEBUG_FUNCPTR (gst_speex_enc_sink_getcaps));
   gst_pad_set_query_function (enc->sinkpad,
@@ -782,11 +759,11 @@ gst_speex_enc_buffer_from_data (GstSpeexEnc * enc, guchar * data,
   GstBuffer *outbuf;
 
   outbuf = gst_buffer_new_and_alloc (data_len);
-  memcpy (GST_BUFFER_DATA (outbuf), data, data_len);
+  gst_buffer_fill (outbuf, 0, data, data_len);
   GST_BUFFER_OFFSET (outbuf) = enc->bytes_out;
   GST_BUFFER_OFFSET_END (outbuf) = granulepos;
 
-  GST_LOG_OBJECT (enc, "encoded buffer of %d bytes", GST_BUFFER_SIZE (outbuf));
+  GST_LOG_OBJECT (enc, "encoded buffer of %d bytes", data_len);
   return outbuf;
 }
 
@@ -797,8 +774,7 @@ gst_speex_enc_push_buffer (GstSpeexEnc * enc, GstBuffer * buffer)
 {
   guint size;
 
-  size = GST_BUFFER_SIZE (buffer);
-
+  size = gst_buffer_get_size (buffer);
   enc->bytes_out += size;
 
   GST_DEBUG_OBJECT (enc, "pushing output buffer of size %u", size);
@@ -818,8 +794,8 @@ gst_speex_enc_set_header_on_caps (GstCaps * caps, GstBuffer * buf1,
   caps = gst_caps_make_writable (caps);
   structure = gst_caps_get_structure (caps, 0);
 
-  g_assert (gst_buffer_is_metadata_writable (buf1));
-  g_assert (gst_buffer_is_metadata_writable (buf2));
+  g_assert (gst_buffer_is_writable (buf1));
+  g_assert (gst_buffer_is_writable (buf2));
 
   /* mark buffers */
   GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_FLAG_IN_CAPS);
@@ -847,7 +823,7 @@ gst_speex_enc_set_header_on_caps (GstCaps * caps, GstBuffer * buf1,
 
 
 static gboolean
-gst_speex_enc_sinkevent (GstPad * pad, GstEvent * event)
+gst_speex_enc_sink_event (GstPad * pad, GstEvent * event)
 {
   gboolean res = TRUE;
   GstSpeexEnc *enc;
@@ -855,6 +831,15 @@ gst_speex_enc_sinkevent (GstPad * pad, GstEvent * event)
   enc = GST_SPEEX_ENC (gst_pad_get_parent (pad));
 
   switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+
+      gst_event_parse_caps (event, &caps);
+      res = gst_speex_enc_sink_setcaps (pad, caps);
+      gst_event_unref (event);
+      break;
+    }
     case GST_EVENT_EOS:
       if (enc->setup)
         gst_speex_enc_encode (enc, TRUE);
@@ -894,8 +879,7 @@ gst_speex_enc_encode (GstSpeexEnc * enc, gboolean flush)
   if (flush && gst_adapter_available (enc->adapter) % bytes != 0) {
     guint diff = gst_adapter_available (enc->adapter) % bytes;
     GstBuffer *buf = gst_buffer_new_and_alloc (diff);
-
-    memset (GST_BUFFER_DATA (buf), 0, diff);
+    gst_buffer_memset (buf, 0, 0, diff);
     gst_adapter_push (enc->adapter, buf);
   }
 
@@ -903,6 +887,7 @@ gst_speex_enc_encode (GstSpeexEnc * enc, gboolean flush)
     gint16 *data;
     gint outsize, written, dtx_ret;
     GstBuffer *outbuf;
+    gchar *outdata;
 
     data = (gint16 *) gst_adapter_take (enc->adapter, bytes);
 
@@ -926,19 +911,21 @@ gst_speex_enc_encode (GstSpeexEnc * enc, gboolean flush)
     speex_bits_insert_terminator (&enc->bits);
     outsize = speex_bits_nbytes (&enc->bits);
 
+#if 0
     ret = gst_pad_alloc_buffer_and_set_caps (enc->srcpad,
         GST_BUFFER_OFFSET_NONE, outsize, GST_PAD_CAPS (enc->srcpad), &outbuf);
-
     if ((GST_FLOW_OK != ret))
       goto done;
+#endif
+    outbuf = gst_buffer_new_allocate (NULL, outsize, 0);
 
-    written = speex_bits_write (&enc->bits,
-        (gchar *) GST_BUFFER_DATA (outbuf), outsize);
+    outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+    written = speex_bits_write (&enc->bits, outdata, outsize);
 
     if (G_UNLIKELY (written != outsize)) {
       GST_ERROR_OBJECT (enc, "short write: %d < %d bytes", written, outsize);
-      GST_BUFFER_SIZE (outbuf) = written;
     }
+    gst_buffer_unmap (outbuf, outdata, written);
 
     speex_bits_reset (&enc->bits);
 
@@ -1001,7 +988,7 @@ gst_speex_enc_chain (GstPad * pad, GstBuffer * buf)
     buf2 = gst_speex_enc_create_metadata_buffer (enc);
 
     /* mark and put on caps */
-    caps = gst_pad_get_caps (enc->srcpad);
+    caps = gst_pad_get_caps (enc->srcpad, NULL);
     caps = gst_speex_enc_set_header_on_caps (caps, buf1, buf2);
 
     gst_caps_set_simple (caps,
@@ -1011,9 +998,6 @@ gst_speex_enc_chain (GstPad * pad, GstBuffer * buf)
     /* negotiate with these caps */
     GST_DEBUG_OBJECT (enc, "here are the caps: %" GST_PTR_FORMAT, caps);
     gst_pad_set_caps (enc->srcpad, caps);
-
-    gst_buffer_set_caps (buf1, caps);
-    gst_buffer_set_caps (buf2, caps);
     gst_caps_unref (caps);
 
     /* push out buffers */
@@ -1061,13 +1045,12 @@ gst_speex_enc_chain (GstPad * pad, GstBuffer * buf)
         GST_TIME_ARGS (enc->next_ts));
 
     diff_bytes = GST_CLOCK_TIME_TO_FRAMES (diff, enc->rate) * enc->channels * 2;
-    if (diff_bytes >= GST_BUFFER_SIZE (buf)) {
+    if (diff_bytes >= gst_buffer_get_size (buf)) {
       gst_buffer_unref (buf);
       return GST_FLOW_OK;
     }
-    buf = gst_buffer_make_metadata_writable (buf);
-    GST_BUFFER_DATA (buf) += diff_bytes;
-    GST_BUFFER_SIZE (buf) -= diff_bytes;
+    buf = gst_buffer_make_writable (buf);
+    gst_buffer_resize (buf, diff_bytes, -1);
 
     GST_BUFFER_TIMESTAMP (buf) += diff;
     if (GST_BUFFER_DURATION_IS_VALID (buf))
@@ -1100,7 +1083,8 @@ gst_speex_enc_chain (GstPad * pad, GstBuffer * buf)
   else
     enc->next_ts = GST_CLOCK_TIME_NONE;
 
-  GST_DEBUG_OBJECT (enc, "received buffer of %u bytes", GST_BUFFER_SIZE (buf));
+  GST_DEBUG_OBJECT (enc, "received buffer of %u bytes",
+      gst_buffer_get_size (buf));
 
   /* push buffer to adapter */
   gst_adapter_push (enc->adapter, buf);
index 6468048..cc307aa 100644 (file)
@@ -368,7 +368,7 @@ add_id3v2frame_tag (ID3v2::Tag * id3v2tag, const GstTagList * list,
     GstBuffer *buf;
 
     val = gst_tag_list_get_value_index (list, tag, i);
-    buf = (GstBuffer *) gst_value_get_mini_object (val);
+    buf = (GstBuffer *) g_value_get_boxed (val);
 
     if (buf && GST_BUFFER_CAPS (buf)) {
       GstStructure *s;
@@ -403,7 +403,7 @@ add_image_tag (ID3v2::Tag * id3v2tag, const GstTagList * list,
     GST_DEBUG ("image %u/%u", n + 1, num_tags);
 
     val = gst_tag_list_get_value_index (list, tag, n);
-    image = (GstBuffer *) gst_value_get_mini_object (val);
+    image = (GstBuffer *) g_value_get_boxed (val);
 
     if (GST_IS_BUFFER (image) && GST_BUFFER_SIZE (image) > 0 &&
         GST_BUFFER_CAPS (image) != NULL &&
diff --git a/gconf/.gitignore b/gconf/.gitignore
deleted file mode 100644 (file)
index 57ec967..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-gstreamer-*.schemas
-gstreamer.schemas
diff --git a/gconf/Makefile.am b/gconf/Makefile.am
deleted file mode 100644 (file)
index 5129c00..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-GST_SCHEMA_FILES = gstreamer-@GST_MAJORMINOR@.schemas
-
-if USE_GCONF
-schemadir = @GCONF_SCHEMA_FILE_DIR@
-schema_DATA = $(GST_SCHEMA_FILES)
-endif
-
-gstreamer-@GST_MAJORMINOR@.schemas: gstreamer.schemas
-       cp gstreamer.schemas gstreamer-@GST_MAJORMINOR@.schemas
-
-if USE_GCONF
-if GCONF_SCHEMAS_INSTALL
-install-data-local:
-       @GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) \
-               --makefile-install-rule $(builddir)/$(schema_DATA) || \
-               (echo ;\
-               echo "*****************************************************"; \
-               echo "Installation of schemas failed, install them manually"; \
-               echo "*****************************************************";) 
-       @true
-else
-install-data-local:
-       @echo "***************************************************************"
-       @echo "Not installing schemas, disabled with --disable-schemas-install"
-       @echo "***************************************************************"
-       @true
-endif
-endif # USE_GCONF
-
-CLEANFILES = $(GST_SCHEMA_FILES)
-EXTRA_DIST = $(GST_SCHEMA_FILES)
diff --git a/gconf/gstreamer.schemas.in b/gconf/gstreamer.schemas.in
deleted file mode 100644 (file)
index bc1ff44..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-<gconfschemafile>
-  <schemalist>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/audiosink</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/audiosink</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>@DEFAULT_AUDIOSINK@</default>
-      <locale name="C">
-        <short>default GStreamer audiosink</short>
-        <long>GStreamer can play audio using any number of output elements.  Some possible choices are osssink, esdsink and alsasink.  The audiosink can be a partial pipeline instead of just one element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/audiosink_description</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/audiosink_description</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>Default</default>
-      <locale name="C">
-        <short>description for default GStreamer audiosink</short>
-        <long>Describes the selected output element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/musicaudiosink</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/musicaudiosink</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>@DEFAULT_AUDIOSINK@</default>
-      <locale name="C">
-        <short>GStreamer audiosink for Music and Movies</short>
-        <long>GStreamer can play audio using any number of output elements.  Some possible choices are osssink, esdsink and alsasink.  The audiosink can be a partial pipeline instead of just one element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/musicaudiosink_description</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/musicaudiosink_description</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>Default</default>
-      <locale name="C">
-        <short>description for GStreamer audiosink for Music and Movies</short>
-        <long>Describes the selected output element for Music and Movies.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/chataudiosink</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/chataudiosink</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>@DEFAULT_AUDIOSINK@</default>
-      <locale name="C">
-        <short>GStreamer audiosink for Audio/Video Conferencing</short>
-        <long>GStreamer can play audio using any number of output elements.  Some possible choices are osssink, esdsink and alsasink.  The audiosink can be a partial pipeline instead of just one element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/chataudiosink_description</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/chataudiosink_description</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>Default</default>
-      <locale name="C">
-        <short>description for GStreamer audiosink for Audio/Video Conferencing</short>
-        <long>Describes the selected output element for Audio/Video Conferencing.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/audiosink_description</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/audiosink_description</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>Default</default>
-      <locale name="C">
-        <short>description for default GStreamer audiosink</short>
-        <long>Describes the selected output element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/musicaudiosink</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/musicaudiosink</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>@DEFAULT_AUDIOSINK@</default>
-      <locale name="C">
-        <short>GStreamer audiosink for Music and Movies</short>
-        <long>GStreamer can play audio using any number of output elements.  Some possible choices are osssink, esdsink and alsasink.  The audiosink can be a partial pipeline instead of just one element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/musicaudiosink_description</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/musicaudiosink_description</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>Default</default>
-      <locale name="C">
-        <short>description for GStreamer audiosink for Music and Movies</short>
-        <long>Describes the selected output element for Music and Movies.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/chataudiosink</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/chataudiosink</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>@DEFAULT_AUDIOSINK@</default>
-      <locale name="C">
-        <short>GStreamer audiosink for Audio/Video Conferencing</short>
-        <long>GStreamer can play audio using any number of output elements.  Some possible choices are osssink, esdsink and alsasink.  The audiosink can be a partial pipeline instead of just one element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/chataudiosink_description</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/chataudiosink_description</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>Default</default>
-      <locale name="C">
-        <short>description for GStreamer audiosink for Audio/Video Conferencing</short>
-        <long>Describes the selected output element for Audio/Video Conferencing.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/videosink</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/videosink</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>@DEFAULT_VIDEOSINK@</default>
-      <locale name="C">
-        <short>default GStreamer videosink</short>
-        <long>GStreamer can play video using any number of output elements.  Some possible choices are xvimagesink, ximagesink, sdlvideosink and aasink.  The videosink can be a partial pipeline instead of just one element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/audiosrc</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/audiosrc</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>@DEFAULT_AUDIOSRC@</default>
-      <locale name="C">
-        <short>default GStreamer audio source</short>
-        <long>GStreamer can record audio using any number of input elements.  Some possible choices are osssrc, esdsrc and alsasrc.  The audio source can be a partial pipeline instead of just one element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/audiosrc_description</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/audiosrc_description</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>Default</default>
-      <locale name="C">
-        <short>description for default GStreamer audiosrc</short>
-        <long>Describes the selected input element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/audiosrc_description</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/audiosrc_description</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>Default</default>
-      <locale name="C">
-        <short>description for default GStreamer audiosrc</short>
-        <long>Describes the selected input element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/videosrc</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/videosrc</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>@DEFAULT_VIDEOSRC@</default>
-      <locale name="C">
-        <short>default GStreamer video source</short>
-        <long>GStreamer can record video from any number of input elements.  Some possible choices are v4lsrc and videotestsrc. The video source can be a partial pipeline instead of just one element.</long>
-      </locale>
-    </schema>
-    <schema>
-      <key>/schemas/system/gstreamer/@GST_MAJORMINOR@/default/visualization</key>
-      <applyto>/system/gstreamer/@GST_MAJORMINOR@/default/visualization</applyto>
-      <owner>gstreamer</owner>
-      <type>string</type>
-      <default>@DEFAULT_VISUALIZER@</default>
-      <locale name="C">
-        <short>default GStreamer visualization plugin</short>
-        <long>GStreamer can put visualization plugins in a pipeline to transform audio stream in video frames. Default is goom but more visualization plugins will be ported soon. The visualization plugin can be a partial pipeline instead of just one element.</long>
-      </locale>
-    </schema>
-  </schemalist>
-</gconfschemafile>
index 2dfc0eb..f1e70eb 100644 (file)
@@ -20,13 +20,7 @@ BuildRequires:         %{gstreamer}-devel >= %{gst_minver}
 
 BuildRequires:  gcc-c++
 
-@USE_ESD_TRUE@BuildRequires: esound-devel >= 0.2.8
-@USE_ESD_TRUE@Obsoletes:     gstreamer-esd
-@USE_ESD_TRUE@
-@USE_ESD_TRUE@Provides:                gstreamer-audiosrc
-@USE_ESD_TRUE@Provides:                gstreamer-audiosink
 @USE_FLAC_TRUE@BuildRequires: flac-devel >= 1.0.3
-@USE_GCONF_TRUE@BuildRequires:         GConf2-devel
 @USE_JPEG_TRUE@BuildRequires: libjpeg-devel
 @USE_LIBCACA_TRUE@BuildRequires: libcaca-devel
 @USE_LIBDV_TRUE@BuildRequires: libdv-devel
@@ -63,9 +57,7 @@ make %{?_smp_mflags}
 %install
 rm -rf $RPM_BUILD_ROOT
 
-export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL=1
 %makeinstall
-unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
                                                                                 
 # Clean out files that should not be part of the rpm.
 rm -f $RPM_BUILD_ROOT%{_libdir}/gstreamer-%{majorminor}/*.la
@@ -79,8 +71,6 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
 rm -rf $RPM_BUILD_ROOT
 
 %post
-@USE_GCONF_TRUE@export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
-@USE_GCONF_TRUE@gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/gstreamer-%{majorminor}.schemas > /dev/null
 
 %files -f gst-plugins-good-%{majorminor}.lang
 %defattr(-, root, root)
@@ -146,14 +136,12 @@ rm -rf $RPM_BUILD_ROOT
 
 # gstreamer-plugins with external dependencies but in the main package
 @USE_LIBCACA_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstcacasink.so
-@USE_ESD_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstesd.so
 @USE_FLAC_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstflac.so
 @USE_JACK_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstjack.so
 @USE_JPEG_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstjpeg.so
 @USE_LIBPNG_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstpng.so
 @USE_OSS_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstossaudio.so
 @USE_SPEEX_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstspeex.so
-@USE_GCONF_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstgconfelements.so
 @USE_HAL_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgsthalelements.so
 @USE_SHOUT2_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstshout2.so
 @USE_AALIB_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstaasink.so
@@ -163,9 +151,6 @@ rm -rf $RPM_BUILD_ROOT
 @USE_SOUP_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstsouphttpsrc.so
 @USE_PULSE_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstpulse.so
 
-# schema files
-@USE_GCONF_TRUE@%{_sysconfdir}/gconf/schemas/gstreamer-%{majorminor}.schemas
-
 %changelog
 * Tue Jun 12 2007 Jan Schmidt <jan at fluendo dot com>
 - wavpack and qtdemux have moved from bad
index d72c8c5..4ef2754 100644 (file)
@@ -31,7 +31,7 @@
  * Sample pipeline:
  * |[
  * gst-launch videotestsrc pattern=smpte75 ! alpha method=green ! \
- *   videomixer name=mixer ! ffmpegcolorspace ! autovideosink     \
+ *   videomixer name=mixer ! videoconvert ! autovideosink     \
  *   videotestsrc pattern=snow ! mixer.
  * ]| This pipeline adds a alpha channel to the SMPTE color bars
  * with green as the transparent color and mixes the output with
@@ -125,41 +125,25 @@ enum
 };
 
 static GstStaticPadTemplate gst_alpha_src_template =
-    GST_STATIC_PAD_TEMPLATE ("src",
+GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";"
-        GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
-        GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA
-        ";" GST_VIDEO_CAPS_YUV ("Y444")
-        ";" GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR
-        ";" GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR
-        ";" GST_VIDEO_CAPS_YUV ("Y42B") ";" GST_VIDEO_CAPS_YUV ("YUY2")
-        ";" GST_VIDEO_CAPS_YUV ("YVYU") ";" GST_VIDEO_CAPS_YUV ("UYVY")
-        ";" GST_VIDEO_CAPS_YUV ("I420") ";" GST_VIDEO_CAPS_YUV ("YV12")
-        ";" GST_VIDEO_CAPS_YUV ("Y41B"))
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, "
+            "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, BGRx, xBGR, "
+            "RGBx, RGB, BGR, Y42B, YUY2, YVYU, UYVY, I420, YV12, Y41B } "))
     );
 
 static GstStaticPadTemplate gst_alpha_sink_template =
-    GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV")
-        ";" GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";" GST_VIDEO_CAPS_ABGR
-        ";" GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_YUV ("Y444")
-        ";" GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR
-        ";" GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR
-        ";" GST_VIDEO_CAPS_YUV ("Y42B") ";" GST_VIDEO_CAPS_YUV ("YUY2")
-        ";" GST_VIDEO_CAPS_YUV ("YVYU") ";" GST_VIDEO_CAPS_YUV ("UYVY")
-        ";" GST_VIDEO_CAPS_YUV ("I420") ";" GST_VIDEO_CAPS_YUV ("YV12")
-        ";" GST_VIDEO_CAPS_YUV ("Y41B")
-    )
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, "
+            "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, BGRx, xBGR, "
+            "RGBx, RGB, BGR, Y42B, YUY2, YVYU, UYVY, I420, YV12, " "Y41B } "))
     );
 
 static GstStaticCaps gst_alpha_alpha_caps =
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV")
-    ";" GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";" GST_VIDEO_CAPS_ABGR ";"
-    GST_VIDEO_CAPS_RGBA);
+GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, ARGB, BGRA, ABGR, RGBA }"));
 
 #define GST_ALPHA_LOCK(alpha) G_STMT_START { \
   GST_LOG_OBJECT (alpha, "Locking alpha from thread %p", g_thread_self ()); \
@@ -174,9 +158,9 @@ static GstStaticCaps gst_alpha_alpha_caps =
 
 static gboolean gst_alpha_start (GstBaseTransform * trans);
 static gboolean gst_alpha_get_unit_size (GstBaseTransform * btrans,
-    GstCaps * caps, guint * size);
+    GstCaps * caps, gsize * size);
 static GstCaps *gst_alpha_transform_caps (GstBaseTransform * btrans,
-    GstPadDirection direction, GstCaps * caps);
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter);
 static gboolean gst_alpha_set_caps (GstBaseTransform * btrans,
     GstCaps * incaps, GstCaps * outcaps);
 static GstFlowReturn gst_alpha_transform (GstBaseTransform * btrans,
@@ -193,7 +177,8 @@ static void gst_alpha_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 static void gst_alpha_finalize (GObject * object);
 
-GST_BOILERPLATE (GstAlpha, gst_alpha, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
+#define gst_alpha_parent_class parent_class
+G_DEFINE_TYPE (GstAlpha, gst_alpha, GST_TYPE_VIDEO_FILTER);
 
 #define GST_TYPE_ALPHA_METHOD (gst_alpha_method_get_type())
 static GType
@@ -215,32 +200,15 @@ gst_alpha_method_get_type (void)
 }
 
 static void
-gst_alpha_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "Alpha filter",
-      "Filter/Effect/Video",
-      "Adds an alpha channel to video - uniform or via chroma-keying",
-      "Wim Taymans <wim@fluendo.com>\n"
-      "Edward Hervey <edward.hervey@collabora.co.uk>\n"
-      "Jan Schmidt <thaytan@noraisin.net>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_alpha_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_alpha_src_template));
-
-  GST_DEBUG_CATEGORY_INIT (gst_alpha_debug, "alpha", 0,
-      "alpha - Element for adding alpha channel to streams");
-}
-
-static void
 gst_alpha_class_init (GstAlphaClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *btrans_class = (GstBaseTransformClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (gst_alpha_debug, "alpha", 0,
+      "alpha - Element for adding alpha channel to streams");
+
   gobject_class->set_property = gst_alpha_set_property;
   gobject_class->get_property = gst_alpha_get_property;
   gobject_class->finalize = gst_alpha_finalize;
@@ -290,6 +258,18 @@ gst_alpha_class_init (GstAlphaClass * klass)
           DEFAULT_PREFER_PASSTHROUGH,
           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "Alpha filter",
+      "Filter/Effect/Video",
+      "Adds an alpha channel to video - uniform or via chroma-keying",
+      "Wim Taymans <wim.taymans@gmail.com>\n"
+      "Edward Hervey <edward.hervey@collabora.co.uk>\n"
+      "Jan Schmidt <thaytan@noraisin.net>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_alpha_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_alpha_src_template));
+
   btrans_class->start = GST_DEBUG_FUNCPTR (gst_alpha_start);
   btrans_class->transform = GST_DEBUG_FUNCPTR (gst_alpha_transform);
   btrans_class->before_transform =
@@ -300,7 +280,7 @@ gst_alpha_class_init (GstAlphaClass * klass)
 }
 
 static void
-gst_alpha_init (GstAlpha * alpha, GstAlphaClass * klass)
+gst_alpha_init (GstAlpha * alpha)
 {
   alpha->alpha = DEFAULT_ALPHA;
   alpha->method = DEFAULT_METHOD;
@@ -458,25 +438,25 @@ gst_alpha_get_property (GObject * object, guint prop_id, GValue * value,
 
 static gboolean
 gst_alpha_get_unit_size (GstBaseTransform * btrans,
-    GstCaps * caps, guint * size)
+    GstCaps * caps, gsize * size)
 {
-  GstVideoFormat format;
-  gint width, height;
+  GstVideoInfo info;
 
-  if (!gst_video_format_parse_caps (caps, &format, &width, &height))
+  if (!gst_video_info_from_caps (&info, caps))
     return FALSE;
 
-  *size = gst_video_format_get_size (format, width, height);
+  *size = info.size;
 
-  GST_DEBUG_OBJECT (btrans, "unit size = %d for format %d w %d height %d",
-      *size, format, width, height);
+  GST_DEBUG_OBJECT (btrans, "unit size = %d for format %s w %d height %d",
+      *size, GST_VIDEO_INFO_NAME (&info), GST_VIDEO_INFO_WIDTH (&info),
+      GST_VIDEO_INFO_HEIGHT (&info));
 
   return TRUE;
 }
 
 static GstCaps *
 gst_alpha_transform_caps (GstBaseTransform * btrans,
-    GstPadDirection direction, GstCaps * caps)
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter)
 {
   GstAlpha *alpha = GST_ALPHA (btrans);
   GstCaps *ret, *tmp, *tmp2;
@@ -490,19 +470,9 @@ gst_alpha_transform_caps (GstBaseTransform * btrans,
     structure = gst_structure_copy (gst_caps_get_structure (caps, i));
 
     gst_structure_remove_field (structure, "format");
-    gst_structure_remove_field (structure, "endianness");
-    gst_structure_remove_field (structure, "depth");
-    gst_structure_remove_field (structure, "bpp");
-    gst_structure_remove_field (structure, "red_mask");
-    gst_structure_remove_field (structure, "green_mask");
-    gst_structure_remove_field (structure, "blue_mask");
-    gst_structure_remove_field (structure, "alpha_mask");
     gst_structure_remove_field (structure, "color-matrix");
     gst_structure_remove_field (structure, "chroma-site");
 
-    gst_structure_set_name (structure, "video/x-raw-yuv");
-    gst_caps_append_structure (tmp, gst_structure_copy (structure));
-    gst_structure_set_name (structure, "video/x-raw-rgb");
     gst_caps_append_structure (tmp, structure);
   }
 
@@ -531,6 +501,18 @@ gst_alpha_transform_caps (GstBaseTransform * btrans,
   GST_DEBUG_OBJECT (alpha,
       "Transformed %" GST_PTR_FORMAT " -> %" GST_PTR_FORMAT, caps, ret);
 
+  if (filter) {
+    GstCaps *intersection;
+
+    GST_DEBUG_OBJECT (alpha, "Using filter caps %" GST_PTR_FORMAT, filter);
+    intersection =
+        gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (ret);
+    ret = intersection;
+    GST_DEBUG_OBJECT (alpha, "Intersection %" GST_PTR_FORMAT, ret);
+  }
+
+
   GST_ALPHA_UNLOCK (alpha);
 
   return ret;
@@ -541,49 +523,55 @@ gst_alpha_set_caps (GstBaseTransform * btrans,
     GstCaps * incaps, GstCaps * outcaps)
 {
   GstAlpha *alpha = GST_ALPHA (btrans);
-  const gchar *matrix;
+  GstVideoInfo in_info, out_info;
   gboolean passthrough;
 
-  GST_ALPHA_LOCK (alpha);
-
-  if (!gst_video_format_parse_caps (incaps, &alpha->in_format,
-          &alpha->width, &alpha->height) ||
-      !gst_video_format_parse_caps (outcaps, &alpha->out_format,
-          &alpha->width, &alpha->height)) {
-    GST_WARNING_OBJECT (alpha,
-        "Failed to parse caps %" GST_PTR_FORMAT " -> %" GST_PTR_FORMAT, incaps,
-        outcaps);
-    GST_ALPHA_UNLOCK (alpha);
-    return FALSE;
-  }
+  if (!gst_video_info_from_caps (&in_info, incaps) ||
+      !gst_video_info_from_caps (&out_info, outcaps))
+    goto invalid_format;
 
-  matrix = gst_video_parse_caps_color_matrix (incaps);
-  alpha->in_sdtv = matrix ? g_str_equal (matrix, "sdtv") : TRUE;
+  GST_ALPHA_LOCK (alpha);
 
-  matrix = gst_video_parse_caps_color_matrix (outcaps);
-  alpha->out_sdtv = matrix ? g_str_equal (matrix, "sdtv") : TRUE;
+  alpha->in_sdtv = in_info.colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT601;
+  alpha->out_sdtv = out_info.colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT601;
 
   passthrough = alpha->prefer_passthrough &&
-      alpha->in_format == alpha->out_format && alpha->in_sdtv == alpha->out_sdtv
-      && alpha->method == ALPHA_METHOD_SET && alpha->alpha == 1.0;
+      GST_VIDEO_INFO_FORMAT (&in_info) == GST_VIDEO_INFO_FORMAT (&out_info)
+      && alpha->in_sdtv == alpha->out_sdtv && alpha->method == ALPHA_METHOD_SET
+      && alpha->alpha == 1.0;
 
   GST_DEBUG_OBJECT (alpha,
       "Setting caps %" GST_PTR_FORMAT " -> %" GST_PTR_FORMAT
       " (passthrough: %d)", incaps, outcaps, passthrough);
   gst_base_transform_set_passthrough (btrans, passthrough);
 
-  if (!gst_alpha_set_process_function (alpha) && !passthrough) {
-    GST_WARNING_OBJECT (alpha,
-        "No processing function for this caps and no passthrough mode");
-    GST_ALPHA_UNLOCK (alpha);
-    return FALSE;
-  }
+  alpha->in_info = in_info;
+  alpha->out_info = out_info;
+
+  if (!gst_alpha_set_process_function (alpha) && !passthrough)
+    goto no_process;
 
   gst_alpha_init_params (alpha);
 
   GST_ALPHA_UNLOCK (alpha);
 
   return TRUE;
+
+  /* ERRORS */
+invalid_format:
+  {
+    GST_WARNING_OBJECT (alpha,
+        "Failed to parse caps %" GST_PTR_FORMAT " -> %" GST_PTR_FORMAT, incaps,
+        outcaps);
+    return FALSE;
+  }
+no_process:
+  {
+    GST_WARNING_OBJECT (alpha,
+        "No processing function for this caps and no passthrough mode");
+    GST_ALPHA_UNLOCK (alpha);
+    return FALSE;
+  }
 }
 
 /* based on http://www.cs.utah.edu/~michael/chroma/
@@ -666,27 +654,28 @@ chroma_keying_yuv (gint a, gint * y, gint * u,
 #define APPLY_MATRIX(m,o,v1,v2,v3) ((m[o*4] * v1 + m[o*4+1] * v2 + m[o*4+2] * v3 + m[o*4+3]) >> 8)
 
 static void
-gst_alpha_set_argb_ayuv (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_set_argb_ayuv (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
   gint s_alpha = CLAMP ((gint) (alpha->alpha * 256), 0, 256);
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint i, j;
   gint matrix[12];
   gint y, u, v;
   gint o[4];
 
-  o[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 3, width,
-      height);
-  o[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
-  o[2] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  o[3] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  o[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 3);
+  o[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
+  o[2] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  o[3] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
 
   memcpy (matrix,
       alpha->out_sdtv ? cog_rgb_to_ycbcr_matrix_8bit_sdtv :
@@ -711,9 +700,12 @@ gst_alpha_set_argb_ayuv (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_chroma_key_argb_ayuv (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_chroma_key_argb_ayuv (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint i, j;
   gint a, y, u, v;
   gint r, g, b;
@@ -729,18 +721,16 @@ gst_alpha_chroma_key_argb_ayuv (const guint8 * src, guint8 * dest, gint width,
   gint matrix[12];
   gint o[4];
 
-  o[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 3, width,
-      height);
-  o[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
-  o[2] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  o[3] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  o[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 3);
+  o[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
+  o[2] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  o[3] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
 
   smin = 128 - alpha->black_sensitivity;
   smax = 128 + alpha->white_sensitivity;
@@ -779,38 +769,31 @@ gst_alpha_chroma_key_argb_ayuv (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_set_argb_argb (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_set_argb_argb (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint s_alpha = CLAMP ((gint) (alpha->alpha * 256), 0, 256);
   gint i, j;
   gint p[4], o[4];
 
-  p[0] =
-      gst_video_format_get_component_offset (alpha->out_format, 3, width,
-      height);
-  p[1] =
-      gst_video_format_get_component_offset (alpha->out_format, 0, width,
-      height);
-  p[2] =
-      gst_video_format_get_component_offset (alpha->out_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->out_format, 2, width,
-      height);
-
-  o[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 3, width,
-      height);
-  o[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
-  o[2] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  o[3] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 3);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 0);
+  p[2] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 2);
+
+  o[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 3);
+  o[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
+  o[2] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  o[3] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
 
   for (i = 0; i < height; i++) {
     for (j = 0; j < width; j++) {
@@ -827,9 +810,12 @@ gst_alpha_set_argb_argb (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_chroma_key_argb_argb (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_chroma_key_argb_argb (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint i, j;
   gint a, y, u, v;
   gint r, g, b;
@@ -845,31 +831,21 @@ gst_alpha_chroma_key_argb_argb (const guint8 * src, guint8 * dest, gint width,
   gint matrix[12], matrix2[12];
   gint p[4], o[4];
 
-  p[0] =
-      gst_video_format_get_component_offset (alpha->out_format, 3, width,
-      height);
-  p[1] =
-      gst_video_format_get_component_offset (alpha->out_format, 0, width,
-      height);
-  p[2] =
-      gst_video_format_get_component_offset (alpha->out_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->out_format, 2, width,
-      height);
-
-  o[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 3, width,
-      height);
-  o[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
-  o[2] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  o[3] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 3);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 0);
+  p[2] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 2);
+
+  o[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 3);
+  o[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
+  o[2] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  o[3] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
 
   smin = 128 - alpha->black_sensitivity;
   smax = 128 + alpha->white_sensitivity;
@@ -911,27 +887,28 @@ gst_alpha_chroma_key_argb_argb (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_set_ayuv_argb (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_set_ayuv_argb (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint s_alpha = CLAMP ((gint) (alpha->alpha * 256), 0, 256);
   gint y, x;
   gint matrix[12];
   gint r, g, b;
   gint p[4];
 
-  p[0] =
-      gst_video_format_get_component_offset (alpha->out_format, 3, width,
-      height);
-  p[1] =
-      gst_video_format_get_component_offset (alpha->out_format, 0, width,
-      height);
-  p[2] =
-      gst_video_format_get_component_offset (alpha->out_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->out_format, 2, width,
-      height);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 3);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 0);
+  p[2] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 2);
 
   memcpy (matrix,
       alpha->in_sdtv ? cog_ycbcr_to_rgb_matrix_8bit_sdtv :
@@ -956,9 +933,12 @@ gst_alpha_set_ayuv_argb (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_chroma_key_ayuv_argb (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_chroma_key_ayuv_argb (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint i, j;
   gint a, y, u, v;
   gint r, g, b;
@@ -974,18 +954,16 @@ gst_alpha_chroma_key_ayuv_argb (const guint8 * src, guint8 * dest, gint width,
   gint matrix[12];
   gint p[4];
 
-  p[0] =
-      gst_video_format_get_component_offset (alpha->out_format, 3, width,
-      height);
-  p[1] =
-      gst_video_format_get_component_offset (alpha->out_format, 0, width,
-      height);
-  p[2] =
-      gst_video_format_get_component_offset (alpha->out_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->out_format, 2, width,
-      height);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 3);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 0);
+  p[2] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 2);
 
   smin = 128 - alpha->black_sensitivity;
   smax = 128 + alpha->white_sensitivity;
@@ -1024,12 +1002,21 @@ gst_alpha_chroma_key_ayuv_argb (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_set_ayuv_ayuv (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_set_ayuv_ayuv (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint s_alpha = CLAMP ((gint) (alpha->alpha * 256), 0, 256);
   gint y, x;
 
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
   if (alpha->in_sdtv == alpha->out_sdtv) {
     for (y = 0; y < height; y++) {
       for (x = 0; x < width; x++) {
@@ -1064,9 +1051,12 @@ gst_alpha_set_ayuv_ayuv (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_chroma_key_ayuv_ayuv (const guint8 * src, guint8 * dest,
-    gint width, gint height, GstAlpha * alpha)
+gst_alpha_chroma_key_ayuv_ayuv (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint i, j;
   gint a, y, u, v;
   gint smin, smax;
@@ -1079,6 +1069,12 @@ gst_alpha_chroma_key_ayuv_ayuv (const guint8 * src, guint8 * dest,
   guint8 kfgy_scale = alpha->kfgy_scale;
   guint noise_level2 = alpha->noise_level2;
 
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
   smin = 128 - alpha->black_sensitivity;
   smax = 128 + alpha->white_sensitivity;
 
@@ -1140,9 +1136,12 @@ gst_alpha_chroma_key_ayuv_ayuv (const guint8 * src, guint8 * dest,
 }
 
 static void
-gst_alpha_set_rgb_ayuv (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_set_rgb_ayuv (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint s_alpha = CLAMP ((gint) (alpha->alpha * 255), 0, 255);
   gint i, j;
   gint matrix[12];
@@ -1150,17 +1149,16 @@ gst_alpha_set_rgb_ayuv (const guint8 * src, guint8 * dest, gint width,
   gint o[3];
   gint bpp;
 
-  bpp = gst_video_format_get_pixel_stride (alpha->in_format, 0);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
 
-  o[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
-  o[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  o[2] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  bpp = GST_VIDEO_FRAME_COMP_PSTRIDE (in_frame, 0);
+  o[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
+  o[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  o[2] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
 
   memcpy (matrix,
       alpha->out_sdtv ? cog_rgb_to_ycbcr_matrix_8bit_sdtv :
@@ -1185,9 +1183,12 @@ gst_alpha_set_rgb_ayuv (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_chroma_key_rgb_ayuv (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_chroma_key_rgb_ayuv (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint i, j;
   gint a, y, u, v;
   gint r, g, b;
@@ -1204,17 +1205,17 @@ gst_alpha_chroma_key_rgb_ayuv (const guint8 * src, guint8 * dest, gint width,
   gint o[3];
   gint bpp;
 
-  bpp = gst_video_format_get_pixel_stride (alpha->in_format, 0);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
 
-  o[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
-  o[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  o[2] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
+  bpp = GST_VIDEO_FRAME_COMP_PSTRIDE (in_frame, 0);
+
+  o[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
+  o[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  o[2] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
 
   smin = 128 - alpha->black_sensitivity;
   smax = 128 + alpha->white_sensitivity;
@@ -1253,38 +1254,33 @@ gst_alpha_chroma_key_rgb_ayuv (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_set_rgb_argb (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_set_rgb_argb (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint s_alpha = CLAMP ((gint) (alpha->alpha * 255), 0, 255);
   gint i, j;
   gint p[4], o[3];
   gint bpp;
 
-  bpp = gst_video_format_get_pixel_stride (alpha->in_format, 0);
-
-  o[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
-  o[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  o[2] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
-
-  p[0] =
-      gst_video_format_get_component_offset (alpha->out_format, 3, width,
-      height);
-  p[1] =
-      gst_video_format_get_component_offset (alpha->out_format, 0, width,
-      height);
-  p[2] =
-      gst_video_format_get_component_offset (alpha->out_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->out_format, 2, width,
-      height);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  bpp = GST_VIDEO_FRAME_COMP_PSTRIDE (in_frame, 0);
+
+  o[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
+  o[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  o[2] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 3);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 0);
+  p[2] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 2);
 
   for (i = 0; i < height; i++) {
     for (j = 0; j < width; j++) {
@@ -1301,9 +1297,12 @@ gst_alpha_set_rgb_argb (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_chroma_key_rgb_argb (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_chroma_key_rgb_argb (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint i, j;
   gint a, y, u, v;
   gint r, g, b;
@@ -1320,30 +1319,22 @@ gst_alpha_chroma_key_rgb_argb (const guint8 * src, guint8 * dest, gint width,
   gint p[4], o[3];
   gint bpp;
 
-  bpp = gst_video_format_get_pixel_stride (alpha->in_format, 0);
-
-  o[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
-  o[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  o[2] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
-
-  p[0] =
-      gst_video_format_get_component_offset (alpha->out_format, 3, width,
-      height);
-  p[1] =
-      gst_video_format_get_component_offset (alpha->out_format, 0, width,
-      height);
-  p[2] =
-      gst_video_format_get_component_offset (alpha->out_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->out_format, 2, width,
-      height);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  bpp = GST_VIDEO_FRAME_COMP_PSTRIDE (in_frame, 0);
+
+  o[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
+  o[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  o[2] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 3);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 0);
+  p[2] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 2);
 
   smin = 128 - alpha->black_sensitivity;
   smax = 128 + alpha->white_sensitivity;
@@ -1385,9 +1376,12 @@ gst_alpha_chroma_key_rgb_argb (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_set_planar_yuv_ayuv (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_set_planar_yuv_ayuv (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint b_alpha = CLAMP ((gint) (alpha->alpha * 255), 0, 255);
   const guint8 *srcY, *srcY_tmp;
   const guint8 *srcU, *srcU_tmp;
@@ -1396,18 +1390,20 @@ gst_alpha_set_planar_yuv_ayuv (const guint8 * src, guint8 * dest, gint width,
   gint y_stride, uv_stride;
   gint v_subs, h_subs;
 
-  y_stride = gst_video_format_get_row_stride (alpha->in_format, 0, width);
-  uv_stride = gst_video_format_get_row_stride (alpha->in_format, 1, width);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  y_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 0);
+  uv_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 1);
 
   srcY_tmp = srcY = src;
-  srcU_tmp = srcU =
-      src + gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  srcV_tmp = srcV =
-      src + gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
-
-  switch (alpha->in_format) {
+  srcU_tmp = srcU = src + GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  srcV_tmp = srcV = src + GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
+
+  switch (GST_VIDEO_FRAME_FORMAT (in_frame)) {
     case GST_VIDEO_FORMAT_I420:
     case GST_VIDEO_FORMAT_YV12:
       v_subs = h_subs = 2;
@@ -1494,9 +1490,12 @@ gst_alpha_set_planar_yuv_ayuv (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_chroma_key_planar_yuv_ayuv (const guint8 * src, guint8 * dest,
-    gint width, gint height, GstAlpha * alpha)
+gst_alpha_chroma_key_planar_yuv_ayuv (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint b_alpha = CLAMP ((gint) (alpha->alpha * 255), 0, 255);
   const guint8 *srcY, *srcY_tmp;
   const guint8 *srcU, *srcU_tmp;
@@ -1515,18 +1514,20 @@ gst_alpha_chroma_key_planar_yuv_ayuv (const guint8 * src, guint8 * dest,
   guint8 kfgy_scale = alpha->kfgy_scale;
   guint noise_level2 = alpha->noise_level2;
 
-  y_stride = gst_video_format_get_row_stride (alpha->in_format, 0, width);
-  uv_stride = gst_video_format_get_row_stride (alpha->in_format, 1, width);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  y_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 0);
+  uv_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 1);
 
   srcY_tmp = srcY = src;
-  srcU_tmp = srcU =
-      src + gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  srcV_tmp = srcV =
-      src + gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
-
-  switch (alpha->in_format) {
+  srcU_tmp = srcU = src + GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  srcV_tmp = srcV = src + GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
+
+  switch (GST_VIDEO_FRAME_FORMAT (in_frame)) {
     case GST_VIDEO_FORMAT_I420:
     case GST_VIDEO_FORMAT_YV12:
       v_subs = h_subs = 2;
@@ -1628,9 +1629,12 @@ gst_alpha_chroma_key_planar_yuv_ayuv (const guint8 * src, guint8 * dest,
 }
 
 static void
-gst_alpha_set_planar_yuv_argb (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_set_planar_yuv_argb (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint b_alpha = CLAMP ((gint) (alpha->alpha * 255), 0, 255);
   const guint8 *srcY, *srcY_tmp;
   const guint8 *srcU, *srcU_tmp;
@@ -1643,31 +1647,25 @@ gst_alpha_set_planar_yuv_argb (const guint8 * src, guint8 * dest, gint width,
   gint r, g, b;
   gint p[4];
 
-  p[0] =
-      gst_video_format_get_component_offset (alpha->out_format, 3, width,
-      height);
-  p[1] =
-      gst_video_format_get_component_offset (alpha->out_format, 0, width,
-      height);
-  p[2] =
-      gst_video_format_get_component_offset (alpha->out_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->out_format, 2, width,
-      height);
-
-  y_stride = gst_video_format_get_row_stride (alpha->in_format, 0, width);
-  uv_stride = gst_video_format_get_row_stride (alpha->in_format, 1, width);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 3);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 0);
+  p[2] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 2);
+
+  y_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 0);
+  uv_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 1);
 
   srcY_tmp = srcY = src;
-  srcU_tmp = srcU =
-      src + gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  srcV_tmp = srcV =
-      src + gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
-
-  switch (alpha->in_format) {
+  srcU_tmp = srcU = src + GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  srcV_tmp = srcV = src + GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
+
+  switch (GST_VIDEO_FRAME_FORMAT (in_frame)) {
     case GST_VIDEO_FORMAT_I420:
     case GST_VIDEO_FORMAT_YV12:
       v_subs = h_subs = 2;
@@ -1727,9 +1725,12 @@ gst_alpha_set_planar_yuv_argb (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_chroma_key_planar_yuv_argb (const guint8 * src, guint8 * dest,
-    gint width, gint height, GstAlpha * alpha)
+gst_alpha_chroma_key_planar_yuv_argb (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint b_alpha = CLAMP ((gint) (alpha->alpha * 255), 0, 255);
   const guint8 *srcY, *srcY_tmp;
   const guint8 *srcU, *srcU_tmp;
@@ -1751,31 +1752,25 @@ gst_alpha_chroma_key_planar_yuv_argb (const guint8 * src, guint8 * dest,
   gint matrix[12];
   gint p[4];
 
-  p[0] =
-      gst_video_format_get_component_offset (alpha->out_format, 3, width,
-      height);
-  p[1] =
-      gst_video_format_get_component_offset (alpha->out_format, 0, width,
-      height);
-  p[2] =
-      gst_video_format_get_component_offset (alpha->out_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->out_format, 2, width,
-      height);
-
-  y_stride = gst_video_format_get_row_stride (alpha->in_format, 0, width);
-  uv_stride = gst_video_format_get_row_stride (alpha->in_format, 1, width);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 3);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 0);
+  p[2] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 2);
+
+  y_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 0);
+  uv_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 1);
 
   srcY_tmp = srcY = src;
-  srcU_tmp = srcU =
-      src + gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  srcV_tmp = srcV =
-      src + gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
-
-  switch (alpha->in_format) {
+  srcU_tmp = srcU = src + GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  srcV_tmp = srcV = src + GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
+
+  switch (GST_VIDEO_FRAME_FORMAT (in_frame)) {
     case GST_VIDEO_FORMAT_I420:
     case GST_VIDEO_FORMAT_YV12:
       v_subs = h_subs = 2;
@@ -1842,9 +1837,12 @@ gst_alpha_chroma_key_planar_yuv_argb (const guint8 * src, guint8 * dest,
 }
 
 static void
-gst_alpha_set_packed_422_ayuv (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_set_packed_422_ayuv (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint s_alpha = CLAMP ((gint) (alpha->alpha * 255), 0, 255);
   gint i, j;
   gint y, u, v;
@@ -1852,18 +1850,18 @@ gst_alpha_set_packed_422_ayuv (const guint8 * src, guint8 * dest, gint width,
   gint src_stride;
   const guint8 *src_tmp;
 
-  src_stride = gst_video_format_get_row_stride (alpha->in_format, 0, width);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
 
-  p[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
+  src_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 0);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
   p[2] = p[0] + 2;
-  p[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
 
   if (alpha->in_sdtv != alpha->out_sdtv) {
     gint matrix[12];
@@ -1961,9 +1959,12 @@ gst_alpha_set_packed_422_ayuv (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_chroma_key_packed_422_ayuv (const guint8 * src, guint8 * dest,
-    gint width, gint height, GstAlpha * alpha)
+gst_alpha_chroma_key_packed_422_ayuv (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint i, j;
   gint a, y, u, v;
   gint smin, smax;
@@ -1979,18 +1980,18 @@ gst_alpha_chroma_key_packed_422_ayuv (const guint8 * src, guint8 * dest,
   gint src_stride;
   const guint8 *src_tmp;
 
-  src_stride = gst_video_format_get_row_stride (alpha->in_format, 0, width);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
 
-  p[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  src_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 0);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
   p[2] = p[0] + 2;
-  p[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
 
   smin = 128 - alpha->black_sensitivity;
   smax = 128 + alpha->white_sensitivity;
@@ -2113,9 +2114,12 @@ gst_alpha_chroma_key_packed_422_ayuv (const guint8 * src, guint8 * dest,
 }
 
 static void
-gst_alpha_set_packed_422_argb (const guint8 * src, guint8 * dest, gint width,
-    gint height, GstAlpha * alpha)
+gst_alpha_set_packed_422_argb (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint s_alpha = CLAMP ((gint) (alpha->alpha * 255), 0, 255);
   gint i, j;
   gint p[4], o[4];
@@ -2124,31 +2128,23 @@ gst_alpha_set_packed_422_argb (const guint8 * src, guint8 * dest, gint width,
   gint matrix[12];
   gint r, g, b;
 
-  src_stride = gst_video_format_get_row_stride (alpha->in_format, 0, width);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  src_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 0);
 
-  o[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
+  o[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
   o[2] = o[0] + 2;
-  o[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  o[3] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
-
-  p[0] =
-      gst_video_format_get_component_offset (alpha->out_format, 3, width,
-      height);
-  p[1] =
-      gst_video_format_get_component_offset (alpha->out_format, 0, width,
-      height);
-  p[2] =
-      gst_video_format_get_component_offset (alpha->out_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->out_format, 2, width,
-      height);
+  o[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  o[3] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 3);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 0);
+  p[2] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 2);
 
   memcpy (matrix,
       alpha->in_sdtv ? cog_ycbcr_to_rgb_matrix_8bit_sdtv :
@@ -2198,9 +2194,12 @@ gst_alpha_set_packed_422_argb (const guint8 * src, guint8 * dest, gint width,
 }
 
 static void
-gst_alpha_chroma_key_packed_422_argb (const guint8 * src, guint8 * dest,
-    gint width, gint height, GstAlpha * alpha)
+gst_alpha_chroma_key_packed_422_argb (const GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame, GstAlpha * alpha)
 {
+  const guint8 *src;
+  guint8 *dest;
+  gint width, height;
   gint i, j;
   gint a, y, u, v;
   gint r, g, b;
@@ -2218,31 +2217,23 @@ gst_alpha_chroma_key_packed_422_argb (const guint8 * src, guint8 * dest,
   const guint8 *src_tmp;
   gint matrix[12];
 
-  src_stride = gst_video_format_get_row_stride (alpha->in_format, 0, width);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
+
+  src_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 0);
 
-  o[0] =
-      gst_video_format_get_component_offset (alpha->in_format, 0, width,
-      height);
+  o[0] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 0);
   o[2] = o[0] + 2;
-  o[1] =
-      gst_video_format_get_component_offset (alpha->in_format, 1, width,
-      height);
-  o[3] =
-      gst_video_format_get_component_offset (alpha->in_format, 2, width,
-      height);
-
-  p[0] =
-      gst_video_format_get_component_offset (alpha->out_format, 3, width,
-      height);
-  p[1] =
-      gst_video_format_get_component_offset (alpha->out_format, 0, width,
-      height);
-  p[2] =
-      gst_video_format_get_component_offset (alpha->out_format, 1, width,
-      height);
-  p[3] =
-      gst_video_format_get_component_offset (alpha->out_format, 2, width,
-      height);
+  o[1] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 1);
+  o[3] = GST_VIDEO_FRAME_COMP_OFFSET (in_frame, 2);
+
+  p[0] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 3);
+  p[1] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 0);
+  p[2] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 1);
+  p[3] = GST_VIDEO_FRAME_COMP_OFFSET (out_frame, 2);
 
   memcpy (matrix,
       alpha->in_sdtv ? cog_ycbcr_to_rgb_matrix_8bit_sdtv :
@@ -2332,23 +2323,27 @@ gst_alpha_init_params (GstAlpha * alpha)
   gfloat tmp;
   gfloat tmp1, tmp2;
   gfloat y;
+  const GstVideoFormatInfo *in_info, *out_info;
   const gint *matrix;
 
+  in_info = alpha->in_info.finfo;
+  out_info = alpha->out_info.finfo;
+
   /* RGB->RGB: convert to SDTV YUV, chroma keying, convert back
    * YUV->RGB: chroma keying, convert to RGB
    * RGB->YUV: convert to YUV, chroma keying
    * YUV->YUV: convert matrix, chroma keying
    */
-  if (gst_video_format_is_rgb (alpha->in_format)
-      && gst_video_format_is_rgb (alpha->out_format))
+  if (GST_VIDEO_FORMAT_INFO_IS_RGB (in_info)
+      && GST_VIDEO_FORMAT_INFO_IS_RGB (out_info))
     matrix = cog_rgb_to_ycbcr_matrix_8bit_sdtv;
-  else if (gst_video_format_is_yuv (alpha->in_format)
-      && gst_video_format_is_rgb (alpha->out_format))
+  else if (GST_VIDEO_FORMAT_INFO_IS_YUV (in_info)
+      && GST_VIDEO_FORMAT_INFO_IS_RGB (out_info))
     matrix =
         (alpha->in_sdtv) ? cog_rgb_to_ycbcr_matrix_8bit_sdtv :
         cog_rgb_to_ycbcr_matrix_8bit_hdtv;
-  else if (gst_video_format_is_rgb (alpha->in_format)
-      && gst_video_format_is_yuv (alpha->out_format))
+  else if (GST_VIDEO_FORMAT_INFO_IS_RGB (in_info)
+      && GST_VIDEO_FORMAT_INFO_IS_YUV (out_info))
     matrix =
         (alpha->out_sdtv) ? cog_rgb_to_ycbcr_matrix_8bit_sdtv :
         cog_rgb_to_ycbcr_matrix_8bit_hdtv;
@@ -2400,9 +2395,9 @@ gst_alpha_set_process_function (GstAlpha * alpha)
 
   switch (alpha->method) {
     case ALPHA_METHOD_SET:
-      switch (alpha->out_format) {
+      switch (GST_VIDEO_INFO_FORMAT (&alpha->out_info)) {
         case GST_VIDEO_FORMAT_AYUV:
-          switch (alpha->in_format) {
+          switch (GST_VIDEO_INFO_FORMAT (&alpha->in_info)) {
             case GST_VIDEO_FORMAT_AYUV:
               alpha->process = gst_alpha_set_ayuv_ayuv;
               break;
@@ -2440,7 +2435,7 @@ gst_alpha_set_process_function (GstAlpha * alpha)
         case GST_VIDEO_FORMAT_ABGR:
         case GST_VIDEO_FORMAT_RGBA:
         case GST_VIDEO_FORMAT_BGRA:
-          switch (alpha->in_format) {
+          switch (GST_VIDEO_INFO_FORMAT (&alpha->in_info)) {
             case GST_VIDEO_FORMAT_AYUV:
               alpha->process = gst_alpha_set_ayuv_argb;
               break;
@@ -2482,9 +2477,9 @@ gst_alpha_set_process_function (GstAlpha * alpha)
     case ALPHA_METHOD_GREEN:
     case ALPHA_METHOD_BLUE:
     case ALPHA_METHOD_CUSTOM:
-      switch (alpha->out_format) {
+      switch (GST_VIDEO_INFO_FORMAT (&alpha->out_info)) {
         case GST_VIDEO_FORMAT_AYUV:
-          switch (alpha->in_format) {
+          switch (GST_VIDEO_INFO_FORMAT (&alpha->in_info)) {
             case GST_VIDEO_FORMAT_AYUV:
               alpha->process = gst_alpha_chroma_key_ayuv_ayuv;
               break;
@@ -2522,7 +2517,7 @@ gst_alpha_set_process_function (GstAlpha * alpha)
         case GST_VIDEO_FORMAT_ABGR:
         case GST_VIDEO_FORMAT_RGBA:
         case GST_VIDEO_FORMAT_BGRA:
-          switch (alpha->in_format) {
+          switch (GST_VIDEO_INFO_FORMAT (&alpha->in_info)) {
             case GST_VIDEO_FORMAT_AYUV:
               alpha->process = gst_alpha_chroma_key_ayuv_argb;
               break;
@@ -2596,25 +2591,48 @@ static GstFlowReturn
 gst_alpha_transform (GstBaseTransform * btrans, GstBuffer * in, GstBuffer * out)
 {
   GstAlpha *alpha = GST_ALPHA (btrans);
-  gint width, height;
+  GstVideoFrame in_frame, out_frame;
 
   GST_ALPHA_LOCK (alpha);
 
-  if (G_UNLIKELY (!alpha->process)) {
-    GST_ERROR_OBJECT (alpha, "Not negotiated yet");
-    GST_ALPHA_UNLOCK (alpha);
-    return GST_FLOW_NOT_NEGOTIATED;
-  }
+  if (G_UNLIKELY (!alpha->process))
+    goto not_negotiated;
+
+  if (!gst_video_frame_map (&in_frame, &alpha->in_info, in, GST_MAP_READ))
+    goto invalid_in;
+
+  if (!gst_video_frame_map (&out_frame, &alpha->out_info, out, GST_MAP_WRITE))
+    goto invalid_out;
 
-  width = alpha->width;
-  height = alpha->height;
+  alpha->process (&in_frame, &out_frame, alpha);
 
-  alpha->process (GST_BUFFER_DATA (in),
-      GST_BUFFER_DATA (out), width, height, alpha);
+  gst_video_frame_unmap (&out_frame);
+  gst_video_frame_unmap (&in_frame);
 
   GST_ALPHA_UNLOCK (alpha);
 
   return GST_FLOW_OK;
+
+  /* ERRORS */
+not_negotiated:
+  {
+    GST_ERROR_OBJECT (alpha, "Not negotiated yet");
+    GST_ALPHA_UNLOCK (alpha);
+    return GST_FLOW_NOT_NEGOTIATED;
+  }
+invalid_in:
+  {
+    GST_ERROR_OBJECT (alpha, "Invalid input frame");
+    GST_ALPHA_UNLOCK (alpha);
+    return GST_FLOW_OK;
+  }
+invalid_out:
+  {
+    GST_ERROR_OBJECT (alpha, "Invalid output frame");
+    gst_video_frame_unmap (&in_frame);
+    GST_ALPHA_UNLOCK (alpha);
+    return GST_FLOW_OK;
+  }
 }
 
 static gboolean
index 4402557..6cae928 100644 (file)
@@ -72,8 +72,7 @@ struct _GstAlpha
   /* caps */
   GStaticMutex lock;
 
-  GstVideoFormat in_format, out_format;
-  gint width, height;
+  GstVideoInfo in_info, out_info;
   gboolean in_sdtv, out_sdtv;
 
   /* properties */
@@ -93,7 +92,7 @@ struct _GstAlpha
   gboolean prefer_passthrough;
 
   /* processing function */
-  void (*process) (const guint8 *src, guint8 *dest, gint width, gint height, GstAlpha *alpha);
+  void (*process) (const GstVideoFrame *in_frame, GstVideoFrame *out_frame, GstAlpha *alpha);
 
   /* precalculated values for chroma keying */
   gint8 cb, cr;
index 2c9eb4a..66e2c33 100644 (file)
@@ -26,8 +26,8 @@
  *
  * Sample pipeline:
  * |[
- * gst-launch videotestsrc ! "video/x-raw-yuv,format=(fourcc)AYUV" ! \
- *   alphacolor ! "video/x-raw-rgb" ! ffmpegcolorspace ! autovideosink
+ * gst-launch videotestsrc ! "video/x-raw,format=(fourcc)AYUV" ! \
+ *   alphacolor ! videoconvert ! autovideosink
  * ]|
  */
 
@@ -49,50 +49,43 @@ GST_DEBUG_CATEGORY_STATIC (alpha_color_debug);
 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_BGRA ";"
-        GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_ABGR ";"
-        GST_VIDEO_CAPS_YUV ("AYUV"))
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ RGBA, BGRA, ARGB, ABGR, AYUV }"))
     );
 
 static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_BGRA ";"
-        GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_ABGR ";"
-        GST_VIDEO_CAPS_YUV ("AYUV"))
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ RGBA, BGRA, ARGB, ABGR, AYUV }"))
     );
 
-GST_BOILERPLATE (GstAlphaColor, gst_alpha_color, GstVideoFilter,
-    GST_TYPE_VIDEO_FILTER);
+G_DEFINE_TYPE (GstAlphaColor, gst_alpha_color, GST_TYPE_VIDEO_FILTER);
 
 static GstCaps *gst_alpha_color_transform_caps (GstBaseTransform * btrans,
-    GstPadDirection direction, GstCaps * caps);
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter);
 static gboolean gst_alpha_color_set_caps (GstBaseTransform * btrans,
     GstCaps * incaps, GstCaps * outcaps);
 static GstFlowReturn gst_alpha_color_transform_ip (GstBaseTransform * btrans,
     GstBuffer * inbuf);
 
 static void
-gst_alpha_color_base_init (gpointer g_class)
+gst_alpha_color_class_init (GstAlphaColorClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
+  GstBaseTransformClass *gstbasetransform_class =
+      (GstBaseTransformClass *) klass;
 
-  gst_element_class_set_details_simple (element_class, "Alpha color filter",
+  GST_DEBUG_CATEGORY_INIT (alpha_color_debug, "alphacolor", 0,
+      "ARGB<->AYUV colorspace conversion preserving the alpha channels");
+
+  gst_element_class_set_details_simple (gstelement_class, "Alpha color filter",
       "Filter/Converter/Video",
       "ARGB from/to AYUV colorspace conversion preserving the alpha channel",
-      "Wim Taymans <wim@fluendo.com>");
+      "Wim Taymans <wim.taymans@gmail.com>");
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&sink_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&src_template));
-}
-
-static void
-gst_alpha_color_class_init (GstAlphaColorClass * klass)
-{
-  GstBaseTransformClass *gstbasetransform_class =
-      (GstBaseTransformClass *) klass;
 
   gstbasetransform_class->transform_caps =
       GST_DEBUG_FUNCPTR (gst_alpha_color_transform_caps);
@@ -100,13 +93,10 @@ gst_alpha_color_class_init (GstAlphaColorClass * klass)
       GST_DEBUG_FUNCPTR (gst_alpha_color_set_caps);
   gstbasetransform_class->transform_ip =
       GST_DEBUG_FUNCPTR (gst_alpha_color_transform_ip);
-
-  GST_DEBUG_CATEGORY_INIT (alpha_color_debug, "alphacolor", 0,
-      "ARGB<->AYUV colorspace conversion preserving the alpha channels");
 }
 
 static void
-gst_alpha_color_init (GstAlphaColor * alpha, GstAlphaColorClass * g_class)
+gst_alpha_color_init (GstAlphaColor * alpha)
 {
   GstBaseTransform *btrans = GST_BASE_TRANSFORM (alpha);
 
@@ -115,7 +105,7 @@ gst_alpha_color_init (GstAlphaColor * alpha, GstAlphaColorClass * g_class)
 
 static GstCaps *
 gst_alpha_color_transform_caps (GstBaseTransform * btrans,
-    GstPadDirection direction, GstCaps * caps)
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter)
 {
   const GstCaps *tmpl_caps = NULL;
   GstCaps *result = NULL, *local_caps = NULL;
@@ -161,6 +151,18 @@ gst_alpha_color_transform_caps (GstBaseTransform * btrans,
   GST_LOG_OBJECT (btrans, "transformed %" GST_PTR_FORMAT " to %" GST_PTR_FORMAT,
       caps, result);
 
+  if (filter) {
+    GstCaps *intersection;
+
+    GST_DEBUG_OBJECT (btrans, "Using filter caps %" GST_PTR_FORMAT, filter);
+    intersection =
+        gst_caps_intersect_full (filter, result, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (result);
+    result = intersection;
+    GST_DEBUG_OBJECT (btrans, "Intersection %" GST_PTR_FORMAT, result);
+  }
+
+
   return result;
 }
 
@@ -203,13 +205,18 @@ static const gint cog_ycbcr_hdtv_to_ycbcr_sdtv_matrix_8bit[] = {
 
 #define DEFINE_ARGB_AYUV_FUNCTIONS(name, A, R, G, B) \
 static void \
-transform_##name##_ayuv (guint8 * data, gint size, const gint *matrix) \
+transform_##name##_ayuv (GstVideoFrame * frame, const gint *matrix) \
 { \
+  guint8 *data; \
+  gsize size; \
   gint y, u, v; \
   gint yc[4]; \
   gint uc[4]; \
   gint vc[4]; \
   \
+  data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);\
+  size = GST_VIDEO_FRAME_SIZE (frame);\
+  \
   memcpy (yc, matrix, 4 * sizeof (gint)); \
   memcpy (uc, matrix + 4, 4 * sizeof (gint)); \
   memcpy (vc, matrix + 8, 4 * sizeof (gint)); \
@@ -230,13 +237,18 @@ transform_##name##_ayuv (guint8 * data, gint size, const gint *matrix) \
 } \
 \
 static void \
-transform_ayuv_##name (guint8 * data, gint size, const gint *matrix) \
+transform_ayuv_##name (GstVideoFrame * frame, const gint *matrix) \
 { \
+  guint8 *data; \
+  gsize size; \
   gint r, g, b; \
   gint rc[4]; \
   gint gc[4]; \
   gint bc[4]; \
   \
+  data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);\
+  size = GST_VIDEO_FRAME_SIZE (frame);\
+  \
   memcpy (rc, matrix, 4 * sizeof (gint)); \
   memcpy (gc, matrix + 4, 4 * sizeof (gint)); \
   memcpy (bc, matrix + 8, 4 * sizeof (gint)); \
@@ -262,8 +274,10 @@ DEFINE_ARGB_AYUV_FUNCTIONS (argb, 0, 1, 2, 3);
 DEFINE_ARGB_AYUV_FUNCTIONS (abgr, 0, 3, 2, 1);
 
 static void
-transform_ayuv_ayuv (guint8 * data, gint size, const gint * matrix)
+transform_ayuv_ayuv (GstVideoFrame * frame, const gint * matrix)
 {
+  guint8 *data;
+  gsize size;
   gint y, u, v;
   gint yc[4];
   gint uc[4];
@@ -272,6 +286,9 @@ transform_ayuv_ayuv (guint8 * data, gint size, const gint * matrix)
   if (matrix == NULL)
     return;
 
+  data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  size = GST_VIDEO_FRAME_SIZE (frame);
+
   memcpy (yc, matrix, 4 * sizeof (gint));
   memcpy (uc, matrix + 4, 4 * sizeof (gint));
   memcpy (vc, matrix + 8, 4 * sizeof (gint));
@@ -292,10 +309,15 @@ transform_ayuv_ayuv (guint8 * data, gint size, const gint * matrix)
 }
 
 static void
-transform_argb_bgra (guint8 * data, gint size, const gint * matrix)
+transform_argb_bgra (GstVideoFrame * frame, const gint * matrix)
 {
+  guint8 *data;
+  gsize size;
   gint r, g, b;
 
+  data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  size = GST_VIDEO_FRAME_SIZE (frame);
+
   while (size > 0) {
     r = data[1];
     g = data[2];
@@ -314,10 +336,15 @@ transform_argb_bgra (guint8 * data, gint size, const gint * matrix)
 #define transform_abgr_rgba transform_argb_bgra
 
 static void
-transform_argb_abgr (guint8 * data, gint size, const gint * matrix)
+transform_argb_abgr (GstVideoFrame * frame, const gint * matrix)
 {
+  guint8 *data;
+  gsize size;
   gint r, g, b;
 
+  data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  size = GST_VIDEO_FRAME_SIZE (frame);
+
   while (size > 0) {
     r = data[1];
     g = data[2];
@@ -336,10 +363,15 @@ transform_argb_abgr (guint8 * data, gint size, const gint * matrix)
 #define transform_abgr_argb transform_argb_abgr
 
 static void
-transform_rgba_bgra (guint8 * data, gint size, const gint * matrix)
+transform_rgba_bgra (GstVideoFrame * frame, const gint * matrix)
 {
+  guint8 *data;
+  gsize size;
   gint r, g, b;
 
+  data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  size = GST_VIDEO_FRAME_SIZE (frame);
+
   while (size > 0) {
     r = data[0];
     g = data[1];
@@ -358,10 +390,15 @@ transform_rgba_bgra (guint8 * data, gint size, const gint * matrix)
 #define transform_bgra_rgba transform_rgba_bgra
 
 static void
-transform_argb_rgba (guint8 * data, gint size, const gint * matrix)
+transform_argb_rgba (GstVideoFrame * frame, const gint * matrix)
 {
+  guint8 *data;
+  gsize size;
   gint r, g, b;
 
+  data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  size = GST_VIDEO_FRAME_SIZE (frame);
+
   while (size > 0) {
     r = data[1];
     g = data[2];
@@ -380,10 +417,15 @@ transform_argb_rgba (guint8 * data, gint size, const gint * matrix)
 #define transform_abgr_bgra transform_argb_rgba
 
 static void
-transform_bgra_argb (guint8 * data, gint size, const gint * matrix)
+transform_bgra_argb (GstVideoFrame * frame, const gint * matrix)
 {
+  guint8 *data;
+  gsize size;
   gint r, g, b;
 
+  data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  size = GST_VIDEO_FRAME_SIZE (frame);
+
   while (size > 0) {
     r = data[2];
     g = data[1];
@@ -402,10 +444,15 @@ transform_bgra_argb (guint8 * data, gint size, const gint * matrix)
 #define transform_rgba_abgr transform_bgra_argb
 
 static void
-transform_rgba_argb (guint8 * data, gint size, const gint * matrix)
+transform_rgba_argb (GstVideoFrame * frame, const gint * matrix)
 {
+  guint8 *data;
+  gsize size;
   gint r, g, b;
 
+  data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  size = GST_VIDEO_FRAME_SIZE (frame);
+
   while (size > 0) {
     r = data[0];
     g = data[1];
@@ -429,36 +476,27 @@ gst_alpha_color_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
 {
   GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans);
   gboolean ret;
-  gint w, h;
-  gint w2, h2;
-  GstVideoFormat in_format, out_format;
-  const gchar *matrix;
+  GstVideoInfo in_info, out_info;
   gboolean in_sdtv, out_sdtv;
 
   alpha->process = NULL;
   alpha->matrix = NULL;
 
-  ret = gst_video_format_parse_caps (incaps, &in_format, &w, &h);
-  ret &= gst_video_format_parse_caps (outcaps, &out_format, &w2, &h2);
+  ret = gst_video_info_from_caps (&in_info, incaps);
+  ret &= gst_video_info_from_caps (&out_info, outcaps);
+  if (!ret)
+    goto invalid_caps;
 
-  if (!ret || w != w2 || h != h2) {
-    GST_DEBUG_OBJECT (alpha, "incomplete or invalid caps!");
-    return FALSE;
-  }
-
-  matrix = gst_video_parse_caps_color_matrix (incaps);
-  in_sdtv = matrix ? g_str_equal (matrix, "sdtv") : TRUE;
-  matrix = gst_video_parse_caps_color_matrix (outcaps);
-  out_sdtv = matrix ? g_str_equal (matrix, "sdtv") : TRUE;
+  if (GST_VIDEO_INFO_WIDTH (&in_info) != GST_VIDEO_INFO_WIDTH (&out_info) ||
+      GST_VIDEO_INFO_HEIGHT (&in_info) != GST_VIDEO_INFO_HEIGHT (&out_info))
+    goto invalid_caps;
 
-  alpha->in_format = in_format;
-  alpha->out_format = out_format;
-  alpha->width = w;
-  alpha->height = h;
+  in_sdtv = in_info.colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT601;
+  out_sdtv = out_info.colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT601;
 
-  switch (alpha->in_format) {
+  switch (GST_VIDEO_INFO_FORMAT (&in_info)) {
     case GST_VIDEO_FORMAT_ARGB:
-      switch (alpha->out_format) {
+      switch (GST_VIDEO_INFO_FORMAT (&out_info)) {
         case GST_VIDEO_FORMAT_ARGB:
           alpha->process = NULL;
           alpha->matrix = NULL;
@@ -488,7 +526,7 @@ gst_alpha_color_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
       }
       break;
     case GST_VIDEO_FORMAT_BGRA:
-      switch (alpha->out_format) {
+      switch (GST_VIDEO_INFO_FORMAT (&out_info)) {
         case GST_VIDEO_FORMAT_BGRA:
           alpha->process = NULL;
           alpha->matrix = NULL;
@@ -518,7 +556,7 @@ gst_alpha_color_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
       }
       break;
     case GST_VIDEO_FORMAT_ABGR:
-      switch (alpha->out_format) {
+      switch (GST_VIDEO_INFO_FORMAT (&out_info)) {
         case GST_VIDEO_FORMAT_ABGR:
           alpha->process = NULL;
           alpha->matrix = NULL;
@@ -548,7 +586,7 @@ gst_alpha_color_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
       }
       break;
     case GST_VIDEO_FORMAT_RGBA:
-      switch (alpha->out_format) {
+      switch (GST_VIDEO_INFO_FORMAT (&out_info)) {
         case GST_VIDEO_FORMAT_RGBA:
           alpha->process = NULL;
           alpha->matrix = NULL;
@@ -578,7 +616,7 @@ gst_alpha_color_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
       }
       break;
     case GST_VIDEO_FORMAT_AYUV:
-      switch (alpha->out_format) {
+      switch (GST_VIDEO_INFO_FORMAT (&out_info)) {
         case GST_VIDEO_FORMAT_AYUV:
           if (in_sdtv == out_sdtv) {
             alpha->process = transform_ayuv_ayuv;
@@ -626,38 +664,60 @@ gst_alpha_color_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
       break;
   }
 
-  if (in_format == out_format && in_sdtv == out_sdtv)
+  if (GST_VIDEO_INFO_FORMAT (&in_info) == GST_VIDEO_INFO_FORMAT (&out_info)
+      && in_sdtv == out_sdtv)
     gst_base_transform_set_passthrough (btrans, TRUE);
   else if (!alpha->process)
-    return FALSE;
+    goto no_process;
 
   return TRUE;
+
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (alpha, "incomplete or invalid caps");
+    return FALSE;
+  }
+no_process:
+  {
+    GST_DEBUG_OBJECT (alpha, "could not find process function");
+    return FALSE;
+  }
 }
 
 static GstFlowReturn
 gst_alpha_color_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf)
 {
   GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans);
-
-  if (G_UNLIKELY (GST_BUFFER_SIZE (inbuf) != 4 * alpha->width * alpha->height)) {
-    GST_ERROR_OBJECT (alpha, "Invalid buffer size (was %u, expected %u)",
-        GST_BUFFER_SIZE (inbuf), alpha->width * alpha->height);
-    return GST_FLOW_ERROR;
-  }
+  GstVideoFrame frame;
 
   if (gst_base_transform_is_passthrough (btrans))
     return GST_FLOW_OK;
 
-  if (G_UNLIKELY (!alpha->process)) {
-    GST_ERROR_OBJECT (alpha, "Not negotiated yet");
-    return GST_FLOW_NOT_NEGOTIATED;
-  }
+  if (G_UNLIKELY (!alpha->process))
+    goto not_negotiated;
+
+  if (!gst_video_frame_map (&frame, &alpha->in_info, inbuf, GST_MAP_READWRITE))
+    goto invalid_buffer;
 
   /* Transform in place */
-  alpha->process (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf),
-      alpha->matrix);
+  alpha->process (&frame, alpha->matrix);
+
+  gst_video_frame_unmap (&frame);
 
   return GST_FLOW_OK;
+
+  /* ERRORS */
+not_negotiated:
+  {
+    GST_ERROR_OBJECT (alpha, "Not negotiated yet");
+    return GST_FLOW_NOT_NEGOTIATED;
+  }
+invalid_buffer:
+  {
+    GST_ERROR_OBJECT (alpha, "Invalid buffer received");
+    return GST_FLOW_ERROR;
+  }
 }
 
 static gboolean
index 636d832..11f8674 100644 (file)
@@ -43,10 +43,9 @@ struct _GstAlphaColor
 
   /*< private >*/
   /* caps */
-  GstVideoFormat in_format, out_format;
-  gint width, height;
+  GstVideoInfo in_info, out_info;
 
-  void (*process) (guint8 * data, gint size, const gint * matrix);
+  void (*process) (GstVideoFrame * frame, const gint * matrix);
   const gint *matrix;
 };
 
index accebee..163a487 100644 (file)
@@ -72,31 +72,27 @@ static GstTagDemuxResult gst_ape_demux_parse_tag (GstTagDemux * demux,
     GstBuffer * buffer, gboolean start_tag, guint * tag_size,
     GstTagList ** tags);
 
-GST_BOILERPLATE (GstApeDemux, gst_ape_demux, GstTagDemux, GST_TYPE_TAG_DEMUX);
+G_DEFINE_TYPE (GstApeDemux, gst_ape_demux, GST_TYPE_TAG_DEMUX);
 
 static void
-gst_ape_demux_base_init (gpointer klass)
+gst_ape_demux_class_init (GstApeDemuxClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *element_class;
+  GstTagDemuxClass *tagdemux_class;
 
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_factory));
+  GST_DEBUG_CATEGORY_INIT (apedemux_debug, "apedemux", 0,
+      "GStreamer APE tag demuxer");
+
+  tagdemux_class = GST_TAG_DEMUX_CLASS (klass);
+  element_class = GST_ELEMENT_CLASS (klass);
 
   gst_element_class_set_details_simple (element_class, "APE tag demuxer",
       "Codec/Demuxer/Metadata",
       "Read and output APE tags while demuxing the contents",
       "Tim-Philipp Müller <tim centricular net>");
 
-  GST_DEBUG_CATEGORY_INIT (apedemux_debug, "apedemux", 0,
-      "GStreamer APE tag demuxer");
-}
-
-static void
-gst_ape_demux_class_init (GstApeDemuxClass * klass)
-{
-  GstTagDemuxClass *tagdemux_class;
-
-  tagdemux_class = GST_TAG_DEMUX_CLASS (klass);
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&sink_factory));
 
   tagdemux_class->identify_tag = GST_DEBUG_FUNCPTR (gst_ape_demux_identify_tag);
   tagdemux_class->parse_tag = GST_DEBUG_FUNCPTR (gst_ape_demux_parse_tag);
@@ -110,7 +106,7 @@ gst_ape_demux_class_init (GstApeDemuxClass * klass)
 }
 
 static void
-gst_ape_demux_init (GstApeDemux * apedemux, GstApeDemuxClass * gclass)
+gst_ape_demux_init (GstApeDemux * apedemux)
 {
   /* nothing to do here */
 }
@@ -333,17 +329,25 @@ static gboolean
 gst_ape_demux_identify_tag (GstTagDemux * demux, GstBuffer * buffer,
     gboolean start_tag, guint * tag_size)
 {
-  if (memcmp (GST_BUFFER_DATA (buffer), "APETAGEX", 8) != 0) {
+  guint8 *data;
+  gsize size;
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
+  if (memcmp (data, "APETAGEX", 8) != 0) {
     GST_DEBUG_OBJECT (demux, "No APETAGEX marker at %s - not an APE file",
         (start_tag) ? "start" : "end");
+    gst_buffer_unmap (buffer, data, size);
     return FALSE;
   }
 
-  *tag_size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buffer) + 12);
+  *tag_size = GST_READ_UINT32_LE (data + 12);
 
   /* size is without header, so add 32 to account for that */
   *tag_size += 32;
 
+  gst_buffer_unmap (buffer, data, size);
+
   return TRUE;
 }
 
@@ -351,17 +355,19 @@ static GstTagDemuxResult
 gst_ape_demux_parse_tag (GstTagDemux * demux, GstBuffer * buffer,
     gboolean start_tag, guint * tag_size, GstTagList ** tags)
 {
-  const guint8 *data;
-  const guint8 *footer;
+  guint8 *data_start, *data;
+  guint8 *footer;
   gboolean have_header;
   gboolean end_tag = !start_tag;
   GstCaps *sink_caps;
   guint version, footer_size;
+  gsize size;
+
+  data_start = data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
-  GST_LOG_OBJECT (demux, "Parsing buffer of size %u", GST_BUFFER_SIZE (buffer));
+  GST_LOG_OBJECT (demux, "Parsing buffer of size %" G_GSIZE_FORMAT, size);
 
-  data = GST_BUFFER_DATA (buffer);
-  footer = GST_BUFFER_DATA (buffer) + GST_BUFFER_SIZE (buffer) - 32;
+  footer = data + size - 32;
 
   GST_LOG_OBJECT (demux, "Checking for footer at offset 0x%04x",
       (guint) (footer - data));
@@ -420,6 +426,8 @@ gst_ape_demux_parse_tag (GstTagDemux * demux, GstBuffer * buffer,
       GST_TAG_CONTAINER_FORMAT, sink_caps);
   gst_caps_unref (sink_caps);
 
+  gst_buffer_unmap (buffer, data_start, size);
+
   return GST_TAG_DEMUX_RESULT_OK;
 }
 
index 5316c96..0a8627d 100644 (file)
@@ -90,56 +90,29 @@ gst_audio_amplify_clipping_method_get_type (void)
       {METHOD_NOCLIP, "No clipping", "none"},
       {0, NULL, NULL}
     };
-
-    /* FIXME 0.11: rename to GstAudioAmplifyClippingMethod */
-    gtype = g_enum_register_static ("GstAudioPanoramaClippingMethod", values);
+    gtype = g_enum_register_static ("GstAudioAmplifyClippingMethod", values);
   }
   return gtype;
 }
 
 #define ALLOWED_CAPS                                                  \
-    "audio/x-raw-int,"                                                \
-    " depth=(int)8,"                                                  \
-    " width=(int)8,"                                                  \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " signed=(bool)TRUE,"                                             \
-    " rate=(int)[1,MAX],"                                             \
-    " channels=(int)[1,MAX]; "                                        \
-    "audio/x-raw-int,"                                                \
-    " depth=(int)16,"                                                 \
-    " width=(int)16,"                                                 \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " signed=(bool)TRUE,"                                             \
-    " rate=(int)[1,MAX],"                                             \
-    " channels=(int)[1,MAX]; "                                        \
-    "audio/x-raw-int,"                                                \
-    " depth=(int)32,"                                                 \
-    " width=(int)32,"                                                 \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " signed=(bool)TRUE,"                                             \
-    " rate=(int)[1,MAX],"                                             \
-    " channels=(int)[1,MAX]; "                                        \
-    "audio/x-raw-float,"                                              \
-    " width=(int){32,64},"                                            \
-    " endianness=(int)BYTE_ORDER,"                                    \
+    "audio/x-raw,"                                                    \
+    " format=(string) {S8,"GST_AUDIO_NE(S16)","GST_AUDIO_NE(S32)","   \
+                           GST_AUDIO_NE(F32)","GST_AUDIO_NE(F64)"},"  \
     " rate=(int)[1,MAX],"                                             \
     " channels=(int)[1,MAX]"
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_amplify_debug, "audioamplify", 0, "audioamplify element");
-
-GST_BOILERPLATE_FULL (GstAudioAmplify, gst_audio_amplify, GstAudioFilter,
-    GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
+G_DEFINE_TYPE (GstAudioAmplify, gst_audio_amplify, GST_TYPE_AUDIO_FILTER);
 
 static gboolean gst_audio_amplify_set_process_function (GstAudioAmplify *
-    filter, gint clipping, gint format, gint width);
+    filter, gint clipping, GstAudioFormat format);
 static void gst_audio_amplify_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
 static void gst_audio_amplify_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
 static gboolean gst_audio_amplify_setup (GstAudioFilter * filter,
-    GstRingBufferSpec * format);
+    const GstAudioInfo * info);
 static GstFlowReturn gst_audio_amplify_transform_ip (GstBaseTransform * base,
     GstBuffer * buf);
 
@@ -279,28 +252,18 @@ MAKE_FLOAT_FUNCS (gdouble)
 /* GObject vmethod implementations */
 
 static void
-gst_audio_amplify_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-  GstCaps *caps;
-
-  gst_element_class_set_details_simple (element_class, "Audio amplifier",
-      "Filter/Effect/Audio",
-      "Amplifies an audio stream by a given factor",
-      "Sebastian Dröge <slomo@circular-chaos.org>");
-
-  caps = gst_caps_from_string (ALLOWED_CAPS);
-  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
-      caps);
-  gst_caps_unref (caps);
-}
-
-static void
 gst_audio_amplify_class_init (GstAudioAmplifyClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+  GstCaps *caps;
+
+  GST_DEBUG_CATEGORY_INIT (gst_audio_amplify_debug, "audioamplify", 0,
+      "audioamplify element");
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+
   gobject_class->set_property = gst_audio_amplify_set_property;
   gobject_class->get_property = gst_audio_amplify_get_property;
 
@@ -324,6 +287,16 @@ gst_audio_amplify_class_init (GstAudioAmplifyClass * klass)
           GST_TYPE_AUDIO_AMPLIFY_CLIPPING_METHOD, METHOD_CLIP,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "Audio amplifier",
+      "Filter/Effect/Audio",
+      "Amplifies an audio stream by a given factor",
+      "Sebastian Dröge <slomo@circular-chaos.org>");
+
+  caps = gst_caps_from_string (ALLOWED_CAPS);
+  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
+      caps);
+  gst_caps_unref (caps);
+
   GST_AUDIO_FILTER_CLASS (klass)->setup =
       GST_DEBUG_FUNCPTR (gst_audio_amplify_setup);
   GST_BASE_TRANSFORM_CLASS (klass)->transform_ip =
@@ -331,84 +304,80 @@ gst_audio_amplify_class_init (GstAudioAmplifyClass * klass)
 }
 
 static void
-gst_audio_amplify_init (GstAudioAmplify * filter, GstAudioAmplifyClass * klass)
+gst_audio_amplify_init (GstAudioAmplify * filter)
 {
   filter->amplification = 1.0;
   gst_audio_amplify_set_process_function (filter, METHOD_CLIP,
-      GST_BUFTYPE_LINEAR, 16);
+      GST_AUDIO_FORMAT_S16);
   gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
   gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (filter), TRUE);
 }
 
 static GstAudioAmplifyProcessFunc
-gst_audio_amplify_process_function (gint clipping, gint format, gint width)
+gst_audio_amplify_process_function (gint clipping, GstAudioFormat format)
 {
   static const struct process
   {
-    gint format;
-    gint width;
+    GstAudioFormat format;
     gint clipping;
     GstAudioAmplifyProcessFunc func;
   } process[] = {
     {
-    GST_BUFTYPE_FLOAT, 32, METHOD_CLIP,
-          gst_audio_amplify_transform_gfloat_clip}, {
-    GST_BUFTYPE_FLOAT, 32, METHOD_WRAP_NEGATIVE,
+    GST_AUDIO_FORMAT_F32, METHOD_CLIP, gst_audio_amplify_transform_gfloat_clip}, {
+    GST_AUDIO_FORMAT_F32, METHOD_WRAP_NEGATIVE,
           gst_audio_amplify_transform_gfloat_wrap_negative}, {
-    GST_BUFTYPE_FLOAT, 32, METHOD_WRAP_POSITIVE,
+    GST_AUDIO_FORMAT_F32, METHOD_WRAP_POSITIVE,
           gst_audio_amplify_transform_gfloat_wrap_positive}, {
-    GST_BUFTYPE_FLOAT, 32, METHOD_NOCLIP,
+    GST_AUDIO_FORMAT_F32, METHOD_NOCLIP,
           gst_audio_amplify_transform_gfloat_noclip}, {
-    GST_BUFTYPE_FLOAT, 64, METHOD_CLIP,
+    GST_AUDIO_FORMAT_F64, METHOD_CLIP,
           gst_audio_amplify_transform_gdouble_clip}, {
-    GST_BUFTYPE_FLOAT, 64, METHOD_WRAP_NEGATIVE,
+    GST_AUDIO_FORMAT_F64, METHOD_WRAP_NEGATIVE,
           gst_audio_amplify_transform_gdouble_wrap_negative}, {
-    GST_BUFTYPE_FLOAT, 64, METHOD_WRAP_POSITIVE,
+    GST_AUDIO_FORMAT_F64, METHOD_WRAP_POSITIVE,
           gst_audio_amplify_transform_gdouble_wrap_positive}, {
-    GST_BUFTYPE_FLOAT, 64, METHOD_NOCLIP,
+    GST_AUDIO_FORMAT_F64, METHOD_NOCLIP,
           gst_audio_amplify_transform_gdouble_noclip}, {
-    GST_BUFTYPE_LINEAR, 8, METHOD_CLIP, gst_audio_amplify_transform_gint8_clip}, {
-    GST_BUFTYPE_LINEAR, 8, METHOD_WRAP_NEGATIVE,
+    GST_AUDIO_FORMAT_S8, METHOD_CLIP, gst_audio_amplify_transform_gint8_clip}, {
+    GST_AUDIO_FORMAT_S8, METHOD_WRAP_NEGATIVE,
           gst_audio_amplify_transform_gint8_wrap_negative}, {
-    GST_BUFTYPE_LINEAR, 8, METHOD_WRAP_POSITIVE,
+    GST_AUDIO_FORMAT_S8, METHOD_WRAP_POSITIVE,
           gst_audio_amplify_transform_gint8_wrap_positive}, {
-    GST_BUFTYPE_LINEAR, 8, METHOD_NOCLIP,
+    GST_AUDIO_FORMAT_S8, METHOD_NOCLIP,
           gst_audio_amplify_transform_gint8_noclip}, {
-    GST_BUFTYPE_LINEAR, 16, METHOD_CLIP,
-          gst_audio_amplify_transform_gint16_clip}, {
-    GST_BUFTYPE_LINEAR, 16, METHOD_WRAP_NEGATIVE,
+    GST_AUDIO_FORMAT_S16, METHOD_CLIP, gst_audio_amplify_transform_gint16_clip}, {
+    GST_AUDIO_FORMAT_S16, METHOD_WRAP_NEGATIVE,
           gst_audio_amplify_transform_gint16_wrap_negative}, {
-    GST_BUFTYPE_LINEAR, 16, METHOD_WRAP_POSITIVE,
+    GST_AUDIO_FORMAT_S16, METHOD_WRAP_POSITIVE,
           gst_audio_amplify_transform_gint16_wrap_positive}, {
-    GST_BUFTYPE_LINEAR, 16, METHOD_NOCLIP,
+    GST_AUDIO_FORMAT_S16, METHOD_NOCLIP,
           gst_audio_amplify_transform_gint16_noclip}, {
-    GST_BUFTYPE_LINEAR, 32, METHOD_CLIP,
-          gst_audio_amplify_transform_gint32_clip}, {
-    GST_BUFTYPE_LINEAR, 32, METHOD_WRAP_NEGATIVE,
+    GST_AUDIO_FORMAT_S32, METHOD_CLIP, gst_audio_amplify_transform_gint32_clip}, {
+    GST_AUDIO_FORMAT_S32, METHOD_WRAP_NEGATIVE,
           gst_audio_amplify_transform_gint32_wrap_negative}, {
-    GST_BUFTYPE_LINEAR, 32, METHOD_WRAP_POSITIVE,
+    GST_AUDIO_FORMAT_S32, METHOD_WRAP_POSITIVE,
           gst_audio_amplify_transform_gint32_wrap_positive}, {
-    GST_BUFTYPE_LINEAR, 32, METHOD_NOCLIP,
+    GST_AUDIO_FORMAT_S32, METHOD_NOCLIP,
           gst_audio_amplify_transform_gint32_noclip}, {
-    0, 0, 0, NULL}
+    0, 0, NULL}
   };
   const struct process *p;
 
   for (p = process; p->func; p++)
-    if (p->format == format && p->width == width && p->clipping == clipping)
+    if (p->format == format && p->clipping == clipping)
       return p->func;
   return NULL;
 }
 
 static gboolean
 gst_audio_amplify_set_process_function (GstAudioAmplify * filter, gint
-    clipping_method, gint format, gint width)
+    clipping_method, GstAudioFormat format)
 {
   GstAudioAmplifyProcessFunc process;
 
   /* set processing function */
 
-  process = gst_audio_amplify_process_function (clipping_method, format, width);
+  process = gst_audio_amplify_process_function (clipping_method, format);
   if (!process) {
     GST_DEBUG ("wrong format");
     return FALSE;
@@ -417,7 +386,6 @@ gst_audio_amplify_set_process_function (GstAudioAmplify * filter, gint
   filter->process = process;
   filter->clipping_method = clipping_method;
   filter->format = format;
-  filter->width = width;
 
   return TRUE;
 }
@@ -436,7 +404,7 @@ gst_audio_amplify_set_property (GObject * object, guint prop_id,
       break;
     case PROP_CLIPPING_METHOD:
       gst_audio_amplify_set_process_function (filter, g_value_get_enum (value),
-          filter->format, filter->width);
+          filter->format);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -465,12 +433,12 @@ gst_audio_amplify_get_property (GObject * object, guint prop_id,
 
 /* GstAudioFilter vmethod implementations */
 static gboolean
-gst_audio_amplify_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_audio_amplify_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (base);
 
   return gst_audio_amplify_set_process_function (filter,
-      filter->clipping_method, format->type, format->width);
+      filter->clipping_method, GST_AUDIO_INFO_FORMAT (info));
 }
 
 /* GstBaseTransform vmethod implementations */
@@ -480,6 +448,8 @@ gst_audio_amplify_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (base);
   guint num_samples;
   GstClockTime timestamp, stream_time;
+  guint8 *data;
+  gsize size;
 
   timestamp = GST_BUFFER_TIMESTAMP (buf);
   stream_time =
@@ -491,14 +461,16 @@ gst_audio_amplify_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
-  num_samples =
-      GST_BUFFER_SIZE (buf) / (GST_AUDIO_FILTER (filter)->format.width / 8);
-
   if (gst_base_transform_is_passthrough (base) ||
       G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
     return GST_FLOW_OK;
 
-  filter->process (filter, GST_BUFFER_DATA (buf), num_samples);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+  num_samples = size / GST_AUDIO_FILTER_BPS (filter);
+
+  filter->process (filter, data, num_samples);
+
+  gst_buffer_unmap (buf, data, size);
 
   return GST_FLOW_OK;
 }
index b28f38b..2f5fc41 100644 (file)
@@ -48,8 +48,7 @@ struct _GstAudioAmplify
   /* < private > */
   GstAudioAmplifyProcessFunc process;
   gint clipping_method;
-  gint format;
-  gint width;
+  GstAudioFormat format;
 };
 
 struct _GstAudioAmplifyClass
index 89a950c..10220d3 100644 (file)
@@ -96,11 +96,9 @@ enum
   PROP_POLES
 };
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_cheb_band_debug, "audiochebband", 0, "audiochebband element");
-
-GST_BOILERPLATE_FULL (GstAudioChebBand, gst_audio_cheb_band,
-    GstAudioFXBaseIIRFilter, GST_TYPE_AUDIO_FX_BASE_IIR_FILTER, DEBUG_INIT);
+#define gst_audio_cheb_band_parent_class parent_class
+G_DEFINE_TYPE (GstAudioChebBand, gst_audio_cheb_band,
+    GST_TYPE_AUDIO_FX_BASE_IIR_FILTER);
 
 static void gst_audio_cheb_band_set_property (GObject * object,
     guint prop_id, const GValue * value, GParamSpec * pspec);
@@ -109,7 +107,7 @@ static void gst_audio_cheb_band_get_property (GObject * object,
 static void gst_audio_cheb_band_finalize (GObject * object);
 
 static gboolean gst_audio_cheb_band_setup (GstAudioFilter * filter,
-    GstRingBufferSpec * format);
+    const GstAudioInfo * info);
 
 enum
 {
@@ -140,22 +138,15 @@ gst_audio_cheb_band_mode_get_type (void)
 /* GObject vmethod implementations */
 
 static void
-gst_audio_cheb_band_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_set_details_simple (element_class,
-      "Band pass & band reject filter", "Filter/Effect/Audio",
-      "Chebyshev band pass and band reject filter",
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-}
-
-static void
 gst_audio_cheb_band_class_init (GstAudioChebBandClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstAudioFilterClass *filter_class = (GstAudioFilterClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (gst_audio_cheb_band_debug, "audiochebband", 0,
+      "audiochebband element");
+
   gobject_class->set_property = gst_audio_cheb_band_set_property;
   gobject_class->get_property = gst_audio_cheb_band_get_property;
   gobject_class->finalize = gst_audio_cheb_band_finalize;
@@ -193,12 +184,16 @@ gst_audio_cheb_band_class_init (GstAudioChebBandClass * klass)
           4, 32, 4,
           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class,
+      "Band pass & band reject filter", "Filter/Effect/Audio",
+      "Chebyshev band pass and band reject filter",
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
   filter_class->setup = GST_DEBUG_FUNCPTR (gst_audio_cheb_band_setup);
 }
 
 static void
-gst_audio_cheb_band_init (GstAudioChebBand * filter,
-    GstAudioChebBandClass * klass)
+gst_audio_cheb_band_init (GstAudioChebBand * filter)
 {
   filter->lower_frequency = filter->upper_frequency = 0.0;
   filter->mode = MODE_BAND_PASS;
@@ -216,6 +211,7 @@ generate_biquad_coefficients (GstAudioChebBand * filter,
 {
   gint np = filter->poles / 2;
   gdouble ripple = filter->ripple;
+  gint rate = GST_AUDIO_FILTER_RATE (filter);
 
   /* pole location in s-plane */
   gdouble rp, ip;
@@ -338,12 +334,8 @@ generate_biquad_coefficients (GstAudioChebBand * filter,
   {
     gdouble a, b, d;
     gdouble alpha, beta;
-    gdouble w0 =
-        2.0 * G_PI * (filter->lower_frequency /
-        GST_AUDIO_FILTER (filter)->format.rate);
-    gdouble w1 =
-        2.0 * G_PI * (filter->upper_frequency /
-        GST_AUDIO_FILTER (filter)->format.rate);
+    gdouble w0 = 2.0 * G_PI * (filter->lower_frequency / rate);
+    gdouble w1 = 2.0 * G_PI * (filter->upper_frequency / rate);
 
     if (filter->mode == MODE_BAND_PASS) {
       a = cos ((w1 + w0) / 2.0) / cos ((w1 - w0) / 2.0);
@@ -396,7 +388,9 @@ generate_biquad_coefficients (GstAudioChebBand * filter,
 static void
 generate_coefficients (GstAudioChebBand * filter)
 {
-  if (GST_AUDIO_FILTER (filter)->format.rate == 0) {
+  gint rate = GST_AUDIO_FILTER_RATE (filter);
+
+  if (rate == 0) {
     gdouble *a = g_new0 (gdouble, 1);
 
     a[0] = 1.0;
@@ -417,8 +411,8 @@ generate_coefficients (GstAudioChebBand * filter)
     return;
   }
 
-  if (filter->upper_frequency > GST_AUDIO_FILTER (filter)->format.rate / 2) {
-    filter->upper_frequency = GST_AUDIO_FILTER (filter)->format.rate / 2;
+  if (filter->upper_frequency > rate / 2) {
+    filter->upper_frequency = rate / 2;
     GST_LOG_OBJECT (filter, "clipped upper frequency to nyquist frequency");
   }
 
@@ -497,12 +491,8 @@ generate_coefficients (GstAudioChebBand * filter)
     } else {
       /* gain is H(wc), wc = center frequency */
 
-      gdouble w1 =
-          2.0 * G_PI * (filter->lower_frequency /
-          GST_AUDIO_FILTER (filter)->format.rate);
-      gdouble w2 =
-          2.0 * G_PI * (filter->upper_frequency /
-          GST_AUDIO_FILTER (filter)->format.rate);
+      gdouble w1 = 2.0 * G_PI * (filter->lower_frequency / rate);
+      gdouble w2 = 2.0 * G_PI * (filter->upper_frequency / rate);
       gdouble w0 = (w2 + w1) / 2.0;
       gdouble zr = cos (w0), zi = sin (w0);
       gdouble gain =
@@ -529,12 +519,8 @@ generate_coefficients (GstAudioChebBand * filter)
         20.0 * log10 (gst_audio_fx_base_iir_filter_calculate_gain (a, np + 1, b,
                 np + 1, 1.0, 0.0)));
     {
-      gdouble w1 =
-          2.0 * G_PI * (filter->lower_frequency /
-          GST_AUDIO_FILTER (filter)->format.rate);
-      gdouble w2 =
-          2.0 * G_PI * (filter->upper_frequency /
-          GST_AUDIO_FILTER (filter)->format.rate);
+      gdouble w1 = 2.0 * G_PI * (filter->lower_frequency / rate);
+      gdouble w2 = 2.0 * G_PI * (filter->upper_frequency / rate);
       gdouble w0 = (w2 + w1) / 2.0;
       gdouble zr, zi;
 
@@ -557,8 +543,7 @@ generate_coefficients (GstAudioChebBand * filter)
     }
     GST_LOG_OBJECT (filter, "%.2f dB gain @ %dHz",
         20.0 * log10 (gst_audio_fx_base_iir_filter_calculate_gain (a, np + 1, b,
-                np + 1, -1.0, 0.0)),
-        GST_AUDIO_FILTER (filter)->format.rate / 2);
+                np + 1, -1.0, 0.0)), rate / 2);
   }
 }
 
@@ -656,11 +641,11 @@ gst_audio_cheb_band_get_property (GObject * object, guint prop_id,
 /* GstAudioFilter vmethod implementations */
 
 static gboolean
-gst_audio_cheb_band_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_audio_cheb_band_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstAudioChebBand *filter = GST_AUDIO_CHEB_BAND (base);
 
   generate_coefficients (filter);
 
-  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, format);
+  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, info);
 }
index 8d51fbb..ef5fc1f 100644 (file)
@@ -91,12 +91,9 @@ enum
   PROP_POLES
 };
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_cheb_limit_debug, "audiocheblimit", 0, "audiocheblimit element");
-
-GST_BOILERPLATE_FULL (GstAudioChebLimit,
-    gst_audio_cheb_limit, GstAudioFXBaseIIRFilter,
-    GST_TYPE_AUDIO_FX_BASE_IIR_FILTER, DEBUG_INIT);
+#define gst_audio_cheb_limit_parent_class parent_class
+G_DEFINE_TYPE (GstAudioChebLimit,
+    gst_audio_cheb_limit, GST_TYPE_AUDIO_FX_BASE_IIR_FILTER);
 
 static void gst_audio_cheb_limit_set_property (GObject * object,
     guint prop_id, const GValue * value, GParamSpec * pspec);
@@ -105,7 +102,7 @@ static void gst_audio_cheb_limit_get_property (GObject * object,
 static void gst_audio_cheb_limit_finalize (GObject * object);
 
 static gboolean gst_audio_cheb_limit_setup (GstAudioFilter * filter,
-    GstRingBufferSpec * format);
+    const GstAudioInfo * info);
 
 enum
 {
@@ -136,23 +133,15 @@ gst_audio_cheb_limit_mode_get_type (void)
 /* GObject vmethod implementations */
 
 static void
-gst_audio_cheb_limit_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_set_details_simple (element_class,
-      "Low pass & high pass filter",
-      "Filter/Effect/Audio",
-      "Chebyshev low pass and high pass filter",
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-}
-
-static void
 gst_audio_cheb_limit_class_init (GstAudioChebLimitClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstAudioFilterClass *filter_class = (GstAudioFilterClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (gst_audio_cheb_limit_debug, "audiocheblimit", 0,
+      "audiocheblimit element");
+
   gobject_class->set_property = gst_audio_cheb_limit_set_property;
   gobject_class->get_property = gst_audio_cheb_limit_get_property;
   gobject_class->finalize = gst_audio_cheb_limit_finalize;
@@ -186,12 +175,17 @@ gst_audio_cheb_limit_class_init (GstAudioChebLimitClass * klass)
           2, 32, 4,
           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class,
+      "Low pass & high pass filter",
+      "Filter/Effect/Audio",
+      "Chebyshev low pass and high pass filter",
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
   filter_class->setup = GST_DEBUG_FUNCPTR (gst_audio_cheb_limit_setup);
 }
 
 static void
-gst_audio_cheb_limit_init (GstAudioChebLimit * filter,
-    GstAudioChebLimitClass * klass)
+gst_audio_cheb_limit_init (GstAudioChebLimit * filter)
 {
   filter->cutoff = 0.0;
   filter->mode = MODE_LOW_PASS;
@@ -324,7 +318,7 @@ generate_biquad_coefficients (GstAudioChebLimit * filter,
   {
     gdouble k, d;
     gdouble omega =
-        2.0 * G_PI * (filter->cutoff / GST_AUDIO_FILTER (filter)->format.rate);
+        2.0 * G_PI * (filter->cutoff / GST_AUDIO_FILTER_RATE (filter));
 
     if (filter->mode == MODE_LOW_PASS)
       k = sin ((1.0 - omega) / 2.0) / sin ((1.0 + omega) / 2.0);
@@ -348,7 +342,7 @@ generate_biquad_coefficients (GstAudioChebLimit * filter,
 static void
 generate_coefficients (GstAudioChebLimit * filter)
 {
-  if (GST_AUDIO_FILTER (filter)->format.rate == 0) {
+  if (GST_AUDIO_FILTER_RATE (filter) == 0) {
     gdouble *a = g_new0 (gdouble, 1);
 
     a[0] = 1.0;
@@ -359,7 +353,7 @@ generate_coefficients (GstAudioChebLimit * filter)
     return;
   }
 
-  if (filter->cutoff >= GST_AUDIO_FILTER (filter)->format.rate / 2.0) {
+  if (filter->cutoff >= GST_AUDIO_FILTER_RATE (filter) / 2.0) {
     gdouble *a = g_new0 (gdouble, 1);
 
     a[0] = (filter->mode == MODE_LOW_PASS) ? 1.0 : 0.0;
@@ -456,8 +450,7 @@ generate_coefficients (GstAudioChebLimit * filter)
 #ifndef GST_DISABLE_GST_DEBUG
     {
       gdouble wc =
-          2.0 * G_PI * (filter->cutoff /
-          GST_AUDIO_FILTER (filter)->format.rate);
+          2.0 * G_PI * (filter->cutoff / GST_AUDIO_FILTER_RATE (filter));
       gdouble zr = cos (wc), zi = sin (wc);
 
       GST_LOG_OBJECT (filter, "%.2f dB gain @ %d Hz",
@@ -468,8 +461,7 @@ generate_coefficients (GstAudioChebLimit * filter)
 
     GST_LOG_OBJECT (filter, "%.2f dB gain @ %d Hz",
         20.0 * log10 (gst_audio_fx_base_iir_filter_calculate_gain (a, np + 1, b,
-                np + 1, -1.0, 0.0)),
-        GST_AUDIO_FILTER (filter)->format.rate / 2);
+                np + 1, -1.0, 0.0)), GST_AUDIO_FILTER_RATE (filter) / 2);
   }
 }
 
@@ -558,11 +550,11 @@ gst_audio_cheb_limit_get_property (GObject * object, guint prop_id,
 /* GstAudioFilter vmethod implementations */
 
 static gboolean
-gst_audio_cheb_limit_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_audio_cheb_limit_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstAudioChebLimit *filter = GST_AUDIO_CHEB_LIMIT (base);
 
   generate_coefficients (filter);
 
-  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, format);
+  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, info);
 }
index 33871d2..f8d77a3 100644 (file)
@@ -70,24 +70,12 @@ enum
 };
 
 #define ALLOWED_CAPS \
-    "audio/x-raw-int,"                                                \
-    " depth=(int)16,"                                                 \
-    " width=(int)16,"                                                 \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " signed=(bool)TRUE,"                                             \
-    " rate=(int)[1,MAX],"                                             \
-    " channels=(int)[1,MAX]; "                                        \
-    "audio/x-raw-float,"                                              \
-    " width=(int)32,"                                                 \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " rate=(int)[1,MAX],"                                             \
+    "audio/x-raw,"                                                \
+    " format=(string) {"GST_AUDIO_NE(S16)","GST_AUDIO_NE(F32)"}," \
+    " rate=(int)[1,MAX],"                                         \
     " channels=(int)[1,MAX]"
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_dynamic_debug, "audiodynamic", 0, "audiodynamic element");
-
-GST_BOILERPLATE_FULL (GstAudioDynamic, gst_audio_dynamic, GstAudioFilter,
-    GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
+G_DEFINE_TYPE (GstAudioDynamic, gst_audio_dynamic, GST_TYPE_AUDIO_FILTER);
 
 static void gst_audio_dynamic_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -95,7 +83,7 @@ static void gst_audio_dynamic_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
 static gboolean gst_audio_dynamic_setup (GstAudioFilter * filter,
-    GstRingBufferSpec * format);
+    const GstAudioInfo * info);
 static GstFlowReturn gst_audio_dynamic_transform_ip (GstBaseTransform * base,
     GstBuffer * buf);
 
@@ -200,7 +188,7 @@ gst_audio_dynamic_set_process_function (GstAudioDynamic * filter)
   func_index = (filter->mode == MODE_COMPRESSOR) ? 0 : 4;
   func_index += (filter->characteristics == CHARACTERISTICS_HARD_KNEE) ? 0 : 2;
   func_index +=
-      (GST_AUDIO_FILTER (filter)->format.type == GST_BUFTYPE_FLOAT) ? 1 : 0;
+      (GST_AUDIO_FILTER_FORMAT (filter) == GST_AUDIO_FORMAT_F32) ? 1 : 0;
 
   if (func_index >= 0 && func_index < 8) {
     filter->process = process_functions[func_index];
@@ -213,27 +201,18 @@ gst_audio_dynamic_set_process_function (GstAudioDynamic * filter)
 /* GObject vmethod implementations */
 
 static void
-gst_audio_dynamic_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-  GstCaps *caps;
-
-  gst_element_class_set_details_simple (element_class,
-      "Dynamic range controller", "Filter/Effect/Audio",
-      "Compressor and Expander", "Sebastian Dröge <slomo@circular-chaos.org>");
-
-  caps = gst_caps_from_string (ALLOWED_CAPS);
-  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
-      caps);
-  gst_caps_unref (caps);
-}
-
-static void
 gst_audio_dynamic_class_init (GstAudioDynamicClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+  GstCaps *caps;
+
+  GST_DEBUG_CATEGORY_INIT (gst_audio_dynamic_debug, "audiodynamic", 0,
+      "audiodynamic element");
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+
   gobject_class->set_property = gst_audio_dynamic_set_property;
   gobject_class->get_property = gst_audio_dynamic_get_property;
 
@@ -263,6 +242,15 @@ gst_audio_dynamic_class_init (GstAudioDynamicClass * klass)
           1.0,
           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class,
+      "Dynamic range controller", "Filter/Effect/Audio",
+      "Compressor and Expander", "Sebastian Dröge <slomo@circular-chaos.org>");
+
+  caps = gst_caps_from_string (ALLOWED_CAPS);
+  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
+      caps);
+  gst_caps_unref (caps);
+
   GST_AUDIO_FILTER_CLASS (klass)->setup =
       GST_DEBUG_FUNCPTR (gst_audio_dynamic_setup);
   GST_BASE_TRANSFORM_CLASS (klass)->transform_ip =
@@ -270,7 +258,7 @@ gst_audio_dynamic_class_init (GstAudioDynamicClass * klass)
 }
 
 static void
-gst_audio_dynamic_init (GstAudioDynamic * filter, GstAudioDynamicClass * klass)
+gst_audio_dynamic_init (GstAudioDynamic * filter)
 {
   filter->ratio = 1.0;
   filter->threshold = 0.0;
@@ -335,7 +323,7 @@ gst_audio_dynamic_get_property (GObject * object, guint prop_id,
 /* GstAudioFilter vmethod implementations */
 
 static gboolean
-gst_audio_dynamic_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_audio_dynamic_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstAudioDynamic *filter = GST_AUDIO_DYNAMIC (base);
   gboolean ret = TRUE;
@@ -584,6 +572,7 @@ gst_audio_dynamic_transform_soft_knee_expander_int (GstAudioDynamic * filter,
   gdouble zero_p, zero_n;
   gdouble a_p, b_p, c_p;
   gdouble a_n, b_n, c_n;
+  gdouble r2;
 
   /* Nothing to do for us here if threshold equals 0.0
    * or ratio equals 1.0 */
@@ -613,11 +602,12 @@ gst_audio_dynamic_transform_soft_knee_expander_int (GstAudioDynamic * filter,
    * b = (1 + r^2) / 2
    * c = t * (1.0 - b - a*t)
    * f(x) = ax^2 + bx + c */
-  a_p = (1.0 - filter->ratio * filter->ratio) / (4.0 * thr_p);
-  b_p = (1.0 + filter->ratio * filter->ratio) / 2.0;
+  r2 = filter->ratio * filter->ratio;
+  a_p = (1.0 - r2) / (4.0 * thr_p);
+  b_p = (1.0 + r2) / 2.0;
   c_p = thr_p * (1.0 - b_p - a_p * thr_p);
-  a_n = (1.0 - filter->ratio * filter->ratio) / (4.0 * thr_n);
-  b_n = (1.0 + filter->ratio * filter->ratio) / 2.0;
+  a_n = (1.0 - r2) / (4.0 * thr_n);
+  b_n = (1.0 + r2) / 2.0;
   c_n = thr_n * (1.0 - b_n - a_n * thr_n);
 
   for (; num_samples; num_samples--) {
@@ -643,6 +633,7 @@ gst_audio_dynamic_transform_soft_knee_expander_float (GstAudioDynamic * filter,
   gdouble zero;
   gdouble a_p, b_p, c_p;
   gdouble a_n, b_n, c_n;
+  gdouble r2;
 
   /* Nothing to do for us here if threshold equals 0.0
    * or ratio equals 1.0 */
@@ -668,11 +659,12 @@ gst_audio_dynamic_transform_soft_knee_expander_float (GstAudioDynamic * filter,
    * b = (1 + r^2) / 2
    * c = t * (1.0 - b - a*t)
    * f(x) = ax^2 + bx + c */
-  a_p = (1.0 - filter->ratio * filter->ratio) / (4.0 * threshold);
-  b_p = (1.0 + filter->ratio * filter->ratio) / 2.0;
+  r2 = filter->ratio * filter->ratio;
+  a_p = (1.0 - r2) / (4.0 * threshold);
+  b_p = (1.0 + r2) / 2.0;
   c_p = threshold * (1.0 - b_p - a_p * threshold);
-  a_n = (1.0 - filter->ratio * filter->ratio) / (-4.0 * threshold);
-  b_n = (1.0 + filter->ratio * filter->ratio) / 2.0;
+  a_n = (1.0 - r2) / (-4.0 * threshold);
+  b_n = (1.0 + r2) / 2.0;
   c_n = -threshold * (1.0 - b_n + a_n * threshold);
 
   for (; num_samples; num_samples--) {
@@ -696,6 +688,8 @@ gst_audio_dynamic_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   GstAudioDynamic *filter = GST_AUDIO_DYNAMIC (base);
   guint num_samples;
   GstClockTime timestamp, stream_time;
+  guint8 *data;
+  gsize size;
 
   timestamp = GST_BUFFER_TIMESTAMP (buf);
   stream_time =
@@ -707,14 +701,16 @@ gst_audio_dynamic_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
-  num_samples =
-      GST_BUFFER_SIZE (buf) / (GST_AUDIO_FILTER (filter)->format.width / 8);
-
   if (gst_base_transform_is_passthrough (base) ||
       G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
     return GST_FLOW_OK;
 
-  filter->process (filter, GST_BUFFER_DATA (buf), num_samples);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+  num_samples = size / GST_AUDIO_FILTER_BPS (filter);
+
+  filter->process (filter, data, num_samples);
+
+  gst_buffer_unmap (buf, data, size);
 
   return GST_FLOW_OK;
 }
index 9064619..feb0d36 100644 (file)
@@ -67,17 +67,13 @@ enum
 };
 
 #define ALLOWED_CAPS \
-    "audio/x-raw-float,"                                              \
-    " width=(int) { 32, 64 }, "                                       \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " rate=(int)[1,MAX],"                                             \
+    "audio/x-raw,"                                                 \
+    " format=(string) {"GST_AUDIO_NE(F32)","GST_AUDIO_NE(F64)"}, " \
+    " rate=(int)[1,MAX],"                                          \
     " channels=(int)[1,MAX]"
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_echo_debug, "audioecho", 0, "audioecho element");
-
-GST_BOILERPLATE_FULL (GstAudioEcho, gst_audio_echo, GstAudioFilter,
-    GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
+#define gst_audio_echo_parent_class parent_class
+G_DEFINE_TYPE (GstAudioEcho, gst_audio_echo, GST_TYPE_AUDIO_FILTER);
 
 static void gst_audio_echo_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -86,7 +82,7 @@ static void gst_audio_echo_get_property (GObject * object, guint prop_id,
 static void gst_audio_echo_finalize (GObject * object);
 
 static gboolean gst_audio_echo_setup (GstAudioFilter * self,
-    GstRingBufferSpec * format);
+    const GstAudioInfo * info);
 static gboolean gst_audio_echo_stop (GstBaseTransform * base);
 static GstFlowReturn gst_audio_echo_transform_ip (GstBaseTransform * base,
     GstBuffer * buf);
@@ -99,28 +95,16 @@ static void gst_audio_echo_transform_double (GstAudioEcho * self,
 /* GObject vmethod implementations */
 
 static void
-gst_audio_echo_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-  GstCaps *caps;
-
-  gst_element_class_set_details_simple (element_class, "Audio echo",
-      "Filter/Effect/Audio",
-      "Adds an echo or reverb effect to an audio stream",
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-
-  caps = gst_caps_from_string (ALLOWED_CAPS);
-  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
-      caps);
-  gst_caps_unref (caps);
-}
-
-static void
 gst_audio_echo_class_init (GstAudioEchoClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *basetransform_class = (GstBaseTransformClass *) klass;
   GstAudioFilterClass *audioself_class = (GstAudioFilterClass *) klass;
+  GstCaps *caps;
+
+  GST_DEBUG_CATEGORY_INIT (gst_audio_echo_debug, "audioecho", 0,
+      "audioecho element");
 
   gobject_class->set_property = gst_audio_echo_set_property;
   gobject_class->get_property = gst_audio_echo_get_property;
@@ -152,6 +136,16 @@ gst_audio_echo_class_init (GstAudioEchoClass * klass)
           0.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
           | GST_PARAM_CONTROLLABLE));
 
+  gst_element_class_set_details_simple (gstelement_class, "Audio echo",
+      "Filter/Effect/Audio",
+      "Adds an echo or reverb effect to an audio stream",
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+  caps = gst_caps_from_string (ALLOWED_CAPS);
+  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
+      caps);
+  gst_caps_unref (caps);
+
   audioself_class->setup = GST_DEBUG_FUNCPTR (gst_audio_echo_setup);
   basetransform_class->transform_ip =
       GST_DEBUG_FUNCPTR (gst_audio_echo_transform_ip);
@@ -159,7 +153,7 @@ gst_audio_echo_class_init (GstAudioEchoClass * klass)
 }
 
 static void
-gst_audio_echo_init (GstAudioEcho * self, GstAudioEchoClass * klass)
+gst_audio_echo_init (GstAudioEcho * self)
 {
   self->delay = 1;
   self->max_delay = 1;
@@ -277,19 +271,24 @@ gst_audio_echo_get_property (GObject * object, guint prop_id,
 /* GstAudioFilter vmethod implementations */
 
 static gboolean
-gst_audio_echo_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_audio_echo_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstAudioEcho *self = GST_AUDIO_ECHO (base);
   gboolean ret = TRUE;
 
-  if (format->type == GST_BUFTYPE_FLOAT && format->width == 32)
-    self->process = (GstAudioEchoProcessFunc)
-        gst_audio_echo_transform_float;
-  else if (format->type == GST_BUFTYPE_FLOAT && format->width == 64)
-    self->process = (GstAudioEchoProcessFunc)
-        gst_audio_echo_transform_double;
-  else
-    ret = FALSE;
+  switch (GST_AUDIO_INFO_FORMAT (info)) {
+    case GST_AUDIO_FORMAT_F32:
+      self->process = (GstAudioEchoProcessFunc)
+          gst_audio_echo_transform_float;
+      break;
+    case GST_AUDIO_FORMAT_F64:
+      self->process = (GstAudioEchoProcessFunc)
+          gst_audio_echo_transform_double;
+      break;
+    default:
+      ret = FALSE;
+      break;
+  }
 
   g_free (self->buffer);
   self->buffer = NULL;
@@ -320,8 +319,8 @@ gst_audio_echo_transform_##name (GstAudioEcho * self, \
     type * data, guint num_samples) \
 { \
   type *buffer = (type *) self->buffer; \
-  guint channels = GST_AUDIO_FILTER (self)->format.channels; \
-  guint rate = GST_AUDIO_FILTER (self)->format.rate; \
+  guint channels = GST_AUDIO_FILTER_CHANNELS (self); \
+  guint rate = GST_AUDIO_FILTER_RATE (self); \
   guint i, j; \
   guint echo_index = self->buffer_size_frames - self->delay_frames; \
   gdouble echo_off = ((((gdouble) self->delay) * rate) / GST_SECOND) - self->delay_frames; \
@@ -360,6 +359,8 @@ gst_audio_echo_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   GstAudioEcho *self = GST_AUDIO_ECHO (base);
   guint num_samples;
   GstClockTime timestamp, stream_time;
+  guint8 *data;
+  gsize size;
 
   timestamp = GST_BUFFER_TIMESTAMP (buf);
   stream_time =
@@ -371,22 +372,18 @@ gst_audio_echo_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (self), stream_time);
 
-  num_samples =
-      GST_BUFFER_SIZE (buf) / (GST_AUDIO_FILTER (self)->format.width / 8);
-
   if (self->buffer == NULL) {
-    guint width, rate, channels;
+    guint bpf, rate;
 
-    width = GST_AUDIO_FILTER (self)->format.width / 8;
-    rate = GST_AUDIO_FILTER (self)->format.rate;
-    channels = GST_AUDIO_FILTER (self)->format.channels;
+    bpf = GST_AUDIO_FILTER_BPS (self);
+    rate = GST_AUDIO_FILTER_RATE (self);
 
     self->delay_frames =
         MAX (gst_util_uint64_scale (self->delay, rate, GST_SECOND), 1);
     self->buffer_size_frames =
         MAX (gst_util_uint64_scale (self->max_delay, rate, GST_SECOND), 1);
 
-    self->buffer_size = self->buffer_size_frames * width * channels;
+    self->buffer_size = self->buffer_size_frames * bpf;
     self->buffer = g_try_malloc0 (self->buffer_size);
     self->buffer_pos = 0;
 
@@ -396,7 +393,12 @@ gst_audio_echo_transform_ip (GstBaseTransform * base, GstBuffer * buf)
     }
   }
 
-  self->process (self, GST_BUFFER_DATA (buf), num_samples);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+  num_samples = size / GST_AUDIO_FILTER_BPS (self);
+
+  self->process (self, data, num_samples);
+
+  gst_buffer_unmap (buf, data, size);
 
   return GST_FLOW_OK;
 }
index b6102ae..7d6d77a 100644 (file)
@@ -75,12 +75,9 @@ enum
 
 static guint gst_audio_fir_filter_signals[LAST_SIGNAL] = { 0, };
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_fir_filter_debug, "audiofirfilter", 0, \
-      "Generic audio FIR filter plugin");
-
-GST_BOILERPLATE_FULL (GstAudioFIRFilter, gst_audio_fir_filter, GstAudioFilter,
-    GST_TYPE_AUDIO_FX_BASE_FIR_FILTER, DEBUG_INIT);
+#define gst_audio_fir_filter_parent_class parent_class
+G_DEFINE_TYPE (GstAudioFIRFilter, gst_audio_fir_filter,
+    GST_TYPE_AUDIO_FX_BASE_FIR_FILTER);
 
 static void gst_audio_fir_filter_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -89,26 +86,19 @@ static void gst_audio_fir_filter_get_property (GObject * object, guint prop_id,
 static void gst_audio_fir_filter_finalize (GObject * object);
 
 static gboolean gst_audio_fir_filter_setup (GstAudioFilter * base,
-    GstRingBufferSpec * format);
+    const GstAudioInfo * info);
 
-/* Element class */
-static void
-gst_audio_fir_filter_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class,
-      "Audio FIR filter", "Filter/Effect/Audio",
-      "Generic audio FIR filter with custom filter kernel",
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-}
 
 static void
 gst_audio_fir_filter_class_init (GstAudioFIRFilterClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstAudioFilterClass *filter_class = (GstAudioFilterClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (gst_audio_fir_filter_debug, "audiofirfilter", 0,
+      "Generic audio FIR filter plugin");
+
   gobject_class->set_property = gst_audio_fir_filter_set_property;
   gobject_class->get_property = gst_audio_fir_filter_get_property;
   gobject_class->finalize = gst_audio_fir_filter_finalize;
@@ -140,6 +130,11 @@ gst_audio_fir_filter_class_init (GstAudioFIRFilterClass * klass)
       g_signal_new ("rate-changed", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstAudioFIRFilterClass, rate_changed),
       NULL, NULL, gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "Audio FIR filter", "Filter/Effect/Audio",
+      "Generic audio FIR filter with custom filter kernel",
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
 }
 
 static void
@@ -167,8 +162,7 @@ gst_audio_fir_filter_update_kernel (GstAudioFIRFilter * self, GValueArray * va)
 }
 
 static void
-gst_audio_fir_filter_init (GstAudioFIRFilter * self,
-    GstAudioFIRFilterClass * g_class)
+gst_audio_fir_filter_init (GstAudioFIRFilter * self)
 {
   GValue v = { 0, };
   GValueArray *va;
@@ -189,17 +183,17 @@ gst_audio_fir_filter_init (GstAudioFIRFilter * self,
 
 /* get notified of caps and plug in the correct process function */
 static gboolean
-gst_audio_fir_filter_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_audio_fir_filter_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstAudioFIRFilter *self = GST_AUDIO_FIR_FILTER (base);
+  gint new_rate = GST_AUDIO_INFO_RATE (info);
 
-  if (self->rate != format->rate) {
+  if (GST_AUDIO_FILTER_RATE (self) != new_rate) {
     g_signal_emit (G_OBJECT (self),
-        gst_audio_fir_filter_signals[SIGNAL_RATE_CHANGED], 0, format->rate);
-    self->rate = format->rate;
+        gst_audio_fir_filter_signals[SIGNAL_RATE_CHANGED], 0, new_rate);
   }
 
-  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, format);
+  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, info);
 }
 
 static void
index d1d896c..8b24885 100644 (file)
@@ -56,7 +56,6 @@ struct _GstAudioFIRFilter {
 
   /* < private > */
   GMutex *lock;
-  gint rate;
 };
 
 struct _GstAudioFIRFilterClass {
index ac1b148..6eb9020 100644 (file)
 #include <gst/audio/gstaudiofilter.h>
 #include <gst/controller/gstcontroller.h>
 
-/* FIXME: Remove this once we depend on gst-plugins-base 0.10.26 */
-#ifndef GST_AUDIO_FILTER_CAST
-#define GST_AUDIO_FILTER_CAST(obj) ((GstAudioFilter *) (obj))
-#endif
-
 #include "audiofxbasefirfilter.h"
 
 #define GST_CAT_DEFAULT gst_audio_fx_base_fir_filter_debug
 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
 
 #define ALLOWED_CAPS \
-    "audio/x-raw-float, "                                             \
-    " width = (int) { 32, 64 }, "                                     \
-    " endianness = (int) BYTE_ORDER, "                                \
-    " rate = (int) [ 1, MAX ], "                                      \
+    "audio/x-raw, "                                              \
+    " format=(string){"GST_AUDIO_NE(F32)","GST_AUDIO_NE(F64)"}, " \
+    " rate = (int) [ 1, MAX ], "                                 \
     " channels = (int) [ 1, MAX ]"
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_fx_base_fir_filter_debug, "audiofxbasefirfilter", 0, \
-      "FIR filter base class");
-
 /* Switch from time-domain to FFT convolution for kernels >= this */
 #define FFT_THRESHOLD 32
 
@@ -66,20 +56,21 @@ enum
 #define DEFAULT_LOW_LATENCY FALSE
 #define DEFAULT_DRAIN_ON_CHANGES TRUE
 
-GST_BOILERPLATE_FULL (GstAudioFXBaseFIRFilter, gst_audio_fx_base_fir_filter,
-    GstAudioFilter, GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
+#define gst_audio_fx_base_fir_filter_parent_class parent_class
+G_DEFINE_TYPE (GstAudioFXBaseFIRFilter, gst_audio_fx_base_fir_filter,
+    GST_TYPE_AUDIO_FILTER);
 
 static GstFlowReturn gst_audio_fx_base_fir_filter_transform (GstBaseTransform *
     base, GstBuffer * inbuf, GstBuffer * outbuf);
 static gboolean gst_audio_fx_base_fir_filter_start (GstBaseTransform * base);
 static gboolean gst_audio_fx_base_fir_filter_stop (GstBaseTransform * base);
-static gboolean gst_audio_fx_base_fir_filter_event (GstBaseTransform * base,
-    GstEvent * event);
+static gboolean gst_audio_fx_base_fir_filter_sink_event (GstBaseTransform *
+    base, GstEvent * event);
 static gboolean gst_audio_fx_base_fir_filter_transform_size (GstBaseTransform *
-    base, GstPadDirection direction, GstCaps * caps, guint size,
-    GstCaps * othercaps, guint * othersize);
+    base, GstPadDirection direction, GstCaps * caps, gsize size,
+    GstCaps * othercaps, gsize * othersize);
 static gboolean gst_audio_fx_base_fir_filter_setup (GstAudioFilter * base,
-    GstRingBufferSpec * format);
+    const GstAudioInfo * info);
 
 static gboolean gst_audio_fx_base_fir_filter_query (GstPad * pad,
     GstQuery * query);
@@ -102,7 +93,7 @@ static const GstQueryType *gst_audio_fx_base_fir_filter_query_type (GstPad *
 static guint \
 process_##width (GstAudioFXBaseFIRFilter * self, const g##ctype * src, g##ctype * dst, guint input_samples) \
 { \
-  gint channels = GST_AUDIO_FILTER_CAST (self)->format.channels; \
+  gint channels = GST_AUDIO_FILTER_CHANNELS (self); \
   TIME_DOMAIN_CONVOLUTION_BODY (channels); \
 }
 
@@ -241,7 +232,7 @@ static guint \
 process_fft_##width (GstAudioFXBaseFIRFilter * self, const g##ctype * src, \
     g##ctype * dst, guint input_samples) \
 { \
-  gint channels = GST_AUDIO_FILTER_CAST (self)->format.channels; \
+  gint channels = GST_AUDIO_FILTER_CHANNELS (self); \
   FFT_CONVOLUTION_BODY (channels); \
 }
 
@@ -419,38 +410,46 @@ static void
 /* Must be called with base transform lock! */
 static void
 gst_audio_fx_base_fir_filter_select_process_function (GstAudioFXBaseFIRFilter *
-    self, gint width, gint channels)
+    self, GstAudioFormat format, gint channels)
 {
-  if (width == 32 && self->fft && !self->low_latency) {
-    if (channels == 1)
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_1_32;
-    else if (channels == 2)
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_2_32;
-    else
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_32;
-  } else if (width == 64 && self->fft && !self->low_latency) {
-    if (channels == 1)
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_1_64;
-    else if (channels == 2)
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_2_64;
-    else
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_64;
-  } else if (width == 32) {
-    if (channels == 1)
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_1_32;
-    else if (channels == 2)
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_2_32;
-    else
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_32;
-  } else if (width == 64) {
-    if (channels == 1)
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_1_64;
-    else if (channels == 2)
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_2_64;
-    else
-      self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_64;
-  } else {
-    self->process = NULL;
+  switch (format) {
+    case GST_AUDIO_FORMAT_F32:
+      if (self->fft && !self->low_latency) {
+        if (channels == 1)
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_1_32;
+        else if (channels == 2)
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_2_32;
+        else
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_32;
+      } else {
+        if (channels == 1)
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_1_32;
+        else if (channels == 2)
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_2_32;
+        else
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_32;
+      }
+      break;
+    case GST_AUDIO_FORMAT_F64:
+      if (self->fft && !self->low_latency) {
+        if (channels == 1)
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_1_64;
+        else if (channels == 2)
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_2_64;
+        else
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_fft_64;
+      } else {
+        if (channels == 1)
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_1_64;
+        else if (channels == 2)
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_2_64;
+        else
+          self->process = (GstAudioFXBaseFIRFilterProcessFunc) process_64;
+      }
+      break;
+    default:
+      self->process = NULL;
+      break;
   }
 }
 
@@ -503,8 +502,7 @@ gst_audio_fx_base_fir_filter_set_property (GObject * object, guint prop_id,
         self->low_latency = low_latency;
         gst_audio_fx_base_fir_filter_calculate_frequency_response (self);
         gst_audio_fx_base_fir_filter_select_process_function (self,
-            GST_AUDIO_FILTER_CAST (self)->format.width,
-            GST_AUDIO_FILTER_CAST (self)->format.channels);
+            GST_AUDIO_FILTER_FORMAT (self), GST_AUDIO_FILTER_CHANNELS (self));
       }
       GST_BASE_TRANSFORM_UNLOCK (self);
       break;
@@ -541,22 +539,15 @@ gst_audio_fx_base_fir_filter_get_property (GObject * object, guint prop_id,
 }
 
 static void
-gst_audio_fx_base_fir_filter_base_init (gpointer g_class)
-{
-  GstCaps *caps;
-
-  caps = gst_caps_from_string (ALLOWED_CAPS);
-  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (g_class),
-      caps);
-  gst_caps_unref (caps);
-}
-
-static void
 gst_audio_fx_base_fir_filter_class_init (GstAudioFXBaseFIRFilterClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
   GstAudioFilterClass *filter_class = (GstAudioFilterClass *) klass;
+  GstCaps *caps;
+
+  GST_DEBUG_CATEGORY_INIT (gst_audio_fx_base_fir_filter_debug,
+      "audiofxbasefirfilter", 0, "FIR filter base class");
 
   gobject_class->dispose = gst_audio_fx_base_fir_filter_dispose;
   gobject_class->set_property = gst_audio_fx_base_fir_filter_set_property;
@@ -593,19 +584,24 @@ gst_audio_fx_base_fir_filter_class_init (GstAudioFXBaseFIRFilterClass * klass)
           DEFAULT_DRAIN_ON_CHANGES,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  caps = gst_caps_from_string (ALLOWED_CAPS);
+  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
+      caps);
+  gst_caps_unref (caps);
+
   trans_class->transform =
       GST_DEBUG_FUNCPTR (gst_audio_fx_base_fir_filter_transform);
   trans_class->start = GST_DEBUG_FUNCPTR (gst_audio_fx_base_fir_filter_start);
   trans_class->stop = GST_DEBUG_FUNCPTR (gst_audio_fx_base_fir_filter_stop);
-  trans_class->event = GST_DEBUG_FUNCPTR (gst_audio_fx_base_fir_filter_event);
+  trans_class->sink_event =
+      GST_DEBUG_FUNCPTR (gst_audio_fx_base_fir_filter_sink_event);
   trans_class->transform_size =
       GST_DEBUG_FUNCPTR (gst_audio_fx_base_fir_filter_transform_size);
   filter_class->setup = GST_DEBUG_FUNCPTR (gst_audio_fx_base_fir_filter_setup);
 }
 
 static void
-gst_audio_fx_base_fir_filter_init (GstAudioFXBaseFIRFilter * self,
-    GstAudioFXBaseFIRFilterClass * g_class)
+gst_audio_fx_base_fir_filter_init (GstAudioFXBaseFIRFilter * self)
 {
   self->kernel = NULL;
   self->buffer = NULL;
@@ -630,11 +626,12 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
 {
   GstBuffer *outbuf;
   GstFlowReturn res;
-  gint rate = GST_AUDIO_FILTER_CAST (self)->format.rate;
-  gint channels = GST_AUDIO_FILTER_CAST (self)->format.channels;
-  gint width = GST_AUDIO_FILTER_CAST (self)->format.width / 8;
+  gint rate = GST_AUDIO_FILTER_RATE (self);
+  gint channels = GST_AUDIO_FILTER_CHANNELS (self);
+  gint bps = GST_AUDIO_FILTER_BPS (self);
   gint outsize, outsamples;
-  guint8 *in, *out;
+  guint8 *in, *out, *data;
+  gsize size;
 
   if (channels == 0 || rate == 0 || self->nsamples_in == 0) {
     self->buffer_fill = 0;
@@ -652,7 +649,7 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
     self->buffer = NULL;
     return;
   }
-  outsize = outsamples * channels * width;
+  outsize = outsamples * channels * bps;
 
   if (!self->fft || self->low_latency) {
     gint64 diffsize, diffsamples;
@@ -663,7 +660,7 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
     diffsamples =
         ((gint64) self->latency) - ((gint64) self->buffer_fill) / channels;
     if (diffsamples > 0) {
-      diffsize = diffsamples * channels * width;
+      diffsize = diffsamples * channels * bps;
       in = g_new0 (guint8, diffsize);
       out = g_new0 (guint8, diffsize);
       self->nsamples_out += self->process (self, in, out, diffsamples);
@@ -671,45 +668,39 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
       g_free (out);
     }
 
-    res = gst_pad_alloc_buffer (GST_BASE_TRANSFORM_CAST (self)->srcpad,
-        GST_BUFFER_OFFSET_NONE, outsize,
-        GST_PAD_CAPS (GST_BASE_TRANSFORM_CAST (self)->srcpad), &outbuf);
-
-    if (G_UNLIKELY (res != GST_FLOW_OK)) {
-      GST_WARNING_OBJECT (self, "failed allocating buffer of %d bytes",
-          outsize);
-      self->buffer_fill = 0;
-      return;
-    }
+    outbuf = gst_buffer_new_and_alloc (outsize);
 
     /* Convolve the residue with zeros to get the actual remaining data */
     in = g_new0 (guint8, outsize);
-    self->nsamples_out +=
-        self->process (self, in, GST_BUFFER_DATA (outbuf), outsamples);
+    data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
+    self->nsamples_out += self->process (self, in, data, outsamples);
+    gst_buffer_unmap (outbuf, data, size);
+
     g_free (in);
   } else {
     guint gensamples = 0;
-    guint8 *data;
 
     outbuf = gst_buffer_new_and_alloc (outsize);
-    data = GST_BUFFER_DATA (outbuf);
+    data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
 
     while (gensamples < outsamples) {
       guint step_insamples = self->block_length - self->buffer_fill;
-      guint8 *zeroes = g_new0 (guint8, step_insamples * channels * width);
-      guint8 *out = g_new (guint8, self->block_length * channels * width);
+      guint8 *zeroes = g_new0 (guint8, step_insamples * channels * bps);
+      guint8 *out = g_new (guint8, self->block_length * channels * bps);
       guint step_gensamples;
 
       step_gensamples = self->process (self, zeroes, out, step_insamples);
       g_free (zeroes);
 
-      memcpy (data + gensamples * width, out, MIN (step_gensamples,
-              outsamples - gensamples) * width);
+      memcpy (data + gensamples * bps, out, MIN (step_gensamples,
+              outsamples - gensamples) * bps);
       gensamples += MIN (step_gensamples, outsamples - gensamples);
 
       g_free (out);
     }
     self->nsamples_out += gensamples;
+
+    gst_buffer_unmap (outbuf, data, size);
   }
 
   /* Set timestamp, offset, etc from the values we
@@ -734,7 +725,8 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
   GST_DEBUG_OBJECT (self, "Pushing residue buffer of size %d with timestamp: %"
       GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %"
       G_GUINT64_FORMAT ", offset_end: %" G_GUINT64_FORMAT ", nsamples_out: %d",
-      GST_BUFFER_SIZE (outbuf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (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), outsamples);
 
@@ -752,7 +744,7 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
 /* get notified of caps and plug in the correct process function */
 static gboolean
 gst_audio_fx_base_fir_filter_setup (GstAudioFilter * base,
-    GstRingBufferSpec * format)
+    const GstAudioInfo * info)
 {
   GstAudioFXBaseFIRFilter *self = GST_AUDIO_FX_BASE_FIR_FILTER (base);
 
@@ -768,8 +760,8 @@ gst_audio_fx_base_fir_filter_setup (GstAudioFilter * base,
     self->nsamples_in = 0;
   }
 
-  gst_audio_fx_base_fir_filter_select_process_function (self, format->width,
-      format->channels);
+  gst_audio_fx_base_fir_filter_select_process_function (self,
+      GST_AUDIO_INFO_FORMAT (info), GST_AUDIO_INFO_CHANNELS (info));
 
   return (self->process != NULL);
 }
@@ -778,32 +770,28 @@ gst_audio_fx_base_fir_filter_setup (GstAudioFilter * base,
 
 static gboolean
 gst_audio_fx_base_fir_filter_transform_size (GstBaseTransform * base,
-    GstPadDirection direction, GstCaps * caps, guint size, GstCaps * othercaps,
-    guint * othersize)
+    GstPadDirection direction, GstCaps * caps, gsize size, GstCaps * othercaps,
+    gsize * othersize)
 {
   GstAudioFXBaseFIRFilter *self = GST_AUDIO_FX_BASE_FIR_FILTER (base);
   guint blocklen;
-  GstStructure *s;
-  gint width, channels;
+  GstAudioInfo info;
+  gint bpf;
 
   if (!self->fft || self->low_latency || direction == GST_PAD_SRC) {
     *othersize = size;
     return TRUE;
   }
 
-  s = gst_caps_get_structure (caps, 0);
-  if (!gst_structure_get_int (s, "width", &width) ||
-      !gst_structure_get_int (s, "channels", &channels))
+  if (!gst_audio_info_from_caps (&info, caps))
     return FALSE;
 
-  width /= 8;
-
-  size /= width * channels;
+  bpf = GST_AUDIO_INFO_BPF (&info);
 
+  size /= bpf;
   blocklen = self->block_length - self->kernel_length + 1;
   *othersize = ((size + blocklen - 1) / blocklen) * blocklen;
-
-  *othersize *= width * channels;
+  *othersize *= bpf;
 
   return TRUE;
 }
@@ -814,11 +802,13 @@ gst_audio_fx_base_fir_filter_transform (GstBaseTransform * base,
 {
   GstAudioFXBaseFIRFilter *self = GST_AUDIO_FX_BASE_FIR_FILTER (base);
   GstClockTime timestamp, expected_timestamp;
-  gint channels = GST_AUDIO_FILTER_CAST (self)->format.channels;
-  gint rate = GST_AUDIO_FILTER_CAST (self)->format.rate;
-  gint width = GST_AUDIO_FILTER_CAST (self)->format.width / 8;
-  guint input_samples = (GST_BUFFER_SIZE (inbuf) / width) / channels;
-  guint output_samples = (GST_BUFFER_SIZE (outbuf) / width) / channels;
+  gint channels = GST_AUDIO_FILTER_CHANNELS (self);
+  gint rate = GST_AUDIO_FILTER_RATE (self);
+  gint bps = GST_AUDIO_FILTER_BPS (self);
+  guint8 *indata, *outdata;
+  gsize insize, outsize;
+  guint input_samples;
+  guint output_samples;
   guint generated_samples;
   guint64 output_offset;
   gint64 diff = 0;
@@ -871,11 +861,18 @@ gst_audio_fx_base_fir_filter_transform (GstBaseTransform * base,
     self->start_off = GST_BUFFER_OFFSET (inbuf);
   }
 
+  indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
+  outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
+
+  input_samples = (insize / bps) / channels;
+  output_samples = (outsize / bps) / channels;
+
   self->nsamples_in += input_samples;
 
-  generated_samples =
-      self->process (self, GST_BUFFER_DATA (inbuf), GST_BUFFER_DATA (outbuf),
-      input_samples);
+  generated_samples = self->process (self, indata, outdata, input_samples);
+
+  gst_buffer_unmap (inbuf, indata, insize);
+  gst_buffer_unmap (outbuf, outdata, outsize);
 
   g_assert (generated_samples <= output_samples);
   self->nsamples_out += generated_samples;
@@ -891,9 +888,9 @@ gst_audio_fx_base_fir_filter_transform (GstBaseTransform * base,
     gint64 tmp = diff;
     diff = generated_samples - diff;
     generated_samples = tmp;
-    GST_BUFFER_DATA (outbuf) += diff * width * channels;
   }
-  GST_BUFFER_SIZE (outbuf) = generated_samples * width * channels;
+  gst_buffer_resize (outbuf, diff * bps * channels,
+      generated_samples * bps * channels);
 
   output_offset = self->nsamples_out - self->latency - generated_samples;
   GST_BUFFER_TIMESTAMP (outbuf) =
@@ -913,7 +910,8 @@ gst_audio_fx_base_fir_filter_transform (GstBaseTransform * base,
   GST_DEBUG_OBJECT (self, "Pushing buffer of size %d with timestamp: %"
       GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %"
       G_GUINT64_FORMAT ", offset_end: %" G_GUINT64_FORMAT ", nsamples_out: %d",
-      GST_BUFFER_SIZE (outbuf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (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), generated_samples);
 
@@ -962,7 +960,7 @@ gst_audio_fx_base_fir_filter_query (GstPad * pad, GstQuery * query)
       gboolean live;
       guint64 latency;
       GstPad *peer;
-      gint rate = GST_AUDIO_FILTER (self)->format.rate;
+      gint rate = GST_AUDIO_FILTER_RATE (self);
 
       if (rate == 0) {
         res = FALSE;
@@ -1019,7 +1017,8 @@ gst_audio_fx_base_fir_filter_query_type (GstPad * pad)
 }
 
 static gboolean
-gst_audio_fx_base_fir_filter_event (GstBaseTransform * base, GstEvent * event)
+gst_audio_fx_base_fir_filter_sink_event (GstBaseTransform * base,
+    GstEvent * event)
 {
   GstAudioFXBaseFIRFilter *self = GST_AUDIO_FX_BASE_FIR_FILTER (base);
 
@@ -1035,7 +1034,7 @@ gst_audio_fx_base_fir_filter_event (GstBaseTransform * base, GstEvent * event)
       break;
   }
 
-  return GST_BASE_TRANSFORM_CLASS (parent_class)->event (base, event);
+  return GST_BASE_TRANSFORM_CLASS (parent_class)->sink_event (base, event);
 }
 
 void
@@ -1079,8 +1078,7 @@ gst_audio_fx_base_fir_filter_set_kernel (GstAudioFXBaseFIRFilter * self,
 
   gst_audio_fx_base_fir_filter_calculate_frequency_response (self);
   gst_audio_fx_base_fir_filter_select_process_function (self,
-      GST_AUDIO_FILTER_CAST (self)->format.width,
-      GST_AUDIO_FILTER_CAST (self)->format.channels);
+      GST_AUDIO_FILTER_FORMAT (self), GST_AUDIO_FILTER_CHANNELS (self));
 
   if (latency_changed) {
     self->latency = latency;
index 0b0fc34..f49e61f 100644 (file)
 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
 
 #define ALLOWED_CAPS \
-    "audio/x-raw-float,"                                              \
-    " width = (int) { 32, 64 }, "                                     \
-    " endianness = (int) BYTE_ORDER,"                                 \
-    " rate = (int) [ 1, MAX ],"                                       \
+    "audio/x-raw,"                                                \
+    " format=(string){"GST_AUDIO_NE(F32)","GST_AUDIO_NE(F64)"},"  \
+    " rate = (int) [ 1, MAX ],"                                   \
     " channels = (int) [ 1, MAX ]"
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_fx_base_iir_filter_debug, "audiofxbaseiirfilter", 0, "Audio IIR Filter Base Class");
-
-GST_BOILERPLATE_FULL (GstAudioFXBaseIIRFilter,
-    gst_audio_fx_base_iir_filter, GstAudioFilter, GST_TYPE_AUDIO_FILTER,
-    DEBUG_INIT);
+#define gst_audio_fx_base_iir_filter_parent_class parent_class
+G_DEFINE_TYPE (GstAudioFXBaseIIRFilter,
+    gst_audio_fx_base_iir_filter, GST_TYPE_AUDIO_FILTER);
 
 static gboolean gst_audio_fx_base_iir_filter_setup (GstAudioFilter * filter,
-    GstRingBufferSpec * format);
+    const GstAudioInfo * info);
 static GstFlowReturn
 gst_audio_fx_base_iir_filter_transform_ip (GstBaseTransform * base,
     GstBuffer * buf);
@@ -64,17 +60,6 @@ static void process_32 (GstAudioFXBaseIIRFilter * filter,
 /* GObject vmethod implementations */
 
 static void
-gst_audio_fx_base_iir_filter_base_init (gpointer klass)
-{
-  GstCaps *caps;
-
-  caps = gst_caps_from_string (ALLOWED_CAPS);
-  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
-      caps);
-  gst_caps_unref (caps);
-}
-
-static void
 gst_audio_fx_base_iir_filter_dispose (GObject * object)
 {
   GstAudioFXBaseIIRFilter *filter = GST_AUDIO_FX_BASE_IIR_FILTER (object);
@@ -112,9 +97,18 @@ gst_audio_fx_base_iir_filter_class_init (GstAudioFXBaseIIRFilterClass * klass)
   GObjectClass *gobject_class = (GObjectClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
   GstAudioFilterClass *filter_class = (GstAudioFilterClass *) klass;
+  GstCaps *caps;
+
+  GST_DEBUG_CATEGORY_INIT (gst_audio_fx_base_iir_filter_debug,
+      "audiofxbaseiirfilter", 0, "Audio IIR Filter Base Class");
 
   gobject_class->dispose = gst_audio_fx_base_iir_filter_dispose;
 
+  caps = gst_caps_from_string (ALLOWED_CAPS);
+  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
+      caps);
+  gst_caps_unref (caps);
+
   filter_class->setup = GST_DEBUG_FUNCPTR (gst_audio_fx_base_iir_filter_setup);
 
   trans_class->transform_ip =
@@ -123,8 +117,7 @@ gst_audio_fx_base_iir_filter_class_init (GstAudioFXBaseIIRFilterClass * klass)
 }
 
 static void
-gst_audio_fx_base_iir_filter_init (GstAudioFXBaseIIRFilter * filter,
-    GstAudioFXBaseIIRFilterClass * klass)
+gst_audio_fx_base_iir_filter_init (GstAudioFXBaseIIRFilter * filter)
 {
   gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
 
@@ -244,47 +237,50 @@ gst_audio_fx_base_iir_filter_set_coefficients (GstAudioFXBaseIIRFilter * filter,
 
 static gboolean
 gst_audio_fx_base_iir_filter_setup (GstAudioFilter * base,
-    GstRingBufferSpec * format)
+    const GstAudioInfo * info)
 {
   GstAudioFXBaseIIRFilter *filter = GST_AUDIO_FX_BASE_IIR_FILTER (base);
   gboolean ret = TRUE;
+  gint channels;
+
+  switch (GST_AUDIO_INFO_FORMAT (info)) {
+    case GST_AUDIO_FORMAT_F32:
+      filter->process = (GstAudioFXBaseIIRFilterProcessFunc)
+          process_32;
+      break;
+    case GST_AUDIO_FORMAT_F64:
+      filter->process = (GstAudioFXBaseIIRFilterProcessFunc)
+          process_64;
+      break;
+    default:
+      ret = FALSE;
+      break;
+  }
 
-  if (format->width == 32)
-    filter->process = (GstAudioFXBaseIIRFilterProcessFunc)
-        process_32;
-  else if (format->width == 64)
-    filter->process = (GstAudioFXBaseIIRFilterProcessFunc)
-        process_64;
-  else
-    ret = FALSE;
+  channels = GST_AUDIO_INFO_CHANNELS (info);
 
-  if (format->channels != filter->nchannels) {
+  if (channels != filter->nchannels) {
     guint i;
     GstAudioFXBaseIIRFilterChannelCtx *ctx;
 
     if (filter->channels) {
-
       for (i = 0; i < filter->nchannels; i++) {
         ctx = &filter->channels[i];
 
         g_free (ctx->x);
         g_free (ctx->y);
       }
-
       g_free (filter->channels);
-      filter->channels = NULL;
     }
 
-    filter->nchannels = format->channels;
-
-    filter->channels =
-        g_new0 (GstAudioFXBaseIIRFilterChannelCtx, filter->nchannels);
+    filter->channels = g_new0 (GstAudioFXBaseIIRFilterChannelCtx, channels);
     for (i = 0; i < filter->nchannels; i++) {
       ctx = &filter->channels[i];
 
       ctx->x = g_new0 (gdouble, filter->na);
       ctx->y = g_new0 (gdouble, filter->nb);
     }
+    filter->nchannels = channels;
   }
 
   return ret;
@@ -333,7 +329,7 @@ static void \
 process_##width (GstAudioFXBaseIIRFilter * filter, \
     g##ctype * data, guint num_samples) \
 { \
-  gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; \
+  gint i, j, channels = filter->nchannels; \
   gdouble val; \
   \
   for (i = 0; i < num_samples / channels; i++) { \
@@ -357,6 +353,8 @@ gst_audio_fx_base_iir_filter_transform_ip (GstBaseTransform * base,
   GstAudioFXBaseIIRFilter *filter = GST_AUDIO_FX_BASE_IIR_FILTER (base);
   guint num_samples;
   GstClockTime timestamp, stream_time;
+  guint8 *data;
+  gsize size;
 
   timestamp = GST_BUFFER_TIMESTAMP (buf);
   stream_time =
@@ -368,15 +366,17 @@ gst_audio_fx_base_iir_filter_transform_ip (GstBaseTransform * base,
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
-  num_samples =
-      GST_BUFFER_SIZE (buf) / (GST_AUDIO_FILTER (filter)->format.width / 8);
-
   if (gst_base_transform_is_passthrough (base))
     return GST_FLOW_OK;
 
   g_return_val_if_fail (filter->a != NULL, GST_FLOW_ERROR);
 
-  filter->process (filter, GST_BUFFER_DATA (buf), num_samples);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+  num_samples = size / GST_AUDIO_FILTER_BPS (filter);
+
+  filter->process (filter, data, num_samples);
+
+  gst_buffer_unmap (buf, data, size);
 
   return GST_FLOW_OK;
 }
@@ -386,7 +386,7 @@ static gboolean
 gst_audio_fx_base_iir_filter_stop (GstBaseTransform * base)
 {
   GstAudioFXBaseIIRFilter *filter = GST_AUDIO_FX_BASE_IIR_FILTER (base);
-  guint channels = GST_AUDIO_FILTER (filter)->format.channels;
+  guint channels = filter->nchannels;
   GstAudioFXBaseIIRFilterChannelCtx *ctx;
   guint i;
 
@@ -401,6 +401,7 @@ gst_audio_fx_base_iir_filter_stop (GstBaseTransform * base)
     g_free (filter->channels);
   }
   filter->channels = NULL;
+  filter->nchannels = 0;
 
   return TRUE;
 }
index bac16b2..761606a 100644 (file)
@@ -71,12 +71,9 @@ enum
 
 static guint gst_audio_iir_filter_signals[LAST_SIGNAL] = { 0, };
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_iir_filter_debug, "audioiirfilter", 0, \
-      "Generic audio IIR filter plugin");
-
-GST_BOILERPLATE_FULL (GstAudioIIRFilter, gst_audio_iir_filter, GstAudioFilter,
-    GST_TYPE_AUDIO_FX_BASE_IIR_FILTER, DEBUG_INIT);
+#define gst_audio_iir_filter_parent_class parent_class
+G_DEFINE_TYPE (GstAudioIIRFilter, gst_audio_iir_filter,
+    GST_TYPE_AUDIO_FX_BASE_IIR_FILTER);
 
 static void gst_audio_iir_filter_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -85,26 +82,18 @@ static void gst_audio_iir_filter_get_property (GObject * object, guint prop_id,
 static void gst_audio_iir_filter_finalize (GObject * object);
 
 static gboolean gst_audio_iir_filter_setup (GstAudioFilter * base,
-    GstRingBufferSpec * format);
-
-/* Element class */
-static void
-gst_audio_iir_filter_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class,
-      "Audio IIR filter", "Filter/Effect/Audio",
-      "Generic audio IIR filter with custom filter kernel",
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-}
+    const GstAudioInfo * info);
 
 static void
 gst_audio_iir_filter_class_init (GstAudioIIRFilterClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstAudioFilterClass *filter_class = (GstAudioFilterClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (gst_audio_iir_filter_debug, "audioiirfilter", 0,
+      "Generic audio IIR filter plugin");
+
   gobject_class->set_property = gst_audio_iir_filter_set_property;
   gobject_class->get_property = gst_audio_iir_filter_get_property;
   gobject_class->finalize = gst_audio_iir_filter_finalize;
@@ -139,6 +128,11 @@ gst_audio_iir_filter_class_init (GstAudioIIRFilterClass * klass)
       g_signal_new ("rate-changed", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstAudioIIRFilterClass, rate_changed),
       NULL, NULL, gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "Audio IIR filter", "Filter/Effect/Audio",
+      "Generic audio IIR filter with custom filter kernel",
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
 }
 
 static void
@@ -184,8 +178,7 @@ gst_audio_iir_filter_update_coefficients (GstAudioIIRFilter * self,
 }
 
 static void
-gst_audio_iir_filter_init (GstAudioIIRFilter * self,
-    GstAudioIIRFilterClass * g_class)
+gst_audio_iir_filter_init (GstAudioIIRFilter * self)
 {
   GValue v = { 0, };
   GValueArray *a, *b;
@@ -207,17 +200,17 @@ gst_audio_iir_filter_init (GstAudioIIRFilter * self,
 
 /* get notified of caps and plug in the correct process function */
 static gboolean
-gst_audio_iir_filter_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_audio_iir_filter_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstAudioIIRFilter *self = GST_AUDIO_IIR_FILTER (base);
+  gint new_rate = GST_AUDIO_INFO_RATE (info);
 
-  if (self->rate != format->rate) {
+  if (GST_AUDIO_FILTER_RATE (self) != new_rate) {
     g_signal_emit (G_OBJECT (self),
-        gst_audio_iir_filter_signals[SIGNAL_RATE_CHANGED], 0, format->rate);
-    self->rate = format->rate;
+        gst_audio_iir_filter_signals[SIGNAL_RATE_CHANGED], 0, new_rate);
   }
 
-  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, format);
+  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, info);
 }
 
 static void
index 607edf2..2a80c09 100644 (file)
@@ -55,7 +55,6 @@ struct _GstAudioIIRFilter {
 
   /* < private > */
   GMutex *lock;
-  gint rate;
 };
 
 struct _GstAudioIIRFilterClass {
index c0a7da4..56a2d0b 100644 (file)
@@ -65,24 +65,12 @@ enum
 };
 
 #define ALLOWED_CAPS \
-    "audio/x-raw-int,"                                                \
-    " depth=(int)16,"                                                 \
-    " width=(int)16,"                                                 \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " signed=(bool)TRUE,"                                             \
-    " rate=(int)[1,MAX],"                                             \
-    " channels=(int)[1,MAX]; "                                        \
-    "audio/x-raw-float,"                                              \
-    " width=(int)32,"                                                 \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " rate=(int)[1,MAX],"                                             \
-    " channels=(int)[1,MAX]"
-
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_invert_debug, "audioinvert", 0, "audioinvert element");
-
-GST_BOILERPLATE_FULL (GstAudioInvert, gst_audio_invert, GstAudioFilter,
-    GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
+    "audio/x-raw,"                                                     \
+    " format=(string) {"GST_AUDIO_NE(S16)","GST_AUDIO_NE(F32)"},"  \
+    " rate=(int)[1,MAX],"                                              \
+    " channels=(int)[1,MAX] "
+
+G_DEFINE_TYPE (GstAudioInvert, gst_audio_invert, GST_TYPE_AUDIO_FILTER);
 
 static void gst_audio_invert_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -90,7 +78,7 @@ static void gst_audio_invert_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
 static gboolean gst_audio_invert_setup (GstAudioFilter * filter,
-    GstRingBufferSpec * format);
+    const GstAudioInfo * info);
 static GstFlowReturn gst_audio_invert_transform_ip (GstBaseTransform * base,
     GstBuffer * buf);
 
@@ -102,28 +90,18 @@ static void gst_audio_invert_transform_float (GstAudioInvert * filter,
 /* GObject vmethod implementations */
 
 static void
-gst_audio_invert_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-  GstCaps *caps;
-
-  gst_element_class_set_details_simple (element_class, "Audio inversion",
-      "Filter/Effect/Audio",
-      "Swaps upper and lower half of audio samples",
-      "Sebastian Dröge <slomo@circular-chaos.org>");
-
-  caps = gst_caps_from_string (ALLOWED_CAPS);
-  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
-      caps);
-  gst_caps_unref (caps);
-}
-
-static void
 gst_audio_invert_class_init (GstAudioInvertClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+  GstCaps *caps;
+
+  GST_DEBUG_CATEGORY_INIT (gst_audio_invert_debug, "audioinvert", 0,
+      "audioinvert element");
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+
   gobject_class->set_property = gst_audio_invert_set_property;
   gobject_class->get_property = gst_audio_invert_get_property;
 
@@ -133,6 +111,16 @@ gst_audio_invert_class_init (GstAudioInvertClass * klass)
           0.0,
           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "Audio inversion",
+      "Filter/Effect/Audio",
+      "Swaps upper and lower half of audio samples",
+      "Sebastian Dröge <slomo@circular-chaos.org>");
+
+  caps = gst_caps_from_string (ALLOWED_CAPS);
+  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
+      caps);
+  gst_caps_unref (caps);
+
   GST_AUDIO_FILTER_CLASS (klass)->setup =
       GST_DEBUG_FUNCPTR (gst_audio_invert_setup);
   GST_BASE_TRANSFORM_CLASS (klass)->transform_ip =
@@ -140,7 +128,7 @@ gst_audio_invert_class_init (GstAudioInvertClass * klass)
 }
 
 static void
-gst_audio_invert_init (GstAudioInvert * filter, GstAudioInvertClass * klass)
+gst_audio_invert_init (GstAudioInvert * filter)
 {
   filter->degree = 0.0;
   gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
@@ -184,20 +172,24 @@ gst_audio_invert_get_property (GObject * object, guint prop_id,
 /* GstAudioFilter vmethod implementations */
 
 static gboolean
-gst_audio_invert_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_audio_invert_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstAudioInvert *filter = GST_AUDIO_INVERT (base);
   gboolean ret = TRUE;
 
-  if (format->type == GST_BUFTYPE_FLOAT && format->width == 32)
-    filter->process = (GstAudioInvertProcessFunc)
-        gst_audio_invert_transform_float;
-  else if (format->type == GST_BUFTYPE_LINEAR && format->width == 16)
-    filter->process = (GstAudioInvertProcessFunc)
-        gst_audio_invert_transform_int;
-  else
-    ret = FALSE;
-
+  switch (GST_AUDIO_INFO_FORMAT (info)) {
+    case GST_AUDIO_FORMAT_S16:
+      filter->process = (GstAudioInvertProcessFunc)
+          gst_audio_invert_transform_int;
+      break;
+    case GST_AUDIO_FORMAT_F32:
+      filter->process = (GstAudioInvertProcessFunc)
+          gst_audio_invert_transform_float;
+      break;
+    default:
+      ret = FALSE;
+      break;
+  }
   return ret;
 }
 
@@ -236,6 +228,8 @@ gst_audio_invert_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   GstAudioInvert *filter = GST_AUDIO_INVERT (base);
   guint num_samples;
   GstClockTime timestamp, stream_time;
+  guint8 *data;
+  gsize size;
 
   timestamp = GST_BUFFER_TIMESTAMP (buf);
   stream_time =
@@ -247,14 +241,16 @@ gst_audio_invert_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
-  num_samples =
-      GST_BUFFER_SIZE (buf) / (GST_AUDIO_FILTER (filter)->format.width / 8);
-
   if (gst_base_transform_is_passthrough (base) ||
       G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
     return GST_FLOW_OK;
 
-  filter->process (filter, GST_BUFFER_DATA (buf), num_samples);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+  num_samples = size / GST_AUDIO_FILTER_BPS (filter);
+
+  filter->process (filter, data, num_samples);
+
+  gst_buffer_unmap (buf, data, size);
 
   return GST_FLOW_OK;
 }
index c6fb93e..d79686d 100644 (file)
@@ -72,24 +72,12 @@ enum
 };
 
 #define ALLOWED_CAPS \
-    "audio/x-raw-int,"                                                \
-    " depth=(int)16,"                                                 \
-    " width=(int)16,"                                                 \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " signed=(bool)TRUE,"                                             \
-    " rate=(int)[1,MAX],"                                             \
-    " channels=(int)[1,MAX]; "                                        \
-    "audio/x-raw-float,"                                              \
-    " width=(int)32,"                                                 \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " rate=(int)[1,MAX],"                                             \
+    "audio/x-raw,"                                                \
+    " format=(string){"GST_AUDIO_NE(S16)","GST_AUDIO_NE(F32)"},"  \
+    " rate=(int)[1,MAX],"                                         \
     " channels=(int)[1,MAX]"
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_karaoke_debug, "audiokaraoke", 0, "audiokaraoke element");
-
-GST_BOILERPLATE_FULL (GstAudioKaraoke, gst_audio_karaoke, GstAudioFilter,
-    GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
+G_DEFINE_TYPE (GstAudioKaraoke, gst_audio_karaoke, GST_TYPE_AUDIO_FILTER);
 
 static void gst_audio_karaoke_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -97,7 +85,7 @@ static void gst_audio_karaoke_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
 static gboolean gst_audio_karaoke_setup (GstAudioFilter * filter,
-    GstRingBufferSpec * format);
+    const GstAudioInfo * info);
 static GstFlowReturn gst_audio_karaoke_transform_ip (GstBaseTransform * base,
     GstBuffer * buf);
 
@@ -109,27 +97,18 @@ static void gst_audio_karaoke_transform_float (GstAudioKaraoke * filter,
 /* GObject vmethod implementations */
 
 static void
-gst_audio_karaoke_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-  GstCaps *caps;
-
-  gst_element_class_set_details_simple (element_class, "AudioKaraoke",
-      "Filter/Effect/Audio",
-      "Removes voice from sound", "Wim Taymans <wim.taymans@gmail.com>");
-
-  caps = gst_caps_from_string (ALLOWED_CAPS);
-  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
-      caps);
-  gst_caps_unref (caps);
-}
-
-static void
 gst_audio_karaoke_class_init (GstAudioKaraokeClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+  GstCaps *caps;
+
+  GST_DEBUG_CATEGORY_INIT (gst_audio_karaoke_debug, "audiokaraoke", 0,
+      "audiokaraoke element");
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+
   gobject_class->set_property = gst_audio_karaoke_set_property;
   gobject_class->get_property = gst_audio_karaoke_get_property;
 
@@ -153,6 +132,15 @@ gst_audio_karaoke_class_init (GstAudioKaraokeClass * klass)
           "The Frequency width of the filter", 0.0, 100.0, DEFAULT_FILTER_WIDTH,
           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "AudioKaraoke",
+      "Filter/Effect/Audio",
+      "Removes voice from sound", "Wim Taymans <wim.taymans@gmail.com>");
+
+  caps = gst_caps_from_string (ALLOWED_CAPS);
+  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass),
+      caps);
+  gst_caps_unref (caps);
+
   GST_AUDIO_FILTER_CLASS (klass)->setup =
       GST_DEBUG_FUNCPTR (gst_audio_karaoke_setup);
   GST_BASE_TRANSFORM_CLASS (klass)->transform_ip =
@@ -160,7 +148,7 @@ gst_audio_karaoke_class_init (GstAudioKaraokeClass * klass)
 }
 
 static void
-gst_audio_karaoke_init (GstAudioKaraoke * filter, GstAudioKaraokeClass * klass)
+gst_audio_karaoke_init (GstAudioKaraoke * filter)
 {
   gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
   gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (filter), TRUE);
@@ -172,10 +160,12 @@ gst_audio_karaoke_init (GstAudioKaraoke * filter, GstAudioKaraokeClass * klass)
 }
 
 static void
-update_filter (GstAudioKaraoke * filter, gint rate)
+update_filter (GstAudioKaraoke * filter)
 {
   gfloat A, B, C;
+  gint rate;
 
+  rate = GST_AUDIO_FILTER_RATE (filter);
   if (rate == 0)
     return;
 
@@ -207,11 +197,11 @@ gst_audio_karaoke_set_property (GObject * object, guint prop_id,
       break;
     case PROP_FILTER_BAND:
       filter->filter_band = g_value_get_float (value);
-      update_filter (filter, filter->rate);
+      update_filter (filter);
       break;
     case PROP_FILTER_WIDTH:
       filter->filter_width = g_value_get_float (value);
-      update_filter (filter, filter->rate);
+      update_filter (filter);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -249,24 +239,25 @@ gst_audio_karaoke_get_property (GObject * object, guint prop_id,
 /* GstAudioFilter vmethod implementations */
 
 static gboolean
-gst_audio_karaoke_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_audio_karaoke_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstAudioKaraoke *filter = GST_AUDIO_KARAOKE (base);
   gboolean ret = TRUE;
 
-  filter->channels = format->channels;
-  filter->rate = format->rate;
-
-  if (format->type == GST_BUFTYPE_FLOAT && format->width == 32)
-    filter->process = (GstAudioKaraokeProcessFunc)
-        gst_audio_karaoke_transform_float;
-  else if (format->type == GST_BUFTYPE_LINEAR && format->width == 16)
-    filter->process = (GstAudioKaraokeProcessFunc)
-        gst_audio_karaoke_transform_int;
-  else
-    ret = FALSE;
-
-  update_filter (filter, format->rate);
+  switch (GST_AUDIO_INFO_FORMAT (info)) {
+    case GST_AUDIO_FORMAT_S16:
+      filter->process = (GstAudioKaraokeProcessFunc)
+          gst_audio_karaoke_transform_int;
+      break;
+    case GST_AUDIO_FORMAT_F32:
+      filter->process = (GstAudioKaraokeProcessFunc)
+          gst_audio_karaoke_transform_float;
+      break;
+    default:
+      ret = FALSE;
+      break;
+  }
+  update_filter (filter);
 
   return ret;
 }
@@ -280,7 +271,7 @@ gst_audio_karaoke_transform_int (GstAudioKaraoke * filter,
   gdouble y;
   gint level;
 
-  channels = filter->channels;
+  channels = GST_AUDIO_FILTER_CHANNELS (filter);
   level = filter->level * 256;
 
   for (i = 0; i < num_samples; i += channels) {
@@ -313,7 +304,7 @@ gst_audio_karaoke_transform_float (GstAudioKaraoke * filter,
   gdouble l, r, o;
   gdouble y;
 
-  channels = filter->channels;
+  channels = GST_AUDIO_FILTER_CHANNELS (filter);
 
   for (i = 0; i < num_samples; i += channels) {
     /* get left and right inputs */
@@ -339,6 +330,8 @@ gst_audio_karaoke_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   GstAudioKaraoke *filter = GST_AUDIO_KARAOKE (base);
   guint num_samples;
   GstClockTime timestamp, stream_time;
+  guint8 *data;
+  gsize size;
 
   timestamp = GST_BUFFER_TIMESTAMP (buf);
   stream_time =
@@ -350,14 +343,16 @@ gst_audio_karaoke_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
-  num_samples =
-      GST_BUFFER_SIZE (buf) / (GST_AUDIO_FILTER (filter)->format.width / 8);
-
   if (gst_base_transform_is_passthrough (base) ||
       G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
     return GST_FLOW_OK;
 
-  filter->process (filter, GST_BUFFER_DATA (buf), num_samples);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+  num_samples = size / GST_AUDIO_FILTER_BPS (filter);
+
+  filter->process (filter, data, num_samples);
+
+  gst_buffer_unmap (buf, data, size);
 
   return GST_FLOW_OK;
 }
index 727fafa..a299b88 100644 (file)
@@ -42,9 +42,6 @@ struct _GstAudioKaraoke
 {
   GstAudioFilter audiofilter;
 
-  gint channels;
-  gint rate;
-
   /* properties */
   gfloat level;
   gfloat mono_level;
index 0bd81b9..aa3bc84 100644 (file)
@@ -117,11 +117,7 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
         "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
     );
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_panorama_debug, "audiopanorama", 0, "audiopanorama element");
-
-GST_BOILERPLATE_FULL (GstAudioPanorama, gst_audio_panorama, GstBaseTransform,
-    GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
+G_DEFINE_TYPE (GstAudioPanorama, gst_audio_panorama, GST_TYPE_BASE_TRANSFORM);
 
 static void gst_audio_panorama_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -129,9 +125,9 @@ static void gst_audio_panorama_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
 static gboolean gst_audio_panorama_get_unit_size (GstBaseTransform * base,
-    GstCaps * caps, guint * size);
+    GstCaps * caps, gsize * size);
 static GstCaps *gst_audio_panorama_transform_caps (GstBaseTransform * base,
-    GstPadDirection direction, GstCaps * caps);
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter);
 static gboolean gst_audio_panorama_set_caps (GstBaseTransform * base,
     GstCaps * incaps, GstCaps * outcaps);
 
@@ -180,26 +176,17 @@ static GstAudioPanoramaProcessFunc panorama_process_functions[2][2][2] = {
 /* GObject vmethod implementations */
 
 static void
-gst_audio_panorama_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template));
-  gst_element_class_set_details_simple (element_class, "Stereo positioning",
-      "Filter/Effect/Audio",
-      "Positions audio streams in the stereo panorama",
-      "Stefan Kost <ensonic@users.sf.net>");
-}
-
-static void
 gst_audio_panorama_class_init (GstAudioPanoramaClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+
+  GST_DEBUG_CATEGORY_INIT (gst_audio_panorama_debug, "audiopanorama", 0,
+      "audiopanorama element");
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+
   gobject_class->set_property = gst_audio_panorama_set_property;
   gobject_class->get_property = gst_audio_panorama_get_property;
 
@@ -224,6 +211,16 @@ gst_audio_panorama_class_init (GstAudioPanoramaClass * klass)
           GST_TYPE_AUDIO_PANORAMA_METHOD, METHOD_PSYCHOACOUSTIC,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "Stereo positioning",
+      "Filter/Effect/Audio",
+      "Positions audio streams in the stereo panorama",
+      "Stefan Kost <ensonic@users.sf.net>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_template));
+
   GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size =
       GST_DEBUG_FUNCPTR (gst_audio_panorama_get_unit_size);
   GST_BASE_TRANSFORM_CLASS (klass)->transform_caps =
@@ -235,8 +232,7 @@ gst_audio_panorama_class_init (GstAudioPanoramaClass * klass)
 }
 
 static void
-gst_audio_panorama_init (GstAudioPanorama * filter,
-    GstAudioPanoramaClass * klass)
+gst_audio_panorama_init (GstAudioPanorama * filter)
 {
 
   filter->panorama = 0;
@@ -315,7 +311,7 @@ gst_audio_panorama_get_property (GObject * object, guint prop_id,
 
 static gboolean
 gst_audio_panorama_get_unit_size (GstBaseTransform * base, GstCaps * caps,
-    guint * size)
+    gsize * size)
 {
   gint width, channels;
   GstStructure *structure;
@@ -335,7 +331,7 @@ gst_audio_panorama_get_unit_size (GstBaseTransform * base, GstCaps * caps,
 
 static GstCaps *
 gst_audio_panorama_transform_caps (GstBaseTransform * base,
-    GstPadDirection direction, GstCaps * caps)
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter)
 {
   GstCaps *res;
   GstStructure *structure;
@@ -655,8 +651,9 @@ gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
     GstBuffer * outbuf)
 {
   GstAudioPanorama *filter = GST_AUDIO_PANORAMA (base);
-  guint num_samples = GST_BUFFER_SIZE (outbuf) / (2 * filter->width);
   GstClockTime timestamp, stream_time;
+  guint8 *indata, *outdata;
+  gsize insize, outsize;
 
   timestamp = GST_BUFFER_TIMESTAMP (inbuf);
   stream_time =
@@ -668,14 +665,20 @@ gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
+  indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
+  outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
+
   if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP))) {
     GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
-    memset (GST_BUFFER_DATA (outbuf), 0, GST_BUFFER_SIZE (outbuf));
-    return GST_FLOW_OK;
+    memset (outdata, 0, outsize);
+  } else {
+    guint num_samples = outsize / (2 * filter->width);
+
+    filter->process (filter, indata, outdata, num_samples);
   }
 
-  filter->process (filter, GST_BUFFER_DATA (inbuf),
-      GST_BUFFER_DATA (outbuf), num_samples);
+  gst_buffer_unmap (inbuf, indata, insize);
+  gst_buffer_unmap (outbuf, outdata, outsize);
 
   return GST_FLOW_OK;
 }
index 07356e2..3f5df12 100644 (file)
@@ -138,12 +138,9 @@ gst_gst_audio_wsincband_window_get_type (void)
   return gtype;
 }
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_gst_audio_wsincband_debug, "audiowsincband", 0, \
-      "Band-pass and Band-reject Windowed sinc filter plugin");
-
-GST_BOILERPLATE_FULL (GstAudioWSincBand, gst_audio_wsincband, GstAudioFilter,
-    GST_TYPE_AUDIO_FX_BASE_FIR_FILTER, DEBUG_INIT);
+#define gst_audio_wsincband_parent_class parent_class
+G_DEFINE_TYPE (GstAudioWSincBand, gst_audio_wsincband,
+    GST_TYPE_AUDIO_FX_BASE_FIR_FILTER);
 
 static void gst_audio_wsincband_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -152,32 +149,20 @@ static void gst_audio_wsincband_get_property (GObject * object, guint prop_id,
 static void gst_audio_wsincband_finalize (GObject * object);
 
 static gboolean gst_audio_wsincband_setup (GstAudioFilter * base,
-    GstRingBufferSpec * format);
-
+    const GstAudioInfo * info);
 
 #define POW2(x)  (x)*(x)
 
-/* Element class */
-static void
-gst_audio_wsincband_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class,
-      "Band pass & band reject filter", "Filter/Effect/Audio",
-      "Band pass and band reject windowed sinc filter",
-      "Thomas Vander Stichele <thomas at apestaart dot org>, "
-      "Steven W. Smith, "
-      "Dreamlab Technologies Ltd. <mathis.hofer@dreamlab.net>, "
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-}
-
 static void
 gst_audio_wsincband_class_init (GstAudioWSincBandClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstAudioFilterClass *filter_class = (GstAudioFilterClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (gst_gst_audio_wsincband_debug, "audiowsincband", 0,
+      "Band-pass and Band-reject Windowed sinc filter plugin");
+
   gobject_class->set_property = gst_audio_wsincband_set_property;
   gobject_class->get_property = gst_audio_wsincband_get_property;
   gobject_class->finalize = gst_audio_wsincband_finalize;
@@ -210,12 +195,19 @@ gst_audio_wsincband_class_init (GstAudioWSincBandClass * klass)
           WINDOW_HAMMING,
           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class,
+      "Band pass & band reject filter", "Filter/Effect/Audio",
+      "Band pass and band reject windowed sinc filter",
+      "Thomas Vander Stichele <thomas at apestaart dot org>, "
+      "Steven W. Smith, "
+      "Dreamlab Technologies Ltd. <mathis.hofer@dreamlab.net>, "
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
   filter_class->setup = GST_DEBUG_FUNCPTR (gst_audio_wsincband_setup);
 }
 
 static void
-gst_audio_wsincband_init (GstAudioWSincBand * self,
-    GstAudioWSincBandClass * g_class)
+gst_audio_wsincband_init (GstAudioWSincBand * self)
 {
   self->kernel_length = 101;
   self->lower_frequency = 0.0;
@@ -235,26 +227,27 @@ gst_audio_wsincband_build_kernel (GstAudioWSincBand * self)
   gdouble *kernel_lp, *kernel_hp;
   gdouble w;
   gdouble *kernel;
+  gint rate, channels;
 
   len = self->kernel_length;
 
-  if (GST_AUDIO_FILTER (self)->format.rate == 0) {
+  rate = GST_AUDIO_FILTER_RATE (self);
+  channels = GST_AUDIO_FILTER_CHANNELS (self);
+
+  if (rate == 0) {
     GST_DEBUG ("rate not set yet");
     return;
   }
 
-  if (GST_AUDIO_FILTER (self)->format.channels == 0) {
+  if (channels == 0) {
     GST_DEBUG ("channels not set yet");
     return;
   }
 
   /* Clamp frequencies */
-  self->lower_frequency =
-      CLAMP (self->lower_frequency, 0.0,
-      GST_AUDIO_FILTER (self)->format.rate / 2);
-  self->upper_frequency =
-      CLAMP (self->upper_frequency, 0.0,
-      GST_AUDIO_FILTER (self)->format.rate / 2);
+  self->lower_frequency = CLAMP (self->lower_frequency, 0.0, rate / 2);
+  self->upper_frequency = CLAMP (self->upper_frequency, 0.0, rate / 2);
+
   if (self->lower_frequency > self->upper_frequency) {
     gint tmp = self->lower_frequency;
 
@@ -269,7 +262,7 @@ gst_audio_wsincband_build_kernel (GstAudioWSincBand * self)
       (self->mode == MODE_BAND_PASS) ? "band-pass" : "band-reject");
 
   /* fill the lp kernel */
-  w = 2 * G_PI * (self->lower_frequency / GST_AUDIO_FILTER (self)->format.rate);
+  w = 2 * G_PI * (self->lower_frequency / rate);
   kernel_lp = g_new (gdouble, len);
   for (i = 0; i < len; ++i) {
     if (i == (len - 1) / 2.0)
@@ -306,7 +299,7 @@ gst_audio_wsincband_build_kernel (GstAudioWSincBand * self)
     kernel_lp[i] /= sum;
 
   /* fill the hp kernel */
-  w = 2 * G_PI * (self->upper_frequency / GST_AUDIO_FILTER (self)->format.rate);
+  w = 2 * G_PI * (self->upper_frequency / rate);
   kernel_hp = g_new (gdouble, len);
   for (i = 0; i < len; ++i) {
     if (i == (len - 1) / 2.0)
@@ -378,13 +371,13 @@ gst_audio_wsincband_build_kernel (GstAudioWSincBand * self)
 
 /* get notified of caps and plug in the correct process function */
 static gboolean
-gst_audio_wsincband_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_audio_wsincband_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstAudioWSincBand *self = GST_AUDIO_WSINC_BAND (base);
 
   gst_audio_wsincband_build_kernel (self);
 
-  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, format);
+  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, info);
 }
 
 static void
index b0dea00..2ade91c 100644 (file)
@@ -1,5 +1,5 @@
 /* -*- c-basic-offset: 2 -*-
- * 
+ *
  * GStreamer
  * Copyright (C) 1999-2001 Erik Walthinsen <omega@cse.ogi.edu>
  *               2006 Dreamlab Technologies Ltd. <mathis.hofer@dreamlab.net>
@@ -19,8 +19,8 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
- * 
- * 
+ *
+ *
  * this windowed sinc filter is taken from the freely downloadable DSP book,
  * "The Scientist and Engineer's Guide to Digital Signal Processing",
  * chapter 16
index aa0cf4b..2779b55 100644 (file)
@@ -137,12 +137,9 @@ gst_audio_wsinclimit_window_get_type (void)
   return gtype;
 }
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_audio_wsinclimit_debug, "audiowsinclimit", 0, \
-      "Low-pass and High-pass Windowed sinc filter plugin");
-
-GST_BOILERPLATE_FULL (GstAudioWSincLimit, gst_audio_wsinclimit, GstAudioFilter,
-    GST_TYPE_AUDIO_FX_BASE_FIR_FILTER, DEBUG_INIT);
+#define gst_audio_wsinclimit_parent_class parent_class
+G_DEFINE_TYPE (GstAudioWSincLimit, gst_audio_wsinclimit,
+    GST_TYPE_AUDIO_FX_BASE_FIR_FILTER);
 
 static void gst_audio_wsinclimit_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -151,33 +148,21 @@ static void gst_audio_wsinclimit_get_property (GObject * object, guint prop_id,
 static void gst_audio_wsinclimit_finalize (GObject * object);
 
 static gboolean gst_audio_wsinclimit_setup (GstAudioFilter * base,
-    GstRingBufferSpec * format);
+    const GstAudioInfo * info);
 
 
 #define POW2(x)  (x)*(x)
 
-/* Element class */
-
-static void
-gst_audio_wsinclimit_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class,
-      "Low pass & high pass filter", "Filter/Effect/Audio",
-      "Low pass and high pass windowed sinc filter",
-      "Thomas Vander Stichele <thomas at apestaart dot org>, "
-      "Steven W. Smith, "
-      "Dreamlab Technologies Ltd. <mathis.hofer@dreamlab.net>, "
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-}
-
 static void
 gst_audio_wsinclimit_class_init (GstAudioWSincLimitClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstAudioFilterClass *filter_class = (GstAudioFilterClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (gst_audio_wsinclimit_debug, "audiowsinclimit", 0,
+      "Low-pass and High-pass Windowed sinc filter plugin");
+
   gobject_class->set_property = gst_audio_wsinclimit_set_property;
   gobject_class->get_property = gst_audio_wsinclimit_get_property;
   gobject_class->finalize = gst_audio_wsinclimit_finalize;
@@ -206,12 +191,19 @@ gst_audio_wsinclimit_class_init (GstAudioWSincLimitClass * klass)
           WINDOW_HAMMING,
           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class,
+      "Low pass & high pass filter", "Filter/Effect/Audio",
+      "Low pass and high pass windowed sinc filter",
+      "Thomas Vander Stichele <thomas at apestaart dot org>, "
+      "Steven W. Smith, "
+      "Dreamlab Technologies Ltd. <mathis.hofer@dreamlab.net>, "
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
   filter_class->setup = GST_DEBUG_FUNCPTR (gst_audio_wsinclimit_setup);
 }
 
 static void
-gst_audio_wsinclimit_init (GstAudioWSincLimit * self,
-    GstAudioWSincLimitClass * g_class)
+gst_audio_wsinclimit_init (GstAudioWSincLimit * self)
 {
   self->mode = MODE_LOW_PASS;
   self->window = WINDOW_HAMMING;
@@ -229,22 +221,25 @@ gst_audio_wsinclimit_build_kernel (GstAudioWSincLimit * self)
   gint len = 0;
   gdouble w;
   gdouble *kernel = NULL;
+  gint rate, channels;
 
   len = self->kernel_length;
 
-  if (GST_AUDIO_FILTER (self)->format.rate == 0) {
+  rate = GST_AUDIO_FILTER_RATE (self);
+  channels = GST_AUDIO_FILTER_CHANNELS (self);
+
+  if (rate == 0) {
     GST_DEBUG ("rate not set yet");
     return;
   }
 
-  if (GST_AUDIO_FILTER (self)->format.channels == 0) {
+  if (channels == 0) {
     GST_DEBUG ("channels not set yet");
     return;
   }
 
   /* Clamp cutoff frequency between 0 and the nyquist frequency */
-  self->cutoff =
-      CLAMP (self->cutoff, 0.0, GST_AUDIO_FILTER (self)->format.rate / 2);
+  self->cutoff = CLAMP (self->cutoff, 0.0, rate / 2);
 
   GST_DEBUG ("gst_audio_wsinclimit_: initializing filter kernel of length %d "
       "with cutoff %.2lf Hz "
@@ -253,7 +248,7 @@ gst_audio_wsinclimit_build_kernel (GstAudioWSincLimit * self)
       (self->mode == MODE_LOW_PASS) ? "low-pass" : "high-pass");
 
   /* fill the kernel */
-  w = 2 * G_PI * (self->cutoff / GST_AUDIO_FILTER (self)->format.rate);
+  w = 2 * G_PI * (self->cutoff / rate);
 
   kernel = g_new (gdouble, len);
 
@@ -311,13 +306,13 @@ gst_audio_wsinclimit_build_kernel (GstAudioWSincLimit * self)
 
 /* get notified of caps and plug in the correct process function */
 static gboolean
-gst_audio_wsinclimit_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_audio_wsinclimit_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstAudioWSincLimit *self = GST_AUDIO_WSINC_LIMIT (base);
 
   gst_audio_wsinclimit_build_kernel (self);
 
-  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, format);
+  return GST_AUDIO_FILTER_CLASS (parent_class)->setup (base, info);
 }
 
 static void
index 5c50da8..070e949 100644 (file)
@@ -91,12 +91,7 @@ gint gst_aac_parse_get_frame_overhead (GstBaseParse * parse,
 
 gboolean gst_aac_parse_event (GstBaseParse * parse, GstEvent * event);
 
-#define _do_init(bla) \
-    GST_DEBUG_CATEGORY_INIT (aacparse_debug, "aacparse", 0, \
-    "AAC audio stream parser");
-
-GST_BOILERPLATE_FULL (GstAacParse, gst_aac_parse, GstBaseParse,
-    GST_TYPE_BASE_PARSE, _do_init);
+G_DEFINE_TYPE (GstAacParse, gst_aac_parse, GST_TYPE_BASE_PARSE);
 
 static inline gint
 gst_aac_parse_get_sample_rate_from_index (guint sr_idx)
@@ -112,14 +107,18 @@ gst_aac_parse_get_sample_rate_from_index (guint sr_idx)
 }
 
 /**
- * gst_aac_parse_base_init:
- * @klass: #GstElementClass.
+ * gst_aac_parse_class_init:
+ * @klass: #GstAacParseClass.
  *
  */
 static void
-gst_aac_parse_base_init (gpointer klass)
+gst_aac_parse_class_init (GstAacParseClass * klass)
 {
   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (klass);
+
+  GST_DEBUG_CATEGORY_INIT (aacparse_debug, "aacparse", 0,
+      "AAC audio stream parser");
 
   gst_element_class_add_pad_template (element_class,
       gst_static_pad_template_get (&sink_template));
@@ -129,18 +128,6 @@ gst_aac_parse_base_init (gpointer klass)
   gst_element_class_set_details_simple (element_class,
       "AAC audio stream parser", "Codec/Parser/Audio",
       "Advanced Audio Coding parser", "Stefan Kost <stefan.kost@nokia.com>");
-}
-
-
-/**
- * gst_aac_parse_class_init:
- * @klass: #GstAacParseClass.
- *
- */
-static void
-gst_aac_parse_class_init (GstAacParseClass * klass)
-{
-  GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (klass);
 
   parse_class->start = GST_DEBUG_FUNCPTR (gst_aac_parse_start);
   parse_class->stop = GST_DEBUG_FUNCPTR (gst_aac_parse_stop);
@@ -158,7 +145,7 @@ gst_aac_parse_class_init (GstAacParseClass * klass)
  *
  */
 static void
-gst_aac_parse_init (GstAacParse * aacparse, GstAacParseClass * klass)
+gst_aac_parse_init (GstAacParse * aacparse)
 {
   GST_DEBUG ("initialized");
 }
@@ -253,15 +240,19 @@ gst_aac_parse_sink_setcaps (GstBaseParse * parse, GstCaps * caps)
     GstBuffer *buf = gst_value_get_buffer (value);
 
     if (buf) {
-      const guint8 *buffer = GST_BUFFER_DATA (buf);
+      guint8 *data;
+      gsize size;
       guint sr_idx;
 
-      sr_idx = ((buffer[0] & 0x07) << 1) | ((buffer[1] & 0x80) >> 7);
-      aacparse->object_type = (buffer[0] & 0xf8) >> 3;
+      data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+
+      sr_idx = ((data[0] & 0x07) << 1) | ((data[1] & 0x80) >> 7);
+      aacparse->object_type = (data[0] & 0xf8) >> 3;
       aacparse->sample_rate = gst_aac_parse_get_sample_rate_from_index (sr_idx);
-      aacparse->channels = (buffer[1] & 0x78) >> 3;
+      aacparse->channels = (data[1] & 0x78) >> 3;
       aacparse->header_type = DSPAAC_HEADER_NONE;
       aacparse->mpegversion = 4;
+      gst_buffer_unmap (buf, data, size);
 
       GST_DEBUG ("codec_data: object_type=%d, sample_rate=%d, channels=%d",
           aacparse->object_type, aacparse->sample_rate, aacparse->channels);
@@ -482,6 +473,7 @@ gst_aac_parse_detect_stream (GstAacParse * aacparse,
     int skip_size = 0;
     int bitstream_type;
     int sr_idx;
+    GstCaps *sinkcaps;
 
     aacparse->header_type = DSPAAC_HEADER_ADIF;
     aacparse->mpegversion = 4;
@@ -544,8 +536,9 @@ gst_aac_parse_detect_stream (GstAacParse * aacparse,
     gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse), 512);
 
     /* arrange for metadata and get out of the way */
-    gst_aac_parse_set_src_caps (aacparse,
-        GST_PAD_CAPS (GST_BASE_PARSE_SINK_PAD (aacparse)));
+    sinkcaps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (aacparse));
+    gst_aac_parse_set_src_caps (aacparse, sinkcaps);
+    gst_caps_unref (sinkcaps);
 
     /* not syncable, not easily seekable (unless we push data from start */
     gst_base_parse_set_syncable (GST_BASE_PARSE_CAST (aacparse), FALSE);
@@ -577,7 +570,8 @@ gboolean
 gst_aac_parse_check_valid_frame (GstBaseParse * parse,
     GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
 {
-  const guint8 *data;
+  guint8 *data;
+  gsize size;
   GstAacParse *aacparse;
   gboolean ret = FALSE;
   gboolean lost_sync;
@@ -585,27 +579,27 @@ gst_aac_parse_check_valid_frame (GstBaseParse * parse,
 
   aacparse = GST_AAC_PARSE (parse);
   buffer = frame->buffer;
-  data = GST_BUFFER_DATA (buffer);
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   lost_sync = GST_BASE_PARSE_LOST_SYNC (parse);
 
   if (aacparse->header_type == DSPAAC_HEADER_ADIF ||
       aacparse->header_type == DSPAAC_HEADER_NONE) {
     /* There is nothing to parse */
-    *framesize = GST_BUFFER_SIZE (buffer);
+    *framesize = size;
     ret = TRUE;
 
   } else if (aacparse->header_type == DSPAAC_HEADER_NOT_PARSED || lost_sync) {
 
-    ret = gst_aac_parse_detect_stream (aacparse, data, GST_BUFFER_SIZE (buffer),
+    ret = gst_aac_parse_detect_stream (aacparse, data, size,
         GST_BASE_PARSE_DRAINING (parse), framesize, skipsize);
 
   } else if (aacparse->header_type == DSPAAC_HEADER_ADTS) {
     guint needed_data = 1024;
 
-    ret = gst_aac_parse_check_adts_frame (aacparse, data,
-        GST_BUFFER_SIZE (buffer), GST_BASE_PARSE_DRAINING (parse),
-        framesize, &needed_data);
+    ret = gst_aac_parse_check_adts_frame (aacparse, data, size,
+        GST_BASE_PARSE_DRAINING (parse), framesize, &needed_data);
 
     if (!ret) {
       GST_DEBUG ("buffer didn't contain valid frame");
@@ -618,6 +612,7 @@ gst_aac_parse_check_valid_frame (GstBaseParse * parse,
     gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse),
         ADTS_MAX_SIZE);
   }
+  gst_buffer_unmap (buffer, data, size);
 
   return ret;
 }
@@ -653,6 +648,8 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
   GstBuffer *buffer;
   GstFlowReturn ret = GST_FLOW_OK;
   gint rate, channels;
+  guint8 *data;
+  gsize size;
 
   aacparse = GST_AAC_PARSE (parse);
   buffer = frame->buffer;
@@ -663,20 +660,27 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
   /* see above */
   frame->overhead = 7;
 
-  gst_aac_parse_parse_adts_header (aacparse, GST_BUFFER_DATA (buffer),
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+  gst_aac_parse_parse_adts_header (aacparse, data,
       &rate, &channels, NULL, NULL);
+  gst_buffer_unmap (buffer, data, size);
+
   GST_LOG_OBJECT (aacparse, "rate: %d, chans: %d", rate, channels);
 
   if (G_UNLIKELY (rate != aacparse->sample_rate
           || channels != aacparse->channels)) {
+    GstCaps *sinkcaps;
+
     aacparse->sample_rate = rate;
     aacparse->channels = channels;
 
-    if (!gst_aac_parse_set_src_caps (aacparse,
-            GST_PAD_CAPS (GST_BASE_PARSE (aacparse)->sinkpad))) {
+    sinkcaps = gst_pad_get_current_caps (GST_BASE_PARSE (aacparse)->sinkpad);
+    if (!gst_aac_parse_set_src_caps (aacparse, sinkcaps)) {
       /* If linking fails, we need to return appropriate error */
+      gst_caps_unref (sinkcaps);
       ret = GST_FLOW_NOT_LINKED;
     }
+    gst_caps_unref (sinkcaps);
 
     gst_base_parse_set_frame_rate (GST_BASE_PARSE (aacparse),
         aacparse->sample_rate, 1024, 2, 2);
index 80c1f4d..aa3351f 100644 (file)
@@ -166,12 +166,20 @@ static GstFlowReturn gst_ac3_parse_parse_frame (GstBaseParse * parse,
 static gboolean gst_ac3_parse_src_event (GstBaseParse * parse,
     GstEvent * event);
 
-GST_BOILERPLATE (GstAc3Parse, gst_ac3_parse, GstBaseParse, GST_TYPE_BASE_PARSE);
+#define gst_ac3_parse_parent_class parent_class
+G_DEFINE_TYPE (GstAc3Parse, gst_ac3_parse, GST_TYPE_BASE_PARSE);
 
 static void
-gst_ac3_parse_base_init (gpointer klass)
+gst_ac3_parse_class_init (GstAc3ParseClass * klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (klass);
+
+  GST_DEBUG_CATEGORY_INIT (ac3_parse_debug, "ac3parse", 0,
+      "AC3 audio stream parser");
+
+  object_class->finalize = gst_ac3_parse_finalize;
 
   gst_element_class_add_pad_template (element_class,
       gst_static_pad_template_get (&sink_template));
@@ -181,18 +189,6 @@ gst_ac3_parse_base_init (gpointer klass)
   gst_element_class_set_details_simple (element_class,
       "AC3 audio stream parser", "Codec/Parser/Audio",
       "AC3 parser", "Tim-Philipp Müller <tim centricular net>");
-}
-
-static void
-gst_ac3_parse_class_init (GstAc3ParseClass * klass)
-{
-  GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (klass);
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-  GST_DEBUG_CATEGORY_INIT (ac3_parse_debug, "ac3parse", 0,
-      "AC3 audio stream parser");
-
-  object_class->finalize = gst_ac3_parse_finalize;
 
   parse_class->start = GST_DEBUG_FUNCPTR (gst_ac3_parse_start);
   parse_class->stop = GST_DEBUG_FUNCPTR (gst_ac3_parse_stop);
@@ -214,7 +210,7 @@ gst_ac3_parse_reset (GstAc3Parse * ac3parse)
 }
 
 static void
-gst_ac3_parse_init (GstAc3Parse * ac3parse, GstAc3ParseClass * klass)
+gst_ac3_parse_init (GstAc3Parse * ac3parse)
 {
   gst_base_parse_set_min_frame_size (GST_BASE_PARSE (ac3parse), 6);
   gst_ac3_parse_reset (ac3parse);
@@ -299,11 +295,16 @@ gst_ac3_parse_frame_header_ac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
     gint skip, guint * frame_size, guint * rate, guint * chans, guint * blks,
     guint * sid)
 {
-  GstBitReader bits = GST_BIT_READER_INIT_FROM_BUFFER (buf);
+  GstBitReader bits;
+  gpointer data;
+  gsize size;
   guint8 fscod, frmsizcod, bsid, acmod, lfe_on;
+  gboolean ret = FALSE;
 
   GST_LOG_OBJECT (ac3parse, "parsing ac3");
 
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  gst_bit_reader_init (&bits, data, size);
   gst_bit_reader_skip_unchecked (&bits, skip * 8);
 
   gst_bit_reader_skip_unchecked (&bits, 16 + 16);
@@ -312,7 +313,7 @@ gst_ac3_parse_frame_header_ac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
 
   if (G_UNLIKELY (fscod == 3 || frmsizcod >= G_N_ELEMENTS (frmsizcod_table))) {
     GST_DEBUG_OBJECT (ac3parse, "bad fscod=%d frmsizcod=%d", fscod, frmsizcod);
-    return FALSE;
+    goto cleanup;
   }
 
   bsid = gst_bit_reader_get_bits_uint8_unchecked (&bits, 5);
@@ -323,7 +324,7 @@ gst_ac3_parse_frame_header_ac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
    * but seemingly only defines 6 and 8 cases */
   if (bsid > 8) {
     GST_DEBUG_OBJECT (ac3parse, "unexpected bsid=%d", bsid);
-    return FALSE;
+    goto cleanup;
   } else if (bsid != 8 && bsid != 6) {
     GST_DEBUG_OBJECT (ac3parse, "undefined bsid=%d", bsid);
   }
@@ -348,7 +349,12 @@ gst_ac3_parse_frame_header_ac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
   if (sid)
     *sid = 0;
 
-  return TRUE;
+  ret = TRUE;
+
+cleanup:
+  gst_buffer_unmap (buf, data, size);
+
+  return ret;
 }
 
 static gboolean
@@ -356,19 +362,24 @@ gst_ac3_parse_frame_header_eac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
     gint skip, guint * frame_size, guint * rate, guint * chans, guint * blks,
     guint * sid)
 {
-  GstBitReader bits = GST_BIT_READER_INIT_FROM_BUFFER (buf);
+  GstBitReader bits;
+  gpointer data;
+  gsize size;
   guint16 frmsiz, sample_rate, blocks;
   guint8 strmtyp, fscod, fscod2, acmod, lfe_on, strmid, numblkscod;
+  gboolean ret = FALSE;
 
   GST_LOG_OBJECT (ac3parse, "parsing e-ac3");
 
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  gst_bit_reader_init (&bits, data, size);
   gst_bit_reader_skip_unchecked (&bits, skip * 8);
 
   gst_bit_reader_skip_unchecked (&bits, 16);
   strmtyp = gst_bit_reader_get_bits_uint8_unchecked (&bits, 2); /* strmtyp     */
   if (G_UNLIKELY (strmtyp == 3)) {
     GST_DEBUG_OBJECT (ac3parse, "bad strmtyp %d", strmtyp);
-    return FALSE;
+    goto cleanup;
   }
 
   strmid = gst_bit_reader_get_bits_uint8_unchecked (&bits, 3);  /* substreamid */
@@ -378,7 +389,7 @@ gst_ac3_parse_frame_header_eac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
     fscod2 = gst_bit_reader_get_bits_uint8_unchecked (&bits, 2);        /* fscod2      */
     if (G_UNLIKELY (fscod2 == 3)) {
       GST_DEBUG_OBJECT (ac3parse, "invalid fscod2");
-      return FALSE;
+      goto cleanup;
     }
     sample_rate = fscod_rates[fscod2] / 2;
     blocks = 6;
@@ -404,7 +415,12 @@ gst_ac3_parse_frame_header_eac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
   if (sid)
     *sid = (strmtyp & 0x1) << 3 | strmid;
 
-  return TRUE;
+  ret = TRUE;
+
+cleanup:
+  gst_buffer_unmap (buf, data, size);
+
+  return ret;
 }
 
 static gboolean
@@ -412,11 +428,17 @@ gst_ac3_parse_frame_header (GstAc3Parse * parse, GstBuffer * buf, gint skip,
     guint * framesize, guint * rate, guint * chans, guint * blocks,
     guint * sid, gboolean * eac)
 {
-  GstBitReader bits = GST_BIT_READER_INIT_FROM_BUFFER (buf);
+  GstBitReader bits;
   guint16 sync;
   guint8 bsid;
+  gpointer data;
+  gsize size;
+  gboolean ret = FALSE;
+
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  gst_bit_reader_init (&bits, data, size);
 
-  GST_MEMDUMP_OBJECT (parse, "AC3 frame sync", GST_BUFFER_DATA (buf), 16);
+  GST_MEMDUMP_OBJECT (parse, "AC3 frame sync", data, MIN (size, 16));
 
   gst_bit_reader_skip_unchecked (&bits, skip * 8);
 
@@ -425,24 +447,33 @@ gst_ac3_parse_frame_header (GstAc3Parse * parse, GstBuffer * buf, gint skip,
   bsid = gst_bit_reader_peek_bits_uint8_unchecked (&bits, 5);
 
   if (G_UNLIKELY (sync != 0x0b77))
-    return FALSE;
+    goto cleanup;
 
   GST_LOG_OBJECT (parse, "bsid = %d", bsid);
 
   if (bsid <= 10) {
     if (eac)
       *eac = FALSE;
-    return gst_ac3_parse_frame_header_ac3 (parse, buf, skip, framesize, rate,
+    ret = gst_ac3_parse_frame_header_ac3 (parse, buf, skip, framesize, rate,
         chans, blocks, sid);
+    goto cleanup;
   } else if (bsid <= 16) {
     if (eac)
       *eac = TRUE;
-    return gst_ac3_parse_frame_header_eac3 (parse, buf, skip, framesize, rate,
+    ret = gst_ac3_parse_frame_header_eac3 (parse, buf, skip, framesize, rate,
         chans, blocks, sid);
+    goto cleanup;
   } else {
     GST_DEBUG_OBJECT (parse, "unexpected bsid %d", bsid);
     return FALSE;
   }
+
+  GST_DEBUG_OBJECT (parse, "unexpected bsid %d", bsid);
+
+cleanup:
+  gst_buffer_unmap (buf, data, size);
+
+  return ret;
 }
 
 static gboolean
@@ -451,37 +482,42 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
 {
   GstAc3Parse *ac3parse = GST_AC3_PARSE (parse);
   GstBuffer *buf = frame->buffer;
-  GstByteReader reader = GST_BYTE_READER_INIT_FROM_BUFFER (buf);
+  GstByteReader reader;
   gint off;
   gboolean lost_sync, draining, eac, more = FALSE;
   guint frmsiz, blocks, sid;
   gint have_blocks = 0;
+  gpointer data;
+  gsize size;
+  gboolean ret = FALSE;
 
-  if (G_UNLIKELY (GST_BUFFER_SIZE (buf) < 6))
-    return FALSE;
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+
+  if (G_UNLIKELY (size < 6))
+    goto cleanup;
 
   off = gst_byte_reader_masked_scan_uint32 (&reader, 0xffff0000, 0x0b770000,
-      0, GST_BUFFER_SIZE (buf));
+      0, size);
 
   GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off);
 
   /* didn't find anything that looks like a sync word, skip */
   if (off < 0) {
-    *skipsize = GST_BUFFER_SIZE (buf) - 3;
-    return FALSE;
+    *skipsize = size - 3;
+    goto cleanup;
   }
 
   /* possible frame header, but not at offset 0? skip bytes before sync */
   if (off > 0) {
     *skipsize = off;
-    return FALSE;
+    goto cleanup;
   }
 
   /* make sure the values in the frame header look sane */
   if (!gst_ac3_parse_frame_header (ac3parse, buf, 0, &frmsiz, NULL, NULL,
           &blocks, &sid, &eac)) {
     *skipsize = off + 2;
-    return FALSE;
+    goto cleanup;
   }
 
   *framesize = frmsiz;
@@ -517,8 +553,7 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
       do {
         *framesize += frmsiz;
 
-        if (!gst_byte_reader_skip (&reader, frmsiz) ||
-            GST_BUFFER_SIZE (buf) < (*framesize + 6)) {
+        if (!gst_byte_reader_skip (&reader, frmsiz) || size < (*framesize + 6)) {
           more = TRUE;
           break;
         }
@@ -545,12 +580,12 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
       GST_DEBUG_OBJECT (ac3parse, "... but not sufficient data");
       gst_base_parse_set_min_frame_size (parse, *framesize + 6);
       *skipsize = 0;
-      return FALSE;
+      goto cleanup;
     } else {
       if (word != 0x0b77) {
         GST_DEBUG_OBJECT (ac3parse, "0x%x not OK", word);
         *skipsize = off + 2;
-        return FALSE;
+        goto cleanup;
       } else {
         /* ok, got sync now, let's assume constant frame size */
         gst_base_parse_set_min_frame_size (parse, *framesize);
@@ -558,7 +593,12 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
     }
   }
 
-  return TRUE;
+  ret = TRUE;
+
+cleanup:
+  gst_buffer_unmap (buf, data, size);
+
+  return ret;
 }
 
 static GstFlowReturn
@@ -598,7 +638,6 @@ gst_ac3_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
     gst_caps_set_simple (caps, "alignment", G_TYPE_STRING,
         g_atomic_int_get (&ac3parse->align) == GST_AC3_PARSE_ALIGN_IEC61937 ?
         "iec61937" : "frame", NULL);
-    gst_buffer_set_caps (buf, caps);
     gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (parse), caps);
     gst_caps_unref (caps);
 
index 99d31b9..f0b54ea 100644 (file)
@@ -83,23 +83,21 @@ gboolean gst_amr_parse_check_valid_frame (GstBaseParse * parse,
 GstFlowReturn gst_amr_parse_parse_frame (GstBaseParse * parse,
     GstBaseParseFrame * frame);
 
-#define _do_init(bla) \
-    GST_DEBUG_CATEGORY_INIT (amrparse_debug, "amrparse", 0, \
-                             "AMR-NB audio stream parser");
-
-GST_BOILERPLATE_FULL (GstAmrParse, gst_amr_parse, GstBaseParse,
-    GST_TYPE_BASE_PARSE, _do_init);
-
+G_DEFINE_TYPE (GstAmrParse, gst_amr_parse, GST_TYPE_BASE_PARSE);
 
 /**
- * gst_amr_parse_base_init:
- * @klass: #GstElementClass.
+ * gst_amr_parse_class_init:
+ * @klass: GstAmrParseClass.
  *
  */
 static void
-gst_amr_parse_base_init (gpointer klass)
+gst_amr_parse_class_init (GstAmrParseClass * klass)
 {
   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (klass);
+
+  GST_DEBUG_CATEGORY_INIT (amrparse_debug, "amrparse", 0,
+      "AMR-NB audio stream parser");
 
   gst_element_class_add_pad_template (element_class,
       gst_static_pad_template_get (&sink_template));
@@ -110,18 +108,6 @@ gst_amr_parse_base_init (gpointer klass)
       "AMR audio stream parser", "Codec/Parser/Audio",
       "Adaptive Multi-Rate audio parser",
       "Ronald Bultje <rbultje@ronald.bitfreak.net>");
-}
-
-
-/**
- * gst_amr_parse_class_init:
- * @klass: GstAmrParseClass.
- *
- */
-static void
-gst_amr_parse_class_init (GstAmrParseClass * klass)
-{
-  GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (klass);
 
   parse_class->start = GST_DEBUG_FUNCPTR (gst_amr_parse_start);
   parse_class->stop = GST_DEBUG_FUNCPTR (gst_amr_parse_stop);
@@ -139,7 +125,7 @@ gst_amr_parse_class_init (GstAmrParseClass * klass)
  *
  */
 static void
-gst_amr_parse_init (GstAmrParse * amrparse, GstAmrParseClass * klass)
+gst_amr_parse_init (GstAmrParse * amrparse)
 {
   /* init rest */
   gst_base_parse_set_min_frame_size (GST_BASE_PARSE (amrparse), 62);
@@ -270,14 +256,17 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
     GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
 {
   GstBuffer *buffer;
-  const guint8 *data;
+  guint8 *data;
+  gsize size;
   gint fsize, mode, dsize;
   GstAmrParse *amrparse;
+  gboolean ret = FALSE;
 
   amrparse = GST_AMR_PARSE (parse);
   buffer = frame->buffer;
-  data = GST_BUFFER_DATA (buffer);
-  dsize = GST_BUFFER_SIZE (buffer);
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+  dsize = size;
 
   GST_LOG ("buffer: %d bytes", dsize);
 
@@ -291,7 +280,7 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
     }
     /* We return FALSE, so this frame won't get pushed forward. Instead,
        the "skip" value is set, so next time we will receive a valid frame. */
-    return FALSE;
+    goto done;
   }
 
   /* Does this look like a possible frame header candidate? */
@@ -311,12 +300,16 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
         (!GST_BASE_PARSE_LOST_SYNC (parse) || GST_BASE_PARSE_DRAINING (parse)
             || (dsize > fsize && (data[fsize] & 0x83) == 0))) {
       *framesize = fsize;
-      return TRUE;
+      ret = TRUE;
+      goto done;
     }
   }
-
   GST_LOG ("sync lost");
-  return FALSE;
+
+done:
+  gst_buffer_unmap (buffer, data, size);
+
+  return ret;
 }
 
 
index 2bf0e38..b4bbe87 100644 (file)
@@ -78,27 +78,14 @@ static gboolean gst_dca_parse_check_valid_frame (GstBaseParse * parse,
 static GstFlowReturn gst_dca_parse_parse_frame (GstBaseParse * parse,
     GstBaseParseFrame * frame);
 
-GST_BOILERPLATE (GstDcaParse, gst_dca_parse, GstBaseParse, GST_TYPE_BASE_PARSE);
-
-static void
-gst_dca_parse_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "DTS Coherent Acoustics audio stream parser", "Codec/Parser/Audio",
-      "DCA parser", "Tim-Philipp Müller <tim centricular net>");
-}
+#define gst_dca_parse_parent_class parent_class
+G_DEFINE_TYPE (GstDcaParse, gst_dca_parse, GST_TYPE_BASE_PARSE);
 
 static void
 gst_dca_parse_class_init (GstDcaParseClass * klass)
 {
   GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (klass);
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   GST_DEBUG_CATEGORY_INIT (dca_parse_debug, "dcaparse", 0,
@@ -111,6 +98,15 @@ gst_dca_parse_class_init (GstDcaParseClass * klass)
   parse_class->check_valid_frame =
       GST_DEBUG_FUNCPTR (gst_dca_parse_check_valid_frame);
   parse_class->parse_frame = GST_DEBUG_FUNCPTR (gst_dca_parse_parse_frame);
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&sink_template));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&src_template));
+
+  gst_element_class_set_details_simple (element_class,
+      "DTS Coherent Acoustics audio stream parser", "Codec/Parser/Audio",
+      "DCA parser", "Tim-Philipp Müller <tim centricular net>");
 }
 
 static void
@@ -126,7 +122,7 @@ gst_dca_parse_reset (GstDcaParse * dcaparse)
 }
 
 static void
-gst_dca_parse_init (GstDcaParse * dcaparse, GstDcaParseClass * klass)
+gst_dca_parse_init (GstDcaParse * dcaparse)
 {
   gst_base_parse_set_min_frame_size (GST_BASE_PARSE (dcaparse),
       DCA_MIN_FRAMESIZE);
@@ -255,7 +251,7 @@ gst_dca_parse_parse_header (GstDcaParse * dcaparse,
 
 static gint
 gst_dca_parse_find_sync (GstDcaParse * dcaparse, GstByteReader * reader,
-    const GstBuffer * buf, guint32 * sync)
+    gsize bufsize, guint32 * sync)
 {
   guint32 best_sync = 0;
   guint best_offset = G_MAXUINT;
@@ -265,7 +261,7 @@ gst_dca_parse_find_sync (GstDcaParse * dcaparse, GstByteReader * reader,
 
   /* Raw little endian */
   off = gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0xfe7f0180,
-      0, GST_BUFFER_SIZE (buf));
+      0, bufsize);
   if (off >= 0 && off < best_offset) {
     best_offset = off;
     best_sync = 0xfe7f0180;
@@ -273,7 +269,7 @@ gst_dca_parse_find_sync (GstDcaParse * dcaparse, GstByteReader * reader,
 
   /* Raw big endian */
   off = gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x7ffe8001,
-      0, GST_BUFFER_SIZE (buf));
+      0, bufsize);
   if (off >= 0 && off < best_offset) {
     best_offset = off;
     best_sync = 0x7ffe8001;
@@ -284,7 +280,7 @@ gst_dca_parse_find_sync (GstDcaParse * dcaparse, GstByteReader * reader,
 
   /* 14-bit little endian  */
   off = gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0xff1f00e8,
-      0, GST_BUFFER_SIZE (buf));
+      0, bufsize);
   if (off >= 0 && off < best_offset) {
     best_offset = off;
     best_sync = 0xff1f00e8;
@@ -292,7 +288,7 @@ gst_dca_parse_find_sync (GstDcaParse * dcaparse, GstByteReader * reader,
 
   /* 14-bit big endian  */
   off = gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x1fffe800,
-      0, GST_BUFFER_SIZE (buf));
+      0, bufsize);
   if (off >= 0 && off < best_offset) {
     best_offset = off;
     best_sync = 0x1fffe800;
@@ -311,33 +307,40 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
 {
   GstDcaParse *dcaparse = GST_DCA_PARSE (parse);
   GstBuffer *buf = frame->buffer;
-  GstByteReader r = GST_BYTE_READER_INIT_FROM_BUFFER (buf);
+  GstByteReader r;
   gboolean parser_draining;
   gboolean parser_in_sync;
   gboolean terminator;
   guint32 sync = 0;
   guint size, rate, chans, num_blocks, samples_per_block;
   gint off = -1;
+  gpointer data;
+  gsize bufsize;
+  gboolean ret = FALSE;
 
-  if (G_UNLIKELY (GST_BUFFER_SIZE (buf) < 16))
-    return FALSE;
+  data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
+
+  if (G_UNLIKELY (bufsize < 16))
+    goto cleanup;
 
   parser_in_sync = !GST_BASE_PARSE_LOST_SYNC (parse);
 
+  gst_byte_reader_init (&r, data, bufsize);
+
   if (G_LIKELY (parser_in_sync && dcaparse->last_sync != 0)) {
     off = gst_byte_reader_masked_scan_uint32 (&r, 0xffffffff,
-        dcaparse->last_sync, 0, GST_BUFFER_SIZE (buf));
+        dcaparse->last_sync, 0, size);
   }
 
   if (G_UNLIKELY (off < 0)) {
-    off = gst_dca_parse_find_sync (dcaparse, &r, buf, &sync);
+    off = gst_dca_parse_find_sync (dcaparse, &r, bufsize, &sync);
   }
 
   /* didn't find anything that looks like a sync word, skip */
   if (off < 0) {
-    *skipsize = GST_BUFFER_SIZE (buf) - 3;
+    *skipsize = bufsize - 3;
     GST_DEBUG_OBJECT (dcaparse, "no sync, skipping %d bytes", *skipsize);
-    return FALSE;
+    goto cleanup;
   }
 
   GST_LOG_OBJECT (parse, "possible sync %08x at buffer offset %d", sync, off);
@@ -345,14 +348,14 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
   /* possible frame header, but not at offset 0? skip bytes before sync */
   if (off > 0) {
     *skipsize = off;
-    return FALSE;
+    goto cleanup;
   }
 
   /* make sure the values in the frame header look sane */
   if (!gst_dca_parse_parse_header (dcaparse, &r, &size, &rate, &chans, NULL,
           NULL, &num_blocks, &samples_per_block, &terminator)) {
     *skipsize = 4;
-    return FALSE;
+    goto cleanup;
   }
 
   GST_LOG_OBJECT (parse, "got frame, sync %08x, size %u, rate %d, channels %d",
@@ -367,19 +370,19 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
   if (!parser_in_sync && !parser_draining) {
     /* check for second frame to be sure */
     GST_DEBUG_OBJECT (dcaparse, "resyncing; checking next frame syncword");
-    if (GST_BUFFER_SIZE (buf) >= (size + 16)) {
+    if (bufsize >= (size + 16)) {
       guint s2, r2, c2, n2, s3;
       gboolean t;
 
-      GST_MEMDUMP ("buf", GST_BUFFER_DATA (buf), size + 16);
-      gst_byte_reader_init_from_buffer (&r, buf);
+      GST_MEMDUMP ("buf", data, size + 16);
+      gst_byte_reader_init (&r, data, bufsize);
       gst_byte_reader_skip_unchecked (&r, size);
 
       if (!gst_dca_parse_parse_header (dcaparse, &r, &s2, &r2, &c2, NULL, NULL,
               &n2, &s3, &t)) {
         GST_DEBUG_OBJECT (dcaparse, "didn't find second syncword");
         *skipsize = 4;
-        return FALSE;
+        goto cleanup;
       }
 
       /* ok, got sync now, let's assume constant frame size */
@@ -388,13 +391,17 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
       /* FIXME: baseparse always seems to hand us buffers of min_frame_size
        * bytes, which is unhelpful here */
       GST_LOG_OBJECT (dcaparse, "next sync out of reach (%u < %u)",
-          GST_BUFFER_SIZE (buf), size + 16);
+          bufsize, size + 16);
       /* *skipsize = 0; */
       /* return FALSE; */
     }
   }
 
-  return TRUE;
+  ret = TRUE;
+
+cleanup:
+  gst_buffer_unmap (buf, data, bufsize);
+  return ret;
 }
 
 static GstFlowReturn
@@ -402,10 +409,15 @@ gst_dca_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
 {
   GstDcaParse *dcaparse = GST_DCA_PARSE (parse);
   GstBuffer *buf = frame->buffer;
-  GstByteReader r = GST_BYTE_READER_INIT_FROM_BUFFER (buf);
+  GstByteReader r;
   guint size, rate, chans, depth, block_size, num_blocks, samples_per_block;
   gint endianness;
   gboolean terminator;
+  gpointer data;
+  gsize bufsize;
+
+  data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
+  gst_byte_reader_init (&r, data, bufsize);
 
   if (!gst_dca_parse_parse_header (dcaparse, &r, &size, &rate, &chans, &depth,
           &endianness, &num_blocks, &samples_per_block, &terminator))
@@ -425,7 +437,6 @@ gst_dca_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
         "endianness", G_TYPE_INT, endianness, "depth", G_TYPE_INT, depth,
         "block-size", G_TYPE_INT, block_size, "frame-size", G_TYPE_INT, size,
         NULL);
-    gst_buffer_set_caps (buf, caps);
     gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (parse), caps);
     gst_caps_unref (caps);
 
@@ -439,6 +450,7 @@ gst_dca_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
     gst_base_parse_set_frame_rate (parse, rate, block_size, 0, 0);
   }
 
+  gst_buffer_unmap (buf, data, bufsize);
   return GST_FLOW_OK;
 
 /* ERRORS */
@@ -446,6 +458,7 @@ broken_header:
   {
     /* this really shouldn't ever happen */
     GST_ELEMENT_ERROR (parse, STREAM, DECODE, (NULL), (NULL));
+    gst_buffer_unmap (buf, data, bufsize);
     return GST_FLOW_ERROR;
   }
 }
index 3011bf0..9764dce 100644 (file)
@@ -202,34 +202,19 @@ static gboolean gst_flac_parse_convert (GstBaseParse * parse,
     GstFormat src_format, gint64 src_value, GstFormat dest_format,
     gint64 * dest_value);
 
-GST_BOILERPLATE (GstFlacParse, gst_flac_parse, GstBaseParse,
-    GST_TYPE_BASE_PARSE);
-
-static void
-gst_flac_parse_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_factory));
-
-  gst_element_class_set_details_simple (element_class, "FLAC audio parser",
-      "Codec/Parser/Audio",
-      "Parses audio with the FLAC lossless audio codec",
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-
-  GST_DEBUG_CATEGORY_INIT (flacparse_debug, "flacparse", 0,
-      "Flac parser element");
-}
+#define gst_flac_parse_parent_class parent_class
+G_DEFINE_TYPE (GstFlacParse, gst_flac_parse, GST_TYPE_BASE_PARSE);
 
 static void
 gst_flac_parse_class_init (GstFlacParseClass * klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
   GstBaseParseClass *baseparse_class = GST_BASE_PARSE_CLASS (klass);
 
+  GST_DEBUG_CATEGORY_INIT (flacparse_debug, "flacparse", 0,
+      "Flac parser element");
+
   gobject_class->finalize = gst_flac_parse_finalize;
   gobject_class->set_property = gst_flac_parse_set_property;
   gobject_class->get_property = gst_flac_parse_get_property;
@@ -248,10 +233,20 @@ gst_flac_parse_class_init (GstFlacParseClass * klass)
   baseparse_class->pre_push_frame =
       GST_DEBUG_FUNCPTR (gst_flac_parse_pre_push_frame);
   baseparse_class->convert = GST_DEBUG_FUNCPTR (gst_flac_parse_convert);
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&src_factory));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&sink_factory));
+
+  gst_element_class_set_details_simple (element_class, "FLAC audio parser",
+      "Codec/Parser/Audio",
+      "Parses audio with the FLAC lossless audio codec",
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
 }
 
 static void
-gst_flac_parse_init (GstFlacParse * flacparse, GstFlacParseClass * klass)
+gst_flac_parse_init (GstFlacParse * flacparse)
 {
   flacparse->check_frame_checksums = DEFAULT_CHECK_FRAME_CHECKSUMS;
 }
@@ -571,15 +566,16 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
     GstBaseParseFrame * frame, guint * ret)
 {
   GstBuffer *buffer;
-  const guint8 *data;
-  guint max, size, remaining;
+  guint8 *data;
+  gsize size;
+  guint max, remaining;
   guint i, search_start, search_end;
   FrameHeaderCheckReturn header_ret;
   guint16 block_size;
+  gboolean result = FALSE;
 
   buffer = frame->buffer;
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   if (size < flacparse->min_framesize)
     goto need_more;
@@ -589,10 +585,10 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
       &block_size);
   if (header_ret == FRAME_HEADER_INVALID) {
     *ret = 0;
-    return FALSE;
-  } else if (header_ret == FRAME_HEADER_MORE_DATA) {
-    goto need_more;
+    goto cleanup;
   }
+  if (header_ret == FRAME_HEADER_MORE_DATA)
+    goto need_more;
 
   /* mind unknown framesize */
   search_start = MAX (2, flacparse->min_framesize);
@@ -619,7 +615,8 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
         }
         *ret = i;
         flacparse->block_size = block_size;
-        return TRUE;
+        result = TRUE;
+        goto cleanup;
       } else if (header_ret == FRAME_HEADER_MORE_DATA) {
         goto need_more;
       }
@@ -635,12 +632,14 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
       if (actual_crc == expected_crc) {
         *ret = size;
         flacparse->block_size = block_size;
-        return TRUE;
+        result = TRUE;
+        goto cleanup;
       }
     } else {
       *ret = size;
       flacparse->block_size = block_size;
-      return TRUE;
+      result = TRUE;
+      goto cleanup;
     }
   }
 
@@ -649,7 +648,11 @@ need_more:
   if (max == 16)
     max = 1 << 24;
   *ret = MIN (size + 4096, max);
-  return FALSE;
+  result = TRUE;
+
+cleanup:
+  gst_buffer_unmap (buffer, data, size);
+  return result;
 }
 
 static gboolean
@@ -658,100 +661,124 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
 {
   GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
   GstBuffer *buffer = frame->buffer;
-  const guint8 *data = GST_BUFFER_DATA (buffer);
+  guint8 *data;
+  gsize bufsize;
+  gboolean result = TRUE;
 
-  if (G_UNLIKELY (GST_BUFFER_SIZE (buffer) < 4))
-    return FALSE;
+  data = gst_buffer_map (buffer, &bufsize, NULL, GST_MAP_READ);
+
+  if (G_UNLIKELY (bufsize < 4)) {
+    result = FALSE;
+    goto cleanup;
+  }
 
   if (flacparse->state == GST_FLAC_PARSE_STATE_INIT) {
-    if (memcmp (GST_BUFFER_DATA (buffer), "fLaC", 4) == 0) {
+    if (memcmp (data, "fLaC", 4) == 0) {
       GST_DEBUG_OBJECT (flacparse, "fLaC marker found");
       *framesize = 4;
-      return TRUE;
-    } else if (data[0] == 0xff && (data[1] >> 2) == 0x3e) {
+      goto cleanup;
+    }
+    if (data[0] == 0xff && (data[1] >> 2) == 0x3e) {
       GST_DEBUG_OBJECT (flacparse, "Found headerless FLAC");
       /* Minimal size of a frame header */
       gst_base_parse_set_min_frame_size (GST_BASE_PARSE (flacparse), 9);
       flacparse->state = GST_FLAC_PARSE_STATE_GENERATE_HEADERS;
       *skipsize = 0;
-      return FALSE;
-    } else {
-      GST_DEBUG_OBJECT (flacparse, "fLaC marker not found");
-      return FALSE;
+      result = FALSE;
+      goto cleanup;
     }
-  } else if (flacparse->state == GST_FLAC_PARSE_STATE_HEADERS) {
+    GST_DEBUG_OBJECT (flacparse, "fLaC marker not found");
+    result = FALSE;
+    goto cleanup;
+  }
+
+  if (flacparse->state == GST_FLAC_PARSE_STATE_HEADERS) {
     guint size = 4 + ((data[1] << 16) | (data[2] << 8) | (data[3]));
 
     GST_DEBUG_OBJECT (flacparse, "Found metadata block of size %u", size);
     *framesize = size;
-    return TRUE;
-  } else {
-    if ((GST_READ_UINT16_BE (data) & 0xfffe) == 0xfff8) {
-      gboolean ret;
-      guint next;
+    goto cleanup;
+  }
 
-      flacparse->offset = GST_BUFFER_OFFSET (buffer);
-      flacparse->blocking_strategy = 0;
-      flacparse->block_size = 0;
-      flacparse->sample_number = 0;
-
-      GST_DEBUG_OBJECT (flacparse, "Found sync code");
-      ret = gst_flac_parse_frame_is_valid (flacparse, frame, &next);
-      if (ret) {
-        *framesize = next;
-        return TRUE;
-      } else {
-        /* If we're at EOS and the frame was not valid, drop it! */
-        if (G_UNLIKELY (GST_BASE_PARSE_DRAINING (flacparse))) {
-          GST_WARNING_OBJECT (flacparse, "EOS");
-          return FALSE;
-        }
+  if ((GST_READ_UINT16_BE (data) & 0xfffe) == 0xfff8) {
+    gboolean ret;
+    guint next;
 
-        if (next == 0) {
-        } else if (next > GST_BUFFER_SIZE (buffer)) {
-          GST_DEBUG_OBJECT (flacparse, "Requesting %u bytes", next);
-          *skipsize = 0;
-          gst_base_parse_set_min_frame_size (parse, next);
-          return FALSE;
-        } else {
-          GST_ERROR_OBJECT (flacparse,
-              "Giving up on invalid frame (%d bytes)",
-              GST_BUFFER_SIZE (buffer));
-          return FALSE;
-        }
-      }
-    } else {
-      GstByteReader reader = GST_BYTE_READER_INIT_FROM_BUFFER (buffer);
-      gint off;
+    flacparse->offset = GST_BUFFER_OFFSET (buffer);
+    flacparse->blocking_strategy = 0;
+    flacparse->block_size = 0;
+    flacparse->sample_number = 0;
 
-      off =
-          gst_byte_reader_masked_scan_uint32 (&reader, 0xfffc0000, 0xfff80000,
-          0, GST_BUFFER_SIZE (buffer));
+    GST_DEBUG_OBJECT (flacparse, "Found sync code");
+    ret = gst_flac_parse_frame_is_valid (flacparse, frame, &next);
+    if (ret) {
+      *framesize = next;
+      goto cleanup;
+    } else {
+      /* If we're at EOS and the frame was not valid, drop it! */
+      if (G_UNLIKELY (GST_BASE_PARSE_DRAINING (flacparse))) {
+        GST_WARNING_OBJECT (flacparse, "EOS");
+        result = FALSE;
+        goto cleanup;
+      }
 
-      if (off > 0) {
-        GST_DEBUG_OBJECT (parse, "Possible sync at buffer offset %d", off);
-        *skipsize = off;
-        return FALSE;
+      if (next == 0) {
+      } else if (next > bufsize) {
+        GST_DEBUG_OBJECT (flacparse, "Requesting %u bytes", next);
+        *skipsize = 0;
+        gst_base_parse_set_min_frame_size (parse, next);
+        result = FALSE;
+        goto cleanup;
       } else {
-        GST_DEBUG_OBJECT (flacparse, "Sync code not found");
-        *skipsize = GST_BUFFER_SIZE (buffer) - 3;
-        return FALSE;
+        GST_ERROR_OBJECT (flacparse,
+            "Giving up on invalid frame (%d bytes)", bufsize);
+        result = FALSE;
+        goto cleanup;
       }
     }
+  } else {
+    GstByteReader reader;
+    gint off;
+
+    gst_byte_reader_init (&reader, data, bufsize);
+    off =
+        gst_byte_reader_masked_scan_uint32 (&reader, 0xfffc0000, 0xfff80000,
+        0, bufsize);
+
+    if (off > 0) {
+      GST_DEBUG_OBJECT (parse, "Possible sync at buffer offset %d", off);
+      *skipsize = off;
+      result = FALSE;
+      goto cleanup;
+    } else {
+      GST_DEBUG_OBJECT (flacparse, "Sync code not found");
+      *skipsize = bufsize - 3;
+      result = FALSE;
+      goto cleanup;
+    }
   }
 
-  return FALSE;
+  result = FALSE;
+
+cleanup:
+  gst_buffer_unmap (buffer, data, bufsize);
+  return result;
 }
 
 static gboolean
 gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
 {
-  GstBitReader reader = GST_BIT_READER_INIT_FROM_BUFFER (buffer);
+  GstBitReader reader;
+  guint8 *data;
+  gsize size;
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+  gst_bit_reader_init (&reader, data, size);
 
-  if (GST_BUFFER_SIZE (buffer) != 4 + 34) {
+  if (size != 4 + 34) {
     GST_ERROR_OBJECT (flacparse, "Invalid metablock size for STREAMINFO: %u",
-        GST_BUFFER_SIZE (buffer));
-    return FALSE;
+        size);
+    goto failure;
   }
 
   /* Skip metadata block header */
@@ -780,7 +807,7 @@ gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
     goto error;
   if (flacparse->samplerate == 0) {
     GST_ERROR_OBJECT (flacparse, "Invalid sample rate 0");
-    return FALSE;
+    goto failure;
   }
 
   if (!gst_bit_reader_get_bits_uint8 (&reader, &flacparse->channels, 3))
@@ -789,7 +816,7 @@ gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
   if (flacparse->channels > 8) {
     GST_ERROR_OBJECT (flacparse, "Invalid number of channels %u",
         flacparse->channels);
-    return FALSE;
+    goto failure;
   }
 
   if (!gst_bit_reader_get_bits_uint8 (&reader, &flacparse->bps, 5))
@@ -803,6 +830,8 @@ gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
         GST_FORMAT_DEFAULT, flacparse->total_samples, 0);
   }
 
+  gst_buffer_unmap (buffer, data, size);
+
   GST_DEBUG_OBJECT (flacparse, "STREAMINFO:\n"
       "\tmin/max blocksize: %u/%u,\n"
       "\tmin/max framesize: %u/%u,\n"
@@ -819,6 +848,8 @@ gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
 
 error:
   GST_ERROR_OBJECT (flacparse, "Failed to read data");
+failure:
+  gst_buffer_unmap (buffer, data, size);
   return FALSE;
 }
 
@@ -826,8 +857,13 @@ static gboolean
 gst_flac_parse_handle_vorbiscomment (GstFlacParse * flacparse,
     GstBuffer * buffer)
 {
-  flacparse->tags = gst_tag_list_from_vorbiscomment_buffer (buffer,
-      GST_BUFFER_DATA (buffer), 4, NULL);
+  guint8 *data;
+  gsize size;
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
+  flacparse->tags = gst_tag_list_from_vorbiscomment (data, size, data, 4, NULL);
+  gst_buffer_unmap (buffer, data, size);
 
   if (flacparse->tags == NULL) {
     GST_ERROR_OBJECT (flacparse, "Invalid vorbiscomment block");
@@ -842,11 +878,15 @@ gst_flac_parse_handle_vorbiscomment (GstFlacParse * flacparse,
 static gboolean
 gst_flac_parse_handle_picture (GstFlacParse * flacparse, GstBuffer * buffer)
 {
-  GstByteReader reader = GST_BYTE_READER_INIT_FROM_BUFFER (buffer);
-  const guint8 *data = GST_BUFFER_DATA (buffer);
+  GstByteReader reader;
+  guint8 *data;
+  gsize bufsize;
   guint32 img_len = 0, img_type = 0;
   guint32 img_mimetype_len = 0, img_description_len = 0;
 
+  data = gst_buffer_map (buffer, &bufsize, NULL, GST_MAP_READ);
+  gst_byte_reader_init (&reader, data, bufsize);
+
   if (!gst_byte_reader_skip (&reader, 4))
     goto error;
 
@@ -880,10 +920,12 @@ gst_flac_parse_handle_picture (GstFlacParse * flacparse, GstBuffer * buffer)
     flacparse->tags = NULL;
   }
 
+  gst_buffer_unmap (buffer, data, bufsize);
   return TRUE;
 
 error:
   GST_ERROR_OBJECT (flacparse, "Error reading data");
+  gst_buffer_unmap (buffer, data, bufsize);
   return FALSE;
 }
 
@@ -904,14 +946,18 @@ gst_flac_parse_process_seektable (GstFlacParse * flacparse, gint64 boffset)
 {
   GstByteReader br;
   gint64 offset = 0, samples = 0;
+  gpointer data;
+  gsize bufsize;
 
   GST_DEBUG_OBJECT (flacparse,
       "parsing seektable; base offset %" G_GINT64_FORMAT, boffset);
 
   if (boffset <= 0)
-    goto done;
+    goto exit;
+
+  data = gst_buffer_map (flacparse->seektable, &bufsize, NULL, GST_MAP_READ);
+  gst_byte_reader_init (&br, data, bufsize);
 
-  gst_byte_reader_init_from_buffer (&br, flacparse->seektable);
   /* skip header */
   if (!gst_byte_reader_skip (&br, 4))
     goto done;
@@ -937,6 +983,8 @@ gst_flac_parse_process_seektable (GstFlacParse * flacparse, gint64 boffset)
   }
 
 done:
+  gst_buffer_unmap (flacparse->seektable, data, bufsize);
+exit:
   gst_buffer_unref (flacparse->seektable);
   flacparse->seektable = NULL;
 }
@@ -978,8 +1026,10 @@ gst_flac_parse_handle_headers (GstFlacParse * flacparse)
 
   for (l = flacparse->headers; l; l = l->next) {
     GstBuffer *header = l->data;
-    const guint8 *data = GST_BUFFER_DATA (header);
-    guint size = GST_BUFFER_SIZE (header);
+    guint8 *data;
+    gsize size;
+
+    data = gst_buffer_map (header, &size, NULL, GST_MAP_READ);
 
     GST_BUFFER_FLAG_SET (header, GST_BUFFER_FLAG_IN_CAPS);
 
@@ -990,6 +1040,8 @@ gst_flac_parse_handle_headers (GstFlacParse * flacparse)
     } else if (size > 1 && (data[0] & 0x7f) == 4) {
       vorbiscomment = header;
     }
+
+    gst_buffer_unmap (header, data, size);
   }
 
   if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) {
@@ -1005,21 +1057,29 @@ gst_flac_parse_handle_headers (GstFlacParse * flacparse)
   {
     GstBuffer *buf;
     guint16 num;
+    guint8 *sinfodata, *writedata;
+    gsize sinfosize, writesize;
+
+    sinfodata = gst_buffer_map (streaminfo, &sinfosize, NULL, GST_MAP_READ);
 
     /* minus one for the marker that is merged with streaminfo here */
     num = g_list_length (flacparse->headers) - 1;
 
-    buf = gst_buffer_new_and_alloc (13 + GST_BUFFER_SIZE (streaminfo));
-    GST_BUFFER_DATA (buf)[0] = 0x7f;
-    memcpy (GST_BUFFER_DATA (buf) + 1, "FLAC", 4);
-    GST_BUFFER_DATA (buf)[5] = 0x01;    /* mapping version major */
-    GST_BUFFER_DATA (buf)[6] = 0x00;    /* mapping version minor */
-    GST_BUFFER_DATA (buf)[7] = (num & 0xFF00) >> 8;
-    GST_BUFFER_DATA (buf)[8] = (num & 0x00FF) >> 0;
-    memcpy (GST_BUFFER_DATA (buf) + 9, "fLaC", 4);
-    memcpy (GST_BUFFER_DATA (buf) + 13, GST_BUFFER_DATA (streaminfo),
-        GST_BUFFER_SIZE (streaminfo));
+    buf = gst_buffer_new_and_alloc (13 + sinfosize);
+    writedata = gst_buffer_map (buf, &writesize, NULL, GST_MAP_WRITE);
+
+    writedata[0] = 0x7f;
+    memcpy (writedata + 1, "FLAC", 4);
+    writedata[5] = 0x01;        /* mapping version major */
+    writedata[6] = 0x00;        /* mapping version minor */
+    writedata[7] = (num & 0xFF00) >> 8;
+    writedata[8] = (num & 0x00FF) >> 0;
+    memcpy (writedata + 9, "fLaC", 4);
+    memcpy (writedata + 13, sinfodata, sinfosize);
     _value_array_append_buffer (&array, buf);
+
+    gst_buffer_unmap (streaminfo, sinfodata, sinfosize);
+    gst_buffer_unmap (buf, writedata, writesize);
     gst_buffer_unref (buf);
   }
 
@@ -1053,9 +1113,7 @@ push_headers:
 
     flacparse->headers =
         g_list_delete_link (flacparse->headers, flacparse->headers);
-    buf = gst_buffer_make_metadata_writable (buf);
-    gst_buffer_set_caps (buf,
-        GST_PAD_CAPS (GST_BASE_PARSE_SRC_PAD (GST_BASE_PARSE (flacparse))));
+    buf = gst_buffer_make_writable (buf);
 
     /* init, set and give away frame */
     gst_base_parse_frame_init (&frame);
@@ -1079,9 +1137,12 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
 {
   GstBuffer *marker, *streaminfo, *vorbiscomment;
   guint8 *data;
+  gsize bufsize;
 
   marker = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (marker), "fLaC", 4);
+  data = gst_buffer_map (marker, &bufsize, NULL, GST_MAP_WRITE);
+  memcpy (data, "fLaC", 4);
+  gst_buffer_unmap (marker, data, bufsize);
   GST_BUFFER_TIMESTAMP (marker) = GST_CLOCK_TIME_NONE;
   GST_BUFFER_DURATION (marker) = GST_CLOCK_TIME_NONE;
   GST_BUFFER_OFFSET (marker) = 0;
@@ -1089,7 +1150,7 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
   flacparse->headers = g_list_append (flacparse->headers, marker);
 
   streaminfo = gst_buffer_new_and_alloc (4 + 34);
-  data = GST_BUFFER_DATA (streaminfo);
+  data = gst_buffer_map (streaminfo, &bufsize, NULL, GST_MAP_WRITE);
   memset (data, 0, 4 + 34);
 
   /* metadata block header */
@@ -1123,10 +1184,9 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
 
   {
     gint64 duration;
-    GstFormat fmt = GST_FORMAT_TIME;
 
-    if (gst_pad_query_peer_duration (GST_BASE_PARSE_SINK_PAD (GST_BASE_PARSE
-                (flacparse)), &fmt, &duration) && fmt == GST_FORMAT_TIME) {
+    if (gst_pad_query_peer_duration (GST_BASE_PARSE_SINK_PAD (flacparse),
+            GST_FORMAT_TIME, &duration)) {
       duration = GST_CLOCK_TIME_TO_FRAMES (duration, flacparse->samplerate);
 
       data[17] |= (duration >> 32) & 0xff;
@@ -1138,6 +1198,7 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
   }
   /* MD5 = 0; */
 
+  gst_buffer_unmap (streaminfo, data, bufsize);
   GST_BUFFER_TIMESTAMP (streaminfo) = GST_CLOCK_TIME_NONE;
   GST_BUFFER_DURATION (streaminfo) = GST_CLOCK_TIME_NONE;
   GST_BUFFER_OFFSET (streaminfo) = 0;
@@ -1157,23 +1218,27 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
         sizeof (header), NULL);
     gst_tag_list_free (taglist);
 
+    data = gst_buffer_map (vorbiscomment, &bufsize, NULL, GST_MAP_WRITE);
+
     /* Get rid of framing bit */
-    if (GST_BUFFER_DATA (vorbiscomment)[GST_BUFFER_SIZE (vorbiscomment) -
-            1] == 1) {
+    if (data[bufsize - 1] == 1) {
       GstBuffer *sub;
 
       sub =
-          gst_buffer_create_sub (vorbiscomment, 0,
-          GST_BUFFER_SIZE (vorbiscomment) - 1);
+          gst_buffer_copy_region (vorbiscomment, GST_BUFFER_COPY_ALL, 0,
+          bufsize - 1);
+      gst_buffer_unmap (vorbiscomment, data, bufsize);
       gst_buffer_unref (vorbiscomment);
       vorbiscomment = sub;
+      data = gst_buffer_map (vorbiscomment, &bufsize, NULL, GST_MAP_WRITE);
     }
 
-    size = GST_BUFFER_SIZE (vorbiscomment) - 4;
-    GST_BUFFER_DATA (vorbiscomment)[1] = ((size & 0xFF0000) >> 16);
-    GST_BUFFER_DATA (vorbiscomment)[2] = ((size & 0x00FF00) >> 8);
-    GST_BUFFER_DATA (vorbiscomment)[3] = (size & 0x0000FF);
+    size = bufsize - 4;
+    data[1] = ((size & 0xFF0000) >> 16);
+    data[2] = ((size & 0x00FF00) >> 8);
+    data[3] = (size & 0x0000FF);
 
+    gst_buffer_unmap (vorbiscomment, data, bufsize);
     GST_BUFFER_TIMESTAMP (vorbiscomment) = GST_CLOCK_TIME_NONE;
     GST_BUFFER_DURATION (vorbiscomment) = GST_CLOCK_TIME_NONE;
     GST_BUFFER_OFFSET (vorbiscomment) = 0;
@@ -1189,7 +1254,11 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
 {
   GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
   GstBuffer *buffer = frame->buffer;
-  const guint8 *data = GST_BUFFER_DATA (buffer);
+  guint8 *data = NULL;
+  gsize bufsize;
+  GstFlowReturn res = GST_FLOW_ERROR;
+
+  data = gst_buffer_map (buffer, &bufsize, NULL, GST_MAP_READ);
 
   if (flacparse->state == GST_FLAC_PARSE_STATE_INIT) {
     GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
@@ -1204,14 +1273,15 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
     flacparse->headers =
         g_list_append (flacparse->headers, gst_buffer_ref (buffer));
 
-    return GST_BASE_PARSE_FLOW_DROPPED;
+    res = GST_BASE_PARSE_FLOW_DROPPED;
   } else if (flacparse->state == GST_FLAC_PARSE_STATE_HEADERS) {
     gboolean is_last = ((data[0] & 0x80) == 0x80);
     guint type = (data[0] & 0x7F);
 
     if (type == 127) {
       GST_WARNING_OBJECT (flacparse, "Invalid metadata block type");
-      return GST_BASE_PARSE_FLOW_DROPPED;
+      res = GST_BASE_PARSE_FLOW_DROPPED;
+      goto cleanup;
     }
 
     GST_DEBUG_OBJECT (flacparse, "Handling metadata block of type %u", type);
@@ -1219,19 +1289,19 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
     switch (type) {
       case 0:                  /* STREAMINFO */
         if (!gst_flac_parse_handle_streaminfo (flacparse, buffer))
-          return GST_FLOW_ERROR;
+          goto cleanup;
         break;
       case 3:                  /* SEEKTABLE */
         if (!gst_flac_parse_handle_seektable (flacparse, buffer))
-          return GST_FLOW_ERROR;
+          goto cleanup;
         break;
       case 4:                  /* VORBIS_COMMENT */
         if (!gst_flac_parse_handle_vorbiscomment (flacparse, buffer))
-          return GST_FLOW_ERROR;
+          goto cleanup;
         break;
       case 6:                  /* PICTURE */
         if (!gst_flac_parse_handle_picture (flacparse, buffer))
-          return GST_FLOW_ERROR;
+          goto cleanup;
         break;
       case 1:                  /* PADDING */
       case 2:                  /* APPLICATION */
@@ -1250,7 +1320,7 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
 
     if (is_last) {
       if (!gst_flac_parse_handle_headers (flacparse))
-        return GST_FLOW_ERROR;
+        goto cleanup;
 
       /* Minimal size of a frame header */
       gst_base_parse_set_min_frame_size (GST_BASE_PARSE (flacparse), MAX (9,
@@ -1259,7 +1329,7 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
     }
 
     /* DROPPED because we pushed already or will push all headers manually */
-    return GST_BASE_PARSE_FLOW_DROPPED;
+    res = GST_BASE_PARSE_FLOW_DROPPED;
   } else {
     if (flacparse->offset != GST_BUFFER_OFFSET (buffer)) {
       FrameHeaderCheckReturn ret;
@@ -1267,17 +1337,17 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
       flacparse->offset = GST_BUFFER_OFFSET (buffer);
       ret =
           gst_flac_parse_frame_header_is_valid (flacparse,
-          GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer), TRUE, NULL);
+          data, bufsize, TRUE, NULL);
       if (ret != FRAME_HEADER_VALID) {
         GST_ERROR_OBJECT (flacparse,
             "Baseclass didn't provide a complete frame");
-        return GST_FLOW_ERROR;
+        goto cleanup;
       }
     }
 
     if (flacparse->block_size == 0) {
       GST_ERROR_OBJECT (flacparse, "Unparsed frame");
-      return GST_FLOW_ERROR;
+      goto cleanup;
     }
 
     if (flacparse->seektable)
@@ -1289,15 +1359,15 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
             "Generating headers for variable blocksize streams not supported");
 
         if (!gst_flac_parse_handle_headers (flacparse))
-          return GST_FLOW_ERROR;
+          goto cleanup;
       } else {
         GST_DEBUG_OBJECT (flacparse, "Generating headers");
 
         if (!gst_flac_parse_generate_headers (flacparse))
-          return GST_FLOW_ERROR;
+          goto cleanup;
 
         if (!gst_flac_parse_handle_headers (flacparse))
-          return GST_FLOW_ERROR;
+          goto cleanup;
       }
       flacparse->state = GST_FLAC_PARSE_STATE_DATA;
     }
@@ -1336,8 +1406,14 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
     flacparse->blocking_strategy = 0;
     flacparse->block_size = 0;
     flacparse->sample_number = 0;
-    return GST_FLOW_OK;
+    res = GST_FLOW_OK;
   }
+
+cleanup:
+  if (data)
+    gst_buffer_unmap (buffer, data, bufsize);
+
+  return res;
 }
 
 static GstFlowReturn
index 94a8993..c454ec8 100644 (file)
@@ -100,8 +100,8 @@ static gboolean gst_mpeg_audio_parse_convert (GstBaseParse * parse,
     GstFormat src_format, gint64 src_value,
     GstFormat dest_format, gint64 * dest_value);
 
-GST_BOILERPLATE (GstMpegAudioParse, gst_mpeg_audio_parse, GstBaseParse,
-    GST_TYPE_BASE_PARSE);
+#define gst_mpeg_audio_parse_parent_class parent_class
+G_DEFINE_TYPE (GstMpegAudioParse, gst_mpeg_audio_parse, GST_TYPE_BASE_PARSE);
 
 #define GST_TYPE_MPEG_AUDIO_CHANNEL_MODE  \
     (gst_mpeg_audio_channel_mode_get_type())
@@ -140,26 +140,10 @@ gst_mpeg_audio_channel_mode_get_nick (gint mode)
 }
 
 static void
-gst_mpeg_audio_parse_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_template));
-
-  gst_element_class_set_details_simple (element_class, "MPEG1 Audio Parser",
-      "Codec/Parser/Audio",
-      "Parses and frames mpeg1 audio streams (levels 1-3), provides seek",
-      "Jan Schmidt <thaytan@mad.scientist.com>,"
-      "Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>");
-}
-
-static void
 gst_mpeg_audio_parse_class_init (GstMpegAudioParseClass * klass)
 {
   GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (klass);
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   GST_DEBUG_CATEGORY_INIT (mpeg_audio_parse_debug, "mpegaudioparse", 0,
@@ -187,6 +171,17 @@ gst_mpeg_audio_parse_class_init (GstMpegAudioParseClass * klass)
       "channel mode", "MPEG audio channel mode", NULL);
 
   g_type_class_ref (GST_TYPE_MPEG_AUDIO_CHANNEL_MODE);
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&sink_template));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&src_template));
+
+  gst_element_class_set_details_simple (element_class, "MPEG1 Audio Parser",
+      "Codec/Parser/Audio",
+      "Parses and frames mpeg1 audio streams (levels 1-3), provides seek",
+      "Jan Schmidt <thaytan@mad.scientist.com>,"
+      "Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>");
 }
 
 static void
@@ -222,8 +217,7 @@ gst_mpeg_audio_parse_reset (GstMpegAudioParse * mp3parse)
 }
 
 static void
-gst_mpeg_audio_parse_init (GstMpegAudioParse * mp3parse,
-    GstMpegAudioParseClass * klass)
+gst_mpeg_audio_parse_init (GstMpegAudioParse * mp3parse)
 {
   gst_mpeg_audio_parse_reset (mp3parse);
 }
@@ -376,13 +370,13 @@ gst_mp3parse_validate_extended (GstMpegAudioParse * mp3parse, GstBuffer * buf,
     guint32 header, int bpf, gboolean at_eos, gint * valid)
 {
   guint32 next_header;
-  const guint8 *data;
-  guint available;
+  guint8 *data;
+  gsize available;
+  gboolean res = TRUE;
   int frames_found = 1;
   int offset = bpf;
 
-  available = GST_BUFFER_SIZE (buf);
-  data = GST_BUFFER_DATA (buf);
+  data = gst_buffer_map (buf, &available, NULL, GST_MAP_READ);
 
   while (frames_found < MIN_RESYNC_FRAMES) {
     /* Check if we have enough data for all these frames, plus the next
@@ -391,10 +385,11 @@ gst_mp3parse_validate_extended (GstMpegAudioParse * mp3parse, GstBuffer * buf,
       if (at_eos) {
         /* Running out of data at EOS is fine; just accept it */
         *valid = TRUE;
-        return TRUE;
+        goto cleanup;
       } else {
         *valid = offset + 4;
-        return FALSE;
+        res = FALSE;
+        goto cleanup;
       }
     }
 
@@ -415,14 +410,14 @@ gst_mp3parse_validate_extended (GstMpegAudioParse * mp3parse, GstBuffer * buf,
           (guint) header, (guint) header & HDRMASK, (guint) next_header,
           (guint) next_header & HDRMASK, bpf);
       *valid = FALSE;
-      return TRUE;
+      goto cleanup;
     } else if ((((next_header >> 12) & 0xf) == 0) ||
         (((next_header >> 12) & 0xf) == 0xf)) {
       /* The essential parts were the same, but the bitrate held an
          invalid value - also reject */
       GST_DEBUG_OBJECT (mp3parse, "next header invalid (bitrate)");
       *valid = FALSE;
-      return TRUE;
+      goto cleanup;
     }
 
     bpf = mp3_type_frame_length_from_header (mp3parse, next_header,
@@ -433,7 +428,10 @@ gst_mp3parse_validate_extended (GstMpegAudioParse * mp3parse, GstBuffer * buf,
   }
 
   *valid = TRUE;
-  return TRUE;
+
+cleanup:
+  gst_buffer_unmap (buf, data, available);
+  return res;
 }
 
 static gboolean
@@ -489,37 +487,43 @@ gst_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse,
 {
   GstMpegAudioParse *mp3parse = GST_MPEG_AUDIO_PARSE (parse);
   GstBuffer *buf = frame->buffer;
-  GstByteReader reader = GST_BYTE_READER_INIT_FROM_BUFFER (buf);
+  GstByteReader reader;
   gint off, bpf;
   gboolean lost_sync, draining, valid, caps_change;
   guint32 header;
   guint bitrate, layer, rate, channels, version, mode, crc;
+  guint8 *data;
+  gsize bufsize;
+  gboolean res = FALSE;
 
-  if (G_UNLIKELY (GST_BUFFER_SIZE (buf) < 6))
-    return FALSE;
+  data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
+  if (G_UNLIKELY (bufsize < 6))
+    goto cleanup;
+
+  gst_byte_reader_init (&reader, data, bufsize);
 
   off = gst_byte_reader_masked_scan_uint32 (&reader, 0xffe00000, 0xffe00000,
-      0, GST_BUFFER_SIZE (buf));
+      0, bufsize);
 
   GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off);
 
   /* didn't find anything that looks like a sync word, skip */
   if (off < 0) {
-    *skipsize = GST_BUFFER_SIZE (buf) - 3;
-    return FALSE;
+    *skipsize = bufsize - 3;
+    goto cleanup;
   }
 
   /* possible frame header, but not at offset 0? skip bytes before sync */
   if (off > 0) {
     *skipsize = off;
-    return FALSE;
+    goto cleanup;
   }
 
   /* make sure the values in the frame header look sane */
-  header = GST_READ_UINT32_BE (GST_BUFFER_DATA (buf));
+  header = GST_READ_UINT32_BE (data);
   if (!gst_mpeg_audio_parse_head_check (mp3parse, header)) {
     *skipsize = 1;
-    return FALSE;
+    goto cleanup;
   }
 
   GST_LOG_OBJECT (parse, "got frame");
@@ -543,24 +547,28 @@ gst_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse,
       /* not enough data */
       gst_base_parse_set_min_frame_size (parse, valid);
       *skipsize = 0;
-      return FALSE;
+      goto cleanup;
     } else {
       if (!valid) {
         *skipsize = off + 2;
-        return FALSE;
+        goto cleanup;
       }
     }
   } else if (draining && lost_sync && caps_change && mp3parse->rate > 0) {
     /* avoid caps jitter that we can't be sure of */
     *skipsize = off + 2;
-    return FALSE;
+    goto cleanup;
   }
 
   /* restore default minimum */
   gst_base_parse_set_min_frame_size (parse, MIN_FRAME_SIZE);
 
   *framesize = bpf;
-  return TRUE;
+  res = TRUE;
+
+cleanup:
+  gst_buffer_unmap (buf, data, bufsize);
+  return res;
 }
 
 static void
@@ -574,9 +582,9 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
   gint offset_xing, offset_vbri;
   guint64 avail;
   gint64 upstream_total_bytes = 0;
-  GstFormat fmt = GST_FORMAT_BYTES;
   guint32 read_id_xing = 0, read_id_vbri = 0;
-  const guint8 *data;
+  guint8 *data, *origdata;
+  gsize bufsize;
   guint bitrate;
 
   if (mp3parse->sent_codec_tag)
@@ -603,8 +611,8 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
   offset_vbri += 4;
 
   /* Check if we have enough data to read the Xing header */
-  avail = GST_BUFFER_SIZE (buf);
-  data = GST_BUFFER_DATA (buf);
+  origdata = data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
+  avail = bufsize;
 
   if (avail >= offset_xing + 4) {
     read_id_xing = GST_READ_UINT32_BE (data + offset_xing);
@@ -614,9 +622,8 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
   }
 
   /* obtain real upstream total bytes */
-  fmt = GST_FORMAT_BYTES;
-  if (!gst_pad_query_peer_duration (GST_BASE_PARSE_SINK_PAD (GST_BASE_PARSE
-              (mp3parse)), &fmt, &upstream_total_bytes))
+  if (!gst_pad_query_peer_duration (GST_BASE_PARSE_SINK_PAD (mp3parse),
+          GST_FORMAT_BYTES, &upstream_total_bytes))
     upstream_total_bytes = 0;
 
   if (read_id_xing == xing_id || read_id_xing == info_id) {
@@ -644,7 +651,7 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
     if (avail < bytes_needed) {
       GST_DEBUG_OBJECT (mp3parse,
           "Not enough data to read Xing header (need %d)", bytes_needed);
-      return;
+      goto cleanup;
     }
 
     GST_DEBUG_OBJECT (mp3parse, "Reading Xing header");
@@ -800,7 +807,7 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
     if (avail < offset_vbri + 26) {
       GST_DEBUG_OBJECT (mp3parse,
           "Not enough data to read VBRI header (need %d)", offset_vbri + 26);
-      return;
+      goto cleanup;
     }
 
     GST_DEBUG_OBJECT (mp3parse, "Reading VBRI header");
@@ -811,7 +818,7 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
     if (GST_READ_UINT16_BE (data) != 0x0001) {
       GST_WARNING_OBJECT (mp3parse,
           "Unsupported VBRI version 0x%x", GST_READ_UINT16_BE (data));
-      return;
+      goto cleanup;
     }
     data += 2;
 
@@ -884,10 +891,10 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
         GST_DEBUG_OBJECT (mp3parse,
             "Not enough data to read VBRI header (need %d)",
             offset_vbri + 26 + nseek_points * seek_bytes);
-        return;
+        goto cleanup;
       }
 
-      data = GST_BUFFER_DATA (buf);
+      data = origdata;
       data += offset_vbri + 26;
 
       /* VBRI seek table: frame/seek_frames -> byte */
@@ -961,6 +968,9 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
     bitrate = 0;
 
   gst_base_parse_set_average_bitrate (GST_BASE_PARSE (mp3parse), bitrate);
+
+cleanup:
+  gst_buffer_unmap (buf, origdata, bufsize);
 }
 
 static GstFlowReturn
@@ -969,12 +979,16 @@ gst_mpeg_audio_parse_parse_frame (GstBaseParse * parse,
 {
   GstMpegAudioParse *mp3parse = GST_MPEG_AUDIO_PARSE (parse);
   GstBuffer *buf = frame->buffer;
+  guint8 *data;
+  gsize bufsize;
   guint bitrate, layer, rate, channels, version, mode, crc;
 
-  g_return_val_if_fail (GST_BUFFER_SIZE (buf) >= 4, GST_FLOW_ERROR);
+  data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
+  if (G_UNLIKELY (bufsize < 4))
+    goto short_buffer;
 
   if (!mp3_type_frame_length_from_header (mp3parse,
-          GST_READ_UINT32_BE (GST_BUFFER_DATA (buf)),
+          GST_READ_UINT32_BE (data),
           &version, &layer, &channels, &bitrate, &rate, &mode, &crc))
     goto broken_header;
 
@@ -986,7 +1000,6 @@ gst_mpeg_audio_parse_parse_frame (GstBaseParse * parse,
         "layer", G_TYPE_INT, layer,
         "rate", G_TYPE_INT, rate,
         "channels", G_TYPE_INT, channels, "parsed", G_TYPE_BOOLEAN, TRUE, NULL);
-    gst_buffer_set_caps (buf, caps);
     gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (parse), caps);
     gst_caps_unref (caps);
 
@@ -1030,15 +1043,23 @@ gst_mpeg_audio_parse_parse_frame (GstBaseParse * parse,
   mp3parse->last_crc = crc;
   mp3parse->last_mode = mode;
 
+  gst_buffer_unmap (buf, data, bufsize);
   return GST_FLOW_OK;
 
 /* ERRORS */
 broken_header:
   {
     /* this really shouldn't ever happen */
+    gst_buffer_unmap (buf, data, bufsize);
     GST_ELEMENT_ERROR (parse, STREAM, DECODE, (NULL), (NULL));
     return GST_FLOW_ERROR;
   }
+
+short_buffer:
+  {
+    gst_buffer_unmap (buf, data, bufsize);
+    return GST_FLOW_ERROR;
+  }
 }
 
 static gboolean
index a79fb7b..3f103b0 100644 (file)
@@ -2,7 +2,7 @@ plugin_LTLIBRARIES = libgstauparse.la
 
 libgstauparse_la_SOURCES = gstauparse.c
 libgstauparse_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
-libgstauparse_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS)
+libgstauparse_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR)
 libgstauparse_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstauparse_la_LIBTOOLFLAGS = --tag=disable-static
 
index d5a5555..054a640 100644 (file)
@@ -43,6 +43,14 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_STATIC_CAPS ("audio/x-au")
     );
 
+#define GST_AU_PARSE_RAW_PAD_TEMPLATE_CAPS \
+    "audio/x-raw, "                         \
+    "format= (string) { S8, S16_LE, S16_BE, S24_3LE, S24_3BE, "  \
+                       "S32_LE, S32_BE, F32_LE, F32_BE, "        \
+                       "F64_LE, F64_BE }, " \
+    "rate = (int) [ 8000, 192000 ], "       \
+    "channels = (int) [ 1, 2 ]"
+
 #define GST_AU_PARSE_ALAW_PAD_TEMPLATE_CAPS \
     "audio/x-alaw, "                        \
     "rate = (int) [ 8000, 192000 ], "       \
@@ -60,9 +68,8 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
 
 static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
-    GST_PAD_SOMETIMES,
-    GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
-        GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS ";"
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS (GST_AU_PARSE_RAW_PAD_TEMPLATE_CAPS "; "
         GST_AU_PARSE_ALAW_PAD_TEMPLATE_CAPS ";"
         GST_AU_PARSE_MULAW_PAD_TEMPLATE_CAPS ";"
         GST_AU_PARSE_ADPCM_PAD_TEMPLATE_CAPS));
@@ -73,8 +80,6 @@ static GstFlowReturn gst_au_parse_chain (GstPad * pad, GstBuffer * buf);
 static GstStateChangeReturn gst_au_parse_change_state (GstElement * element,
     GstStateChange transition);
 static void gst_au_parse_reset (GstAuParse * auparse);
-static gboolean gst_au_parse_remove_srcpad (GstAuParse * auparse);
-static gboolean gst_au_parse_add_srcpad (GstAuParse * auparse, GstCaps * caps);
 static gboolean gst_au_parse_src_query (GstPad * pad, GstQuery * query);
 static gboolean gst_au_parse_src_event (GstPad * pad, GstEvent * event);
 static gboolean gst_au_parse_sink_event (GstPad * pad, GstEvent * event);
@@ -82,24 +87,8 @@ static gboolean gst_au_parse_src_convert (GstAuParse * auparse,
     GstFormat src_format, gint64 srcval, GstFormat dest_format,
     gint64 * destval);
 
-GST_BOILERPLATE (GstAuParse, gst_au_parse, GstElement, GST_TYPE_ELEMENT);
-
-static void
-gst_au_parse_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_template));
-  gst_element_class_set_details_simple (element_class, "AU audio demuxer",
-      "Codec/Demuxer/Audio",
-      "Parse an .au file into raw audio",
-      "Erik Walthinsen <omega@cse.ogi.edu>");
-
-  GST_DEBUG_CATEGORY_INIT (auparse_debug, "auparse", 0, ".au parser");
-}
+#define gst_au_parse_parent_class parent_class
+G_DEFINE_TYPE (GstAuParse, gst_au_parse, GST_TYPE_ELEMENT);
 
 static void
 gst_au_parse_class_init (GstAuParseClass * klass)
@@ -107,6 +96,8 @@ gst_au_parse_class_init (GstAuParseClass * klass)
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
 
+  GST_DEBUG_CATEGORY_INIT (auparse_debug, "auparse", 0, ".au parser");
+
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
 
@@ -114,10 +105,19 @@ gst_au_parse_class_init (GstAuParseClass * klass)
 
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_au_parse_change_state);
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_template));
+  gst_element_class_set_details_simple (gstelement_class,
+      "AU audio demuxer",
+      "Codec/Demuxer/Audio",
+      "Parse an .au file into raw audio",
+      "Erik Walthinsen <omega@cse.ogi.edu>");
 }
 
 static void
-gst_au_parse_init (GstAuParse * auparse, GstAuParseClass * klass)
+gst_au_parse_init (GstAuParse * auparse)
 {
   auparse->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
   gst_pad_set_chain_function (auparse->sinkpad,
@@ -126,7 +126,14 @@ gst_au_parse_init (GstAuParse * auparse, GstAuParseClass * klass)
       GST_DEBUG_FUNCPTR (gst_au_parse_sink_event));
   gst_element_add_pad (GST_ELEMENT (auparse), auparse->sinkpad);
 
-  auparse->srcpad = NULL;
+  auparse->srcpad = gst_pad_new_from_static_template (&src_template, "src");
+  gst_pad_set_query_function (auparse->srcpad,
+      GST_DEBUG_FUNCPTR (gst_au_parse_src_query));
+  gst_pad_set_event_function (auparse->srcpad,
+      GST_DEBUG_FUNCPTR (gst_au_parse_src_event));
+  gst_pad_use_fixed_caps (auparse->srcpad);
+  gst_element_add_pad (GST_ELEMENT (auparse), auparse->srcpad);
+
   auparse->adapter = gst_adapter_new ();
   gst_au_parse_reset (auparse);
 }
@@ -146,8 +153,6 @@ gst_au_parse_dispose (GObject * object)
 static void
 gst_au_parse_reset (GstAuParse * auparse)
 {
-  gst_au_parse_remove_srcpad (auparse);
-
   auparse->offset = 0;
   auparse->buffer_offset = 0;
   auparse->encoding = 0;
@@ -159,66 +164,20 @@ gst_au_parse_reset (GstAuParse * auparse)
   /* gst_segment_init (&auparse->segment, GST_FORMAT_TIME); */
 }
 
-static gboolean
-gst_au_parse_add_srcpad (GstAuParse * auparse, GstCaps * new_caps)
+static void
+gst_au_parse_negotiate_srcpad (GstAuParse * auparse, GstCaps * new_caps)
 {
   if (auparse->src_caps && gst_caps_is_equal (new_caps, auparse->src_caps)) {
     GST_LOG_OBJECT (auparse, "same caps, nothing to do");
-    return TRUE;
+    return;
   }
 
   gst_caps_replace (&auparse->src_caps, new_caps);
-  if (auparse->srcpad != NULL) {
-    GST_DEBUG_OBJECT (auparse, "Changing src pad caps to %" GST_PTR_FORMAT,
-        auparse->src_caps);
-    gst_pad_set_caps (auparse->srcpad, auparse->src_caps);
-  }
-
-  if (auparse->srcpad == NULL) {
-    auparse->srcpad = gst_pad_new_from_static_template (&src_template, "src");
-    g_return_val_if_fail (auparse->srcpad != NULL, FALSE);
-
-#if 0
-    gst_pad_set_query_type_function (auparse->srcpad,
-        GST_DEBUG_FUNCPTR (gst_au_parse_src_get_query_types));
-#endif
-    gst_pad_set_query_function (auparse->srcpad,
-        GST_DEBUG_FUNCPTR (gst_au_parse_src_query));
-    gst_pad_set_event_function (auparse->srcpad,
-        GST_DEBUG_FUNCPTR (gst_au_parse_src_event));
-
-    gst_pad_use_fixed_caps (auparse->srcpad);
-    gst_pad_set_active (auparse->srcpad, TRUE);
-
-    if (auparse->src_caps)
-      gst_pad_set_caps (auparse->srcpad, auparse->src_caps);
-
-    GST_DEBUG_OBJECT (auparse, "Adding src pad with caps %" GST_PTR_FORMAT,
-        auparse->src_caps);
-
-    gst_object_ref (auparse->srcpad);
-    if (!gst_element_add_pad (GST_ELEMENT (auparse), auparse->srcpad))
-      return FALSE;
-    gst_element_no_more_pads (GST_ELEMENT (auparse));
-  }
-
-  return TRUE;
-}
-
-static gboolean
-gst_au_parse_remove_srcpad (GstAuParse * auparse)
-{
-  gboolean res = TRUE;
-
-  if (auparse->srcpad != NULL) {
-    GST_DEBUG_OBJECT (auparse, "Removing src pad");
-    res = gst_element_remove_pad (GST_ELEMENT (auparse), auparse->srcpad);
-    g_return_val_if_fail (res != FALSE, FALSE);
-    gst_object_unref (auparse->srcpad);
-    auparse->srcpad = NULL;
-  }
+  GST_DEBUG_OBJECT (auparse, "Changing src pad caps to %" GST_PTR_FORMAT,
+      auparse->src_caps);
+  gst_pad_set_caps (auparse->srcpad, auparse->src_caps);
 
-  return res;
+  return;
 }
 
 static GstFlowReturn
@@ -228,9 +187,11 @@ gst_au_parse_parse_header (GstAuParse * auparse)
   guint32 size;
   guint8 *head;
   gchar layout[7] = { 0, };
-  gint law = 0, depth = 0, ieee = 0;
+  GstAudioFormat format = GST_AUDIO_FORMAT_UNKNOWN;
+  gint law = 0;
+  guint endianness;
 
-  head = (guint8 *) gst_adapter_peek (auparse->adapter, 24);
+  head = (guint8 *) gst_adapter_map (auparse->adapter, 24);
   g_assert (head != NULL);
 
   GST_DEBUG_OBJECT (auparse, "[%c%c%c%c]", head[0], head[1], head[2], head[3]);
@@ -238,14 +199,14 @@ gst_au_parse_parse_header (GstAuParse * auparse)
   switch (GST_READ_UINT32_BE (head)) {
       /* normal format is big endian (au is a Sparc format) */
     case 0x2e736e64:{          /* ".snd" */
-      auparse->endianness = G_BIG_ENDIAN;
+      endianness = G_BIG_ENDIAN;
       break;
     }
       /* and of course, someone had to invent a little endian
        * version.  Used by DEC systems. */
     case 0x646e732e:           /* dns.                          */
     case 0x0064732e:{          /* other source say it is "dns." */
-      auparse->endianness = G_LITTLE_ENDIAN;
+      endianness = G_LITTLE_ENDIAN;
       break;
     }
     default:{
@@ -285,33 +246,50 @@ gst_au_parse_parse_header (GstAuParse * auparse)
   switch (auparse->encoding) {
     case 1:                    /* 8-bit ISDN mu-law G.711 */
       law = 1;
-      depth = 8;
       break;
     case 27:                   /* 8-bit ISDN  A-law G.711 */
       law = 2;
-      depth = 8;
       break;
 
-    case 2:                    /*  8-bit linear PCM */
-      depth = 8;
+    case 2:                    /*  8-bit linear PCM, FIXME signed? */
+      format = GST_AUDIO_FORMAT_S8;
+      auparse->sample_size = auparse->channels;
       break;
     case 3:                    /* 16-bit linear PCM */
-      depth = 16;
+      if (endianness == G_LITTLE_ENDIAN)
+        format = GST_AUDIO_FORMAT_S16_LE;
+      else
+        format = GST_AUDIO_FORMAT_S16_BE;
+      auparse->sample_size = auparse->channels * 2;
       break;
     case 4:                    /* 24-bit linear PCM */
-      depth = 24;
+      if (endianness == G_LITTLE_ENDIAN)
+        format = GST_AUDIO_FORMAT_S24_3LE;
+      else
+        format = GST_AUDIO_FORMAT_S24_3BE;
+      auparse->sample_size = auparse->channels * 3;
       break;
     case 5:                    /* 32-bit linear PCM */
-      depth = 32;
+      if (endianness == G_LITTLE_ENDIAN)
+        format = GST_AUDIO_FORMAT_S32_LE;
+      else
+        format = GST_AUDIO_FORMAT_S32_BE;
+      auparse->sample_size = auparse->channels * 4;
       break;
 
     case 6:                    /* 32-bit IEEE floating point */
-      ieee = 1;
-      depth = 32;
+      if (endianness == G_LITTLE_ENDIAN)
+        format = GST_AUDIO_FORMAT_F32_LE;
+      else
+        format = GST_AUDIO_FORMAT_F32_BE;
+      auparse->sample_size = auparse->channels * 4;
       break;
     case 7:                    /* 64-bit IEEE floating point */
-      ieee = 1;
-      depth = 64;
+      if (endianness == G_LITTLE_ENDIAN)
+        format = GST_AUDIO_FORMAT_F64_LE;
+      else
+        format = GST_AUDIO_FORMAT_F64_BE;
+      auparse->sample_size = auparse->channels * 8;
       break;
 
     case 23:                   /* 4-bit CCITT G.721   ADPCM 32kbps -> modplug/libsndfile (compressed 8-bit mu-law) */
@@ -356,35 +334,24 @@ gst_au_parse_parse_header (GstAuParse * auparse)
         "rate", G_TYPE_INT, auparse->samplerate,
         "channels", G_TYPE_INT, auparse->channels, NULL);
     auparse->sample_size = auparse->channels;
-  } else if (ieee) {
-    tempcaps = gst_caps_new_simple ("audio/x-raw-float",
+  } else if (format != GST_AUDIO_FORMAT_UNKNOWN) {
+    tempcaps = gst_caps_new_simple ("audio/x-raw",
+        "format", G_TYPE_STRING, gst_audio_format_to_string (format),
         "rate", G_TYPE_INT, auparse->samplerate,
-        "channels", G_TYPE_INT, auparse->channels,
-        "endianness", G_TYPE_INT, auparse->endianness,
-        "width", G_TYPE_INT, depth, NULL);
-    auparse->sample_size = auparse->channels * depth / 8;
+        "channels", G_TYPE_INT, auparse->channels, NULL);
   } else if (layout[0]) {
     tempcaps = gst_caps_new_simple ("audio/x-adpcm",
         "layout", G_TYPE_STRING, layout, NULL);
     auparse->sample_size = 0;
-  } else {
-    tempcaps = gst_caps_new_simple ("audio/x-raw-int",
-        "rate", G_TYPE_INT, auparse->samplerate,
-        "channels", G_TYPE_INT, auparse->channels,
-        "endianness", G_TYPE_INT, auparse->endianness,
-        "depth", G_TYPE_INT, depth, "width", G_TYPE_INT, depth,
-        /* FIXME: signed TRUE even for 8-bit PCM? */
-        "signed", G_TYPE_BOOLEAN, TRUE, NULL);
-    auparse->sample_size = auparse->channels * depth / 8;
-  }
+  } else
+    goto unknown_format;
 
   GST_DEBUG_OBJECT (auparse, "sample_size=%d", auparse->sample_size);
 
-  if (!gst_au_parse_add_srcpad (auparse, tempcaps))
-    goto add_pad_failed;
+  gst_au_parse_negotiate_srcpad (auparse, tempcaps);
 
   GST_DEBUG_OBJECT (auparse, "offset=%" G_GINT64_FORMAT, auparse->offset);
-  gst_adapter_flush (auparse->adapter, auparse->offset);
+  gst_adapter_unmap (auparse->adapter, auparse->offset);
 
   gst_caps_unref (tempcaps);
   return GST_FLOW_OK;
@@ -392,34 +359,31 @@ gst_au_parse_parse_header (GstAuParse * auparse)
   /* ERRORS */
 unknown_header:
   {
+    gst_adapter_unmap (auparse->adapter, 0);
     GST_ELEMENT_ERROR (auparse, STREAM, WRONG_TYPE, (NULL), (NULL));
     return GST_FLOW_ERROR;
   }
 unsupported_sample_rate:
   {
+    gst_adapter_unmap (auparse->adapter, 0);
     GST_ELEMENT_ERROR (auparse, STREAM, FORMAT, (NULL),
         ("Unsupported samplerate: %u", auparse->samplerate));
     return GST_FLOW_ERROR;
   }
 unsupported_number_of_channels:
   {
+    gst_adapter_unmap (auparse->adapter, 0);
     GST_ELEMENT_ERROR (auparse, STREAM, FORMAT, (NULL),
         ("Unsupported number of channels: %u", auparse->channels));
     return GST_FLOW_ERROR;
   }
 unknown_format:
   {
+    gst_adapter_unmap (auparse->adapter, 0);
     GST_ELEMENT_ERROR (auparse, STREAM, FORMAT, (NULL),
         ("Unsupported encoding: %u", auparse->encoding));
     return GST_FLOW_ERROR;
   }
-add_pad_failed:
-  {
-    GST_ELEMENT_ERROR (auparse, STREAM, FAILED, (NULL),
-        ("Failed to add srcpad"));
-    gst_caps_unref (tempcaps);
-    return GST_FLOW_ERROR;
-  }
 }
 
 #define AU_HEADER_SIZE 24
@@ -433,16 +397,17 @@ gst_au_parse_chain (GstPad * pad, GstBuffer * buf)
   gint64 timestamp;
   gint64 duration;
   gint64 offset;
+  GstSegment segment;
 
   auparse = GST_AU_PARSE (gst_pad_get_parent (pad));
 
-  GST_LOG_OBJECT (auparse, "got buffer of size %u", GST_BUFFER_SIZE (buf));
+  GST_LOG_OBJECT (auparse, "got buffer of size %u", gst_buffer_get_size (buf));
 
   gst_adapter_push (auparse->adapter, buf);
   buf = NULL;
 
   /* if we haven't seen any data yet... */
-  if (auparse->srcpad == NULL) {
+  if (!gst_pad_has_current_caps (auparse->srcpad)) {
     if (gst_adapter_available (auparse->adapter) < AU_HEADER_SIZE) {
       GST_DEBUG_OBJECT (auparse, "need more data to parse header");
       ret = GST_FLOW_OK;
@@ -453,9 +418,8 @@ gst_au_parse_chain (GstPad * pad, GstBuffer * buf)
     if (ret != GST_FLOW_OK)
       goto out;
 
-    gst_pad_push_event (auparse->srcpad,
-        gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
-            0, GST_CLOCK_TIME_NONE, 0));
+    gst_segment_init (&segment, GST_FORMAT_TIME);
+    gst_pad_push_event (auparse->srcpad, gst_event_new_segment (&segment));
   }
 
   avail = gst_adapter_available (auparse->adapter);
@@ -471,21 +435,10 @@ gst_au_parse_chain (GstPad * pad, GstBuffer * buf)
 
   if (sendnow > 0) {
     GstBuffer *outbuf;
-    const guint8 *data;
     gint64 pos;
 
-    ret = gst_pad_alloc_buffer_and_set_caps (auparse->srcpad,
-        auparse->buffer_offset, sendnow, GST_PAD_CAPS (auparse->srcpad),
-        &outbuf);
-
-    if (ret != GST_FLOW_OK) {
-      GST_DEBUG_OBJECT (auparse, "pad alloc flow: %s", gst_flow_get_name (ret));
-      goto out;
-    }
-
-    data = gst_adapter_peek (auparse->adapter, sendnow);
-    memcpy (GST_BUFFER_DATA (outbuf), data, sendnow);
-    gst_adapter_flush (auparse->adapter, sendnow);
+    outbuf = gst_adapter_take_buffer (auparse->adapter, sendnow);
+    outbuf = gst_buffer_make_writable (outbuf);
 
     pos = auparse->buffer_offset - auparse->offset;
     pos = MAX (pos, 0);
@@ -596,12 +549,12 @@ gst_au_parse_src_query (GstPad * pad, GstQuery * query)
 
   switch (GST_QUERY_TYPE (query)) {
     case GST_QUERY_DURATION:{
-      GstFormat bformat = GST_FORMAT_BYTES;
       GstFormat format;
       gint64 len, val;
 
       gst_query_parse_duration (query, &format, NULL);
-      if (!gst_pad_query_peer_duration (auparse->sinkpad, &bformat, &len)) {
+      if (!gst_pad_query_peer_duration (auparse->sinkpad, GST_FORMAT_BYTES,
+              &len)) {
         GST_DEBUG_OBJECT (auparse, "failed to query upstream length");
         break;
       }
@@ -609,7 +562,9 @@ gst_au_parse_src_query (GstPad * pad, GstQuery * query)
       len -= auparse->offset;
       GST_OBJECT_UNLOCK (auparse);
 
-      ret = gst_au_parse_src_convert (auparse, bformat, len, format, &val);
+      ret =
+          gst_au_parse_src_convert (auparse, GST_FORMAT_BYTES, len, format,
+          &val);
 
       if (ret) {
         gst_query_set_duration (query, format, val);
@@ -617,12 +572,12 @@ gst_au_parse_src_query (GstPad * pad, GstQuery * query)
       break;
     }
     case GST_QUERY_POSITION:{
-      GstFormat bformat = GST_FORMAT_BYTES;
       GstFormat format;
       gint64 pos, val;
 
       gst_query_parse_position (query, &format, NULL);
-      if (!gst_pad_query_peer_position (auparse->sinkpad, &bformat, &pos)) {
+      if (!gst_pad_query_peer_position (auparse->sinkpad, GST_FORMAT_BYTES,
+              &pos)) {
         GST_DEBUG_OBJECT (auparse, "failed to query upstream position");
         break;
       }
@@ -702,21 +657,25 @@ gst_au_parse_sink_event (GstPad * pad, GstEvent * event)
   auparse = GST_AU_PARSE (gst_pad_get_parent (pad));
 
   switch (GST_EVENT_TYPE (event)) {
-    case GST_EVENT_NEWSEGMENT:
+    case GST_EVENT_CAPS:
     {
-      GstFormat format;
-      gdouble rate, arate;
-      gint64 start, stop, time, offset = 0;
-      gboolean update;
+      /* discard, we'll come up with proper src caps */
+      gst_event_unref (event);
+      break;
+    }
+    case GST_EVENT_SEGMENT:
+    {
+      gint64 start, stop, offset = 0;
       GstSegment segment;
       GstEvent *new_event = NULL;
 
-      gst_segment_init (&segment, GST_FORMAT_UNDEFINED);
-      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
-          &start, &stop, &time);
-      gst_segment_set_newsegment_full (&segment, update, rate, arate, format,
-          start, stop, time);
+      /* some debug output */
+      gst_event_copy_segment (event, &segment);
+      GST_DEBUG_OBJECT (auparse, "received newsegment %" GST_SEGMENT_FORMAT,
+          &segment);
 
+      start = segment.start;
+      stop = segment.stop;
       if (auparse->sample_size > 0) {
         if (start > 0) {
           offset = start;
@@ -733,16 +692,16 @@ gst_au_parse_sink_event (GstPad * pad, GstEvent * event)
             GST_FORMAT_TIME, &stop);
       }
 
-      if (auparse->srcpad) {
-        GST_INFO_OBJECT (auparse,
-            "new segment: %" GST_TIME_FORMAT " ... %" GST_TIME_FORMAT,
-            GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
+      GST_INFO_OBJECT (auparse,
+          "new segment: %" GST_TIME_FORMAT " ... %" GST_TIME_FORMAT,
+          GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
 
-        new_event = gst_event_new_new_segment_full (update, rate, arate,
-            GST_FORMAT_TIME, start, stop, start);
+      gst_segment_init (&segment, GST_FORMAT_TIME);
+      segment.start = segment.time = start;
+      segment.stop = stop;
+      new_event = gst_event_new_segment (&segment);
 
-        ret = gst_pad_push_event (auparse->srcpad, new_event);
-      }
+      ret = gst_pad_push_event (auparse->srcpad, new_event);
 
       auparse->buffer_offset = offset;
 
@@ -791,7 +750,7 @@ gst_au_parse_change_state (GstElement * element, GstStateChange transition)
   GstAuParse *auparse = GST_AU_PARSE (element);
   GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
 
-  ret = parent_class->change_state (element, transition);
+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
   if (ret == GST_STATE_CHANGE_FAILURE)
     return ret;
 
index 55d13e2..5744d26 100644 (file)
@@ -60,7 +60,6 @@ struct _GstAuParse {
   guint       sample_size;
   guint       encoding;
   guint       samplerate;
-  guint       endianness;
   guint       channels;
 };
 
index fae54f5..19cbca6 100644 (file)
@@ -61,7 +61,8 @@ static void gst_auto_audio_sink_set_property (GObject * object, guint prop_id,
 static void gst_auto_audio_sink_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-GST_BOILERPLATE (GstAutoAudioSink, gst_auto_audio_sink, GstBin, GST_TYPE_BIN);
+#define gst_auto_audio_sink_parent_class parent_class
+G_DEFINE_TYPE (GstAutoAudioSink, gst_auto_audio_sink, GST_TYPE_BIN);
 
 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
@@ -69,20 +70,6 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_STATIC_CAPS_ANY);
 
 static void
-gst_auto_audio_sink_base_init (gpointer klass)
-{
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (eklass,
-      gst_static_pad_template_get (&sink_template));
-
-  gst_element_class_set_details_simple (eklass, "Auto audio sink",
-      "Sink/Audio",
-      "Wrapper audio sink for automatically detected audio sink",
-      "Jan Schmidt <thaytan@noraisin.net>");
-}
-
-static void
 gst_auto_audio_sink_class_init (GstAutoAudioSinkClass * klass)
 {
   GObjectClass *gobject_class;
@@ -112,6 +99,14 @@ gst_auto_audio_sink_class_init (GstAutoAudioSinkClass * klass)
       g_param_spec_boxed ("filter-caps", "Filter caps",
           "Filter sink candidates using these caps.", GST_TYPE_CAPS,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_add_pad_template (eklass,
+      gst_static_pad_template_get (&sink_template));
+
+  gst_element_class_set_details_simple (eklass, "Auto audio sink",
+      "Sink/Audio",
+      "Wrapper audio sink for automatically detected audio sink",
+      "Jan Schmidt <thaytan@noraisin.net>");
 }
 
 static void
@@ -159,12 +154,10 @@ gst_auto_audio_sink_reset (GstAutoAudioSink * sink)
   gst_object_unref (targetpad);
 }
 
-static GstStaticCaps raw_caps =
-    GST_STATIC_CAPS ("audio/x-raw-int; audio/x-raw-float");
+static GstStaticCaps raw_caps = GST_STATIC_CAPS ("audio/x-raw");
 
 static void
-gst_auto_audio_sink_init (GstAutoAudioSink * sink,
-    GstAutoAudioSinkClass * g_class)
+gst_auto_audio_sink_init (GstAutoAudioSink * sink)
 {
   sink->pad = gst_ghost_pad_new_no_target ("sink", GST_PAD_SINK);
   gst_element_add_pad (GST_ELEMENT (sink), sink->pad);
@@ -220,7 +213,7 @@ gst_auto_audio_sink_create_element_with_pretty_name (GstAutoAudioSink * sink,
   GstElement *element;
   gchar *name, *marker;
 
-  marker = g_strdup (GST_PLUGIN_FEATURE (factory)->name);
+  marker = g_strdup (GST_OBJECT_NAME (factory));
   if (g_str_has_suffix (marker, "sink"))
     marker[strlen (marker) - 4] = '\0';
   if (g_str_has_prefix (marker, "gst"))
@@ -262,13 +255,13 @@ gst_auto_audio_sink_find_best (GstAutoAudioSink * sink)
     if ((el = gst_auto_audio_sink_create_element_with_pretty_name (sink, f))) {
       GstStateChangeReturn ret;
 
-      GST_DEBUG_OBJECT (sink, "Testing %s", GST_PLUGIN_FEATURE (f)->name);
+      GST_DEBUG_OBJECT (sink, "Testing %s", GST_OBJECT_NAME (f));
 
       /* If autoaudiosink has been provided with filter caps,
        * accept only sinks that match with the filter caps */
       if (sink->filter_caps) {
         el_pad = gst_element_get_static_pad (GST_ELEMENT (el), "sink");
-        el_caps = gst_pad_get_caps (el_pad);
+        el_caps = gst_pad_get_caps (el_pad, NULL);
         gst_object_unref (el_pad);
         GST_DEBUG_OBJECT (sink,
             "Checking caps: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
index 40c53c6..b46a88c 100644 (file)
@@ -62,7 +62,8 @@ static void gst_auto_audio_src_set_property (GObject * object, guint prop_id,
 static void gst_auto_audio_src_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-GST_BOILERPLATE (GstAutoAudioSrc, gst_auto_audio_src, GstBin, GST_TYPE_BIN);
+#define gst_auto_audio_src_parent_class parent_class
+G_DEFINE_TYPE (GstAutoAudioSrc, gst_auto_audio_src, GST_TYPE_BIN);
 
 static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
@@ -70,21 +71,6 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
     GST_STATIC_CAPS_ANY);
 
 static void
-gst_auto_audio_src_base_init (gpointer klass)
-{
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (eklass,
-      gst_static_pad_template_get (&src_template));
-
-  gst_element_class_set_details_simple (eklass, "Auto audio source",
-      "Source/Audio",
-      "Wrapper audio source for automatically detected audio source",
-      "Jan Schmidt <thaytan@noraisin.net>, "
-      "Stefan Kost <ensonic@users.sf.net>");
-}
-
-static void
 gst_auto_audio_src_class_init (GstAutoAudioSrcClass * klass)
 {
   GObjectClass *gobject_class;
@@ -114,6 +100,15 @@ gst_auto_audio_src_class_init (GstAutoAudioSrcClass * klass)
       g_param_spec_boxed ("filter-caps", "Filter caps",
           "Filter sink candidates using these caps.", GST_TYPE_CAPS,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_add_pad_template (eklass,
+      gst_static_pad_template_get (&src_template));
+
+  gst_element_class_set_details_simple (eklass, "Auto audio source",
+      "Source/Audio",
+      "Wrapper audio source for automatically detected audio source",
+      "Jan Schmidt <thaytan@noraisin.net>, "
+      "Stefan Kost <ensonic@users.sf.net>");
 }
 
 static void
@@ -162,11 +157,10 @@ gst_auto_audio_src_reset (GstAutoAudioSrc * src)
   gst_object_unref (targetpad);
 }
 
-static GstStaticCaps raw_caps =
-    GST_STATIC_CAPS ("audio/x-raw-int; audio/x-raw-float");
+static GstStaticCaps raw_caps = GST_STATIC_CAPS ("audio/x-raw");
 
 static void
-gst_auto_audio_src_init (GstAutoAudioSrc * src, GstAutoAudioSrcClass * g_class)
+gst_auto_audio_src_init (GstAutoAudioSrc * src)
 {
   src->pad = gst_ghost_pad_new_no_target ("src", GST_PAD_SRC);
   gst_element_add_pad (GST_ELEMENT (src), src->pad);
@@ -222,7 +216,7 @@ gst_auto_audio_src_create_element_with_pretty_name (GstAutoAudioSrc * src,
   GstElement *element;
   gchar *name, *marker;
 
-  marker = g_strdup (GST_PLUGIN_FEATURE (factory)->name);
+  marker = g_strdup (GST_OBJECT_NAME (factory));
   if (g_str_has_suffix (marker, "src"))
     marker[strlen (marker) - 4] = '\0';
   if (g_str_has_prefix (marker, "gst"))
@@ -264,13 +258,13 @@ gst_auto_audio_src_find_best (GstAutoAudioSrc * src)
     if ((el = gst_auto_audio_src_create_element_with_pretty_name (src, f))) {
       GstStateChangeReturn ret;
 
-      GST_DEBUG_OBJECT (src, "Testing %s", GST_PLUGIN_FEATURE (f)->name);
+      GST_DEBUG_OBJECT (src, "Testing %s", GST_OBJECT_NAME (f));
 
       /* If autoAudioSrc has been provided with filter caps,
        * accept only sources that match with the filter caps */
       if (src->filter_caps) {
         el_pad = gst_element_get_static_pad (GST_ELEMENT (el), "src");
-        el_caps = gst_pad_get_caps (el_pad);
+        el_caps = gst_pad_get_caps (el_pad, NULL);
         gst_object_unref (el_pad);
         GST_DEBUG_OBJECT (src,
             "Checking caps: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
index 7e37ffe..e5cfafe 100644 (file)
@@ -62,7 +62,8 @@ static void gst_auto_video_sink_set_property (GObject * object, guint prop_id,
 static void gst_auto_video_sink_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-GST_BOILERPLATE (GstAutoVideoSink, gst_auto_video_sink, GstBin, GST_TYPE_BIN);
+#define gst_auto_video_sink_parent_class parent_class
+G_DEFINE_TYPE (GstAutoVideoSink, gst_auto_video_sink, GST_TYPE_BIN);
 
 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
@@ -70,19 +71,6 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_STATIC_CAPS_ANY);
 
 static void
-gst_auto_video_sink_base_init (gpointer klass)
-{
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (eklass,
-      gst_static_pad_template_get (&sink_template));
-  gst_element_class_set_details_simple (eklass, "Auto video sink",
-      "Sink/Video",
-      "Wrapper video sink for automatically detected video sink",
-      "Jan Schmidt <thaytan@noraisin.net>");
-}
-
-static void
 gst_auto_video_sink_class_init (GstAutoVideoSinkClass * klass)
 {
   GObjectClass *gobject_class;
@@ -109,6 +97,13 @@ gst_auto_video_sink_class_init (GstAutoVideoSinkClass * klass)
       g_param_spec_boxed ("filter-caps", "Filter caps",
           "Filter sink candidates using these caps.", GST_TYPE_CAPS,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_add_pad_template (eklass,
+      gst_static_pad_template_get (&sink_template));
+  gst_element_class_set_details_simple (eklass, "Auto video sink",
+      "Sink/Video",
+      "Wrapper video sink for automatically detected video sink",
+      "Jan Schmidt <thaytan@noraisin.net>");
 }
 
 static void
@@ -158,12 +153,10 @@ gst_auto_video_sink_reset (GstAutoVideoSink * sink)
   gst_object_unref (targetpad);
 }
 
-static GstStaticCaps raw_caps =
-    GST_STATIC_CAPS ("video/x-raw-yuv; video/x-raw-rgb");
+static GstStaticCaps raw_caps = GST_STATIC_CAPS ("video/x-raw");
 
 static void
-gst_auto_video_sink_init (GstAutoVideoSink * sink,
-    GstAutoVideoSinkClass * g_class)
+gst_auto_video_sink_init (GstAutoVideoSink * sink)
 {
   sink->pad = gst_ghost_pad_new_no_target ("sink", GST_PAD_SINK);
   gst_element_add_pad (GST_ELEMENT (sink), sink->pad);
@@ -219,7 +212,7 @@ gst_auto_video_sink_create_element_with_pretty_name (GstAutoVideoSink * sink,
   GstElement *element;
   gchar *name, *marker;
 
-  marker = g_strdup (GST_PLUGIN_FEATURE (factory)->name);
+  marker = g_strdup (GST_OBJECT_NAME (factory));
   if (g_str_has_suffix (marker, "sink"))
     marker[strlen (marker) - 4] = '\0';
   if (g_str_has_prefix (marker, "gst"))
@@ -258,13 +251,13 @@ gst_auto_video_sink_find_best (GstAutoVideoSink * sink)
     if ((el = gst_auto_video_sink_create_element_with_pretty_name (sink, f))) {
       GstStateChangeReturn ret;
 
-      GST_DEBUG_OBJECT (sink, "Testing %s", GST_PLUGIN_FEATURE (f)->name);
+      GST_DEBUG_OBJECT (sink, "Testing %s", GST_OBJECT_NAME (f));
 
       /* If autovideosink has been provided with filter caps,
        * accept only sinks that match with the filter caps */
       if (sink->filter_caps) {
         el_pad = gst_element_get_static_pad (GST_ELEMENT (el), "sink");
-        el_caps = gst_pad_get_caps (el_pad);
+        el_caps = gst_pad_get_caps (el_pad, NULL);
         gst_object_unref (el_pad);
         GST_DEBUG_OBJECT (sink,
             "Checking caps: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
index af19456..202e887 100644 (file)
@@ -63,7 +63,8 @@ static void gst_auto_video_src_set_property (GObject * object, guint prop_id,
 static void gst_auto_video_src_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-GST_BOILERPLATE (GstAutoVideoSrc, gst_auto_video_src, GstBin, GST_TYPE_BIN);
+#define gst_auto_video_src_parent_class parent_class
+G_DEFINE_TYPE (GstAutoVideoSrc, gst_auto_video_src, GST_TYPE_BIN);
 
 static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
@@ -71,20 +72,6 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
     GST_STATIC_CAPS_ANY);
 
 static void
-gst_auto_video_src_base_init (gpointer klass)
-{
-  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (eklass,
-      gst_static_pad_template_get (&src_template));
-  gst_element_class_set_details_simple (eklass, "Auto video source",
-      "Source/Video",
-      "Wrapper video source for automatically detected video source",
-      "Jan Schmidt <thaytan@noraisin.net>, "
-      "Stefan Kost <ensonic@users.sf.net>");
-}
-
-static void
 gst_auto_video_src_class_init (GstAutoVideoSrcClass * klass)
 {
   GObjectClass *gobject_class;
@@ -112,6 +99,14 @@ gst_auto_video_src_class_init (GstAutoVideoSrcClass * klass)
       g_param_spec_boxed ("filter-caps", "Filter caps",
           "Filter src candidates using these caps.", GST_TYPE_CAPS,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_add_pad_template (eklass,
+      gst_static_pad_template_get (&src_template));
+  gst_element_class_set_details_simple (eklass, "Auto video source",
+      "Source/Video",
+      "Wrapper video source for automatically detected video source",
+      "Jan Schmidt <thaytan@noraisin.net>, "
+      "Stefan Kost <ensonic@users.sf.net>");
 }
 
 static void
@@ -161,11 +156,10 @@ gst_auto_video_src_reset (GstAutoVideoSrc * src)
   gst_object_unref (targetpad);
 }
 
-static GstStaticCaps raw_caps =
-    GST_STATIC_CAPS ("video/x-raw-yuv; video/x-raw-rgb");
+static GstStaticCaps raw_caps = GST_STATIC_CAPS ("video/x-raw");
 
 static void
-gst_auto_video_src_init (GstAutoVideoSrc * src, GstAutoVideoSrcClass * g_class)
+gst_auto_video_src_init (GstAutoVideoSrc * src)
 {
   src->pad = gst_ghost_pad_new_no_target ("src", GST_PAD_SRC);
   gst_element_add_pad (GST_ELEMENT (src), src->pad);
@@ -221,7 +215,7 @@ gst_auto_video_src_create_element_with_pretty_name (GstAutoVideoSrc * src,
   GstElement *element;
   gchar *name, *marker;
 
-  marker = g_strdup (GST_PLUGIN_FEATURE (factory)->name);
+  marker = g_strdup (GST_OBJECT_NAME (factory));
   if (g_str_has_suffix (marker, "src"))
     marker[strlen (marker) - 4] = '\0';
   if (g_str_has_prefix (marker, "gst"))
@@ -260,13 +254,13 @@ gst_auto_video_src_find_best (GstAutoVideoSrc * src)
     if ((el = gst_auto_video_src_create_element_with_pretty_name (src, f))) {
       GstStateChangeReturn ret;
 
-      GST_DEBUG_OBJECT (src, "Testing %s", GST_PLUGIN_FEATURE (f)->name);
+      GST_DEBUG_OBJECT (src, "Testing %s", GST_OBJECT_NAME (f));
 
       /* If AutoVideoSrc has been provided with filter caps,
        * accept only sources that match with the filter caps */
       if (src->filter_caps) {
         el_pad = gst_element_get_static_pad (GST_ELEMENT (el), "src");
-        el_caps = gst_pad_get_caps (el_pad);
+        el_caps = gst_pad_get_caps (el_pad, NULL);
         gst_object_unref (el_pad);
         GST_DEBUG_OBJECT (src,
             "Checking caps: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
index 90ea0ed..d9d9ba2 100644 (file)
@@ -19,7 +19,8 @@ libgstavi_la_LIBADD = \
        $(GST_LIBS) \
        -lgstriff-@GST_MAJORMINOR@ \
        -lgstaudio-@GST_MAJORMINOR@ \
-       -lgsttag-@GST_MAJORMINOR@
+       -lgsttag-@GST_MAJORMINOR@ \
+       -lgstvideo-@GST_MAJORMINOR@
 
 libgstavi_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstavi_la_LIBTOOLFLAGS = --tag=disable-static
index 5f2673b..f9c5390 100644 (file)
@@ -72,9 +72,6 @@ static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_STATIC_CAPS ("video/x-msvideo")
     );
 
-static void gst_avi_demux_base_init (GstAviDemuxClass * klass);
-static void gst_avi_demux_class_init (GstAviDemuxClass * klass);
-static void gst_avi_demux_init (GstAviDemux * avi);
 static void gst_avi_demux_finalize (GObject * object);
 
 static void gst_avi_demux_reset (GstAviDemux * avi);
@@ -118,43 +115,29 @@ static void gst_avi_demux_get_buffer_info (GstAviDemux * avi,
 
 static void gst_avi_demux_parse_idit (GstAviDemux * avi, GstBuffer * buf);
 
-static GstElementClass *parent_class = NULL;
-
 /* GObject methods */
 
-GType
-gst_avi_demux_get_type (void)
-{
-  static GType avi_demux_type = 0;
-
-  if (!avi_demux_type) {
-    static const GTypeInfo avi_demux_info = {
-      sizeof (GstAviDemuxClass),
-      (GBaseInitFunc) gst_avi_demux_base_init,
-      NULL,
-      (GClassInitFunc) gst_avi_demux_class_init,
-      NULL,
-      NULL,
-      sizeof (GstAviDemux),
-      0,
-      (GInstanceInitFunc) gst_avi_demux_init,
-    };
-
-    avi_demux_type =
-        g_type_register_static (GST_TYPE_ELEMENT,
-        "GstAviDemux", &avi_demux_info, 0);
-  }
-
-  return avi_demux_type;
-}
+#define gst_avi_demux_parent_class parent_class
+G_DEFINE_TYPE (GstAviDemux, gst_avi_demux, GST_TYPE_ELEMENT);
 
 static void
-gst_avi_demux_base_init (GstAviDemuxClass * klass)
+gst_avi_demux_class_init (GstAviDemuxClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+  GObjectClass *gobject_class = (GObjectClass *) klass;
   GstPadTemplate *videosrctempl, *audiosrctempl, *subsrctempl;
   GstCaps *audcaps, *vidcaps, *subcaps;
 
+  GST_DEBUG_CATEGORY_INIT (avidemux_debug, "avidemux",
+      0, "Demuxer for AVI streams");
+
+  gobject_class->finalize = gst_avi_demux_finalize;
+
+  gstelement_class->change_state =
+      GST_DEBUG_FUNCPTR (gst_avi_demux_change_state);
+  gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_avi_demux_set_index);
+  gstelement_class->get_index = GST_DEBUG_FUNCPTR (gst_avi_demux_get_index);
+
   audcaps = gst_riff_create_audio_template_caps ();
   gst_caps_append (audcaps, gst_caps_new_simple ("audio/x-avi-unknown", NULL));
   audiosrctempl = gst_pad_template_new ("audio_%02d",
@@ -169,12 +152,13 @@ gst_avi_demux_base_init (GstAviDemuxClass * klass)
   subcaps = gst_caps_new_simple ("application/x-subtitle-avi", NULL);
   subsrctempl = gst_pad_template_new ("subtitle_%02d",
       GST_PAD_SRC, GST_PAD_SOMETIMES, subcaps);
-  gst_element_class_add_pad_template (element_class, audiosrctempl);
-  gst_element_class_add_pad_template (element_class, videosrctempl);
-  gst_element_class_add_pad_template (element_class, subsrctempl);
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class, audiosrctempl);
+  gst_element_class_add_pad_template (gstelement_class, videosrctempl);
+  gst_element_class_add_pad_template (gstelement_class, subsrctempl);
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&sink_templ));
-  gst_element_class_set_details_simple (element_class, "Avi demuxer",
+
+  gst_element_class_set_details_simple (gstelement_class, "Avi demuxer",
       "Codec/Demuxer",
       "Demultiplex an avi file into audio and video",
       "Erik Walthinsen <omega@cse.ogi.edu>, "
@@ -183,25 +167,6 @@ gst_avi_demux_base_init (GstAviDemuxClass * klass)
 }
 
 static void
-gst_avi_demux_class_init (GstAviDemuxClass * klass)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
-  GObjectClass *gobject_class = (GObjectClass *) klass;
-
-  GST_DEBUG_CATEGORY_INIT (avidemux_debug, "avidemux",
-      0, "Demuxer for AVI streams");
-
-  parent_class = g_type_class_peek_parent (klass);
-
-  gobject_class->finalize = gst_avi_demux_finalize;
-  gstelement_class->change_state =
-      GST_DEBUG_FUNCPTR (gst_avi_demux_change_state);
-
-  gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_avi_demux_set_index);
-  gstelement_class->get_index = GST_DEBUG_FUNCPTR (gst_avi_demux_get_index);
-}
-
-static void
 gst_avi_demux_init (GstAviDemux * avi)
 {
   avi->sinkpad = gst_pad_new_from_static_template (&sink_templ, "sink");
@@ -289,10 +254,6 @@ gst_avi_demux_reset (GstAviDemux * avi)
     gst_object_unref (avi->element_index);
   avi->element_index = NULL;
 
-  if (avi->close_seg_event) {
-    gst_event_unref (avi->close_seg_event);
-    avi->close_seg_event = NULL;
-  }
   if (avi->seg_event) {
     gst_event_unref (avi->seg_event);
     avi->seg_event = NULL;
@@ -570,7 +531,7 @@ gst_avi_demux_handle_src_query (GstPad * pad, GstQuery * query)
           if (stream->idx_n >= 0)
             gst_query_set_duration (query, fmt, stream->idx_n);
           else if (gst_pad_query_convert (pad, GST_FORMAT_TIME,
-                  duration, &fmt, &dur))
+                  duration, fmt, &dur))
             gst_query_set_duration (query, fmt, dur);
           break;
         }
@@ -754,22 +715,14 @@ gst_avi_demux_handle_sink_event (GstPad * pad, GstEvent * event)
       "have event type %s: %p on sink pad", GST_EVENT_TYPE_NAME (event), event);
 
   switch (GST_EVENT_TYPE (event)) {
-    case GST_EVENT_NEWSEGMENT:
+    case GST_EVENT_SEGMENT:
     {
-      GstFormat format;
-      gdouble rate, arate;
-      gint64 start, stop, time, offset = 0;
-      gboolean update;
+      gint64 boffset, offset = 0;
       GstSegment segment;
 
       /* some debug output */
-      gst_segment_init (&segment, GST_FORMAT_UNDEFINED);
-      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
-          &start, &stop, &time);
-      gst_segment_set_newsegment_full (&segment, update, rate, arate, format,
-          start, stop, time);
-      GST_DEBUG_OBJECT (avi,
-          "received format %d newsegment %" GST_SEGMENT_FORMAT, format,
+      gst_event_copy_segment (event, &segment);
+      GST_DEBUG_OBJECT (avi, "received newsegment %" GST_SEGMENT_FORMAT,
           &segment);
 
       /* chain will send initial newsegment after pads have been added */
@@ -779,7 +732,7 @@ gst_avi_demux_handle_sink_event (GstPad * pad, GstEvent * event)
       }
 
       /* we only expect a BYTE segment, e.g. following a seek */
-      if (format != GST_FORMAT_BYTES) {
+      if (segment.format != GST_FORMAT_BYTES) {
         GST_DEBUG_OBJECT (avi, "unsupported segment format, ignoring");
         goto exit;
       }
@@ -790,7 +743,7 @@ gst_avi_demux_handle_sink_event (GstPad * pad, GstEvent * event)
         GstAviStream *stream;
 
         /* compensate chunk header, stored index offset points after header */
-        start += 8;
+        boffset = segment.start + 8;
         /* find which stream we're on */
         do {
           stream = &avi->stream[i];
@@ -799,7 +752,7 @@ gst_avi_demux_handle_sink_event (GstPad * pad, GstEvent * event)
           entry = gst_util_array_binary_search (stream->index,
               stream->idx_n, sizeof (GstAviIndexEntry),
               (GCompareDataFunc) gst_avi_demux_index_entry_offset_search,
-              GST_SEARCH_MODE_AFTER, &start, NULL);
+              GST_SEARCH_MODE_AFTER, &boffset, NULL);
 
           if (entry == NULL)
             continue;
@@ -811,10 +764,10 @@ gst_avi_demux_handle_sink_event (GstPad * pad, GstEvent * event)
             k = i;
           }
           /* exact match needs no further searching */
-          if (stream->index[index].offset == start)
+          if (stream->index[index].offset == segment.start)
             break;
         } while (++i < avi->num_streams);
-        start -= 8;
+        boffset -= 8;
         offset -= 8;
         stream = &avi->stream[k];
 
@@ -826,14 +779,14 @@ gst_avi_demux_handle_sink_event (GstPad * pad, GstEvent * event)
 
         /* get the ts corresponding to start offset bytes for the stream */
         gst_avi_demux_get_buffer_info (avi, stream, index,
-            (GstClockTime *) & time, NULL, NULL, NULL);
+            (GstClockTime *) & segment.time, NULL, NULL, NULL);
       } else if (avi->element_index) {
         GstIndexEntry *entry;
 
         /* Let's check if we have an index entry for this position */
         entry = gst_index_get_assoc_entry (avi->element_index, avi->index_id,
             GST_INDEX_LOOKUP_AFTER, GST_ASSOCIATION_FLAG_NONE,
-            GST_FORMAT_BYTES, start);
+            GST_FORMAT_BYTES, segment.start);
 
         /* we can not go where we have not yet been before ... */
         if (!entry) {
@@ -841,27 +794,30 @@ gst_avi_demux_handle_sink_event (GstPad * pad, GstEvent * event)
           goto eos;
         }
 
-        gst_index_entry_assoc_map (entry, GST_FORMAT_TIME, &time);
+        gst_index_entry_assoc_map (entry, GST_FORMAT_TIME,
+            (gint64 *) & segment.time);
         gst_index_entry_assoc_map (entry, GST_FORMAT_BYTES, &offset);
       } else {
         GST_WARNING_OBJECT (avi, "no index data, forcing EOS");
         goto eos;
       }
 
-      stop = GST_CLOCK_TIME_NONE;
+      segment.format = GST_FORMAT_TIME;
+      segment.start = segment.time;
+      segment.stop = GST_CLOCK_TIME_NONE;
+      segment.position = segment.start;
+
+      /* rescue duration */
+      segment.duration = avi->segment.duration;
 
       /* set up segment and send downstream */
-      gst_segment_set_newsegment_full (&avi->segment, update, rate, arate,
-          GST_FORMAT_TIME, time, stop, time);
-      GST_DEBUG_OBJECT (avi, "Pushing newseg update %d, rate %g, "
-          "applied rate %g, format %d, start %" G_GINT64_FORMAT ", "
-          "stop %" G_GINT64_FORMAT, update, rate, arate, GST_FORMAT_TIME,
-          time, stop);
-      gst_avi_demux_push_event (avi,
-          gst_event_new_new_segment_full (update, rate, arate, GST_FORMAT_TIME,
-              time, stop, time));
-
-      GST_DEBUG_OBJECT (avi, "next chunk expected at %" G_GINT64_FORMAT, start);
+      gst_segment_copy_into (&segment, &avi->segment);
+
+      GST_DEBUG_OBJECT (avi, "Pushing newseg %" GST_SEGMENT_FORMAT, &segment);
+      gst_avi_demux_push_event (avi, gst_event_new_segment (&segment));
+
+      GST_DEBUG_OBJECT (avi, "next chunk expected at %" G_GINT64_FORMAT,
+          boffset);
 
       /* adjust state for streaming thread accordingly */
       if (avi->have_index)
@@ -870,9 +826,9 @@ gst_avi_demux_handle_sink_event (GstPad * pad, GstEvent * event)
         gst_avi_demux_seek_streams (avi, offset, FALSE);
 
       /* set up streaming thread */
-      g_assert (offset >= start);
-      avi->offset = start;
-      avi->todrop = offset - start;
+      g_assert (offset >= boffset);
+      avi->offset = boffset;
+      avi->todrop = offset - boffset;
 
     exit:
       gst_event_unref (event);
@@ -970,9 +926,10 @@ gst_avi_demux_peek_chunk_info (GstAviDemux * avi, guint32 * tag, guint32 * size)
   if (gst_adapter_available (avi->adapter) < 8)
     return FALSE;
 
-  data = gst_adapter_peek (avi->adapter, 8);
+  data = gst_adapter_map (avi->adapter, 8);
   *tag = GST_READ_UINT32_LE (data);
   *size = GST_READ_UINT32_LE (data + 4);
+  gst_adapter_unmap (avi->adapter, 0);
 
   return TRUE;
 }
@@ -1151,14 +1108,17 @@ gst_avi_demux_parse_avih (GstAviDemux * avi,
     GstBuffer * buf, gst_riff_avih ** _avih)
 {
   gst_riff_avih *avih;
+  gsize size;
 
   if (buf == NULL)
     goto no_buffer;
 
-  if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_avih))
+  size = gst_buffer_get_size (buf);
+  if (size < sizeof (gst_riff_avih))
     goto avih_too_small;
 
-  avih = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  avih = g_malloc (size);
+  gst_buffer_extract (buf, 0, avih, size);
 
 #if (G_BYTE_ORDER == G_BIG_ENDIAN)
   avih->us_frame = GUINT32_FROM_LE (avih->us_frame);
@@ -1218,7 +1178,7 @@ avih_too_small:
   {
     GST_ELEMENT_ERROR (avi, STREAM, DEMUX, (NULL),
         ("Too small avih (%d available, %d needed)",
-            GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_avih)));
+            size, (int) sizeof (gst_riff_avih)));
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -1245,16 +1205,20 @@ gst_avi_demux_parse_superindex (GstAviDemux * avi,
   guint16 bpe = 16;
   guint32 num, i;
   guint64 *indexes;
-  guint size;
+  gsize size;
 
   *_indexes = NULL;
 
-  size = buf ? GST_BUFFER_SIZE (buf) : 0;
+  if (buf) {
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  } else {
+    data = NULL;
+    size = 0;
+  }
+
   if (size < 24)
     goto too_small;
 
-  data = GST_BUFFER_DATA (buf);
-
   /* check type of index. The opendml2 specs state that
    * there should be 4 dwords per array entry. Type can be
    * either frame or field (and we don't care). */
@@ -1285,6 +1249,7 @@ gst_avi_demux_parse_superindex (GstAviDemux * avi,
   indexes[i] = GST_BUFFER_OFFSET_NONE;
   *_indexes = indexes;
 
+  gst_buffer_unmap (buf, data, size);
   gst_buffer_unref (buf);
 
   return TRUE;
@@ -1294,16 +1259,18 @@ too_small:
   {
     GST_ERROR_OBJECT (avi,
         "Not enough data to parse superindex (%d available, 24 needed)", size);
-    if (buf)
+    if (buf) {
+      gst_buffer_unmap (buf, data, size);
       gst_buffer_unref (buf);
+    }
     return FALSE;
   }
 invalid_params:
   {
     GST_ERROR_OBJECT (avi, "invalid index parameters (num = %d, bpe = %d)",
         num, bpe);
-    if (buf)
-      gst_buffer_unref (buf);
+    gst_buffer_unmap (buf, data, size);
+    gst_buffer_unref (buf);
     return FALSE;
   }
 }
@@ -1508,19 +1475,16 @@ gst_avi_demux_parse_subindex (GstAviDemux * avi, GstAviStream * stream,
   guint16 bpe;
   guint32 num, i;
   guint64 baseoff;
-  guint size;
+  gsize size;
 
-  if (!buf)
+  if (buf == NULL)
     return TRUE;
 
-  size = GST_BUFFER_SIZE (buf);
-
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
   /* check size */
   if (size < 24)
     goto too_small;
 
-  data = GST_BUFFER_DATA (buf);
-
   /* We don't support index-data yet */
   if (data[3] & 0x80)
     goto not_implemented;
@@ -1570,6 +1534,8 @@ gst_avi_demux_parse_subindex (GstAviDemux * avi, GstAviStream * stream,
     if (G_UNLIKELY (!gst_avi_demux_add_index (avi, stream, num, &entry)))
       goto out_of_mem;
   }
+done:
+  gst_buffer_unmap (buf, data, size);
   gst_buffer_unref (buf);
 
   return TRUE;
@@ -1579,21 +1545,20 @@ too_small:
   {
     GST_ERROR_OBJECT (avi,
         "Not enough data to parse subindex (%d available, 24 needed)", size);
-    gst_buffer_unref (buf);
-    return TRUE;                /* continue */
+    goto done;                  /* continue */
   }
 not_implemented:
   {
     GST_ELEMENT_ERROR (avi, STREAM, NOT_IMPLEMENTED, (NULL),
         ("Subindex-is-data is not implemented"));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
 empty_index:
   {
     GST_DEBUG_OBJECT (avi, "the index is empty");
-    gst_buffer_unref (buf);
-    return TRUE;
+    goto done;                  /* continue */
   }
 out_of_mem:
   {
@@ -1601,6 +1566,7 @@ out_of_mem:
         ("Cannot allocate memory for %u*%u=%u bytes",
             (guint) sizeof (GstAviIndexEntry), num,
             (guint) sizeof (GstAviIndexEntry) * num));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -1754,14 +1720,18 @@ gst_avi_demux_riff_parse_vprp (GstElement * element,
 {
   gst_riff_vprp *vprp;
   gint k;
+  gsize size;
 
   g_return_val_if_fail (buf != NULL, FALSE);
   g_return_val_if_fail (_vprp != NULL, FALSE);
 
-  if (GST_BUFFER_SIZE (buf) < G_STRUCT_OFFSET (gst_riff_vprp, field_info))
+  size = gst_buffer_get_size (buf);
+
+  if (size < G_STRUCT_OFFSET (gst_riff_vprp, field_info))
     goto too_small;
 
-  vprp = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  vprp = g_malloc (size);
+  gst_buffer_extract (buf, 0, vprp, size);
 
 #if (G_BYTE_ORDER == G_BIG_ENDIAN)
   vprp->format_token = GUINT32_FROM_LE (vprp->format_token);
@@ -1777,8 +1747,7 @@ gst_avi_demux_riff_parse_vprp (GstElement * element,
 
   /* size checking */
   /* calculate fields based on size */
-  k = (GST_BUFFER_SIZE (buf) - G_STRUCT_OFFSET (gst_riff_vprp, field_info)) /
-      vprp->fields;
+  k = (size - G_STRUCT_OFFSET (gst_riff_vprp, field_info)) / vprp->fields;
   if (vprp->fields > k) {
     GST_WARNING_OBJECT (element,
         "vprp header indicated %d fields, only %d available", vprp->fields, k);
@@ -1850,8 +1819,7 @@ too_small:
   {
     GST_ERROR_OBJECT (element,
         "Too small vprp (%d available, at least %d needed)",
-        GST_BUFFER_SIZE (buf),
-        (int) G_STRUCT_OFFSET (gst_riff_vprp, field_info));
+        size, (int) G_STRUCT_OFFSET (gst_riff_vprp, field_info));
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -1868,8 +1836,8 @@ gst_avi_demux_expose_streams (GstAviDemux * avi, gboolean force)
     GstAviStream *stream = &avi->stream[i];
 
     if (force || stream->idx_n != 0) {
-      GST_LOG_OBJECT (avi, "Added pad %s with caps %" GST_PTR_FORMAT,
-          GST_PAD_NAME (stream->pad), GST_PAD_CAPS (stream->pad));
+      GST_LOG_OBJECT (avi, "Adding pad %s" GST_PTR_FORMAT,
+          GST_PAD_NAME (stream->pad));
       gst_element_add_pad ((GstElement *) avi, stream->pad);
 
       if (avi->element_index)
@@ -1893,16 +1861,22 @@ gst_avi_demux_expose_streams (GstAviDemux * avi, gboolean force)
 static inline void
 gst_avi_demux_roundup_list (GstAviDemux * avi, GstBuffer ** buf)
 {
-  gint size = GST_BUFFER_SIZE (*buf);
+  gsize size;
+
+  size = gst_buffer_get_size (*buf);
 
   if (G_UNLIKELY (size & 1)) {
     GstBuffer *obuf;
+    guint8 *data;
 
     GST_DEBUG_OBJECT (avi, "rounding up dubious list size %d", size);
     obuf = gst_buffer_new_and_alloc (size + 1);
-    memcpy (GST_BUFFER_DATA (obuf), GST_BUFFER_DATA (*buf), size);
+
+    data = gst_buffer_map (obuf, NULL, NULL, GST_MAP_WRITE);
+    gst_buffer_extract (*buf, 0, data, size);
     /* assume 0 padding, at least makes outcome deterministic */
-    (GST_BUFFER_DATA (obuf))[size] = 0;
+    data[size] = 0;
+    gst_buffer_unmap (obuf, data, size + 1);
     gst_buffer_replace (buf, obuf);
   }
 }
@@ -2127,9 +2101,12 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
       case GST_RIFF_TAG_strn:
         g_free (stream->name);
         if (sub != NULL) {
-          stream->name =
-              g_strndup ((gchar *) GST_BUFFER_DATA (sub),
-              (gsize) GST_BUFFER_SIZE (sub));
+          gchar *bdata;
+          gsize bsize;
+
+          bdata = gst_buffer_map (sub, &bsize, NULL, GST_MAP_READ);
+          stream->name = g_strndup (bdata, bsize);
+          gst_buffer_unmap (sub, bdata, bsize);
           gst_buffer_unref (sub);
           sub = NULL;
         } else {
@@ -2191,7 +2168,7 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
           stream->strf.vids, stream->extradata, stream->initdata, &codec_name);
       if (!caps) {
         caps = gst_caps_new_simple ("video/x-avi-unknown", "fourcc",
-            GST_TYPE_FOURCC, fourcc, NULL);
+            G_TYPE_INT, fourcc, NULL);
       } else if (got_vprp && vprp) {
         guint32 aspect_n, aspect_d;
         gint n, d;
@@ -2235,7 +2212,7 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
           stream->strf.iavs, stream->extradata, stream->initdata, &codec_name);
       if (!caps) {
         caps = gst_caps_new_simple ("video/x-avi-unknown", "fourcc",
-            GST_TYPE_FOURCC, fourcc, NULL);
+            G_TYPE_INT, fourcc, NULL);
       }
       tag_name = GST_TAG_VIDEO_CODEC;
       avi->num_v_streams++;
@@ -2309,8 +2286,8 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
   gst_pad_set_element_private (pad, stream);
   avi->num_streams++;
 
-  gst_pad_set_caps (pad, caps);
   gst_pad_set_active (pad, TRUE);
+  gst_pad_push_event (pad, gst_event_new_caps (caps));
   gst_caps_unref (caps);
 
   /* make tags */
@@ -2365,20 +2342,26 @@ gst_avi_demux_parse_odml (GstAviDemux * avi, GstBuffer * buf)
     switch (tag) {
       case GST_RIFF_TAG_dmlh:{
         gst_riff_dmlh dmlh, *_dmlh;
-        guint size;
+        gsize size;
+        guint8 *data;
 
         /* sub == NULL is possible and means an empty buffer */
-        size = sub ? GST_BUFFER_SIZE (sub) : 0;
+        if (sub == NULL)
+          goto next;
+
+        data = gst_buffer_map (sub, &size, NULL, GST_MAP_READ);
 
         /* check size */
         if (size < sizeof (gst_riff_dmlh)) {
           GST_ERROR_OBJECT (avi,
               "DMLH entry is too small (%d bytes, %d needed)",
               size, (int) sizeof (gst_riff_dmlh));
+          gst_buffer_unmap (sub, data, size);
           goto next;
         }
-        _dmlh = (gst_riff_dmlh *) GST_BUFFER_DATA (sub);
+        _dmlh = (gst_riff_dmlh *) data;
         dmlh.totalframes = GST_READ_UINT32_LE (&_dmlh->totalframes);
+        gst_buffer_unmap (sub, data, size);
 
         GST_INFO_OBJECT (avi, "dmlh tag found: totalframes: %u",
             dmlh.totalframes);
@@ -2556,7 +2539,7 @@ static gboolean
 gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
 {
   guint8 *data;
-  guint size;
+  gsize size;
   guint i, num, n;
   gst_riff_index_entry *index;
   GstClockTime stamp;
@@ -2567,8 +2550,7 @@ gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
   if (!buf)
     return FALSE;
 
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
 
   stamp = gst_util_get_timestamp ();
 
@@ -2630,6 +2612,7 @@ gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
 
     n++;
   }
+  gst_buffer_unmap (buf, data, size);
   gst_buffer_unref (buf);
 
   /* get stream stats now */
@@ -2645,6 +2628,7 @@ gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
 empty_list:
   {
     GST_DEBUG_OBJECT (avi, "empty index");
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -2654,6 +2638,7 @@ out_of_mem:
         ("Cannot allocate memory for %u*%u=%u bytes",
             (guint) sizeof (GstAviIndexEntry), num,
             (guint) sizeof (GstAviIndexEntry) * num));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -2673,6 +2658,8 @@ gst_avi_demux_stream_index (GstAviDemux * avi)
   GstBuffer *buf;
   guint32 tag;
   guint32 size;
+  gsize bsize;
+  guint8 *bdata;
 
   GST_DEBUG ("demux stream index at offset %" G_GUINT64_FORMAT, offset);
 
@@ -2680,34 +2667,41 @@ gst_avi_demux_stream_index (GstAviDemux * avi)
   res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
   if (res != GST_FLOW_OK)
     goto pull_failed;
-  else if (GST_BUFFER_SIZE (buf) < 8)
+
+  bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+  if (bsize < 8)
     goto too_small;
 
   /* check tag first before blindy trying to read 'size' bytes */
-  tag = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf));
-  size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf) + 4);
+  tag = GST_READ_UINT32_LE (bdata);
+  size = GST_READ_UINT32_LE (bdata + 4);
   if (tag == GST_RIFF_TAG_LIST) {
     /* this is the movi tag */
     GST_DEBUG_OBJECT (avi, "skip LIST chunk, size %" G_GUINT32_FORMAT,
         (8 + GST_ROUND_UP_2 (size)));
     offset += 8 + GST_ROUND_UP_2 (size);
+    gst_buffer_unmap (buf, bdata, bsize);
     gst_buffer_unref (buf);
+
     res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
     if (res != GST_FLOW_OK)
       goto pull_failed;
-    else if (GST_BUFFER_SIZE (buf) < 8)
+
+    bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+    if (bsize < 8)
       goto too_small;
-    tag = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf));
-    size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf) + 4);
+
+    tag = GST_READ_UINT32_LE (bdata);
+    size = GST_READ_UINT32_LE (bdata + 4);
   }
+  gst_buffer_unmap (buf, bdata, bsize);
+  gst_buffer_unref (buf);
 
   if (tag != GST_RIFF_TAG_idx1)
     goto no_index;
   if (!size)
     goto zero_index;
 
-  gst_buffer_unref (buf);
-
   GST_DEBUG ("index found at offset %" G_GUINT64_FORMAT, offset);
 
   /* read chunk, advance offset */
@@ -2716,7 +2710,7 @@ gst_avi_demux_stream_index (GstAviDemux * avi)
     return;
 
   GST_DEBUG ("will parse index chunk size %u for tag %"
-      GST_FOURCC_FORMAT, GST_BUFFER_SIZE (buf), GST_FOURCC_ARGS (tag));
+      GST_FOURCC_FORMAT, gst_buffer_get_size (buf), GST_FOURCC_ARGS (tag));
 
   gst_avi_demux_parse_index (avi, buf);
 
@@ -2745,6 +2739,7 @@ pull_failed:
 too_small:
   {
     GST_DEBUG_OBJECT (avi, "Buffer is too small");
+    gst_buffer_unmap (buf, bdata, bsize);
     gst_buffer_unref (buf);
     return;
   }
@@ -2753,13 +2748,11 @@ no_index:
     GST_WARNING_OBJECT (avi,
         "No index data (idx1) after movi chunk, but %" GST_FOURCC_FORMAT,
         GST_FOURCC_ARGS (tag));
-    gst_buffer_unref (buf);
     return;
   }
 zero_index:
   {
     GST_WARNING_OBJECT (avi, "Empty index data (idx1) after movi chunk");
-    gst_buffer_unref (buf);
     return;
   }
 }
@@ -2810,7 +2803,7 @@ gst_avi_demux_stream_index_push (GstAviDemux * avi)
   offset += 8 + GST_ROUND_UP_2 (size);
 
   GST_DEBUG ("will parse index chunk size %u for tag %"
-      GST_FOURCC_FORMAT, GST_BUFFER_SIZE (buf), GST_FOURCC_ARGS (tag));
+      GST_FOURCC_FORMAT, gst_buffer_get_size (buf), GST_FOURCC_ARGS (tag));
 
   avi->offset = avi->first_movi_offset;
   gst_avi_demux_parse_index (avi, buf);
@@ -2858,19 +2851,17 @@ gst_avi_demux_peek_tag (GstAviDemux * avi, guint64 offset, guint32 * tag,
 {
   GstFlowReturn res = GST_FLOW_OK;
   GstBuffer *buf = NULL;
-  guint bufsize;
+  gsize bufsize;
   guint8 *bufdata;
 
   res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
   if (res != GST_FLOW_OK)
     goto pull_failed;
 
-  bufsize = GST_BUFFER_SIZE (buf);
+  bufdata = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
   if (bufsize != 8)
     goto wrong_size;
 
-  bufdata = GST_BUFFER_DATA (buf);
-
   *tag = GST_READ_UINT32_LE (bufdata);
   *size = GST_READ_UINT32_LE (bufdata + 4);
 
@@ -2879,6 +2870,7 @@ gst_avi_demux_peek_tag (GstAviDemux * avi, guint64 offset, guint32 * tag,
       *size, offset + 8, offset + 8 + (gint64) * size);
 
 done:
+  gst_buffer_unmap (buf, bufdata, bufsize);
   gst_buffer_unref (buf);
 
   return res;
@@ -2939,7 +2931,6 @@ gst_avi_demux_stream_scan (GstAviDemux * avi)
 {
   GstFlowReturn res;
   GstAviStream *stream;
-  GstFormat format;
   guint64 pos = 0;
   guint64 length;
   gint64 tmplength;
@@ -2952,8 +2943,7 @@ gst_avi_demux_stream_scan (GstAviDemux * avi)
   GST_DEBUG_OBJECT (avi, "Creating index");
 
   /* get the size of the file */
-  format = GST_FORMAT_BYTES;
-  if (!gst_pad_query_peer_duration (avi->sinkpad, &format, &tmplength))
+  if (!gst_pad_query_peer_duration (avi->sinkpad, GST_FORMAT_BYTES, &tmplength))
     return FALSE;
   length = tmplength;
 
@@ -3071,7 +3061,7 @@ gst_avi_demux_calculate_durations_from_index (GstAviDemux * avi)
   GST_INFO ("Setting total duration to: %" GST_TIME_FORMAT,
       GST_TIME_ARGS (total));
 
-  gst_segment_set_duration (&avi->segment, GST_FORMAT_TIME, total);
+  avi->segment.duration = total;
 }
 
 /* returns FALSE if there are no pads to deliver event to,
@@ -3115,10 +3105,8 @@ gst_avi_demux_check_seekability (GstAviDemux * avi)
 
   /* try harder to query upstream size if we didn't get it the first time */
   if (seekable && stop == -1) {
-    GstFormat fmt = GST_FORMAT_BYTES;
-
     GST_DEBUG_OBJECT (avi, "doing duration query to fix up unset stop");
-    gst_pad_query_peer_duration (avi->sinkpad, &fmt, &stop);
+    gst_pad_query_peer_duration (avi->sinkpad, GST_FORMAT_BYTES, &stop);
   }
 
   /* if upstream doesn't know the size, it's likely that it's not seekable in
@@ -3149,9 +3137,9 @@ gst_avi_demux_stream_header_push (GstAviDemux * avi)
   const guint8 *data;
   GstBuffer *buf = NULL, *sub = NULL;
   guint offset = 4;
-  gint64 stop;
   gint i;
   GstTagList *tags = NULL;
+  guint8 fourcc[4];
 
   GST_DEBUG ("Reading and parsing avi headers: %d", avi->header_state);
 
@@ -3167,7 +3155,9 @@ gst_avi_demux_stream_header_push (GstAviDemux * avi)
         GST_DEBUG ("Reading %d bytes", size);
         buf = gst_adapter_take_buffer (avi->adapter, size);
 
-        if (GST_READ_UINT32_LE (GST_BUFFER_DATA (buf)) != GST_RIFF_LIST_hdrl)
+        gst_buffer_extract (buf, 0, fourcc, 4);
+
+        if (GST_READ_UINT32_LE (fourcc) != GST_RIFF_LIST_hdrl)
           goto header_no_hdrl;
 
         /* mind padding */
@@ -3200,10 +3190,12 @@ gst_avi_demux_stream_header_push (GstAviDemux * avi)
 
           switch (tag) {
             case GST_RIFF_TAG_LIST:
-              if (GST_BUFFER_SIZE (sub) < 4)
+              if (gst_buffer_get_size (sub) < 4)
                 goto next;
 
-              switch (GST_READ_UINT32_LE (GST_BUFFER_DATA (sub))) {
+              gst_buffer_extract (sub, 0, fourcc, 4);
+
+              switch (GST_READ_UINT32_LE (fourcc)) {
                 case GST_RIFF_LIST_strl:
                   if (!(gst_avi_demux_parse_stream (avi, sub))) {
                     sub = NULL;
@@ -3220,14 +3212,13 @@ gst_avi_demux_stream_header_push (GstAviDemux * avi)
                 default:
                   GST_WARNING_OBJECT (avi,
                       "Unknown list %" GST_FOURCC_FORMAT " in AVI header",
-                      GST_FOURCC_ARGS (GST_READ_UINT32_LE (GST_BUFFER_DATA
-                              (sub))));
+                      GST_FOURCC_ARGS (GST_READ_UINT32_LE (fourcc)));
                   /* fall-through */
                 case GST_RIFF_TAG_JUNQ:
                 case GST_RIFF_TAG_JUNK:
                   goto next;
+                  break;
               }
-              break;
             case GST_RIFF_IDIT:
               gst_avi_demux_parse_idit (avi, sub);
               goto next;
@@ -3270,10 +3261,11 @@ gst_avi_demux_stream_header_push (GstAviDemux * avi)
         if (gst_adapter_available (avi->adapter) < 12)
           return GST_FLOW_OK;
 
-        data = gst_adapter_peek (avi->adapter, 12);
+        data = gst_adapter_map (avi->adapter, 12);
         tag = GST_READ_UINT32_LE (data);
         size = GST_READ_UINT32_LE (data + 4);
         ltag = GST_READ_UINT32_LE (data + 8);
+        gst_adapter_unmap (avi->adapter, 0);
 
         if (tag == GST_RIFF_TAG_LIST) {
           switch (ltag) {
@@ -3361,16 +3353,9 @@ skipping_done:
     avi->stream[i].current_entry = 0;
 
   /* create initial NEWSEGMENT event */
-  if ((stop = avi->segment.stop) == GST_CLOCK_TIME_NONE)
-    stop = avi->segment.duration;
-
-  GST_DEBUG_OBJECT (avi, "segment stop %" G_GINT64_FORMAT, stop);
-
   if (avi->seg_event)
     gst_event_unref (avi->seg_event);
-  avi->seg_event = gst_event_new_new_segment_full
-      (FALSE, avi->segment.rate, avi->segment.applied_rate, GST_FORMAT_TIME,
-      avi->segment.start, stop, avi->segment.time);
+  avi->seg_event = gst_event_new_segment (&avi->segment);
 
   gst_avi_demux_check_seekability (avi);
 
@@ -3525,10 +3510,11 @@ gst_avi_demux_parse_idit_text (GstAviDemux * avi, gchar * data)
 static void
 gst_avi_demux_parse_idit (GstAviDemux * avi, GstBuffer * buf)
 {
-  gchar *data = (gchar *) GST_BUFFER_DATA (buf);
-  guint size = GST_BUFFER_SIZE (buf);
+  gchar *data, *ptr;
+  gsize size, left;
   gchar *safedata = NULL;
 
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
   /*
    * According to:
    * http://www.eden-foundation.org/products/code/film_date_stamp/index.html
@@ -3542,24 +3528,27 @@ gst_avi_demux_parse_idit (GstAviDemux * avi, GstBuffer * buf)
    */
 
   /* skip eventual initial whitespace */
-  while (size > 0 && g_ascii_isspace (data[0])) {
-    data++;
-    size--;
+  ptr = data;
+  left = size;
+
+  while (left > 0 && g_ascii_isspace (ptr[0])) {
+    ptr++;
+    left--;
   }
 
-  if (size == 0) {
+  if (left == 0) {
     goto non_parsable;
   }
 
   /* make a safe copy to add a \0 to the end of the string */
-  safedata = g_strndup (data, size);
+  safedata = g_strndup (ptr, left);
 
   /* test if the first char is a alpha or a number */
-  if (g_ascii_isdigit (data[0])) {
+  if (g_ascii_isdigit (ptr[0])) {
     gst_avi_demux_parse_idit_nums_only (avi, safedata);
     g_free (safedata);
     return;
-  } else if (g_ascii_isalpha (data[0])) {
+  } else if (g_ascii_isalpha (ptr[0])) {
     gst_avi_demux_parse_idit_text (avi, safedata);
     g_free (safedata);
     return;
@@ -3569,6 +3558,7 @@ gst_avi_demux_parse_idit (GstAviDemux * avi, GstBuffer * buf)
 
 non_parsable:
   GST_WARNING_OBJECT (avi, "IDIT tag has no parsable info");
+  gst_buffer_unmap (buf, data, size);
 }
 
 /*
@@ -3581,10 +3571,10 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
   GstBuffer *buf, *sub = NULL;
   guint32 tag;
   guint offset = 4;
-  gint64 stop;
   GstElement *element = GST_ELEMENT_CAST (avi);
   GstClockTime stamp;
   GstTagList *tags = NULL;
+  guint8 fourcc[4];
 
   stamp = gst_util_get_timestamp ();
 
@@ -3594,15 +3584,16 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
     goto pull_range_failed;
   else if (tag != GST_RIFF_TAG_LIST)
     goto no_list;
-  else if (GST_BUFFER_SIZE (buf) < 4)
+  else if (gst_buffer_get_size (buf) < 4)
     goto no_header;
 
   GST_DEBUG_OBJECT (avi, "parsing headers");
 
   /* Find the 'hdrl' LIST tag */
-  while (GST_READ_UINT32_LE (GST_BUFFER_DATA (buf)) != GST_RIFF_LIST_hdrl) {
+  gst_buffer_extract (buf, 0, fourcc, 4);
+  while (GST_READ_UINT32_LE (fourcc) != GST_RIFF_LIST_hdrl) {
     GST_LOG_OBJECT (avi, "buffer contains %" GST_FOURCC_FORMAT,
-        GST_FOURCC_ARGS (GST_READ_UINT32_LE (GST_BUFFER_DATA (buf))));
+        GST_FOURCC_ARGS (GST_READ_UINT32_LE (fourcc)));
 
     /* Eat up */
     gst_buffer_unref (buf);
@@ -3613,8 +3604,9 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
       goto pull_range_failed;
     else if (tag != GST_RIFF_TAG_LIST)
       goto no_list;
-    else if (GST_BUFFER_SIZE (buf) < 4)
+    else if (gst_buffer_get_size (buf) < 4)
       goto no_header;
+    gst_buffer_extract (buf, 0, fourcc, 4);
   }
 
   GST_DEBUG_OBJECT (avi, "hdrl LIST tag found");
@@ -3633,23 +3625,21 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
 
   /* now, read the elements from the header until the end */
   while (gst_riff_parse_chunk (element, buf, &offset, &tag, &sub)) {
+    gsize size;
+    guint8 *data;
+
     /* sub can be NULL on empty tags */
     if (!sub)
       continue;
 
+    data = gst_buffer_map (sub, &size, NULL, GST_MAP_READ);
+
     switch (tag) {
       case GST_RIFF_TAG_LIST:
-      {
-        guint8 *data;
-        guint32 fourcc;
-
-        if (GST_BUFFER_SIZE (sub) < 4)
+        if (size < 4)
           goto next;
 
-        data = GST_BUFFER_DATA (sub);
-        fourcc = GST_READ_UINT32_LE (data);
-
-        switch (fourcc) {
+        switch (GST_READ_UINT32_LE (data)) {
           case GST_RIFF_LIST_strl:
             if (!(gst_avi_demux_parse_stream (avi, sub))) {
               GST_ELEMENT_WARNING (avi, STREAM, DEMUX, (NULL),
@@ -3663,8 +3653,7 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
             sub = NULL;
             break;
           case GST_RIFF_LIST_INFO:
-            GST_BUFFER_DATA (sub) = data + 4;
-            GST_BUFFER_SIZE (sub) -= 4;
+            gst_buffer_resize (sub, 4, -1);
             gst_riff_parse_info (element, sub, &tags);
             if (tags) {
               if (avi->globaltags) {
@@ -3679,16 +3668,14 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
           default:
             GST_WARNING_OBJECT (avi,
                 "Unknown list %" GST_FOURCC_FORMAT " in AVI header",
-                GST_FOURCC_ARGS (fourcc));
-            GST_MEMDUMP_OBJECT (avi, "Unknown list", GST_BUFFER_DATA (sub),
-                GST_BUFFER_SIZE (sub));
+                GST_FOURCC_ARGS (GST_READ_UINT32_LE (data)));
+            GST_MEMDUMP_OBJECT (avi, "Unknown list", data, size);
             /* fall-through */
           case GST_RIFF_TAG_JUNQ:
           case GST_RIFF_TAG_JUNK:
             goto next;
         }
         break;
-      }
       case GST_RIFF_IDIT:
         gst_avi_demux_parse_idit (avi, sub);
         goto next;
@@ -3696,14 +3683,15 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
         GST_WARNING_OBJECT (avi,
             "Unknown tag %" GST_FOURCC_FORMAT " in AVI header at off %d",
             GST_FOURCC_ARGS (tag), offset);
-        GST_MEMDUMP_OBJECT (avi, "Unknown tag", GST_BUFFER_DATA (sub),
-            GST_BUFFER_SIZE (sub));
+        GST_MEMDUMP_OBJECT (avi, "Unknown tag", data, size);
         /* fall-through */
       case GST_RIFF_TAG_JUNQ:
       case GST_RIFF_TAG_JUNK:
       next:
-        if (sub)
+        if (sub) {
+          gst_buffer_unmap (sub, data, size);
           gst_buffer_unref (sub);
+        }
         sub = NULL;
         break;
     }
@@ -3726,6 +3714,7 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
   /* Now, find the data (i.e. skip all junk between header and data) */
   do {
     guint size;
+    gsize bsize;
     guint8 *data;
     guint32 tag, ltag;
 
@@ -3733,22 +3722,22 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
     if (res != GST_FLOW_OK) {
       GST_DEBUG_OBJECT (avi, "pull_range failure while looking for tags");
       goto pull_range_failed;
-    } else if (GST_BUFFER_SIZE (buf) < 12) {
+    } else if (gst_buffer_get_size (buf) < 12) {
       GST_DEBUG_OBJECT (avi, "got %d bytes which is less than 12 bytes",
-          GST_BUFFER_SIZE (buf));
+          gst_buffer_get_size (buf));
       gst_buffer_unref (buf);
       return GST_FLOW_ERROR;
     }
 
-    data = GST_BUFFER_DATA (buf);
-
+    data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
     tag = GST_READ_UINT32_LE (data);
     size = GST_READ_UINT32_LE (data + 4);
     ltag = GST_READ_UINT32_LE (data + 8);
 
     GST_DEBUG ("tag %" GST_FOURCC_FORMAT ", size %u",
         GST_FOURCC_ARGS (tag), size);
-    GST_MEMDUMP ("Tag content", data, GST_BUFFER_SIZE (buf));
+    GST_MEMDUMP ("Tag content", data, bsize);
+    gst_buffer_unmap (buf, data, bsize);
     gst_buffer_unref (buf);
 
     switch (tag) {
@@ -3766,7 +3755,7 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
               GST_DEBUG_OBJECT (avi, "couldn't read INFO chunk");
               goto pull_range_failed;
             }
-            GST_DEBUG ("got size %u", GST_BUFFER_SIZE (buf));
+            GST_DEBUG ("got size %u", gst_buffer_get_size (buf));
             if (size < 4) {
               GST_DEBUG ("skipping INFO LIST prefix");
               avi->offset += (4 - GST_ROUND_UP_2 (size));
@@ -3774,7 +3763,7 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
               continue;
             }
 
-            sub = gst_buffer_create_sub (buf, 4, GST_BUFFER_SIZE (buf) - 4);
+            sub = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, 4, -1);
             gst_riff_parse_info (element, sub, &tags);
             if (tags) {
               if (avi->globaltags) {
@@ -3814,7 +3803,9 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
             GST_DEBUG_OBJECT (avi, "couldn't read INFO chunk");
             goto pull_range_failed;
           }
-          GST_MEMDUMP ("Junk", GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+          data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+          GST_MEMDUMP ("Junk", data, bsize);
+          gst_buffer_unmap (buf, data, bsize);
           gst_buffer_unref (buf);
         }
         avi->offset += 8 + GST_ROUND_UP_2 (size);
@@ -3851,21 +3842,13 @@ skipping_done:
 
   gst_avi_demux_expose_streams (avi, FALSE);
 
-  /* create initial NEWSEGMENT event */
-  if ((stop = avi->segment.stop) == GST_CLOCK_TIME_NONE)
-    stop = avi->segment.duration;
-
-  GST_DEBUG_OBJECT (avi, "segment stop %" G_GINT64_FORMAT, stop);
-
   /* do initial seek to the default segment values */
   gst_avi_demux_do_seek (avi, &avi->segment);
 
-  /* prepare initial segment */
+  /* create initial NEWSEGMENT event */
   if (avi->seg_event)
     gst_event_unref (avi->seg_event);
-  avi->seg_event = gst_event_new_new_segment_full
-      (FALSE, avi->segment.rate, avi->segment.applied_rate, GST_FORMAT_TIME,
-      avi->segment.start, stop, avi->segment.time);
+  avi->seg_event = gst_event_new_segment (&avi->segment);
 
   stamp = gst_util_get_timestamp () - stamp;
   GST_DEBUG_OBJECT (avi, "pulling header took %" GST_TIME_FORMAT,
@@ -3995,8 +3978,8 @@ gst_avi_demux_do_seek (GstAviDemux * avi, GstSegment * segment)
   guint i, index;
   GstAviStream *stream;
 
-  seek_time = segment->last_stop;
-  keyframe = !!(segment->flags & GST_SEEK_FLAG_KEY_UNIT);
+  seek_time = segment->position;
+  keyframe = ! !(segment->flags & GST_SEEK_FLAG_KEY_UNIT);
 
   GST_DEBUG_OBJECT (avi, "seek to: %" GST_TIME_FORMAT
       " keyframe seeking:%d", GST_TIME_ARGS (seek_time), keyframe);
@@ -4029,9 +4012,9 @@ gst_avi_demux_do_seek (GstAviDemux * avi, GstSegment * segment)
         GST_TIME_ARGS (seek_time));
   }
 
-  /* the seek time is also the last_stop and stream time when going
+  /* the seek time is also the position and stream time when going
    * forwards */
-  segment->last_stop = seek_time;
+  segment->position = seek_time;
   if (segment->rate > 0.0)
     segment->time = seek_time;
 
@@ -4083,17 +4066,16 @@ gst_avi_demux_handle_seek (GstAviDemux * avi, GstPad * pad, GstEvent * event)
     /* we have to have a format as the segment format. Try to convert
      * if not. */
     if (format != GST_FORMAT_TIME) {
-      GstFormat fmt = GST_FORMAT_TIME;
       gboolean res = TRUE;
 
       if (cur_type != GST_SEEK_TYPE_NONE)
-        res = gst_pad_query_convert (pad, format, cur, &fmt, &cur);
+        res = gst_pad_query_convert (pad, format, cur, GST_FORMAT_TIME, &cur);
       if (res && stop_type != GST_SEEK_TYPE_NONE)
-        res = gst_pad_query_convert (pad, format, stop, &fmt, &stop);
+        res = gst_pad_query_convert (pad, format, stop, GST_FORMAT_TIME, &stop);
       if (!res)
         goto no_format;
 
-      format = fmt;
+      format = GST_FORMAT_TIME;
     }
     GST_DEBUG_OBJECT (avi,
         "seek requested: rate %g cur %" GST_TIME_FORMAT " stop %"
@@ -4134,28 +4116,19 @@ gst_avi_demux_handle_seek (GstAviDemux * avi, GstPad * pad, GstEvent * event)
 
   if (event) {
     GST_DEBUG_OBJECT (avi, "configuring seek");
-    gst_segment_set_seek (&seeksegment, rate, format, flags,
+    gst_segment_do_seek (&seeksegment, rate, format, flags,
         cur_type, cur, stop_type, stop, &update);
   }
-  /* do the seek, seeksegment.last_stop contains the new position, this
+  /* do the seek, seeksegment.position contains the new position, this
    * actually never fails. */
   gst_avi_demux_do_seek (avi, &seeksegment);
 
-  gst_event_replace (&avi->close_seg_event, NULL);
   if (flush) {
-    GstEvent *fevent = gst_event_new_flush_stop ();
+    GstEvent *fevent = gst_event_new_flush_stop (TRUE);
 
     GST_DEBUG_OBJECT (avi, "sending flush stop");
     gst_avi_demux_push_event (avi, gst_event_ref (fevent));
     gst_pad_push_event (avi->sinkpad, fevent);
-  } else if (avi->segment_running) {
-    /* we are running the current segment and doing a non-flushing seek,
-     * close the segment first based on the last_stop. */
-    GST_DEBUG_OBJECT (avi, "closing running segment %" G_GINT64_FORMAT
-        " to %" G_GINT64_FORMAT, avi->segment.start, avi->segment.last_stop);
-    avi->close_seg_event = gst_event_new_new_segment_full (TRUE,
-        avi->segment.rate, avi->segment.applied_rate, avi->segment.format,
-        avi->segment.start, avi->segment.last_stop, avi->segment.time);
   }
 
   /* now update the real segment info */
@@ -4165,30 +4138,15 @@ gst_avi_demux_handle_seek (GstAviDemux * avi, GstPad * pad, GstEvent * event)
   if (avi->segment.flags & GST_SEEK_FLAG_SEGMENT) {
     gst_element_post_message (GST_ELEMENT_CAST (avi),
         gst_message_new_segment_start (GST_OBJECT_CAST (avi),
-            avi->segment.format, avi->segment.last_stop));
+            avi->segment.format, avi->segment.position));
   }
 
-  /* prepare for streaming again */
-  if ((stop = avi->segment.stop) == GST_CLOCK_TIME_NONE)
-    stop = avi->segment.duration;
-
   /* queue the segment event for the streaming thread. */
   if (avi->seg_event)
     gst_event_unref (avi->seg_event);
-  if (avi->segment.rate > 0.0) {
-    /* forwards goes from last_stop to stop */
-    avi->seg_event = gst_event_new_new_segment_full (FALSE,
-        avi->segment.rate, avi->segment.applied_rate, avi->segment.format,
-        avi->segment.last_stop, stop, avi->segment.time);
-  } else {
-    /* reverse goes from start to last_stop */
-    avi->seg_event = gst_event_new_new_segment_full (FALSE,
-        avi->segment.rate, avi->segment.applied_rate, avi->segment.format,
-        avi->segment.start, avi->segment.last_stop, avi->segment.time);
-  }
+  avi->seg_event = gst_event_new_segment (&avi->segment);
 
   if (!avi->streaming) {
-    avi->segment_running = TRUE;
     gst_pad_start_task (avi->sinkpad, (GstTaskFunction) gst_avi_demux_loop,
         avi->sinkpad);
   }
@@ -4241,29 +4199,28 @@ avi_demux_handle_seek_push (GstAviDemux * avi, GstPad * pad, GstEvent * event)
       &cur_type, &cur, &stop_type, &stop);
 
   if (format != GST_FORMAT_TIME) {
-    GstFormat fmt = GST_FORMAT_TIME;
     gboolean res = TRUE;
 
     if (cur_type != GST_SEEK_TYPE_NONE)
-      res = gst_pad_query_convert (pad, format, cur, &fmt, &cur);
+      res = gst_pad_query_convert (pad, format, cur, GST_FORMAT_TIME, &cur);
     if (res && stop_type != GST_SEEK_TYPE_NONE)
-      res = gst_pad_query_convert (pad, format, stop, &fmt, &stop);
+      res = gst_pad_query_convert (pad, format, stop, GST_FORMAT_TIME, &stop);
     if (!res) {
       GST_DEBUG_OBJECT (avi, "unsupported format given, seek aborted.");
       return FALSE;
     }
 
-    format = fmt;
+    format = GST_FORMAT_TIME;
   }
 
   /* let gst_segment handle any tricky stuff */
   GST_DEBUG_OBJECT (avi, "configuring seek");
   memcpy (&seeksegment, &avi->segment, sizeof (GstSegment));
-  gst_segment_set_seek (&seeksegment, rate, format, flags,
+  gst_segment_do_seek (&seeksegment, rate, format, flags,
       cur_type, cur, stop_type, stop, &update);
 
-  keyframe = !!(flags & GST_SEEK_FLAG_KEY_UNIT);
-  cur = seeksegment.last_stop;
+  keyframe = ! !(flags & GST_SEEK_FLAG_KEY_UNIT);
+  cur = seeksegment.position;
 
   GST_DEBUG_OBJECT (avi,
       "Seek requested: ts %" GST_TIME_FORMAT " stop %" GST_TIME_FORMAT
@@ -4450,7 +4407,9 @@ gst_avi_demux_invert (GstAviStream * stream, GstBuffer * buf)
   GstStructure *s;
   gint y, w, h;
   gint bpp, stride;
-  guint8 *tmp = NULL;
+  guint8 *tmp = NULL, *data;
+  gsize size;
+  GstCaps *caps;
 
   if (stream->strh->type != GST_RIFF_FCC_vids)
     return buf;
@@ -4459,7 +4418,10 @@ gst_avi_demux_invert (GstAviStream * stream, GstBuffer * buf)
     return buf;                 /* Ignore non DIB buffers */
   }
 
-  s = gst_caps_get_structure (GST_PAD_CAPS (stream->pad), 0);
+  caps = gst_pad_get_current_caps (stream->pad);
+  s = gst_caps_get_structure (caps, 0);
+  gst_caps_unref (caps);
+
   if (!gst_structure_get_int (s, "bpp", &bpp)) {
     GST_WARNING ("Failed to retrieve depth from caps");
     return buf;
@@ -4475,20 +4437,24 @@ gst_avi_demux_invert (GstAviStream * stream, GstBuffer * buf)
   stride = w * (bpp / 8);
 
   buf = gst_buffer_make_writable (buf);
-  if (GST_BUFFER_SIZE (buf) < (stride * h)) {
+
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+  if (size < (stride * h)) {
     GST_WARNING ("Buffer is smaller than reported Width x Height x Depth");
+    gst_buffer_unmap (buf, data, size);
     return buf;
   }
 
   tmp = g_malloc (stride);
 
   for (y = 0; y < h / 2; y++) {
-    swap_line (GST_BUFFER_DATA (buf) + stride * y,
-        GST_BUFFER_DATA (buf) + stride * (h - 1 - y), tmp, stride);
+    swap_line (data + stride * y, data + stride * (h - 1 - y), tmp, stride);
   }
 
   g_free (tmp);
 
+  gst_buffer_unmap (buf, data, size);
+
   return buf;
 }
 
@@ -4742,7 +4708,7 @@ gst_avi_demux_loop_data (GstAviDemux * avi)
       goto pull_failed;
 
     /* check for short buffers, this is EOS as well */
-    if (GST_BUFFER_SIZE (buf) < size)
+    if (gst_buffer_get_size (buf) < size)
       goto short_buffer;
 
     /* invert the picture if needed */
@@ -4768,15 +4734,13 @@ gst_avi_demux_loop_data (GstAviDemux * avi)
 
     gst_avi_demux_add_assoc (avi, stream, timestamp, offset, keyframe);
 
-    gst_buffer_set_caps (buf, GST_PAD_CAPS (stream->pad));
-
     /* update current position in the segment */
-    gst_segment_set_last_stop (&avi->segment, GST_FORMAT_TIME, timestamp);
+    avi->segment.position = timestamp;
 
     GST_DEBUG_OBJECT (avi, "Pushing buffer of size %u, ts %"
         GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT ", off %" G_GUINT64_FORMAT
         ", off_end %" G_GUINT64_FORMAT,
-        GST_BUFFER_SIZE (buf), GST_TIME_ARGS (timestamp),
+        gst_buffer_get_size (buf), GST_TIME_ARGS (timestamp),
         GST_TIME_ARGS (duration), out_offset, out_offset_end);
 
     ret = gst_pad_push (stream->pad, buf);
@@ -4831,7 +4795,7 @@ short_buffer:
   {
     GST_WARNING_OBJECT (avi, "Short read at offset %" G_GUINT64_FORMAT
         ", only got %d/%" G_GUINT64_FORMAT " bytes (truncated file?)", offset,
-        GST_BUFFER_SIZE (buf), size);
+        gst_buffer_get_size (buf), size);
     gst_buffer_unref (buf);
     ret = GST_FLOW_UNEXPECTED;
     goto beach;
@@ -4849,7 +4813,6 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
   guint32 size = 0;
   gint stream_nr = 0;
   GstFlowReturn res = GST_FLOW_OK;
-  GstFormat format = GST_FORMAT_TIME;
 
   if (G_UNLIKELY (avi->have_eos)) {
     /* Clean adapter, we're done */
@@ -4976,7 +4939,7 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
         if (size) {
           buf = gst_adapter_take_buffer (avi->adapter, GST_ROUND_UP_2 (size));
           /* patch the size */
-          GST_BUFFER_SIZE (buf) = size;
+          gst_buffer_resize (buf, 0, size);
         } else {
           buf = NULL;
         }
@@ -5005,9 +4968,8 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
           gst_buffer_unref (buf);
       } else {
         /* get time of this buffer */
-        gst_pad_query_position (stream->pad, &format, (gint64 *) & next_ts);
-        if (G_UNLIKELY (format != GST_FORMAT_TIME))
-          goto wrong_format;
+        gst_pad_query_position (stream->pad, GST_FORMAT_TIME,
+            (gint64 *) & next_ts);
 
         gst_avi_demux_add_assoc (avi, stream, next_ts, offset, FALSE);
 
@@ -5016,7 +4978,7 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
         stream->current_total += size;
 
         /* update current position in the segment */
-        gst_segment_set_last_stop (&avi->segment, GST_FORMAT_TIME, next_ts);
+        avi->segment.position = next_ts;
 
         if (saw_desired_kf && buf) {
           GstClockTime dur_ts = 0;
@@ -5024,9 +4986,8 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
           /* invert the picture if needed */
           buf = gst_avi_demux_invert (stream, buf);
 
-          gst_pad_query_position (stream->pad, &format, (gint64 *) & dur_ts);
-          if (G_UNLIKELY (format != GST_FORMAT_TIME))
-            goto wrong_format;
+          gst_pad_query_position (stream->pad, GST_FORMAT_TIME,
+              (gint64 *) & dur_ts);
 
           GST_BUFFER_TIMESTAMP (buf) = next_ts;
           GST_BUFFER_DURATION (buf) = dur_ts - next_ts;
@@ -5038,7 +4999,6 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
             GST_BUFFER_OFFSET_END (buf) = GST_BUFFER_OFFSET_NONE;
           }
 
-          gst_buffer_set_caps (buf, GST_PAD_CAPS (stream->pad));
           GST_DEBUG_OBJECT (avi,
               "Pushing buffer with time=%" GST_TIME_FORMAT ", duration %"
               GST_TIME_FORMAT ", offset %" G_GUINT64_FORMAT
@@ -5066,17 +5026,7 @@ gst_avi_demux_stream_data (GstAviDemux * avi)
     }
   }
 
-done:
   return res;
-
-  /* ERRORS */
-wrong_format:
-  {
-    GST_DEBUG_OBJECT (avi, "format %s != GST_FORMAT_TIME",
-        gst_format_get_name (format));
-    res = GST_FLOW_ERROR;
-    goto done;
-  }
 }
 
 /*
@@ -5143,10 +5093,6 @@ gst_avi_demux_loop (GstPad * pad)
       avi->state = GST_AVI_DEMUX_MOVI;
       break;
     case GST_AVI_DEMUX_MOVI:
-      if (G_UNLIKELY (avi->close_seg_event)) {
-        gst_avi_demux_push_event (avi, avi->close_seg_event);
-        avi->close_seg_event = NULL;
-      }
       if (G_UNLIKELY (avi->seg_event)) {
         gst_avi_demux_push_event (avi, avi->seg_event);
         avi->seg_event = NULL;
@@ -5176,12 +5122,17 @@ pause:{
 
     gboolean push_eos = FALSE;
     GST_LOG_OBJECT (avi, "pausing task, reason %s", gst_flow_get_name (res));
-    avi->segment_running = FALSE;
     gst_pad_pause_task (avi->sinkpad);
 
-
     if (res == GST_FLOW_UNEXPECTED) {
       /* handle end-of-stream/segment */
+      /* so align our position with the end of it, if there is one
+       * this ensures a subsequent will arrive at correct base/acc time */
+      if (avi->segment.rate > 0.0 &&
+          GST_CLOCK_TIME_IS_VALID (avi->segment.stop))
+        avi->segment.position = avi->segment.stop;
+      else if (avi->segment.rate < 0.0)
+        avi->segment.position = avi->segment.start;
       if (avi->segment.flags & GST_SEEK_FLAG_SEGMENT) {
         gint64 stop;
 
@@ -5233,7 +5184,7 @@ gst_avi_demux_chain (GstPad * pad, GstBuffer * buf)
       avi->stream[i].discont = TRUE;
   }
 
-  GST_DEBUG ("Store %d bytes in adapter", GST_BUFFER_SIZE (buf));
+  GST_DEBUG ("Store %d bytes in adapter", gst_buffer_get_size (buf));
   gst_adapter_push (avi->adapter, buf);
 
   switch (avi->state) {
@@ -5250,10 +5201,6 @@ gst_avi_demux_chain (GstPad * pad, GstBuffer * buf)
       }
       break;
     case GST_AVI_DEMUX_MOVI:
-      if (G_UNLIKELY (avi->close_seg_event)) {
-        gst_avi_demux_push_event (avi, avi->close_seg_event);
-        avi->close_seg_event = NULL;
-      }
       if (G_UNLIKELY (avi->seg_event)) {
         gst_avi_demux_push_event (avi, avi->seg_event);
         avi->seg_event = NULL;
@@ -5336,11 +5283,28 @@ abort_buffering:
 static gboolean
 gst_avi_demux_sink_activate (GstPad * sinkpad)
 {
-  if (gst_pad_check_pull_range (sinkpad)) {
-    GST_DEBUG ("going to pull mode");
-    return gst_pad_activate_pull (sinkpad, TRUE);
-  } else {
-    GST_DEBUG ("going to push (streaming) mode");
+  GstQuery *query;
+  gboolean pull_mode;
+
+  query = gst_query_new_scheduling ();
+
+  if (!gst_pad_peer_query (sinkpad, query)) {
+    gst_query_unref (query);
+    goto activate_push;
+  }
+
+  gst_query_parse_scheduling (query, &pull_mode, NULL, NULL, NULL, NULL, NULL);
+  gst_query_unref (query);
+
+  if (!pull_mode)
+    goto activate_push;
+
+  GST_DEBUG_OBJECT (sinkpad, "activating pull");
+  return gst_pad_activate_pull (sinkpad, TRUE);
+
+activate_push:
+  {
+    GST_DEBUG_OBJECT (sinkpad, "activating push");
     return gst_pad_activate_push (sinkpad, TRUE);
   }
 }
@@ -5351,12 +5315,10 @@ gst_avi_demux_sink_activate_pull (GstPad * sinkpad, gboolean active)
   GstAviDemux *avi = GST_AVI_DEMUX (GST_OBJECT_PARENT (sinkpad));
 
   if (active) {
-    avi->segment_running = TRUE;
     avi->streaming = FALSE;
     return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_avi_demux_loop,
         sinkpad);
   } else {
-    avi->segment_running = FALSE;
     return gst_pad_stop_task (sinkpad);
   }
 }
index cdd99d0..fe3dd58 100644 (file)
@@ -174,11 +174,9 @@ typedef struct _GstAviDemux {
 
   /* segment in TIME */
   GstSegment     segment;
-  gboolean       segment_running;
 
   /* pending tags/events */
   GstEvent      *seg_event;
-  GstEvent      *close_seg_event;
   GstTagList   *globaltags;
   gboolean      got_tags;
 
index c8be86b..514257e 100644 (file)
@@ -35,7 +35,7 @@
  * <para>(write everything in one line, without the backslash characters)</para>
  * |[
  * gst-launch videotestsrc num-buffers=250 \
- * ! 'video/x-raw-yuv,format=(fourcc)I420,width=320,height=240,framerate=(fraction)25/1' \
+ * ! 'video/x-raw,format=(string)I420,width=320,height=240,framerate=(fraction)25/1' \
  * ! queue ! mux. \
  * audiotestsrc num-buffers=440 ! audioconvert \
  * ! 'audio/x-raw-int,rate=44100,channels=2' ! queue ! mux. \
@@ -45,7 +45,7 @@
  * test sound.
  * |[
  * gst-launch videotestsrc num-buffers=250 \
- * ! 'video/x-raw-yuv,format=(fourcc)I420,width=320,height=240,framerate=(fraction)25/1' \
+ * ! 'video/x-raw,format=(string)I420,width=320,height=240,framerate=(fraction)25/1' \
  * ! xvidenc ! queue ! mux. \
  * audiotestsrc num-buffers=440 ! audioconvert ! 'audio/x-raw-int,rate=44100,channels=2' \
  * ! lame ! queue ! mux. \
@@ -91,8 +91,8 @@ static GstStaticPadTemplate video_sink_factory =
     GST_STATIC_PAD_TEMPLATE ("video_%d",
     GST_PAD_SINK,
     GST_PAD_REQUEST,
-    GST_STATIC_CAPS ("video/x-raw-yuv, "
-        "format = (fourcc) { YUY2, I420 }, "
+    GST_STATIC_CAPS ("video/x-raw, "
+        "format = (string) { YUY2, I420 }, "
         "width = (int) [ 16, 4096 ], "
         "height = (int) [ 16, 4096 ], "
         "framerate = (fraction) [ 0, MAX ]; "
@@ -190,16 +190,13 @@ static GstStaticPadTemplate audio_sink_factory =
         "wmaversion = (int) [ 1, 2 ] ")
     );
 
-static void gst_avi_mux_base_init (gpointer g_class);
-static void gst_avi_mux_class_init (GstAviMuxClass * klass);
-static void gst_avi_mux_init (GstAviMux * avimux);
 static void gst_avi_mux_pad_reset (GstAviPad * avipad, gboolean free);
 
 static GstFlowReturn gst_avi_mux_collect_pads (GstCollectPads * pads,
     GstAviMux * avimux);
 static gboolean gst_avi_mux_handle_event (GstPad * pad, GstEvent * event);
 static GstPad *gst_avi_mux_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name);
+    GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
 static void gst_avi_mux_release_pad (GstElement * element, GstPad * pad);
 static void gst_avi_mux_set_property (GObject * object,
     guint prop_id, const GValue * value, GParamSpec * pspec);
@@ -208,58 +205,9 @@ static void gst_avi_mux_get_property (GObject * object,
 static GstStateChangeReturn gst_avi_mux_change_state (GstElement * element,
     GstStateChange transition);
 
-static GstElementClass *parent_class = NULL;
-
-GType
-gst_avi_mux_get_type (void)
-{
-  static GType avimux_type = 0;
-
-  if (!avimux_type) {
-    static const GTypeInfo avimux_info = {
-      sizeof (GstAviMuxClass),
-      gst_avi_mux_base_init,
-      NULL,
-      (GClassInitFunc) gst_avi_mux_class_init,
-      NULL,
-      NULL,
-      sizeof (GstAviMux),
-      0,
-      (GInstanceInitFunc) gst_avi_mux_init,
-    };
-    static const GInterfaceInfo tag_setter_info = {
-      NULL,
-      NULL,
-      NULL
-    };
-
-    avimux_type =
-        g_type_register_static (GST_TYPE_ELEMENT, "GstAviMux", &avimux_info, 0);
-    g_type_add_interface_static (avimux_type, GST_TYPE_TAG_SETTER,
-        &tag_setter_info);
-  }
-  return avimux_type;
-}
-
-static void
-gst_avi_mux_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&audio_sink_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&video_sink_factory));
-
-  gst_element_class_set_details_simple (element_class, "Avi muxer",
-      "Codec/Muxer",
-      "Muxes audio and video into an avi stream",
-      "GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
-
-  GST_DEBUG_CATEGORY_INIT (avimux_debug, "avimux", 0, "Muxer for AVI streams");
-}
+#define gst_avi_mux_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstAviMux, gst_avi_mux, GST_TYPE_ELEMENT,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
 
 static void
 gst_avi_mux_finalize (GObject * object)
@@ -297,7 +245,7 @@ gst_avi_mux_class_init (GstAviMuxClass * klass)
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
 
-  parent_class = g_type_class_peek_parent (klass);
+  GST_DEBUG_CATEGORY_INIT (avimux_debug, "avimux", 0, "Muxer for AVI streams");
 
   gobject_class->get_property = gst_avi_mux_get_property;
   gobject_class->set_property = gst_avi_mux_set_property;
@@ -312,6 +260,18 @@ gst_avi_mux_class_init (GstAviMuxClass * klass)
       GST_DEBUG_FUNCPTR (gst_avi_mux_request_new_pad);
   gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_avi_mux_release_pad);
   gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_avi_mux_change_state);
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&audio_sink_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&video_sink_factory));
+
+  gst_element_class_set_details_simple (gstelement_class, "Avi muxer",
+      "Codec/Muxer",
+      "Muxes audio and video into an avi stream",
+      "GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
 }
 
 /* reset pad to initial state
@@ -506,18 +466,24 @@ gst_avi_mux_vidsink_set_caps (GstPad * pad, GstCaps * vscaps)
     avipad->vprp.field_info[0].valid_bm_width = width;
   }
 
-  if (!strcmp (mimetype, "video/x-raw-yuv")) {
-    guint32 format;
+  if (!strcmp (mimetype, "video/x-raw")) {
+    const gchar *format;
+    GstVideoFormat fmt;
+
+    format = gst_structure_get_string (structure, "format");
+    fmt = gst_video_format_from_string (format);
 
-    gst_structure_get_fourcc (structure, "format", &format);
-    avipad->vids.compression = format;
-    switch (format) {
-      case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+    switch (fmt) {
+      case GST_VIDEO_FORMAT_YUY2:
+        avipad->vids.compression = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
         avipad->vids.bit_cnt = 16;
         break;
-      case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+      case GST_VIDEO_FORMAT_I420:
+        avipad->vids.compression = GST_MAKE_FOURCC ('I', '4', '2', '0');
         avipad->vids.bit_cnt = 12;
         break;
+      default:
+        break;
     }
   } else {
     avipad->vids.bit_cnt = 24;
@@ -631,7 +597,7 @@ gst_avi_mux_vidsink_set_caps (GstPad * pad, GstCaps * vscaps)
       avipad->vids_codec_data = gst_value_get_buffer (codec_data);
       gst_buffer_ref (avipad->vids_codec_data);
       /* keep global track of size */
-      avimux->codec_data_size += GST_BUFFER_SIZE (avipad->vids_codec_data);
+      avimux->codec_data_size += gst_buffer_get_size (avipad->vids_codec_data);
     } else {
       avipad->prepend_buffer =
           gst_buffer_ref (gst_value_get_buffer (codec_data));
@@ -662,16 +628,14 @@ gst_avi_mux_audsink_scan_mpeg_audio (GstAviMux * avimux, GstAviPad * avipad,
     GstBuffer * buffer)
 {
   guint8 *data;
-  guint size;
+  gsize size;
   guint spf;
   guint32 header;
   gulong layer;
   gulong version;
   gint lsf, mpg25;
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
-
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   if (size < 4)
     goto not_parsed;
 
@@ -710,6 +674,8 @@ gst_avi_mux_audsink_scan_mpeg_audio (GstAviMux * avimux, GstAviPad * avipad,
     GST_WARNING_OBJECT (avimux, "input mpeg audio has varying frame size");
     goto cbr_fallback;
   }
+done:
+  gst_buffer_unmap (buffer, data, size);
 
   return GST_FLOW_OK;
 
@@ -725,7 +691,7 @@ cbr_fallback:
     avipad->hdr.scale = 1;
     /* no need to check further */
     avipad->hook = NULL;
-    return GST_FLOW_OK;
+    goto done;
   }
 }
 
@@ -789,7 +755,7 @@ gst_avi_mux_audsink_set_caps (GstPad * pad, GstCaps * vscaps)
     avipad->auds_codec_data = gst_value_get_buffer (codec_data);
     gst_buffer_ref (avipad->auds_codec_data);
     /* keep global track of size */
-    avimux->codec_data_size += GST_BUFFER_SIZE (avipad->auds_codec_data);
+    avimux->codec_data_size += gst_buffer_get_size (avipad->auds_codec_data);
   }
 
   if (!strcmp (mimetype, "audio/x-raw-int")) {
@@ -868,6 +834,7 @@ gst_avi_mux_audsink_set_caps (GstPad * pad, GstCaps * vscaps)
           GstBuffer *codec_data_buf = avipad->auds_codec_data;
           const gchar *stream_format;
           guint codec;
+          guint8 data[2];
 
           stream_format = gst_structure_get_string (structure, "stream-format");
           if (stream_format) {
@@ -882,13 +849,14 @@ gst_avi_mux_audsink_set_caps (GstPad * pad, GstCaps * vscaps)
           }
 
           /* vbr case needs some special handling */
-          if (!codec_data_buf || GST_BUFFER_SIZE (codec_data_buf) < 2) {
+          if (!codec_data_buf || gst_buffer_get_size (codec_data_buf) < 2) {
             GST_WARNING_OBJECT (avimux, "no (valid) codec_data for AAC audio");
             break;
           }
           avipad->auds.format = GST_RIFF_WAVE_FORMAT_AAC;
           /* need to determine frame length */
-          codec = GST_READ_UINT16_BE (GST_BUFFER_DATA (codec_data_buf));
+          gst_buffer_extract (codec_data_buf, 0, data, 2);
+          codec = GST_READ_UINT16_BE (data);
           avipad->parent.hdr.scale = (codec & 0x4) ? 960 : 1024;
           break;
         }
@@ -956,7 +924,7 @@ refuse_caps:
 
 static GstPad *
 gst_avi_mux_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * req_name)
+    GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps)
 {
   GstAviMux *avimux;
   GstPad *newpad;
@@ -964,7 +932,6 @@ gst_avi_mux_request_new_pad (GstElement * element,
   GstElementClass *klass;
   gchar *name = NULL;
   const gchar *pad_name = NULL;
-  GstPadSetCapsFunction setcapsfunc = NULL;
   gint pad_id;
 
   g_return_val_if_fail (templ != NULL, NULL);
@@ -991,7 +958,6 @@ gst_avi_mux_request_new_pad (GstElement * element,
       name = g_strdup_printf ("audio_%02d", avimux->audio_pads++);
       pad_name = name;
     }
-    setcapsfunc = GST_DEBUG_FUNCPTR (gst_avi_mux_audsink_set_caps);
 
     /* init pad specific data */
     avipad = g_malloc0 (sizeof (GstAviAudioPad));
@@ -1009,7 +975,6 @@ gst_avi_mux_request_new_pad (GstElement * element,
     /* setup pad */
     pad_name = "video_00";
     avimux->video_pads++;
-    setcapsfunc = GST_DEBUG_FUNCPTR (gst_avi_mux_vidsink_set_caps);
 
     /* init pad specific data */
     avipad = g_malloc0 (sizeof (GstAviVideoPad));
@@ -1021,7 +986,6 @@ gst_avi_mux_request_new_pad (GstElement * element,
     goto wrong_template;
 
   newpad = gst_pad_new_from_template (templ, pad_name);
-  gst_pad_set_setcaps_function (newpad, setcapsfunc);
 
   g_free (name);
 
@@ -1187,6 +1151,8 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
   GstByteWriter bw;
   GSList *node;
   guint avih, riff, hdrl;
+  guint8 *bdata;
+  gsize bsize;
 
   GST_DEBUG_OBJECT (avimux, "creating avi header, data_size %u, idx_size %u",
       avimux->data_size, avimux->idx_size);
@@ -1262,7 +1228,7 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
 
     if (avipad->is_video) {
       codec_size = vidpad->vids_codec_data ?
-          GST_BUFFER_SIZE (vidpad->vids_codec_data) : 0;
+          gst_buffer_get_size (vidpad->vids_codec_data) : 0;
       /* the video header */
       strf = gst_avi_mux_start_chunk (&bw, "strf", 0);
       /* the actual header */
@@ -1278,9 +1244,11 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
       gst_byte_writer_put_uint32_le (&bw, vidpad->vids.num_colors);
       gst_byte_writer_put_uint32_le (&bw, vidpad->vids.imp_colors);
       if (vidpad->vids_codec_data) {
-        gst_byte_writer_put_data (&bw,
-            GST_BUFFER_DATA (vidpad->vids_codec_data),
-            GST_BUFFER_SIZE (vidpad->vids_codec_data));
+        bdata =
+            gst_buffer_map (vidpad->vids_codec_data, &bsize, NULL,
+            GST_MAP_READ);
+        gst_byte_writer_put_data (&bw, bdata, bsize);
+        gst_buffer_unmap (vidpad->vids_codec_data, bdata, bsize);
       }
       gst_avi_mux_end_chunk (&bw, strf);
 
@@ -1322,7 +1290,7 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
       }
     } else {
       codec_size = audpad->auds_codec_data ?
-          GST_BUFFER_SIZE (audpad->auds_codec_data) : 0;
+          gst_buffer_get_size (audpad->auds_codec_data) : 0;
       /* the audio header */
       strf = gst_avi_mux_start_chunk (&bw, "strf", 0);
       /* the actual header */
@@ -1334,9 +1302,11 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
       gst_byte_writer_put_uint16_le (&bw, audpad->auds.size);
       gst_byte_writer_put_uint16_le (&bw, codec_size);
       if (audpad->auds_codec_data) {
-        gst_byte_writer_put_data (&bw,
-            GST_BUFFER_DATA (audpad->auds_codec_data),
-            GST_BUFFER_SIZE (audpad->auds_codec_data));
+        bdata =
+            gst_buffer_map (audpad->auds_codec_data, &bsize, NULL,
+            GST_MAP_READ);
+        gst_byte_writer_put_data (&bw, bdata, bsize);
+        gst_buffer_unmap (vidpad->vids_codec_data, bdata, bsize);
       }
       gst_avi_mux_end_chunk (&bw, strf);
     }
@@ -1407,12 +1377,13 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
   buffer = gst_byte_writer_reset_and_get_buffer (&bw);
 
   /* ... but RIFF includes more than just header */
-  size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buffer) + 4);
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READWRITE);
+  size = GST_READ_UINT32_LE (bdata + 4);
   size += 8 + avimux->data_size + avimux->idx_size;
-  GST_WRITE_UINT32_LE (GST_BUFFER_DATA (buffer) + 4, size);
+  GST_WRITE_UINT32_LE (bdata + 4, size);
 
-  GST_MEMDUMP_OBJECT (avimux, "avi header", GST_BUFFER_DATA (buffer),
-      GST_BUFFER_SIZE (buffer));
+  GST_MEMDUMP_OBJECT (avimux, "avi header", bdata, bsize);
+  gst_buffer_unmap (buffer, bdata, bsize);
 
   return buffer;
 }
@@ -1421,17 +1392,19 @@ static GstBuffer *
 gst_avi_mux_riff_get_avix_header (guint32 datax_size)
 {
   GstBuffer *buffer;
-  guint8 *buffdata;
+  guint8 *bdata;
+  gsize bsize;
 
   buffer = gst_buffer_new_and_alloc (24);
-  buffdata = GST_BUFFER_DATA (buffer);
 
-  memcpy (buffdata + 0, "RIFF", 4);
-  GST_WRITE_UINT32_LE (buffdata + 4, datax_size + 3 * 4);
-  memcpy (buffdata + 8, "AVIX", 4);
-  memcpy (buffdata + 12, "LIST", 4);
-  GST_WRITE_UINT32_LE (buffdata + 16, datax_size);
-  memcpy (buffdata + 20, "movi", 4);
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
+  memcpy (bdata + 0, "RIFF", 4);
+  GST_WRITE_UINT32_LE (bdata + 4, datax_size + 3 * 4);
+  memcpy (bdata + 8, "AVIX", 4);
+  memcpy (bdata + 12, "LIST", 4);
+  GST_WRITE_UINT32_LE (bdata + 16, datax_size);
+  memcpy (bdata + 20, "movi", 4);
+  gst_buffer_unmap (buffer, bdata, bsize);
 
   return buffer;
 }
@@ -1440,12 +1413,15 @@ static inline GstBuffer *
 gst_avi_mux_riff_get_header (GstAviPad * avipad, guint32 video_frame_size)
 {
   GstBuffer *buffer;
-  guint8 *buffdata;
+  guint8 *bdata;
+  gsize bsize;
 
   buffer = gst_buffer_new_and_alloc (8);
-  buffdata = GST_BUFFER_DATA (buffer);
-  memcpy (buffdata + 0, avipad->tag, 4);
-  GST_WRITE_UINT32_LE (buffdata + 4, video_frame_size);
+
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
+  memcpy (bdata + 0, avipad->tag, 4);
+  GST_WRITE_UINT32_LE (bdata + 4, video_frame_size);
+  gst_buffer_unmap (buffer, bdata, bsize);
 
   return buffer;
 }
@@ -1458,12 +1434,14 @@ gst_avi_mux_write_avix_index (GstAviMux * avimux, GstAviPad * avipad,
 {
   GstFlowReturn res;
   GstBuffer *buffer;
-  guint8 *buffdata, *data;
+  guint8 *data;
   gst_riff_index_entry *entry;
   gint i;
   guint32 size, entry_count;
   gboolean is_pcm = FALSE;
   guint32 pcm_samples = 0;
+  guint8 *bdata;
+  gsize bsize;
 
   /* check if it is pcm */
   if (avipad && !avipad->is_video) {
@@ -1476,19 +1454,21 @@ gst_avi_mux_write_avix_index (GstAviMux * avimux, GstAviPad * avipad,
 
   /* allocate the maximum possible */
   buffer = gst_buffer_new_and_alloc (32 + 8 * avimux->idx_index);
-  buffdata = GST_BUFFER_DATA (buffer);
+
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
+  data = bdata;
 
   /* general index chunk info */
-  memcpy (buffdata + 0, chunk, 4);      /* chunk id */
-  GST_WRITE_UINT32_LE (buffdata + 4, 0);        /* chunk size; fill later */
-  GST_WRITE_UINT16_LE (buffdata + 8, 2);        /* index entry is 2 words */
-  buffdata[10] = 0;             /* index subtype */
-  buffdata[11] = GST_AVI_INDEX_OF_CHUNKS;       /* index type: AVI_INDEX_OF_CHUNKS */
-  GST_WRITE_UINT32_LE (buffdata + 12, 0);       /* entries in use; fill later */
-  memcpy (buffdata + 16, code, 4);      /* stream to which index refers */
-  GST_WRITE_UINT64_LE (buffdata + 20, avimux->avix_start);      /* base offset */
-  GST_WRITE_UINT32_LE (buffdata + 28, 0);       /* reserved */
-  buffdata += 32;
+  memcpy (bdata + 0, chunk, 4); /* chunk id */
+  GST_WRITE_UINT32_LE (bdata + 4, 0);   /* chunk size; fill later */
+  GST_WRITE_UINT16_LE (bdata + 8, 2);   /* index entry is 2 words */
+  bdata[10] = 0;                /* index subtype */
+  bdata[11] = GST_AVI_INDEX_OF_CHUNKS;  /* index type: AVI_INDEX_OF_CHUNKS */
+  GST_WRITE_UINT32_LE (bdata + 12, 0);  /* entries in use; fill later */
+  memcpy (bdata + 16, code, 4); /* stream to which index refers */
+  GST_WRITE_UINT64_LE (bdata + 20, avimux->avix_start); /* base offset */
+  GST_WRITE_UINT32_LE (bdata + 28, 0);  /* reserved */
+  bdata += 32;
 
   /* now the actual index entries */
   i = avimux->idx_index;
@@ -1496,26 +1476,25 @@ gst_avi_mux_write_avix_index (GstAviMux * avimux, GstAviPad * avipad,
   while (i > 0) {
     if (memcmp (&entry->id, code, 4) == 0) {
       /* enter relative offset to the data (!) */
-      GST_WRITE_UINT32_LE (buffdata, GUINT32_FROM_LE (entry->offset) + 8);
+      GST_WRITE_UINT32_LE (bdata, GUINT32_FROM_LE (entry->offset) + 8);
       /* msb is set if not (!) keyframe */
-      GST_WRITE_UINT32_LE (buffdata + 4, GUINT32_FROM_LE (entry->size)
+      GST_WRITE_UINT32_LE (bdata + 4, GUINT32_FROM_LE (entry->size)
           | (GUINT32_FROM_LE (entry->flags)
               & GST_RIFF_IF_KEYFRAME ? 0 : 1U << 31));
-      buffdata += 8;
+      bdata += 8;
     }
     i--;
     entry++;
   }
 
   /* ok, now we know the size and no of entries, fill in where needed */
-  data = GST_BUFFER_DATA (buffer);
-  GST_BUFFER_SIZE (buffer) = size = buffdata - data;
+  size = bdata - data;
   GST_WRITE_UINT32_LE (data + 4, size - 8);
   entry_count = (size - 32) / 8;
   GST_WRITE_UINT32_LE (data + 12, entry_count);
+  gst_buffer_unmap (buffer, data, size);
 
-  /* decorate and send */
-  gst_buffer_set_caps (buffer, GST_PAD_CAPS (avimux->srcpad));
+  /* send */
   if ((res = gst_pad_push (avimux->srcpad, buffer)) != GST_FLOW_OK)
     return res;
 
@@ -1580,26 +1559,31 @@ gst_avi_mux_write_index (GstAviMux * avimux)
   GstFlowReturn res;
   GstBuffer *buffer;
   guint8 *buffdata;
+  gsize buffsize;
 
   buffer = gst_buffer_new_and_alloc (8);
-  buffdata = GST_BUFFER_DATA (buffer);
+
+  buffdata = gst_buffer_map (buffer, &buffsize, NULL, GST_MAP_WRITE);
   memcpy (buffdata + 0, "idx1", 4);
   GST_WRITE_UINT32_LE (buffdata + 4,
       avimux->idx_index * sizeof (gst_riff_index_entry));
+  gst_buffer_unmap (buffer, buffdata, buffsize);
 
-  gst_buffer_set_caps (buffer, GST_PAD_CAPS (avimux->srcpad));
   res = gst_pad_push (avimux->srcpad, buffer);
   if (res != GST_FLOW_OK)
     return res;
 
   buffer = gst_buffer_new ();
-  GST_BUFFER_SIZE (buffer) = avimux->idx_index * sizeof (gst_riff_index_entry);
-  GST_BUFFER_DATA (buffer) = (guint8 *) avimux->idx;
-  GST_BUFFER_MALLOCDATA (buffer) = GST_BUFFER_DATA (buffer);
+
+  buffsize = avimux->idx_index * sizeof (gst_riff_index_entry);
+  buffdata = (guint8 *) avimux->idx;
   avimux->idx = NULL;           /* will be free()'ed by gst_buffer_unref() */
-  avimux->total_data += GST_BUFFER_SIZE (buffer) + 8;
 
-  gst_buffer_set_caps (buffer, GST_PAD_CAPS (avimux->srcpad));
+  gst_buffer_take_memory (buffer, -1,
+      gst_memory_new_wrapped (0, buffdata, g_free, buffsize, 0, buffsize));
+
+  avimux->total_data += buffsize + 8;
+
   res = gst_pad_push (avimux->srcpad, buffer);
   if (res != GST_FLOW_OK)
     return res;
@@ -1616,7 +1600,6 @@ gst_avi_mux_bigfile (GstAviMux * avimux, gboolean last)
 {
   GstFlowReturn res = GST_FLOW_OK;
   GstBuffer *header;
-  GstEvent *event;
   GSList *node;
 
   /* first some odml standard index chunks in the movi list */
@@ -1633,21 +1616,23 @@ gst_avi_mux_bigfile (GstAviMux * avimux, gboolean last)
   }
 
   if (avimux->is_bigfile) {
+    GstSegment segment;
+
+    gst_segment_init (&segment, GST_FORMAT_BYTES);
+
     /* search back */
-    event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
-        avimux->avix_start, GST_CLOCK_TIME_NONE, avimux->avix_start);
-    /* if the event succeeds */
-    gst_pad_push_event (avimux->srcpad, event);
+    segment.start = avimux->avix_start;
+    segment.time = avimux->avix_start;
+    gst_pad_push_event (avimux->srcpad, gst_event_new_segment (&segment));
 
     /* rewrite AVIX header */
     header = gst_avi_mux_riff_get_avix_header (avimux->datax_size);
-    gst_buffer_set_caps (header, GST_PAD_CAPS (avimux->srcpad));
     res = gst_pad_push (avimux->srcpad, header);
 
     /* go back to current location, at least try */
-    event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
-        avimux->total_data, GST_CLOCK_TIME_NONE, avimux->total_data);
-    gst_pad_push_event (avimux->srcpad, event);
+    segment.start = avimux->total_data;
+    segment.time = avimux->total_data;
+    gst_pad_push_event (avimux->srcpad, gst_event_new_segment (&segment));
 
     if (res != GST_FLOW_OK)
       return res;
@@ -1679,10 +1664,10 @@ gst_avi_mux_bigfile (GstAviMux * avimux, gboolean last)
   }
 
   header = gst_avi_mux_riff_get_avix_header (0);
-  avimux->total_data += GST_BUFFER_SIZE (header);
+  avimux->total_data += gst_buffer_get_size (header);
   /* avix_start is used as base offset for the odml index chunk */
   avimux->idx_offset = avimux->total_data - avimux->avix_start;
-  gst_buffer_set_caps (header, GST_PAD_CAPS (avimux->srcpad));
+
   return gst_pad_push (avimux->srcpad, header);
 }
 
@@ -1695,6 +1680,7 @@ gst_avi_mux_start_file (GstAviMux * avimux)
   GstBuffer *header;
   GSList *node;
   GstCaps *caps;
+  GstSegment segment;
 
   avimux->total_data = 0;
   avimux->total_frames = 0;
@@ -1742,17 +1728,16 @@ gst_avi_mux_start_file (GstAviMux * avimux)
   gst_caps_unref (caps);
 
   /* let downstream know we think in BYTES and expect to do seeking later on */
-  gst_pad_push_event (avimux->srcpad,
-      gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
+  gst_segment_init (&segment, GST_FORMAT_BYTES);
+  gst_pad_push_event (avimux->srcpad, gst_event_new_segment (&segment));
 
   /* header */
   avimux->avi_hdr.streams = g_slist_length (avimux->sinkpads);
   avimux->is_bigfile = FALSE;
 
   header = gst_avi_mux_riff_get_avi_header (avimux);
-  avimux->total_data += GST_BUFFER_SIZE (header);
+  avimux->total_data += gst_buffer_get_size (header);
 
-  gst_buffer_set_caps (header, GST_PAD_CAPS (avimux->srcpad));
   res = gst_pad_push (avimux->srcpad, header);
 
   avimux->idx_offset = avimux->total_data;
@@ -1764,9 +1749,9 @@ static GstFlowReturn
 gst_avi_mux_stop_file (GstAviMux * avimux)
 {
   GstFlowReturn res = GST_FLOW_OK;
-  GstEvent *event;
   GstBuffer *header;
   GSList *node;
+  GstSegment segment;
 
   /* if bigfile, rewrite header, else write indexes */
   /* don't bail out at once if error, still try to re-write header */
@@ -1826,21 +1811,19 @@ gst_avi_mux_stop_file (GstAviMux * avimux)
   avimux->avi_hdr.tot_frames = avimux->num_frames;
 
   /* seek and rewrite the header */
-  header = gst_avi_mux_riff_get_avi_header (avimux);
-  event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
-      0, GST_CLOCK_TIME_NONE, 0);
-  gst_pad_push_event (avimux->srcpad, event);
+  gst_segment_init (&segment, GST_FORMAT_BYTES);
+  gst_pad_push_event (avimux->srcpad, gst_event_new_segment (&segment));
 
-  gst_buffer_set_caps (header, GST_PAD_CAPS (avimux->srcpad));
   /* the first error survives */
+  header = gst_avi_mux_riff_get_avi_header (avimux);
   if (res == GST_FLOW_OK)
     res = gst_pad_push (avimux->srcpad, header);
   else
     gst_pad_push (avimux->srcpad, header);
 
-  event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
-      avimux->total_data, GST_CLOCK_TIME_NONE, avimux->total_data);
-  gst_pad_push_event (avimux->srcpad, event);
+  segment.start = avimux->total_data;
+  segment.time = avimux->total_data;
+  gst_pad_push_event (avimux->srcpad, gst_event_new_segment (&segment));
 
   avimux->write_header = TRUE;
 
@@ -1865,11 +1848,32 @@ static gboolean
 gst_avi_mux_handle_event (GstPad * pad, GstEvent * event)
 {
   GstAviMux *avimux;
-  gboolean ret;
+  gboolean ret = TRUE;
 
   avimux = GST_AVI_MUX (gst_pad_get_parent (pad));
 
   switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+      GstAviCollectData *collect_pad;
+      GstAviVideoPad *avipad;
+
+      gst_event_parse_caps (event, &caps);
+
+      /* find stream data */
+      collect_pad = (GstAviCollectData *) gst_pad_get_element_private (pad);
+      g_assert (collect_pad);
+      avipad = (GstAviVideoPad *) collect_pad->avipad;
+      g_assert (avipad);
+
+      if (avipad->parent.is_video) {
+        ret = gst_avi_mux_vidsink_set_caps (pad, caps);
+      } else {
+        ret = gst_avi_mux_audsink_set_caps (pad, caps);
+      }
+      break;
+    }
     case GST_EVENT_TAG:{
       GstTagList *list;
       GstTagSetter *setter = GST_TAG_SETTER (avimux);
@@ -1884,7 +1888,8 @@ gst_avi_mux_handle_event (GstPad * pad, GstEvent * event)
   }
 
   /* now GstCollectPads can take care of the rest, e.g. EOS */
-  ret = avimux->collect_event (pad, event);
+  if (ret)
+    ret = avimux->collect_event (pad, event);
 
   gst_object_unref (avimux);
 
@@ -1896,10 +1901,15 @@ static GstFlowReturn
 gst_avi_mux_send_pad_data (GstAviMux * avimux, gulong num_bytes)
 {
   GstBuffer *buffer;
+  guint8 *bdata;
+  gsize bsize;
 
   buffer = gst_buffer_new_and_alloc (num_bytes);
-  memset (GST_BUFFER_DATA (buffer), 0, num_bytes);
-  gst_buffer_set_caps (buffer, GST_PAD_CAPS (avimux->srcpad));
+
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
+  memset (bdata, 0, num_bytes);
+  gst_buffer_unmap (buffer, bdata, bsize);
+
   return gst_pad_push (avimux->srcpad, buffer);
 }
 
@@ -1911,10 +1921,11 @@ gst_avi_mux_do_buffer (GstAviMux * avimux, GstAviPad * avipad)
   GstBuffer *data, *header;
   gulong total_size, pad_bytes = 0;
   guint flags;
+  gsize datasize;
 
   data = gst_collect_pads_pop (avimux->collect, avipad->collect);
   /* arrange downstream running time */
-  data = gst_buffer_make_metadata_writable (data);
+  data = gst_buffer_make_writable (data);
   GST_BUFFER_TIMESTAMP (data) =
       gst_segment_to_running_time (&avipad->collect->segment,
       GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (data));
@@ -1925,7 +1936,7 @@ gst_avi_mux_do_buffer (GstAviMux * avimux, GstAviPad * avipad)
 
     if (vidpad->prepend_buffer) {
       GstBuffer *newdata = gst_buffer_merge (vidpad->prepend_buffer, data);
-      gst_buffer_copy_metadata (newdata, data, GST_BUFFER_COPY_TIMESTAMPS);
+      gst_buffer_copy_into (newdata, data, GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
       gst_buffer_unref (data);
       gst_buffer_unref (vidpad->prepend_buffer);
 
@@ -1939,9 +1950,11 @@ gst_avi_mux_do_buffer (GstAviMux * avimux, GstAviPad * avipad)
       return res;
   }
 
+  datasize = gst_buffer_get_size (data);
+
   /* need to restart or start a next avix chunk ? */
   if ((avimux->is_bigfile ? avimux->datax_size : avimux->data_size) +
-      GST_BUFFER_SIZE (data) > GST_AVI_MAX_SIZE) {
+      datasize > GST_AVI_MAX_SIZE) {
     if (avimux->enable_large_avi) {
       if ((res = gst_avi_mux_bigfile (avimux, FALSE)) != GST_FLOW_OK)
         return res;
@@ -1952,11 +1965,11 @@ gst_avi_mux_do_buffer (GstAviMux * avimux, GstAviPad * avipad)
   }
 
   /* get header and record some stats */
-  if (GST_BUFFER_SIZE (data) & 1) {
-    pad_bytes = 2 - (GST_BUFFER_SIZE (data) & 1);
+  if (datasize & 1) {
+    pad_bytes = 2 - (datasize & 1);
   }
-  header = gst_avi_mux_riff_get_header (avipad, GST_BUFFER_SIZE (data));
-  total_size = GST_BUFFER_SIZE (header) + GST_BUFFER_SIZE (data) + pad_bytes;
+  header = gst_avi_mux_riff_get_header (avipad, datasize);
+  total_size = gst_buffer_get_size (header) + datasize + pad_bytes;
 
   if (avimux->is_bigfile) {
     avimux->datax_size += total_size;
@@ -1968,8 +1981,8 @@ gst_avi_mux_do_buffer (GstAviMux * avimux, GstAviPad * avipad)
     avipad->hook (avimux, avipad, data);
 
   /* the suggested buffer size is the max frame size */
-  if (avipad->hdr.bufsize < GST_BUFFER_SIZE (data))
-    avipad->hdr.bufsize = GST_BUFFER_SIZE (data);
+  if (avipad->hdr.bufsize < datasize)
+    avipad->hdr.bufsize = datasize;
 
   if (avipad->is_video) {
     avimux->total_frames++;
@@ -1987,17 +2000,13 @@ gst_avi_mux_do_buffer (GstAviMux * avimux, GstAviPad * avipad)
     GstAviAudioPad *audpad = (GstAviAudioPad *) avipad;
 
     flags = 0;
-    audpad->audio_size += GST_BUFFER_SIZE (data);
+    audpad->audio_size += datasize;
     audpad->audio_time += GST_BUFFER_DURATION (data);
   }
 
-  gst_avi_mux_add_index (avimux, avipad, flags, GST_BUFFER_SIZE (data));
-
-  /* prepare buffers for sending */
-  gst_buffer_set_caps (header, GST_PAD_CAPS (avimux->srcpad));
-  data = gst_buffer_make_metadata_writable (data);
-  gst_buffer_set_caps (data, GST_PAD_CAPS (avimux->srcpad));
+  gst_avi_mux_add_index (avimux, avipad, flags, datasize);
 
+  /* send buffers */
   GST_LOG_OBJECT (avimux, "pushing buffers: head, data");
 
   if ((res = gst_pad_push (avimux->srcpad, header)) != GST_FLOW_OK)
index 10c4faf..f669154 100644 (file)
@@ -81,8 +81,8 @@ static GstStateChangeReturn gst_avi_subtitle_change_state (GstElement * element,
 static gboolean gst_avi_subtitle_send_event (GstElement * element,
     GstEvent * event);
 
-GST_BOILERPLATE (GstAviSubtitle, gst_avi_subtitle, GstElement,
-    GST_TYPE_ELEMENT);
+#define gst_avi_subtitle_parent_class parent_class
+G_DEFINE_TYPE (GstAviSubtitle, gst_avi_subtitle, GST_TYPE_ELEMENT);
 
 #define IS_BOM_UTF8(data)     ((GST_READ_UINT32_BE(data) >> 8) == 0xEFBBBF)
 #define IS_BOM_UTF16_BE(data) (GST_READ_UINT16_BE(data) == 0xFEFF)
@@ -96,13 +96,17 @@ gst_avi_subtitle_extract_file (GstAviSubtitle * sub, GstBuffer * buffer,
 {
   const gchar *input_enc = NULL;
   GstBuffer *ret = NULL;
-  gchar *data;
+  gchar *data, *bdata;
+  gsize bsize;
 
-  data = (gchar *) GST_BUFFER_DATA (buffer) + offset;
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
+  data = bdata + offset;
 
   if (len >= (3 + 1) && IS_BOM_UTF8 (data) &&
       g_utf8_validate (data + 3, len - 3, NULL)) {
-    ret = gst_buffer_create_sub (buffer, offset + 3, len - 3);
+    ret =
+        gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, offset + 3,
+        len - 3);
   } else if (len >= 2 && IS_BOM_UTF16_BE (data)) {
     input_enc = "UTF-16BE";
     data += 2;
@@ -121,11 +125,12 @@ gst_avi_subtitle_extract_file (GstAviSubtitle * sub, GstBuffer * buffer,
     len -= 4;
   } else if (g_utf8_validate (data, len, NULL)) {
     /* not specified, check if it's UTF-8 */
-    ret = gst_buffer_create_sub (buffer, offset, len);
+    ret = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, offset, len);
   } else {
     /* we could fall back to gst_tag_freeform_to_utf8() here */
     GST_WARNING_OBJECT (sub, "unspecified encoding, and not UTF-8");
-    return NULL;
+    ret = NULL;
+    goto done;
   }
 
   g_return_val_if_fail (ret != NULL || input_enc != NULL, NULL);
@@ -133,6 +138,7 @@ gst_avi_subtitle_extract_file (GstAviSubtitle * sub, GstBuffer * buffer,
   if (input_enc) {
     GError *err = NULL;
     gchar *utf8;
+    gsize slen;
 
     GST_DEBUG_OBJECT (sub, "converting subtitles from %s to UTF-8", input_enc);
     utf8 = g_convert (data, len, "UTF-8", input_enc, NULL, NULL, &err);
@@ -140,17 +146,21 @@ gst_avi_subtitle_extract_file (GstAviSubtitle * sub, GstBuffer * buffer,
     if (err != NULL) {
       GST_WARNING_OBJECT (sub, "conversion to UTF-8 failed : %s", err->message);
       g_error_free (err);
-      return NULL;
+      ret = NULL;
+      goto done;
     }
 
     ret = gst_buffer_new ();
-    GST_BUFFER_DATA (ret) = (guint8 *) utf8;
-    GST_BUFFER_MALLOCDATA (ret) = (guint8 *) utf8;
-    GST_BUFFER_SIZE (ret) = strlen (utf8);
+    slen = strlen (utf8);
+    gst_buffer_take_memory (ret, -1,
+        gst_memory_new_wrapped (0, utf8, g_free, slen, 0, slen));
+
     GST_BUFFER_OFFSET (ret) = 0;
   }
 
-  GST_BUFFER_CAPS (ret) = gst_caps_new_simple ("application/x-subtitle", NULL);
+done:
+  gst_buffer_unmap (buffer, bdata, bsize);
+
   return ret;
 }
 
@@ -175,14 +185,13 @@ gst_avi_subtitle_title_tag (GstAviSubtitle * sub, gchar * title)
 static GstFlowReturn
 gst_avi_subtitle_parse_gab2_chunk (GstAviSubtitle * sub, GstBuffer * buf)
 {
-  const guint8 *data;
+  guint8 *data;
   gchar *name_utf8;
   guint name_length;
   guint file_length;
-  guint size;
+  gsize size;
 
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
 
   /* check the magic word "GAB2\0", and the next word must be 2 */
   if (size < 12 || memcmp (data, "GAB2\0\2\0", 5 + 2) != 0)
@@ -222,18 +231,22 @@ gst_avi_subtitle_parse_gab2_chunk (GstAviSubtitle * sub, GstBuffer * buf)
   if (sub->subfile == NULL)
     goto extract_failed;
 
+  gst_buffer_unmap (buf, data, size);
+
   return GST_FLOW_OK;
 
   /* ERRORS */
 wrong_magic_word:
   {
     GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL), ("Wrong magic word"));
+    gst_buffer_unmap (buf, data, size);
     return GST_FLOW_ERROR;
   }
 wrong_name_length:
   {
     GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
         ("name doesn't fit in buffer (%d < %d)", size, 17 + name_length));
+    gst_buffer_unmap (buf, data, size);
     return GST_FLOW_ERROR;
   }
 wrong_fixed_word_2:
@@ -241,6 +254,7 @@ wrong_fixed_word_2:
     GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
         ("wrong fixed word: expected %u, got %u", 4,
             GST_READ_UINT16_LE (data + 11 + name_length)));
+    gst_buffer_unmap (buf, data, size);
     return GST_FLOW_ERROR;
   }
 wrong_total_length:
@@ -248,12 +262,14 @@ wrong_total_length:
     GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
         ("buffer size is wrong: need %d bytes, have %d bytes",
             17 + name_length + file_length, size));
+    gst_buffer_unmap (buf, data, size);
     return GST_FLOW_ERROR;
   }
 extract_failed:
   {
     GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
         ("could not extract subtitles"));
+    gst_buffer_unmap (buf, data, size);
     return GST_FLOW_ERROR;
   }
 }
@@ -302,36 +318,30 @@ gst_avi_subtitle_send_event (GstElement * element, GstEvent * event)
 }
 
 static void
-gst_avi_subtitle_base_init (gpointer klass)
+gst_avi_subtitle_class_init (GstAviSubtitleClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
 
   GST_DEBUG_CATEGORY_INIT (avisubtitle_debug, "avisubtitle", 0,
       "parse avi subtitle stream");
 
-  gst_element_class_add_pad_template (element_class,
+  gstelement_class->change_state =
+      GST_DEBUG_FUNCPTR (gst_avi_subtitle_change_state);
+  gstelement_class->send_event =
+      GST_DEBUG_FUNCPTR (gst_avi_subtitle_send_event);
+
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&sink_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&src_template));
 
-  gst_element_class_set_details_simple (element_class,
+  gst_element_class_set_details_simple (gstelement_class,
       "Avi subtitle parser", "Codec/Parser/Subtitle",
       "Parse avi subtitle stream", "Thijs Vermeir <thijsvermeir@gmail.com>");
 }
 
 static void
-gst_avi_subtitle_class_init (GstAviSubtitleClass * klass)
-{
-  GstElementClass *gstelement_class = (GstElementClass *) klass;
-
-  gstelement_class->change_state =
-      GST_DEBUG_FUNCPTR (gst_avi_subtitle_change_state);
-  gstelement_class->send_event =
-      GST_DEBUG_FUNCPTR (gst_avi_subtitle_send_event);
-}
-
-static void
-gst_avi_subtitle_init (GstAviSubtitle * self, GstAviSubtitleClass * klass)
+gst_avi_subtitle_init (GstAviSubtitle * self)
 {
   GstCaps *caps;
 
index 81cc762..2168a28 100644 (file)
@@ -68,12 +68,9 @@ GST_DEBUG_CATEGORY_STATIC (cutter_debug);
 static GstStaticPadTemplate cutter_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "rate = (int) [ 1, MAX ], "
-        "channels = (int) [ 1, MAX ], "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) { 8, 16 }, "
-        "depth = (int) { 8, 16 }, " "signed = (boolean) true")
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) { " GST_AUDIO_NE (S8) "," GST_AUDIO_NE (S16) " }, "
+        "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
     );
 
 static GstStaticPadTemplate cutter_sink_factory =
@@ -81,11 +78,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS ("audio/x-raw-int, "
-        "rate = (int) [ 1, MAX ], "
-        "channels = (int) [ 1, MAX ], "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) { 8, 16 }, "
-        "depth = (int) { 8, 16 }, " "signed = (boolean) true")
+        "format = (string) { " GST_AUDIO_NE (S8) "," GST_AUDIO_NE (S16) " }, "
+        "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
     );
 
 enum
@@ -98,38 +92,25 @@ enum
   PROP_LEAKY
 };
 
-GST_BOILERPLATE (GstCutter, gst_cutter, GstElement, GST_TYPE_ELEMENT);
+#define gst_cutter_parent_class parent_class
+G_DEFINE_TYPE (GstCutter, gst_cutter, GST_TYPE_ELEMENT);
 
 static void gst_cutter_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
 static void gst_cutter_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
+static gboolean gst_cutter_event (GstPad * pad, GstEvent * event);
 static GstFlowReturn gst_cutter_chain (GstPad * pad, GstBuffer * buffer);
 
-static gboolean gst_cutter_get_caps (GstPad * pad, GstCutter * filter);
-
-static void
-gst_cutter_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&cutter_src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&cutter_sink_factory));
-  gst_element_class_set_details_simple (element_class, "Audio cutter",
-      "Filter/Editor/Audio",
-      "Audio Cutter to split audio into non-silent bits",
-      "Thomas Vander Stichele <thomas at apestaart dot org>");
-}
-
 static void
 gst_cutter_class_init (GstCutterClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *element_class;
 
   gobject_class = (GObjectClass *) klass;
+  element_class = (GstElementClass *) klass;
 
   gobject_class->set_property = gst_cutter_set_property;
   gobject_class->get_property = gst_cutter_get_property;
@@ -158,15 +139,31 @@ gst_cutter_class_init (GstCutterClass * klass)
           FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   GST_DEBUG_CATEGORY_INIT (cutter_debug, "cutter", 0, "Audio cutting");
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&cutter_src_factory));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&cutter_sink_factory));
+  gst_element_class_set_details_simple (element_class, "Audio cutter",
+      "Filter/Editor/Audio",
+      "Audio Cutter to split audio into non-silent bits",
+      "Thomas Vander Stichele <thomas at apestaart dot org>");
 }
 
 static void
-gst_cutter_init (GstCutter * filter, GstCutterClass * g_class)
+gst_cutter_init (GstCutter * filter)
 {
   filter->sinkpad =
       gst_pad_new_from_static_template (&cutter_sink_factory, "sink");
+  gst_pad_set_chain_function (filter->sinkpad, gst_cutter_chain);
+  gst_pad_set_event_function (filter->sinkpad, gst_cutter_event);
+  gst_pad_use_fixed_caps (filter->sinkpad);
+  gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+
   filter->srcpad =
       gst_pad_new_from_static_template (&cutter_src_factory, "src");
+  gst_pad_use_fixed_caps (filter->srcpad);
+  gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
 
   filter->threshold_level = CUTTER_DEFAULT_THRESHOLD_LEVEL;
   filter->threshold_length = CUTTER_DEFAULT_THRESHOLD_LENGTH;
@@ -178,13 +175,6 @@ gst_cutter_init (GstCutter * filter, GstCutterClass * g_class)
   filter->pre_run_length = 0 * GST_SECOND;
   filter->pre_buffer = NULL;
   filter->leaky = FALSE;
-
-  gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
-  gst_pad_set_chain_function (filter->sinkpad, gst_cutter_chain);
-  gst_pad_use_fixed_caps (filter->sinkpad);
-
-  gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
-  gst_pad_use_fixed_caps (filter->srcpad);
 }
 
 static GstMessage *
@@ -232,67 +222,104 @@ gst_cutter_calculate_##TYPE (TYPE * in, guint num,                            \
 DEFINE_CUTTER_CALCULATOR (gint16, 15);
 DEFINE_CUTTER_CALCULATOR (gint8, 7);
 
+static gboolean
+gst_cutter_setcaps (GstCutter * filter, GstCaps * caps)
+{
+  GstAudioInfo info;
+
+  if (!gst_audio_info_from_caps (&info, caps))
+    return FALSE;
+
+  filter->info = info;
+
+  return gst_pad_set_caps (filter->srcpad, caps);
+}
+
+static gboolean
+gst_cutter_event (GstPad * pad, GstEvent * event)
+{
+  gboolean ret;
+  GstCutter *filter;
+
+  filter = GST_CUTTER (GST_OBJECT_PARENT (pad));
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+
+      gst_event_parse_caps (event, &caps);
+      ret = gst_cutter_setcaps (filter, caps);
+      break;
+    }
+    default:
+      ret = gst_pad_event_default (pad, event);
+      break;
+  }
+  return ret;
+}
 
 static GstFlowReturn
 gst_cutter_chain (GstPad * pad, GstBuffer * buf)
 {
+  GstFlowReturn ret = GST_FLOW_OK;
   GstCutter *filter;
   gint16 *in_data;
+  gint bpf, rate;
+  gsize in_size;
   guint num_samples;
   gdouble NCS = 0.0;            /* Normalized Cumulative Square of buffer */
   gdouble RMS = 0.0;            /* RMS of signal in buffer */
   gdouble NMS = 0.0;            /* Normalized Mean Square of buffer */
   GstBuffer *prebuf;            /* pointer to a prebuffer element */
-
-  g_return_val_if_fail (pad != NULL, GST_FLOW_ERROR);
-  g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
-  g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
+  GstClockTime duration;
 
   filter = GST_CUTTER (GST_OBJECT_PARENT (pad));
-  g_return_val_if_fail (filter != NULL, GST_FLOW_ERROR);
-  g_return_val_if_fail (GST_IS_CUTTER (filter), GST_FLOW_ERROR);
 
-  if (!filter->have_caps) {
-    if (!(gst_cutter_get_caps (pad, filter)))
-      return GST_FLOW_NOT_NEGOTIATED;
-  }
+  if (GST_AUDIO_INFO_FORMAT (&filter->info) == GST_AUDIO_FORMAT_UNKNOWN)
+    goto not_negotiated;
+
+  bpf = GST_AUDIO_INFO_BPF (&filter->info);
+  rate = GST_AUDIO_INFO_RATE (&filter->info);
+
+  in_data = gst_buffer_map (buf, &in_size, NULL, GST_MAP_READ);
 
-  in_data = (gint16 *) GST_BUFFER_DATA (buf);
   GST_LOG_OBJECT (filter, "length of prerec buffer: %" GST_TIME_FORMAT,
       GST_TIME_ARGS (filter->pre_run_length));
 
   /* calculate mean square value on buffer */
-  switch (filter->width) {
-    case 16:
-      num_samples = GST_BUFFER_SIZE (buf) / 2;
+  switch (GST_AUDIO_INFO_FORMAT (&filter->info)) {
+    case GST_AUDIO_FORMAT_S16:
+      num_samples = in_size / 2;
       gst_cutter_calculate_gint16 (in_data, num_samples, &NCS);
       NMS = NCS / num_samples;
       break;
-    case 8:
-      num_samples = GST_BUFFER_SIZE (buf);
+    case GST_AUDIO_FORMAT_S8:
+      num_samples = in_size;
       gst_cutter_calculate_gint8 ((gint8 *) in_data, num_samples, &NCS);
       NMS = NCS / num_samples;
       break;
     default:
       /* this shouldn't happen */
-      g_warning ("no mean square function for width %d\n", filter->width);
+      g_warning ("no mean square function for format");
       break;
   }
 
+  gst_buffer_unmap (buf, in_data, in_size);
+
   filter->silent_prev = filter->silent;
 
+  duration = gst_util_uint64_scale (in_size / bpf, GST_SECOND, rate);
+
   RMS = sqrt (NMS);
   /* if RMS below threshold, add buffer length to silent run length count
    * if not, reset
    */
   GST_LOG_OBJECT (filter, "buffer stats: NMS %f, RMS %f, audio length %f", NMS,
-      RMS,
-      gst_guint64_to_gdouble (gst_audio_duration_from_pad_buffer
-          (filter->sinkpad, buf)));
+      RMS, gst_guint64_to_gdouble (duration));
+
   if (RMS < filter->threshold_level)
-    filter->silent_run_length +=
-        gst_guint64_to_gdouble (gst_audio_duration_from_pad_buffer
-        (filter->sinkpad, buf));
+    filter->silent_run_length += gst_guint64_to_gdouble (duration);
   else {
     filter->silent_run_length = 0 * GST_SECOND;
     filter->silent = FALSE;
@@ -321,6 +348,7 @@ gst_cutter_chain (GstPad * pad, GstBuffer * buf)
       /* first of all, flush current buffer */
       GST_DEBUG_OBJECT (filter, "flushing buffer of length %" GST_TIME_FORMAT,
           GST_TIME_ARGS (filter->pre_run_length));
+
       while (filter->pre_buffer) {
         prebuf = (g_list_first (filter->pre_buffer))->data;
         filter->pre_buffer = g_list_remove (filter->pre_buffer, prebuf);
@@ -335,50 +363,39 @@ gst_cutter_chain (GstPad * pad, GstBuffer * buf)
    * or to the srcpad */
   if (filter->silent) {
     filter->pre_buffer = g_list_append (filter->pre_buffer, buf);
-    filter->pre_run_length +=
-        gst_guint64_to_gdouble (gst_audio_duration_from_pad_buffer
-        (filter->sinkpad, buf));
+    filter->pre_run_length += gst_guint64_to_gdouble (duration);
+
     while (filter->pre_run_length > filter->pre_length) {
+      GstClockTime pduration;
+      gsize psize;
+
       prebuf = (g_list_first (filter->pre_buffer))->data;
       g_assert (GST_IS_BUFFER (prebuf));
+
+      psize = gst_buffer_get_size (prebuf);
+      pduration = gst_util_uint64_scale (psize / bpf, GST_SECOND, rate);
+
       filter->pre_buffer = g_list_remove (filter->pre_buffer, prebuf);
-      filter->pre_run_length -=
-          gst_guint64_to_gdouble (gst_audio_duration_from_pad_buffer
-          (filter->sinkpad, prebuf));
+      filter->pre_run_length -= gst_guint64_to_gdouble (pduration);
+
       /* only pass buffers if we don't leak */
       if (!filter->leaky)
-        gst_pad_push (filter->srcpad, prebuf);
+        ret = gst_pad_push (filter->srcpad, prebuf);
       else
         gst_buffer_unref (prebuf);
     }
   } else
-    gst_pad_push (filter->srcpad, buf);
-
-  return GST_FLOW_OK;
-}
+    ret = gst_pad_push (filter->srcpad, buf);
 
+  return ret;
 
-static gboolean
-gst_cutter_get_caps (GstPad * pad, GstCutter * filter)
-{
-  GstCaps *caps;
-  GstStructure *structure;
-
-  caps = gst_pad_get_caps (pad);
-  if (!caps) {
-    GST_INFO ("no caps on pad %s:%s", GST_DEBUG_PAD_NAME (pad));
-    return FALSE;
+  /* ERRORS */
+not_negotiated:
+  {
+    return GST_FLOW_NOT_NEGOTIATED;
   }
-  structure = gst_caps_get_structure (caps, 0);
-  gst_structure_get_int (structure, "width", &filter->width);
-  filter->max_sample = 1 << (filter->width - 1);        /* signed */
-  filter->have_caps = TRUE;
-
-  gst_caps_unref (caps);
-  return TRUE;
 }
 
-
 static void
 gst_cutter_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec)
index d64c301..47c1750 100644 (file)
@@ -54,7 +54,6 @@ struct _GstCutter
   double threshold_level;       /* level below which to cut */
   double threshold_length;      /* how long signal has to remain
                                  * below this level before cutting */
-
   double silent_run_length;     /* how long has it been below threshold ? */
   gboolean silent;
   gboolean silent_prev;
@@ -64,9 +63,7 @@ struct _GstCutter
   GList *pre_buffer;            /* list of GstBuffers in pre-record buffer */
   gboolean leaky;               /* do we leak an overflowing prebuffer ? */
 
-  gboolean have_caps;           /* did we get the needed caps yet ? */
-  gint width;                   /* bit width of data */
-  long max_sample;              /* maximum sample value */
+  GstAudioInfo info;
 };
 
 struct _GstCutterClass
index 7f3edf0..4361795 100644 (file)
@@ -1,7 +1,7 @@
 if GST_HAVE_MMAP
-EFENCE_PLUGIN=libgstefence.la
-else
 EFENCE_PLUGIN=
+else
+EFENCE_PLUGIN=libgstefence.la
 endif
 
 plugin_LTLIBRARIES = $(EFENCE_PLUGIN) libgstdebug.la libgstnavigationtest.la 
@@ -35,7 +35,6 @@ libgstnavigationtest_la_LIBTOOLFLAGS = --tag=disable-static
 libgstdebug_la_SOURCES = \
        gstdebug.c \
        breakmydata.c \
-       gstcapsdebug.c \
        gstcapssetter.c \
        gstnavseek.c \
        gstpushfilesrc.c \
@@ -46,6 +45,8 @@ libgstdebug_la_SOURCES = \
        cpureport.c \
        testplugin.c
 
+#      gstcapsdebug.c
+
 libgstdebug_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS)
 libgstdebug_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS)
 libgstdebug_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
index c4009fc..d641623 100644 (file)
@@ -45,6 +45,8 @@ GST_DEBUG_CATEGORY_STATIC (gst_break_my_data_debug);
 #define GST_IS_BREAK_MY_DATA_CLASS(klass) \
   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BREAK_MY_DATA))
 
+GType gst_break_my_data_get_type (void);
+
 enum
 {
   ARG_0,
@@ -95,40 +97,24 @@ GstStaticPadTemplate bmd_sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS_ANY);
 
-
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_break_my_data_debug, "breakmydata", 0, \
-      "debugging category for breakmydata element");
-
-GType gst_break_my_data_get_type (void);
-GST_BOILERPLATE_FULL (GstBreakMyData, gst_break_my_data, GstBaseTransform,
-    GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
+#define gst_break_my_data_parent_class parent_class
+G_DEFINE_TYPE (GstBreakMyData, gst_break_my_data, GST_TYPE_BASE_TRANSFORM);
 
 
 static void
-gst_break_my_data_base_init (gpointer g_class)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&bmd_sink_template));
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&bmd_src_template));
-
-  gst_element_class_set_details_simple (gstelement_class, "Break my data",
-      "Testing",
-      "randomly change data in the stream", "Benjamin Otte <otte@gnome>");
-}
-
-static void
 gst_break_my_data_class_init (GstBreakMyDataClass * klass)
 {
   GstBaseTransformClass *gstbasetrans_class;
+  GstElementClass *gstelement_class;
   GObjectClass *gobject_class;
 
   gobject_class = G_OBJECT_CLASS (klass);
+  gstelement_class = GST_ELEMENT_CLASS (klass);
   gstbasetrans_class = GST_BASE_TRANSFORM_CLASS (klass);
 
+  GST_DEBUG_CATEGORY_INIT (gst_break_my_data_debug, "breakmydata", 0,
+      "debugging category for breakmydata element");
+
   gobject_class->set_property = gst_break_my_data_set_property;
   gobject_class->get_property = gst_break_my_data_get_property;
 
@@ -152,6 +138,15 @@ gst_break_my_data_class_init (GstBreakMyDataClass * klass)
           "probability for each byte in the buffer to be changed", 0.0, 1.0,
           0.0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&bmd_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&bmd_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "Break my data",
+      "Testing",
+      "randomly change data in the stream", "Benjamin Otte <otte@gnome>");
+
   gstbasetrans_class->transform_ip =
       GST_DEBUG_FUNCPTR (gst_break_my_data_transform_ip);
   gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_break_my_data_start);
@@ -159,7 +154,7 @@ gst_break_my_data_class_init (GstBreakMyDataClass * klass)
 }
 
 static void
-gst_break_my_data_init (GstBreakMyData * bmd, GstBreakMyDataClass * g_class)
+gst_break_my_data_init (GstBreakMyData * bmd)
 {
   gst_base_transform_set_in_place (GST_BASE_TRANSFORM (bmd), TRUE);
 }
@@ -226,7 +221,8 @@ static GstFlowReturn
 gst_break_my_data_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
 {
   GstBreakMyData *bmd = GST_BREAK_MY_DATA (trans);
-  guint i, size;
+  guint8 *data;
+  gsize i, size;
 
   g_return_val_if_fail (gst_buffer_is_writable (buf), GST_FLOW_ERROR);
 
@@ -238,7 +234,7 @@ gst_break_my_data_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
     i = 0;
   }
 
-  size = GST_BUFFER_SIZE (buf);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
 
   GST_LOG_OBJECT (bmd,
       "got buffer %p (size %u, timestamp %" G_GUINT64_FORMAT ", offset %"
@@ -255,13 +251,14 @@ gst_break_my_data_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
         new = bmd->set;
       }
       GST_INFO_OBJECT (bmd, "changing byte %u from 0x%02X to 0x%02X", i,
-          (guint) GST_READ_UINT8 (GST_BUFFER_DATA (buf) + i),
-          (guint) ((guint8) new));
-      GST_BUFFER_DATA (buf)[i] = new;
+          (guint) GST_READ_UINT8 (data + i), (guint) ((guint8) new));
+      data[i] = new;
     }
   }
   /* don't overflow */
-  bmd->skipped += MIN (G_MAXUINT - bmd->skipped, GST_BUFFER_SIZE (buf));
+  bmd->skipped += MIN (G_MAXUINT - bmd->skipped, size);
+
+  gst_buffer_unmap (buf, data, size);
 
   GST_OBJECT_UNLOCK (bmd);
 
index a528769..8ddaf83 100644 (file)
@@ -50,24 +50,8 @@ static GstFlowReturn gst_cpu_report_transform_ip (GstBaseTransform * trans,
 static gboolean gst_cpu_report_start (GstBaseTransform * trans);
 static gboolean gst_cpu_report_stop (GstBaseTransform * trans);
 
-GST_BOILERPLATE (GstCpuReport, gst_cpu_report, GstBaseTransform,
-    GST_TYPE_BASE_TRANSFORM);
-
-static void
-gst_cpu_report_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&cpu_report_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&cpu_report_src_template));
-
-  gst_element_class_set_details_simple (element_class, "CPU report",
-      "Testing",
-      "Post cpu usage information every buffer",
-      "Zaheer Abbas Merali <zaheerabbas at merali dot org>");
-}
+#define gst_cpu_report_parent_class parent_class
+G_DEFINE_TYPE (GstCpuReport, gst_cpu_report, GST_TYPE_BASE_TRANSFORM);
 
 static void
 gst_cpu_report_finalize (GObject * obj)
@@ -79,13 +63,25 @@ static void
 gst_cpu_report_class_init (GstCpuReportClass * g_class)
 {
   GstBaseTransformClass *gstbasetrans_class;
+  GstElementClass *element_class;
   GObjectClass *gobject_class;
 
   gobject_class = G_OBJECT_CLASS (g_class);
+  element_class = GST_ELEMENT_CLASS (g_class);
   gstbasetrans_class = GST_BASE_TRANSFORM_CLASS (g_class);
 
   gobject_class->finalize = gst_cpu_report_finalize;
 
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&cpu_report_sink_template));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&cpu_report_src_template));
+
+  gst_element_class_set_details_simple (element_class, "CPU report",
+      "Testing",
+      "Post cpu usage information every buffer",
+      "Zaheer Abbas Merali <zaheerabbas at merali dot org>");
+
   gstbasetrans_class->transform_ip =
       GST_DEBUG_FUNCPTR (gst_cpu_report_transform_ip);
   gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_cpu_report_start);
@@ -93,7 +89,7 @@ gst_cpu_report_class_init (GstCpuReportClass * g_class)
 }
 
 static void
-gst_cpu_report_init (GstCpuReport * report, GstCpuReportClass * g_class)
+gst_cpu_report_init (GstCpuReport * report)
 {
   gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (report), TRUE);
 
index fa64326..9aa9d2d 100644 (file)
@@ -84,26 +84,40 @@ static gboolean gst_efence_activate_src_pull (GstPad * pad, gboolean active);
 
 static GstElementClass *parent_class = NULL;
 
-typedef struct _GstFencedBuffer GstFencedBuffer;
-struct _GstFencedBuffer
+typedef struct _GstMetaFenced
 {
-  GstBuffer buffer;
+  GstMeta meta;
+
   void *region;
   unsigned int length;
-};
+} GstMetaFenced;
+
+static const GstMetaInfo *
+gst_meta_fenced_get_info (void)
+{
+  static const GstMetaInfo *meta_fenced_info = NULL;
+
+  if (meta_fenced_info == NULL) {
+    meta_fenced_info = gst_meta_register ("GstMetaFenced", "GstMetaFenced",
+        sizeof (GstMetaFenced),
+        (GstMetaInitFunction) NULL,
+        (GstMetaFreeFunction) NULL,
+        (GstMetaCopyFunction) NULL, (GstMetaTransformFunction) NULL);
+  }
+  return meta_fenced_info;
+}
 
-GType gst_fenced_buffer_get_type (void);
-static void gst_fenced_buffer_finalize (GstFencedBuffer * buf);
-static GstFencedBuffer *gst_fenced_buffer_copy (const GstBuffer * buffer);
+#define GST_META_FENCED_GET(buf) ((GstMetaFenced *)gst_buffer_get_meta(buf,gst_meta_fenced_get_info()))
+#define GST_META_FENCED_ADD(buf) ((GstMetaFenced *)gst_buffer_add_meta(buf,gst_meta_fenced_get_info(),NULL))
+
+static void gst_fenced_buffer_dispose (GstBuffer * buf);
+static GstBuffer *gst_fenced_buffer_copy (const GstBuffer * buffer);
 static void *gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
     gboolean fence_top);
+#if 0
 static GstFlowReturn gst_efence_buffer_alloc (GstPad * pad, guint64 offset,
     guint size, GstCaps * caps, GstBuffer ** buf);
-
-#define GST_TYPE_FENCED_BUFFER (gst_fenced_buffer_get_type())
-
-#define GST_IS_FENCED_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FENCED_BUFFER))
-#define GST_FENCED_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_FENCED_BUFFER, GstFencedBuffer))
+#endif
 
 GType
 gst_gst_efence_get_type (void)
@@ -182,8 +196,10 @@ gst_efence_init (GstEFence * filter)
       GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps));
   gst_pad_set_chain_function (filter->sinkpad,
       GST_DEBUG_FUNCPTR (gst_efence_chain));
+#if 0
   gst_pad_set_bufferalloc_function (filter->sinkpad,
       GST_DEBUG_FUNCPTR (gst_efence_buffer_alloc));
+#endif
   gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
 
   filter->srcpad =
@@ -217,11 +233,13 @@ gst_efence_chain (GstPad * pad, GstBuffer * buffer)
   efence = GST_EFENCE (GST_OBJECT_PARENT (pad));
   g_return_val_if_fail (GST_IS_EFENCE (efence), GST_FLOW_ERROR);
 
+#if 0
   if (GST_IS_FENCED_BUFFER (buffer)) {
     GST_DEBUG_OBJECT (efence, "Passing on existing fenced buffer with caps %"
         GST_PTR_FORMAT, GST_BUFFER_CAPS (buffer));
     return gst_pad_push (efence->srcpad, buffer);
   }
+#endif
 
   copy = (GstBuffer *) gst_fenced_buffer_copy (buffer);
 
@@ -277,6 +295,7 @@ gst_efence_activate_src_pull (GstPad * pad, gboolean active)
   return gst_pad_activate_pull (efence->sinkpad, active);
 }
 
+#if 0
 static GstFlowReturn
 gst_efence_buffer_alloc (GstPad * pad, guint64 offset,
     guint size, GstCaps * caps, GstBuffer ** buf)
@@ -306,6 +325,7 @@ gst_efence_buffer_alloc (GstPad * pad, guint64 offset,
 
   return GST_FLOW_OK;
 }
+#endif
 
 static void
 gst_efence_set_property (GObject * object, guint prop_id,
@@ -374,29 +394,23 @@ GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
     plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
 
 
-static GstBufferClass *fenced_buffer_parent_class = NULL;
-
 static void
-gst_fenced_buffer_finalize (GstFencedBuffer * buffer)
+gst_fenced_buffer_dispose (GstBuffer * buffer)
 {
-  GstFencedBuffer *fenced_buffer;
+  GstMetaFenced *meta;
 
-  GST_DEBUG ("free buffer=%p", buffer);
+  meta = GST_META_FENCED_GET (buffer);
 
-  fenced_buffer = GST_FENCED_BUFFER (buffer);
+  GST_DEBUG ("free buffer=%p", buffer);
 
   /* free our data */
   if (GST_BUFFER_DATA (buffer)) {
-    GST_DEBUG ("free region %p %d", fenced_buffer->region,
-        fenced_buffer->length);
-    munmap (fenced_buffer->region, fenced_buffer->length);
+    GST_DEBUG ("free region %p %d", meta->region, meta->length);
+    munmap (meta->region, meta->length);
   }
-
-  GST_MINI_OBJECT_CLASS (fenced_buffer_parent_class)->finalize (GST_MINI_OBJECT
-      (buffer));
 }
 
-static GstFencedBuffer *
+static GstBuffer *
 gst_fenced_buffer_copy (const GstBuffer * buffer)
 {
   GstBuffer *copy;
@@ -406,11 +420,10 @@ gst_fenced_buffer_copy (const GstBuffer * buffer)
   g_return_val_if_fail (buffer != NULL, NULL);
 
   /* create a fresh new buffer */
-  copy = (GstBuffer *) gst_mini_object_new (GST_TYPE_FENCED_BUFFER);
+  copy = gst_buffer_new ();
 
   /* we simply copy everything from our parent */
-  ptr = gst_fenced_buffer_alloc (GST_BUFFER (copy),
-      GST_BUFFER_SIZE (buffer), TRUE);
+  ptr = gst_fenced_buffer_alloc (copy, GST_BUFFER_SIZE (buffer), TRUE);
   memcpy (ptr, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
 
   /* copy relevant flags */
@@ -434,7 +447,7 @@ gst_fenced_buffer_copy (const GstBuffer * buffer)
       ", caps: %" GST_PTR_FORMAT, buffer,
       GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (copy)), GST_BUFFER_CAPS (copy));
 
-  return GST_FENCED_BUFFER (copy);
+  return copy;
 }
 
 void *
@@ -443,7 +456,7 @@ gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
 {
   int alloc_size;
   void *region;
-  GstFencedBuffer *fenced_buffer = (GstFencedBuffer *) buffer;
+  GstMetaFenced *meta;
   int page_size;
 
   GST_DEBUG ("buffer=%p length=%d fence_top=%d", buffer, length, fence_top);
@@ -467,21 +480,29 @@ gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
     g_warning ("mmap failed");
     return NULL;
   }
+
+  GST_MINI_OBJECT_CAST (buffer)->dispose =
+      (GstMiniObjectDisposeFunction) gst_fenced_buffer_dispose;
+  GST_MINI_OBJECT_CAST (buffer)->copy =
+      (GstMiniObjectCopyFunction) gst_fenced_buffer_copy;
+
+  meta = GST_META_FENCED_ADD (buffer);
+
 #if 0
   munmap (region, page_size);
   munmap (region + alloc_size - page_size, page_size);
 
-  fenced_buffer->region = region + page_size;
-  fenced_buffer->length = alloc_size - page_size;
+  meta->region = region + page_size;
+  meta->length = alloc_size - page_size;
 #else
   mprotect (region, page_size, PROT_NONE);
   mprotect ((char *) region + alloc_size - page_size, page_size, PROT_NONE);
 
-  fenced_buffer->region = region;
-  fenced_buffer->length = alloc_size;
+  meta->region = region;
+  meta->length = alloc_size;
 #endif
 
-  GST_DEBUG ("new region %p %d", fenced_buffer->region, fenced_buffer->length);
+  GST_DEBUG ("new region %p %d", meta->region, meta->length);
 
   if (fence_top) {
     int offset;
@@ -494,39 +515,3 @@ gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
     return (void *) ((char *) region + page_size);
   }
 }
-
-static void
-gst_fenced_buffer_class_init (gpointer g_class, gpointer class_data)
-{
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
-
-  fenced_buffer_parent_class = g_type_class_peek_parent (g_class);
-
-  mini_object_class->finalize =
-      (GstMiniObjectFinalizeFunction) gst_fenced_buffer_finalize;
-  mini_object_class->copy = (GstMiniObjectCopyFunction) gst_fenced_buffer_copy;
-}
-
-GType
-gst_fenced_buffer_get_type (void)
-{
-  static GType fenced_buf_type = 0;
-
-  if (G_UNLIKELY (!fenced_buf_type)) {
-    static const GTypeInfo fenced_buf_info = {
-      sizeof (GstBufferClass),
-      NULL,
-      NULL,
-      (GClassInitFunc) gst_fenced_buffer_class_init,
-      NULL,
-      NULL,
-      sizeof (GstFencedBuffer),
-      0,
-      NULL,
-    };
-
-    fenced_buf_type = g_type_register_static (GST_TYPE_BUFFER,
-        "GstFencedBuffer", &fenced_buf_info, 0);
-  }
-  return fenced_buf_type;
-}
index dcb0996..6a15d3f 100644 (file)
@@ -61,26 +61,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
 
 /* class initialization */
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_caps_debug_debug, "capsdebug", 0, \
-      "debug category for capsdebug element");
-
-GST_BOILERPLATE_FULL (GstCapsDebug, gst_caps_debug, GstElement,
-    GST_TYPE_ELEMENT, DEBUG_INIT);
-
-static void
-gst_caps_debug_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_caps_debug_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_caps_debug_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "Caps debug",
-      "Generic", "Debug caps negotiation", "David Schleef <ds@schleef.org>");
-}
+#define gst_caps_debug_parent_class parent_class
+G_DEFINE_TYPE (GstCapsDebug, gst_caps_debug, GST_TYPE_ELEMENT);
 
 static void
 gst_caps_debug_class_init (GstCapsDebugClass * klass)
@@ -92,11 +74,20 @@ gst_caps_debug_class_init (GstCapsDebugClass * klass)
   gobject_class->finalize = gst_caps_debug_finalize;
   element_class->change_state = GST_DEBUG_FUNCPTR (gst_caps_debug_change_state);
 
+  GST_DEBUG_CATEGORY_INIT (gst_caps_debug_debug, "capsdebug", 0,
+      "debug category for capsdebug element");
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&gst_caps_debug_src_template));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&gst_caps_debug_sink_template));
+
+  gst_element_class_set_details_simple (element_class, "Caps debug",
+      "Generic", "Debug caps negotiation", "David Schleef <ds@schleef.org>");
 }
 
 static void
-gst_caps_debug_init (GstCapsDebug * capsdebug,
-    GstCapsDebugClass * capsdebug_class)
+gst_caps_debug_init (GstCapsDebug * capsdebug)
 {
 
   capsdebug->srcpad =
index d01408e..977a502 100644 (file)
@@ -97,10 +97,10 @@ GST_STATIC_PAD_TEMPLATE (GST_BASE_TRANSFORM_SINK_NAME,
 
 
 static gboolean gst_caps_setter_transform_size (GstBaseTransform * trans,
-    GstPadDirection direction, GstCaps * caps, guint size,
-    GstCaps * othercaps, guint * othersize);
+    GstPadDirection direction, GstCaps * caps, gsize size,
+    GstCaps * othercaps, gsize * othersize);
 static GstCaps *gst_caps_setter_transform_caps (GstBaseTransform * trans,
-    GstPadDirection direction, GstCaps * caps);
+    GstPadDirection direction, GstCaps * caps, GstCaps * cfilter);
 static GstFlowReturn gst_caps_setter_transform_ip (GstBaseTransform * btrans,
     GstBuffer * in);
 
@@ -111,29 +111,14 @@ static void gst_caps_setter_set_property (GObject * object, guint prop_id,
 static void gst_caps_setter_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-GST_BOILERPLATE (GstCapsSetter, gst_caps_setter, GstBaseTransform,
-    GST_TYPE_BASE_TRANSFORM);
-
-static void
-gst_caps_setter_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "CapsSetter",
-      "Generic",
-      "Set/merge caps on stream",
-      "Mark Nauwelaerts <mnauw@users.sourceforge.net>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_caps_setter_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_caps_setter_src_template));
-}
+#define gst_caps_setter_parent_class parent_class
+G_DEFINE_TYPE (GstCapsSetter, gst_caps_setter, GST_TYPE_BASE_TRANSFORM);
 
 static void
 gst_caps_setter_class_init (GstCapsSetterClass * g_class)
 {
   GObjectClass *gobject_class = (GObjectClass *) g_class;
+  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) g_class;
 
   GST_DEBUG_CATEGORY_INIT (caps_setter_debug, "capssetter", 0, "capssetter");
@@ -156,6 +141,16 @@ gst_caps_setter_class_init (GstCapsSetterClass * g_class)
           "Drop fields of incoming caps", DEFAULT_REPLACE,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (element_class, "CapsSetter",
+      "Generic",
+      "Set/merge caps on stream",
+      "Mark Nauwelaerts <mnauw@users.sourceforge.net>");
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&gst_caps_setter_sink_template));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&gst_caps_setter_src_template));
+
   trans_class->transform_size =
       GST_DEBUG_FUNCPTR (gst_caps_setter_transform_size);
   trans_class->transform_caps =
@@ -165,7 +160,7 @@ gst_caps_setter_class_init (GstCapsSetterClass * g_class)
 }
 
 static void
-gst_caps_setter_init (GstCapsSetter * filter, GstCapsSetterClass * g_class)
+gst_caps_setter_init (GstCapsSetter * filter)
 {
   filter->caps = gst_caps_new_any ();
   filter->join = DEFAULT_JOIN;
@@ -184,8 +179,8 @@ gst_caps_setter_finalize (GObject * object)
 
 static gboolean
 gst_caps_setter_transform_size (GstBaseTransform * trans,
-    GstPadDirection direction, GstCaps * caps, guint size,
-    GstCaps * othercaps, guint * othersize)
+    GstPadDirection direction, GstCaps * caps, gsize size,
+    GstCaps * othercaps, gsize * othersize)
 {
   *othersize = size;
 
@@ -194,7 +189,7 @@ gst_caps_setter_transform_size (GstBaseTransform * trans,
 
 static GstCaps *
 gst_caps_setter_transform_caps (GstBaseTransform * trans,
-    GstPadDirection direction, GstCaps * caps)
+    GstPadDirection direction, GstCaps * caps, GstCaps * cfilter)
 {
   GstCapsSetter *filter = GST_CAPS_SETTER (trans);
   GstCaps *ret, *filter_caps;
index de57285..dacad5a 100644 (file)
@@ -24,7 +24,7 @@
 #include <gst/gst.h>
 
 GType gst_break_my_data_get_type (void);
-GType gst_caps_debug_get_type (void);
+//GType gst_caps_debug_get_type (void);
 GType gst_caps_setter_get_type (void);
 GType gst_rnd_buffer_size_get_type (void);
 GType gst_navseek_get_type (void);
@@ -57,8 +57,10 @@ plugin_init (GstPlugin * plugin)
           gst_tag_inject_get_type ())
       || !gst_element_register (plugin, "testsink", GST_RANK_NONE,
           gst_test_get_type ())
+#if 0
       || !gst_element_register (plugin, "capsdebug", GST_RANK_NONE,
           gst_caps_debug_get_type ())
+#endif
       || !gst_element_register (plugin, "cpureport", GST_RANK_NONE,
           gst_cpu_report_get_type ()))
 
index dfa00c6..a9ed443 100644 (file)
@@ -39,14 +39,14 @@ static GstStaticPadTemplate gst_navigationtest_src_template =
 GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("I420"))
     );
 
 static GstStaticPadTemplate gst_navigationtest_sink_template =
 GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("I420"))
     );
 
 static GstVideoFilterClass *parent_class = NULL;
@@ -65,8 +65,8 @@ gst_navigationtest_handle_src_event (GstPad * pad, GstEvent * event)
       const GstStructure *s = gst_event_get_structure (event);
       gint fps_n, fps_d;
 
-      fps_n = gst_value_get_fraction_numerator ((&navtest->framerate));
-      fps_d = gst_value_get_fraction_denominator ((&navtest->framerate));
+      fps_n = GST_VIDEO_INFO_FPS_N (&navtest->info);
+      fps_d = GST_VIDEO_INFO_FPS_D (&navtest->info);
 
       type = gst_structure_get_string (s, "event");
       if (g_str_equal (type, "mouse-move")) {
@@ -116,7 +116,7 @@ gst_navigationtest_handle_src_event (GstPad * pad, GstEvent * event)
 
 static gboolean
 gst_navigationtest_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
-    guint * size)
+    gsize * size)
 {
   GstNavigationtest *navtest;
   GstStructure *structure;
@@ -143,31 +143,34 @@ gst_navigationtest_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstNavigationtest *navtest = GST_NAVIGATIONTEST (btrans);
-  gboolean ret = FALSE;
-  GstStructure *structure;
+  GstVideoInfo info;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  if (gst_structure_get_int (structure, "width", &navtest->width) &&
-      gst_structure_get_int (structure, "height", &navtest->height)) {
-    const GValue *framerate;
+  navtest->info = info;
 
-    framerate = gst_structure_get_value (structure, "framerate");
-    if (framerate && GST_VALUE_HOLDS_FRACTION (framerate)) {
-      g_value_copy (framerate, &navtest->framerate);
-      ret = TRUE;
-    }
-  }
+  return TRUE;
 
-  return ret;
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_ERROR_OBJECT (navtest, "invalid caps");
+    return FALSE;
+  }
 }
 
 static void
-draw_box_planar411 (guint8 * dest, int width, int height, int x, int y,
+draw_box_planar411 (GstVideoFrame * frame, int x, int y,
     guint8 colory, guint8 coloru, guint8 colorv)
 {
+  gint width, height;
   int x1, x2, y1, y2;
-  guint8 *d = dest;
+  guint8 *d;
+  gint stride;
+
+  width = GST_VIDEO_FRAME_WIDTH (frame);
+  height = GST_VIDEO_FRAME_HEIGHT (frame);
 
   if (x < 0 || y < 0 || x >= width || y >= height)
     return;
@@ -177,27 +180,34 @@ draw_box_planar411 (guint8 * dest, int width, int height, int x, int y,
   y1 = MAX (y - 5, 0);
   y2 = MIN (y + 5, height);
 
+  d = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0);
+
   for (y = y1; y < y2; y++) {
     for (x = x1; x < x2; x++) {
-      ((guint8 *) d)[y * GST_VIDEO_I420_Y_ROWSTRIDE (width) + x] = colory;
+      d[y * stride + x] = colory;
     }
   }
 
-  d = dest + GST_VIDEO_I420_U_OFFSET (width, height);
+  d = GST_VIDEO_FRAME_PLANE_DATA (frame, 1);
+  stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 1);
+
   x1 /= 2;
   x2 /= 2;
   y1 /= 2;
   y2 /= 2;
   for (y = y1; y < y2; y++) {
     for (x = x1; x < x2; x++) {
-      ((guint8 *) d)[y * GST_VIDEO_I420_U_ROWSTRIDE (width) + x] = coloru;
+      d[y * stride + x] = coloru;
     }
   }
 
-  d = dest + GST_VIDEO_I420_V_OFFSET (width, height);
+  d = GST_VIDEO_FRAME_PLANE_DATA (frame, 2);
+  stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 2);
+
   for (y = y1; y < y2; y++) {
     for (x = x1; x < x2; x++) {
-      ((guint8 *) d)[y * GST_VIDEO_I420_V_ROWSTRIDE (width) + x] = colorv;
+      d[y * stride + x] = colorv;
     }
   }
 }
@@ -208,31 +218,48 @@ gst_navigationtest_transform (GstBaseTransform * trans, GstBuffer * in,
 {
   GstNavigationtest *navtest = GST_NAVIGATIONTEST (trans);
   GSList *walk;
-  GstFlowReturn ret = GST_FLOW_OK;
+  GstVideoFrame in_frame, out_frame;
 
-  /* do something interesting here.  This simply copies the source
-   * to the destination. */
-  gst_buffer_copy_metadata (out, in, GST_BUFFER_COPY_TIMESTAMPS);
+  if (!gst_video_frame_map (&in_frame, &navtest->info, in, GST_MAP_READ))
+    goto invalid_in;
 
-  memcpy (GST_BUFFER_DATA (out), GST_BUFFER_DATA (in),
-      MIN (GST_BUFFER_SIZE (in), GST_BUFFER_SIZE (out)));
+  if (!gst_video_frame_map (&out_frame, &navtest->info, out, GST_MAP_WRITE))
+    goto invalid_out;
+
+  gst_video_frame_copy (&out_frame, &in_frame);
 
   walk = navtest->clicks;
   while (walk) {
     ButtonClick *click = walk->data;
 
     walk = g_slist_next (walk);
-    draw_box_planar411 (GST_BUFFER_DATA (out), navtest->width, navtest->height,
+    draw_box_planar411 (&out_frame,
         rint (click->x), rint (click->y), click->cy, click->cu, click->cv);
     if (--click->images_left < 1) {
       navtest->clicks = g_slist_remove (navtest->clicks, click);
       g_free (click);
     }
   }
-  draw_box_planar411 (GST_BUFFER_DATA (out), navtest->width, navtest->height,
+  draw_box_planar411 (&out_frame,
       rint (navtest->x), rint (navtest->y), 0, 128, 128);
 
-  return ret;
+  gst_video_frame_unmap (&out_frame);
+  gst_video_frame_unmap (&in_frame);
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+invalid_in:
+  {
+    GST_ERROR_OBJECT (navtest, "received invalid input buffer");
+    return GST_FLOW_OK;
+  }
+invalid_out:
+  {
+    GST_ERROR_OBJECT (navtest, "received invalid output buffer");
+    gst_video_frame_unmap (&in_frame);
+    return GST_FLOW_OK;
+  }
 }
 
 static GstStateChangeReturn
@@ -308,7 +335,6 @@ gst_navigationtest_init (GTypeInstance * instance, gpointer g_class)
 
   navtest->x = -1;
   navtest->y = -1;
-  g_value_init (&navtest->framerate, GST_TYPE_FRACTION);
 }
 
 GType
index efdbb22..6ff9ef4 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef __GST_NAVIGATIONTEST_H__
 #define __GST_NAVIGATIONTEST_H__
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -49,11 +50,9 @@ struct _GstNavigationtest
 {
   GstVideoFilter videofilter;
 
-  gint width, height;
+  GstVideoInfo info;
 
-  GValue framerate;
   gdouble x, y;
-
   GSList *clicks;
 };
 
index c7b674d..9678a92 100644 (file)
@@ -47,10 +47,12 @@ GstStaticPadTemplate navseek_sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS_ANY);
 
-static gboolean gst_navseek_event (GstBaseTransform * trans, GstEvent * event);
+static gboolean gst_navseek_sink_event (GstBaseTransform * trans,
+    GstEvent * event);
 static GstFlowReturn gst_navseek_transform_ip (GstBaseTransform * basetrans,
     GstBuffer * buf);
-static gboolean gst_navseek_handle_src_event (GstPad * pad, GstEvent * event);
+static gboolean gst_navseek_src_event (GstBaseTransform * trans,
+    GstEvent * event);
 static gboolean gst_navseek_stop (GstBaseTransform * trans);
 static gboolean gst_navseek_start (GstBaseTransform * trans);
 
@@ -60,32 +62,18 @@ static void gst_navseek_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
 GType gst_navseek_get_type (void);
-GST_BOILERPLATE (GstNavSeek, gst_navseek, GstBaseTransform,
-    GST_TYPE_BASE_TRANSFORM);
-
-static void
-gst_navseek_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&navseek_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&navseek_src_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "Seek based on left-right arrows", "Filter/Video",
-      "Seek based on navigation keys left-right",
-      "Jan Schmidt <thaytan@mad.scientist.com>");
-}
+#define gst_navseek_parent_class parent_class
+G_DEFINE_TYPE (GstNavSeek, gst_navseek, GST_TYPE_BASE_TRANSFORM);
 
 static void
 gst_navseek_class_init (GstNavSeekClass * klass)
 {
   GstBaseTransformClass *gstbasetrans_class;
+  GstElementClass *element_class;
   GObjectClass *gobject_class;
 
   gobject_class = G_OBJECT_CLASS (klass);
+  element_class = GST_ELEMENT_CLASS (klass);
   gstbasetrans_class = GST_BASE_TRANSFORM_CLASS (klass);
 
   gobject_class->set_property = gst_navseek_set_property;
@@ -96,7 +84,18 @@ gst_navseek_class_init (GstNavSeekClass * klass)
           "Time in seconds to seek by", 0.0, G_MAXDOUBLE, 5.0,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
-  gstbasetrans_class->event = GST_DEBUG_FUNCPTR (gst_navseek_event);
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&navseek_sink_template));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&navseek_src_template));
+
+  gst_element_class_set_details_simple (element_class,
+      "Seek based on left-right arrows", "Filter/Video",
+      "Seek based on navigation keys left-right",
+      "Jan Schmidt <thaytan@mad.scientist.com>");
+
+  gstbasetrans_class->src_event = GST_DEBUG_FUNCPTR (gst_navseek_src_event);
+  gstbasetrans_class->sink_event = GST_DEBUG_FUNCPTR (gst_navseek_sink_event);
   gstbasetrans_class->transform_ip =
       GST_DEBUG_FUNCPTR (gst_navseek_transform_ip);
   gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_navseek_start);
@@ -104,11 +103,8 @@ gst_navseek_class_init (GstNavSeekClass * klass)
 }
 
 static void
-gst_navseek_init (GstNavSeek * navseek, GstNavSeekClass * g_class)
+gst_navseek_init (GstNavSeek * navseek)
 {
-  gst_pad_set_event_function (GST_BASE_TRANSFORM (navseek)->srcpad,
-      GST_DEBUG_FUNCPTR (gst_navseek_handle_src_event));
-
   gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (navseek), TRUE);
 
   navseek->seek_offset = 5.0;
@@ -122,16 +118,15 @@ gst_navseek_init (GstNavSeek * navseek, GstNavSeekClass * g_class)
 static void
 gst_navseek_seek (GstNavSeek * navseek, gint64 offset)
 {
-  GstFormat peer_format = GST_FORMAT_TIME;
   gboolean ret;
   GstPad *peer_pad;
   gint64 peer_value;
 
   /* Query for the current time then attempt to set to time + offset */
   peer_pad = gst_pad_get_peer (GST_BASE_TRANSFORM (navseek)->sinkpad);
-  ret = gst_pad_query_position (peer_pad, &peer_format, &peer_value);
+  ret = gst_pad_query_position (peer_pad, GST_FORMAT_TIME, &peer_value);
 
-  if (ret && peer_format == GST_FORMAT_TIME) {
+  if (ret) {
     GstEvent *event;
 
     peer_value += offset;
@@ -151,15 +146,14 @@ gst_navseek_seek (GstNavSeek * navseek, gint64 offset)
 static void
 gst_navseek_change_playback_rate (GstNavSeek * navseek, gdouble rate)
 {
-  GstFormat peer_format = GST_FORMAT_TIME;
   gboolean ret;
   GstPad *peer_pad;
   gint64 current_position;
 
   peer_pad = gst_pad_get_peer (GST_BASE_TRANSFORM (navseek)->sinkpad);
-  ret = gst_pad_query_position (peer_pad, &peer_format, &current_position);
+  ret = gst_pad_query_position (peer_pad, GST_FORMAT_TIME, &current_position);
 
-  if (ret && peer_format == GST_FORMAT_TIME) {
+  if (ret) {
     GstEvent *event;
     gint64 start;
     gint64 stop;
@@ -212,17 +206,17 @@ gst_navseek_segseek (GstNavSeek * navseek)
 }
 
 static gboolean
-gst_navseek_handle_src_event (GstPad * pad, GstEvent * event)
+gst_navseek_src_event (GstBaseTransform * trans, GstEvent * event)
 {
   GstNavSeek *navseek;
   gboolean ret = TRUE;
 
-  navseek = GST_NAVSEEK (GST_PAD_PARENT (pad));
+  navseek = GST_NAVSEEK (trans);
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_NAVIGATION:
-      /* Check for a keyup and convert left/right to a seek event */
     {
+      /* Check for a keyup and convert left/right to a seek event */
       const GstStructure *structure;
       const gchar *event_type;
 
@@ -269,18 +263,14 @@ gst_navseek_handle_src_event (GstPad * pad, GstEvent * event)
       }
       gst_event_unref (event);
       event = NULL;
-    }
       break;
+    }
     default:
       break;
   }
 
-  if (event && GST_PAD_IS_LINKED (GST_BASE_TRANSFORM (navseek)->sinkpad)) {
-    GstPad *peer_pad = gst_pad_get_peer (GST_BASE_TRANSFORM (navseek)->sinkpad);
-
-    ret = gst_pad_send_event (peer_pad, event);
-    gst_object_unref (peer_pad);
-  }
+  if (event)
+    ret = GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans, event);
 
   return ret;
 }
@@ -322,7 +312,7 @@ gst_navseek_get_property (GObject * object, guint prop_id,
 }
 
 static gboolean
-gst_navseek_event (GstBaseTransform * trans, GstEvent * event)
+gst_navseek_sink_event (GstBaseTransform * trans, GstEvent * event)
 {
   GstNavSeek *navseek = GST_NAVSEEK (trans);
 
@@ -336,7 +326,7 @@ gst_navseek_event (GstBaseTransform * trans, GstEvent * event)
     default:
       break;
   }
-  return GST_BASE_TRANSFORM_CLASS (parent_class)->event (trans, event);
+  return GST_BASE_TRANSFORM_CLASS (parent_class)->sink_event (trans, event);
 }
 
 static GstFlowReturn
index ac4f4ba..41bc0b4 100644 (file)
@@ -55,38 +55,11 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
 
 static void gst_push_file_src_uri_handler_init (gpointer g_iface,
     gpointer iface_data);
-static void gst_file_push_src_add_uri_handler (GType type);
 
-GST_BOILERPLATE_FULL (GstPushFileSrc, gst_push_file_src, GstBin, GST_TYPE_BIN,
-    gst_file_push_src_add_uri_handler);
-
-static void
-gst_file_push_src_add_uri_handler (GType type)
-{
-  static const GInterfaceInfo info = {
-    gst_push_file_src_uri_handler_init,
-    NULL,
-    NULL
-  };
-
-  g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &info);
-  GST_DEBUG_CATEGORY_INIT (pushfilesrc_debug, "pushfilesrc", 0,
-      "pushfilesrc element");
-}
-
-static void
-gst_push_file_src_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&srctemplate));
-
-  gst_element_class_set_details_simple (element_class, "Push File Source",
-      "Testing",
-      "Implements pushfile:// URI-handler for push-based file access",
-      "Tim-Philipp Müller <tim centricular net>");
-}
+#define gst_push_file_src_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstPushFileSrc, gst_push_file_src, GST_TYPE_BIN,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
+        gst_push_file_src_uri_handler_init));
 
 static void
 gst_push_file_src_dispose (GObject * obj)
@@ -109,20 +82,44 @@ static void
 gst_push_file_src_class_init (GstPushFileSrcClass * g_class)
 {
   GObjectClass *gobject_class;
+  GstElementClass *element_class;
 
   gobject_class = G_OBJECT_CLASS (g_class);
+  element_class = GST_ELEMENT_CLASS (g_class);
+
+  GST_DEBUG_CATEGORY_INIT (pushfilesrc_debug, "pushfilesrc", 0,
+      "pushfilesrc element");
 
   gobject_class->dispose = gst_push_file_src_dispose;
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&srctemplate));
+
+  gst_element_class_set_details_simple (element_class, "Push File Source",
+      "Testing",
+      "Implements pushfile:// URI-handler for push-based file access",
+      "Tim-Philipp Müller <tim centricular net>");
 }
 
 static gboolean
-gst_push_file_src_ghostpad_checkgetrange (GstPad * pad)
+gst_push_file_src_ghostpad_query (GstPad * pad, GstQuery * query)
 {
-  return FALSE;
+  gboolean res;
+
+  switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_SCHEDULING:
+      gst_query_set_scheduling (query, FALSE, TRUE, FALSE, 1, -1, 1);
+      res = TRUE;
+      break;
+    default:
+      res = gst_proxy_pad_query_default (pad, query);
+      break;
+  }
+  return res;
 }
 
 static void
-gst_push_file_src_init (GstPushFileSrc * src, GstPushFileSrcClass * g_class)
+gst_push_file_src_init (GstPushFileSrc * src)
 {
   src->filesrc = gst_element_factory_make ("filesrc", "real-filesrc");
   if (src->filesrc) {
@@ -134,8 +131,8 @@ gst_push_file_src_init (GstPushFileSrc * src, GstPushFileSrcClass * g_class)
     src->srcpad = gst_ghost_pad_new ("src", pad);
     /* FIXME^H^HCORE: try pushfile:///foo/bar.ext ! typefind ! fakesink without
      * this and watch core bugginess (some pad stays in flushing state) */
-    gst_pad_set_checkgetrange_function (src->srcpad,
-        GST_DEBUG_FUNCPTR (gst_push_file_src_ghostpad_checkgetrange));
+    gst_pad_set_query_function (src->srcpad,
+        GST_DEBUG_FUNCPTR (gst_push_file_src_ghostpad_query));
     gst_element_add_pad (GST_ELEMENT (src), src->srcpad);
     gst_object_unref (pad);
   }
@@ -144,13 +141,13 @@ gst_push_file_src_init (GstPushFileSrc * src, GstPushFileSrcClass * g_class)
 /*** GSTURIHANDLER INTERFACE *************************************************/
 
 static GstURIType
-gst_push_file_src_uri_get_type (void)
+gst_push_file_src_uri_get_type (GType type)
 {
   return GST_URI_SRC;
 }
 
 static gchar **
-gst_push_file_src_uri_get_protocols (void)
+gst_push_file_src_uri_get_protocols (GType type)
 {
   static gchar *protocols[] = { (char *) "pushfile", NULL };
 
index a5e78fe..5d5fc76 100644 (file)
@@ -62,11 +62,8 @@ enum
 };
 
 
-#define DEBUG_INIT(bla) \
-    GST_DEBUG_CATEGORY_INIT (gst_tag_inject_debug, "taginject", 0, "tag inject element");
-
-GST_BOILERPLATE_FULL (GstTagInject, gst_tag_inject, GstBaseTransform,
-    GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
+#define gst_tag_inject_parent_class parent_class
+G_DEFINE_TYPE (GstTagInject, gst_tag_inject, GST_TYPE_BASE_TRANSFORM);
 
 static void gst_tag_inject_finalize (GObject * object);
 static void gst_tag_inject_set_property (GObject * object, guint prop_id,
@@ -80,20 +77,6 @@ static gboolean gst_tag_inject_start (GstBaseTransform * trans);
 
 
 static void
-gst_tag_inject_base_init (gpointer g_class)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (gstelement_class,
-      "TagInject",
-      "Generic", "inject metadata tags", "Stefan Kost <ensonic@users.sf.net>");
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&srctemplate));
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&sinktemplate));
-}
-
-static void
 gst_tag_inject_finalize (GObject * object)
 {
   GstTagInject *self = GST_TAG_INJECT (object);
@@ -110,11 +93,16 @@ static void
 gst_tag_inject_class_init (GstTagInjectClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseTransformClass *gstbasetrans_class;
 
   gobject_class = G_OBJECT_CLASS (klass);
+  gstelement_class = GST_ELEMENT_CLASS (klass);
   gstbasetrans_class = GST_BASE_TRANSFORM_CLASS (klass);
 
+  GST_DEBUG_CATEGORY_INIT (gst_tag_inject_debug, "taginject", 0,
+      "tag inject element");
+
   gobject_class->set_property = gst_tag_inject_set_property;
   gobject_class->get_property = gst_tag_inject_get_property;
 
@@ -125,6 +113,14 @@ gst_tag_inject_class_init (GstTagInjectClass * klass)
 
   gobject_class->finalize = gst_tag_inject_finalize;
 
+  gst_element_class_set_details_simple (gstelement_class,
+      "TagInject",
+      "Generic", "inject metadata tags", "Stefan Kost <ensonic@users.sf.net>");
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&srctemplate));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sinktemplate));
+
   gstbasetrans_class->transform_ip =
       GST_DEBUG_FUNCPTR (gst_tag_inject_transform_ip);
 
@@ -132,7 +128,7 @@ gst_tag_inject_class_init (GstTagInjectClass * klass)
 }
 
 static void
-gst_tag_inject_init (GstTagInject * self, GstTagInjectClass * g_class)
+gst_tag_inject_init (GstTagInject * self)
 {
   self->tags = NULL;
 }
index a1b2e7e..5e2eecf 100644 (file)
@@ -107,7 +107,7 @@ static void gst_progress_report_set_property (GObject * object, guint prop_id,
 static void gst_progress_report_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-static gboolean gst_progress_report_event (GstBaseTransform * trans,
+static gboolean gst_progress_report_sink_event (GstBaseTransform * trans,
     GstEvent * event);
 static GstFlowReturn gst_progress_report_transform_ip (GstBaseTransform * trans,
     GstBuffer * buf);
@@ -115,24 +115,8 @@ static GstFlowReturn gst_progress_report_transform_ip (GstBaseTransform * trans,
 static gboolean gst_progress_report_start (GstBaseTransform * trans);
 static gboolean gst_progress_report_stop (GstBaseTransform * trans);
 
-GST_BOILERPLATE (GstProgressReport, gst_progress_report, GstBaseTransform,
-    GST_TYPE_BASE_TRANSFORM);
-
-static void
-gst_progress_report_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&progress_report_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&progress_report_src_template));
-
-  gst_element_class_set_details_simple (element_class, "Progress report",
-      "Testing",
-      "Periodically query and report on processing progress",
-      "Jan Schmidt <thaytan@mad.scientist.com>");
-}
+#define gst_progress_report_parent_class parent_class
+G_DEFINE_TYPE (GstProgressReport, gst_progress_report, GST_TYPE_BASE_TRANSFORM);
 
 static void
 gst_progress_report_finalize (GObject * obj)
@@ -149,9 +133,11 @@ static void
 gst_progress_report_class_init (GstProgressReportClass * g_class)
 {
   GstBaseTransformClass *gstbasetrans_class;
+  GstElementClass *element_class;
   GObjectClass *gobject_class;
 
   gobject_class = G_OBJECT_CLASS (g_class);
+  element_class = GST_ELEMENT_CLASS (g_class);
   gstbasetrans_class = GST_BASE_TRANSFORM_CLASS (g_class);
 
   gobject_class->finalize = gst_progress_report_finalize;
@@ -179,7 +165,18 @@ gst_progress_report_class_init (GstProgressReportClass * g_class)
           "Format to use for the querying", DEFAULT_FORMAT,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
-  gstbasetrans_class->event = GST_DEBUG_FUNCPTR (gst_progress_report_event);
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&progress_report_sink_template));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&progress_report_src_template));
+
+  gst_element_class_set_details_simple (element_class, "Progress report",
+      "Testing",
+      "Periodically query and report on processing progress",
+      "Jan Schmidt <thaytan@mad.scientist.com>");
+
+  gstbasetrans_class->sink_event =
+      GST_DEBUG_FUNCPTR (gst_progress_report_sink_event);
   gstbasetrans_class->transform_ip =
       GST_DEBUG_FUNCPTR (gst_progress_report_transform_ip);
   gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_progress_report_start);
@@ -187,8 +184,7 @@ gst_progress_report_class_init (GstProgressReportClass * g_class)
 }
 
 static void
-gst_progress_report_init (GstProgressReport * report,
-    GstProgressReportClass * g_class)
+gst_progress_report_init (GstProgressReport * report)
 {
   gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (report), TRUE);
 
@@ -244,16 +240,15 @@ gst_progress_report_do_query (GstProgressReport * filter, GstFormat format,
 
   if (filter->do_query || !buf) {
     GST_LOG_OBJECT (filter, "using upstream query");
-    if (!gst_pad_query_peer_position (sink_pad, &format, &cur) ||
-        !gst_pad_query_peer_duration (sink_pad, &format, &total)) {
+    if (!gst_pad_query_peer_position (sink_pad, format, &cur) ||
+        !gst_pad_query_peer_duration (sink_pad, format, &total)) {
       return FALSE;
     }
   } else {
     GstBaseTransform *base = GST_BASE_TRANSFORM (filter);
 
     GST_LOG_OBJECT (filter, "using buffer metadata");
-    if (format == GST_FORMAT_TIME && base->have_newsegment &&
-        base->segment.format == GST_FORMAT_TIME) {
+    if (format == GST_FORMAT_TIME && base->segment.format == GST_FORMAT_TIME) {
       cur = gst_segment_to_stream_time (&base->segment, format,
           GST_BUFFER_TIMESTAMP (buf));
       total = base->segment.duration;
@@ -281,17 +276,20 @@ gst_progress_report_do_query (GstProgressReport * filter, GstFormat format,
       GstCaps *caps;
 
       format_name = "bogounits";
-      caps = GST_PAD_CAPS (GST_BASE_TRANSFORM (filter)->sinkpad);
-      if (caps && gst_caps_is_fixed (caps) && !gst_caps_is_any (caps)) {
-        GstStructure *s = gst_caps_get_structure (caps, 0);
-        const gchar *mime_type = gst_structure_get_name (s);
-
-        if (g_str_has_prefix (mime_type, "video/") ||
-            g_str_has_prefix (mime_type, "image/")) {
-          format_name = "frames";
-        } else if (g_str_has_prefix (mime_type, "audio/")) {
-          format_name = "samples";
+      caps = gst_pad_get_current_caps (GST_BASE_TRANSFORM (filter)->sinkpad);
+      if (caps) {
+        if (gst_caps_is_fixed (caps) && !gst_caps_is_any (caps)) {
+          GstStructure *s = gst_caps_get_structure (caps, 0);
+          const gchar *mime_type = gst_structure_get_name (s);
+
+          if (g_str_has_prefix (mime_type, "video/") ||
+              g_str_has_prefix (mime_type, "image/")) {
+            format_name = "frames";
+          } else if (g_str_has_prefix (mime_type, "audio/")) {
+            format_name = "samples";
+          }
         }
+        gst_caps_unref (caps);
       }
       break;
     }
@@ -377,19 +375,25 @@ gst_progress_report_report (GstProgressReport * filter, GTimeVal cur_time,
 }
 
 static gboolean
-gst_progress_report_event (GstBaseTransform * trans, GstEvent * event)
+gst_progress_report_sink_event (GstBaseTransform * trans, GstEvent * event)
 {
   GstProgressReport *filter;
 
   filter = GST_PROGRESS_REPORT (trans);
 
-  if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
-    GTimeVal cur_time;
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_EOS:
+    {
+      GTimeVal cur_time;
 
-    g_get_current_time (&cur_time);
-    gst_progress_report_report (filter, cur_time, NULL);
+      g_get_current_time (&cur_time);
+      gst_progress_report_report (filter, cur_time, NULL);
+      break;
+    }
+    default:
+      break;
   }
-  return GST_BASE_TRANSFORM_CLASS (parent_class)->event (trans, event);
+  return GST_BASE_TRANSFORM_CLASS (parent_class)->sink_event (trans, event);
 }
 
 static GstFlowReturn
index 4193490..71463a6 100644 (file)
@@ -92,19 +92,22 @@ static void gst_rnd_buffer_size_loop (GstRndBufferSize * self);
 static GstStateChangeReturn gst_rnd_buffer_size_change_state (GstElement *
     element, GstStateChange transition);
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_rnd_buffer_size_debug, "rndbuffersize", 0, \
-      "rndbuffersize element");
-
 GType gst_rnd_buffer_size_get_type (void);
-GST_BOILERPLATE_FULL (GstRndBufferSize, gst_rnd_buffer_size, GstElement,
-    GST_TYPE_ELEMENT, DEBUG_INIT);
-
+#define gst_rnd_buffer_size_parent_class parent_class
+G_DEFINE_TYPE (GstRndBufferSize, gst_rnd_buffer_size, GST_TYPE_ELEMENT);
 
 static void
-gst_rnd_buffer_size_base_init (gpointer g_class)
+gst_rnd_buffer_size_class_init (GstRndBufferSizeClass * klass)
 {
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+
+  GST_DEBUG_CATEGORY_INIT (gst_rnd_buffer_size_debug, "rndbuffersize", 0,
+      "rndbuffersize element");
+
+  gobject_class->set_property = gst_rnd_buffer_size_set_property;
+  gobject_class->get_property = gst_rnd_buffer_size_get_property;
+  gobject_class->finalize = gst_rnd_buffer_size_finalize;
 
   gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&sink_template));
@@ -114,18 +117,6 @@ gst_rnd_buffer_size_base_init (gpointer g_class)
   gst_element_class_set_details_simple (gstelement_class, "Random buffer size",
       "Testing", "pull random sized buffers",
       "Stefan Kost <stefan.kost@nokia.com>");
-}
-
-
-static void
-gst_rnd_buffer_size_class_init (GstRndBufferSizeClass * klass)
-{
-  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
-
-  gobject_class->set_property = gst_rnd_buffer_size_set_property;
-  gobject_class->get_property = gst_rnd_buffer_size_get_property;
-  gobject_class->finalize = gst_rnd_buffer_size_finalize;
 
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_change_state);
@@ -149,8 +140,7 @@ gst_rnd_buffer_size_class_init (GstRndBufferSizeClass * klass)
 }
 
 static void
-gst_rnd_buffer_size_init (GstRndBufferSize * self,
-    GstRndBufferSizeClass * g_class)
+gst_rnd_buffer_size_init (GstRndBufferSize * self)
 {
   self->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
   gst_pad_set_activate_function (self->sinkpad,
@@ -227,10 +217,28 @@ gst_rnd_buffer_size_get_property (GObject * object, guint prop_id,
 static gboolean
 gst_rnd_buffer_size_activate (GstPad * pad)
 {
-  if (gst_pad_check_pull_range (pad)) {
-    return gst_pad_activate_pull (pad, TRUE);
-  } else {
-    GST_INFO_OBJECT (pad, "push mode not supported");
+  GstQuery *query;
+  gboolean pull_mode;
+
+  query = gst_query_new_scheduling ();
+
+  if (!gst_pad_peer_query (pad, query)) {
+    gst_query_unref (query);
+    goto no_pull;
+  }
+
+  gst_query_parse_scheduling (query, &pull_mode, NULL, NULL, NULL, NULL, NULL);
+
+  if (!pull_mode)
+    goto no_pull;
+
+  GST_DEBUG_OBJECT (pad, "activating pull");
+  return gst_pad_activate_pull (pad, TRUE);
+
+  /* ERRORS */
+no_pull:
+  {
+    GST_DEBUG_OBJECT (pad, "pull mode not supported");
     return FALSE;
   }
 }
@@ -257,7 +265,7 @@ gst_rnd_buffer_size_loop (GstRndBufferSize * self)
 {
   GstBuffer *buf = NULL;
   GstFlowReturn ret;
-  guint num_bytes;
+  guint num_bytes, size;
 
   if (G_UNLIKELY (self->min > self->max))
     goto bogus_minmax;
@@ -276,11 +284,13 @@ gst_rnd_buffer_size_loop (GstRndBufferSize * self)
   if (ret != GST_FLOW_OK)
     goto pull_failed;
 
-  if (GST_BUFFER_SIZE (buf) < num_bytes) {
-    GST_WARNING_OBJECT (self, "short buffer: %u bytes", GST_BUFFER_SIZE (buf));
+  size = gst_buffer_get_size (buf);
+
+  if (size < num_bytes) {
+    GST_WARNING_OBJECT (self, "short buffer: %u bytes", size);
   }
 
-  self->offset += GST_BUFFER_SIZE (buf);
+  self->offset += size;
 
   ret = gst_pad_push (self->srcpad, buf);
 
index 51be3aa..00bebf5 100644 (file)
@@ -80,34 +80,22 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS_ANY);
 
-#define DEBUG_INIT(bla) \
-  GST_DEBUG_CATEGORY_INIT (gst_test_debug, "testsink", 0, \
-      "debugging category for testsink element");
-
 GType gst_test_get_type (void);
-GST_BOILERPLATE_FULL (GstTest, gst_test, GstBaseSink, GST_TYPE_BASE_SINK,
-    DEBUG_INIT);
-
-
-static void
-gst_test_base_init (gpointer g_class)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+#define gst_test_parent_class parent_class
+G_DEFINE_TYPE (GstTest, gst_test, GST_TYPE_BASE_SINK);
 
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&sinktemplate));
-
-  gst_element_class_set_details_simple (gstelement_class, "Test plugin",
-      "Testing", "perform a number of tests", "Benjamin Otte <otte@gnome>");
-}
 
 static void
 gst_test_class_init (GstTestClass * klass)
 {
   GstBaseSinkClass *basesink_class = GST_BASE_SINK_CLASS (klass);
+  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   guint i;
 
+  GST_DEBUG_CATEGORY_INIT (gst_test_debug, "testsink", 0,
+      "debugging category for testsink element");
+
   object_class->set_property = gst_test_set_property;
   object_class->get_property = gst_test_get_property;
 
@@ -124,6 +112,12 @@ gst_test_class_init (GstTestClass * klass)
     g_object_class_install_property (object_class, 2 * i + 2, spec);
   }
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sinktemplate));
+
+  gst_element_class_set_details_simple (gstelement_class, "Test plugin",
+      "Testing", "perform a number of tests", "Benjamin Otte <otte@gnome>");
+
   basesink_class->render = GST_DEBUG_FUNCPTR (gst_test_render_buffer);
   basesink_class->event = GST_DEBUG_FUNCPTR (gst_test_sink_event);
   basesink_class->start = GST_DEBUG_FUNCPTR (gst_test_start);
@@ -131,7 +125,7 @@ gst_test_class_init (GstTestClass * klass)
 }
 
 static void
-gst_test_init (GstTest * test, GstTestClass * g_class)
+gst_test_init (GstTest * test)
 {
   GstTestClass *klass;
   guint i;
index 93afd0e..9a20f74 100644 (file)
@@ -64,7 +64,7 @@ length_add (gpointer test, GstBuffer * buffer)
 {
   LengthTest *t = test;
 
-  t->value += GST_BUFFER_SIZE (buffer);
+  t->value += gst_buffer_get_size (buffer);
 }
 
 static gboolean
@@ -214,8 +214,12 @@ md5_new (const GstTestInfo * info)
 static void
 md5_add (gpointer checksum, GstBuffer * buffer)
 {
-  g_checksum_update (checksum, GST_BUFFER_DATA (buffer),
-      GST_BUFFER_SIZE (buffer));
+  guint8 *data;
+  gsize size;
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+  g_checksum_update (checksum, data, size);
+  gst_buffer_unmap (buffer, data, size);
 }
 
 static gboolean
index 8bd2a85..2d1af98 100644 (file)
@@ -33,7 +33,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! agingtv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! agingtv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of agingtv on a test stream.
  * </refsect2>
  */
@@ -48,7 +48,6 @@
 #include "gstaging.h"
 #include "gsteffectv.h"
 
-#include <gst/video/video.h>
 #include <gst/controller/gstcontroller.h>
 
 static const gint dx[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
@@ -69,9 +68,9 @@ enum
 #define DEFAULT_DUSTS TRUE
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define CAPS_STR GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_RGBx
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ BGRx, RGBx }")
 #else
-#define CAPS_STR GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ xRGB, xBGR }")
 #endif
 
 static GstStaticPadTemplate gst_agingtv_src_template =
@@ -88,27 +87,28 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     GST_STATIC_CAPS (CAPS_STR)
     );
 
-GST_BOILERPLATE (GstAgingTV, gst_agingtv, GstVideoFilter,
-    GST_TYPE_VIDEO_FILTER);
+G_DEFINE_TYPE (GstAgingTV, gst_agingtv, GST_TYPE_VIDEO_FILTER);
 
 static gboolean
 gst_agingtv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstAgingTV *filter = GST_AGINGTV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  GST_OBJECT_LOCK (filter);
-  if (gst_structure_get_int (structure, "width", &filter->width) &&
-      gst_structure_get_int (structure, "height", &filter->height)) {
-    ret = TRUE;
-  }
-  GST_OBJECT_UNLOCK (filter);
+  filter->info = info;
+
+  return TRUE;
 
-  return ret;
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_ERROR_OBJECT (filter, "could not parse caps");
+    return GST_FLOW_ERROR;
+  }
 }
 
 static void
@@ -327,12 +327,11 @@ gst_agingtv_transform (GstBaseTransform * trans, GstBuffer * in,
     GstBuffer * out)
 {
   GstAgingTV *agingtv = GST_AGINGTV (trans);
-  gint width, height, video_size;
-  guint32 *src = (guint32 *) GST_BUFFER_DATA (in);
-  guint32 *dest = (guint32 *) GST_BUFFER_DATA (out);
+  GstVideoFrame in_frame, out_frame;
   gint area_scale;
-  GstFlowReturn ret = GST_FLOW_OK;
   GstClockTime timestamp, stream_time;
+  gint width, height, stride, video_size;
+  guint32 *src, *dest;
 
   timestamp = GST_BUFFER_TIMESTAMP (in);
   stream_time =
@@ -344,10 +343,20 @@ gst_agingtv_transform (GstBaseTransform * trans, GstBuffer * in,
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (agingtv), stream_time);
 
-  GST_OBJECT_LOCK (agingtv);
-  width = agingtv->width;
-  height = agingtv->height;
-  video_size = width * height;
+  if (!gst_video_frame_map (&in_frame, &agingtv->info, in, GST_MAP_READ))
+    goto invalid_in;
+
+  if (!gst_video_frame_map (&out_frame, &agingtv->info, out, GST_MAP_WRITE))
+    goto invalid_out;
+
+
+  width = GST_VIDEO_FRAME_WIDTH (&in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (&in_frame);
+  stride = GST_VIDEO_FRAME_PLANE_STRIDE (&in_frame, 0);
+  video_size = stride * height;
+
+  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
 
   area_scale = width * height / 64 / 480;
   if (area_scale <= 0)
@@ -356,38 +365,38 @@ gst_agingtv_transform (GstBaseTransform * trans, GstBuffer * in,
   if (agingtv->color_aging)
     coloraging (src, dest, video_size, &agingtv->coloraging_state);
   else
-    memcpy (dest, src, GST_BUFFER_SIZE (in));
+    memcpy (dest, src, video_size);
 
   scratching (agingtv->scratches, agingtv->scratch_lines, dest, width, height);
   if (agingtv->pits)
     pits (dest, width, height, area_scale, &agingtv->pits_interval);
   if (area_scale > 1 && agingtv->dusts)
     dusts (dest, width, height, &agingtv->dust_interval, area_scale);
-  GST_OBJECT_UNLOCK (agingtv);
 
-  return ret;
-}
-
-static void
-gst_agingtv_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  gst_video_frame_unmap (&in_frame);
+  gst_video_frame_unmap (&out_frame);
 
-  gst_element_class_set_details_simple (element_class, "AgingTV effect",
-      "Filter/Effect/Video",
-      "AgingTV adds age to video input using scratches and dust",
-      "Sam Lantinga <slouken@devolution.com>");
+  return GST_FLOW_OK;
 
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_agingtv_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_agingtv_src_template));
+  /* ERRORS */
+invalid_in:
+  {
+    GST_DEBUG_OBJECT (agingtv, "invalid input frame");
+    return GST_FLOW_ERROR;
+  }
+invalid_out:
+  {
+    GST_DEBUG_OBJECT (agingtv, "invalid output frame");
+    gst_video_frame_unmap (&in_frame);
+    return GST_FLOW_ERROR;
+  }
 }
 
 static void
 gst_agingtv_class_init (GstAgingTVClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
   gobject_class->set_property = gst_agingtv_set_property;
@@ -413,13 +422,23 @@ gst_agingtv_class_init (GstAgingTVClass * klass)
           "Dusts", DEFAULT_DUSTS,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
 
+  gst_element_class_set_details_simple (gstelement_class, "AgingTV effect",
+      "Filter/Effect/Video",
+      "AgingTV adds age to video input using scratches and dust",
+      "Sam Lantinga <slouken@devolution.com>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_agingtv_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_agingtv_src_template));
+
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_agingtv_set_caps);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_agingtv_transform);
   trans_class->start = GST_DEBUG_FUNCPTR (gst_agingtv_start);
 }
 
 static void
-gst_agingtv_init (GstAgingTV * agingtv, GstAgingTVClass * klass)
+gst_agingtv_init (GstAgingTV * agingtv)
 {
   agingtv->scratch_lines = DEFAULT_SCRATCH_LINES;
   agingtv->color_aging = DEFAULT_COLOR_AGING;
index 0ac6c8e..ec02f66 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -61,8 +62,7 @@ struct _GstAgingTV
   GstVideoFilter videofilter;
 
   /* < private > */
-
-  gint width, height;
+  GstVideoInfo info;
 
   gboolean color_aging;
   gboolean pits;
index bedabe0..675ee69 100644 (file)
@@ -39,7 +39,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! dicetv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! dicetv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of dicetv on a test stream.
  * </refsect2>
  */
@@ -53,7 +53,6 @@
 #include "gstdice.h"
 #include "gsteffectv.h"
 
-#include <gst/video/video.h>
 #include <gst/controller/gstcontroller.h>
 
 #define DEFAULT_CUBE_BITS   4
@@ -68,24 +67,23 @@ typedef enum _dice_dir
   DICE_LEFT = 3
 } DiceDir;
 
-GST_BOILERPLATE (GstDiceTV, gst_dicetv, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
+#define gst_dicetv_parent_class parent_class
+G_DEFINE_TYPE (GstDiceTV, gst_dicetv, GST_TYPE_VIDEO_FILTER);
 
 static void gst_dicetv_create_map (GstDiceTV * filter);
 
 static GstStaticPadTemplate gst_dicetv_src_template =
-    GST_STATIC_PAD_TEMPLATE ("src",
+GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_xRGB ";"
-        GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ RGBx, xRGB, BGRx, xBGR }"))
     );
 
 static GstStaticPadTemplate gst_dicetv_sink_template =
-    GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_xRGB ";"
-        GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ RGBx, xRGB, BGRx, xBGR }"))
     );
 
 enum
@@ -99,39 +97,41 @@ gst_dicetv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstDiceTV *filter = GST_DICETV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  GST_OBJECT_LOCK (filter);
-  if (gst_structure_get_int (structure, "width", &filter->width) &&
-      gst_structure_get_int (structure, "height", &filter->height)) {
-    g_free (filter->dicemap);
-    filter->dicemap = (guint8 *) g_malloc (filter->height * filter->width);
-    gst_dicetv_create_map (filter);
-    ret = TRUE;
-  }
-  GST_OBJECT_UNLOCK (filter);
+  g_free (filter->dicemap);
+  filter->dicemap =
+      (guint8 *) g_malloc (GST_VIDEO_INFO_WIDTH (&info) *
+      GST_VIDEO_INFO_WIDTH (&info));
+  gst_dicetv_create_map (filter);
 
-  return ret;
+  filter->info = info;
+
+  return TRUE;
+
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid caps");
+    return FALSE;
+  }
 }
 
 static GstFlowReturn
 gst_dicetv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
 {
   GstDiceTV *filter = GST_DICETV (trans);
+  GstVideoFrame in_frame, out_frame;
   guint32 *src, *dest;
   gint i, map_x, map_y, map_i, base, dx, dy, di;
-  gint video_width, g_cube_bits, g_cube_size;
+  gint video_stride, g_cube_bits, g_cube_size;
   gint g_map_height, g_map_width;
-  GstFlowReturn ret = GST_FLOW_OK;
   GstClockTime timestamp, stream_time;
   const guint8 *dicemap;
 
-  src = (guint32 *) GST_BUFFER_DATA (in);
-  dest = (guint32 *) GST_BUFFER_DATA (out);
-
   timestamp = GST_BUFFER_TIMESTAMP (in);
   stream_time =
       gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME, timestamp);
@@ -142,8 +142,14 @@ gst_dicetv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
+  gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ);
+  gst_video_frame_map (&out_frame, &filter->info, out, GST_MAP_WRITE);
+
+  src = (guint32 *) GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  dest = (guint32 *) GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
+  video_stride = GST_VIDEO_FRAME_PLANE_STRIDE (&in_frame, 0);
+
   GST_OBJECT_LOCK (filter);
-  video_width = filter->width;
   g_cube_bits = filter->g_cube_bits;
   g_cube_size = filter->g_cube_size;
   g_map_height = filter->g_map_height;
@@ -154,12 +160,12 @@ gst_dicetv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
   map_i = 0;
   for (map_y = 0; map_y < g_map_height; map_y++) {
     for (map_x = 0; map_x < g_map_width; map_x++) {
-      base = (map_y << g_cube_bits) * video_width + (map_x << g_cube_bits);
+      base = (map_y << g_cube_bits) * video_stride + (map_x << g_cube_bits);
 
       switch (dicemap[map_i]) {
         case DICE_UP:
           for (dy = 0; dy < g_cube_size; dy++) {
-            i = base + dy * video_width;
+            i = base + dy * video_stride;
             for (dx = 0; dx < g_cube_size; dx++) {
               dest[i] = src[i];
               i++;
@@ -168,10 +174,10 @@ gst_dicetv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
           break;
         case DICE_LEFT:
           for (dy = 0; dy < g_cube_size; dy++) {
-            i = base + dy * video_width;
+            i = base + dy * video_stride;
 
             for (dx = 0; dx < g_cube_size; dx++) {
-              di = base + (dx * video_width) + (g_cube_size - dy - 1);
+              di = base + (dx * video_stride) + (g_cube_size - dy - 1);
               dest[di] = src[i];
               i++;
             }
@@ -179,8 +185,8 @@ gst_dicetv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
           break;
         case DICE_DOWN:
           for (dy = 0; dy < g_cube_size; dy++) {
-            di = base + dy * video_width;
-            i = base + (g_cube_size - dy - 1) * video_width + g_cube_size;
+            di = base + dy * video_stride;
+            i = base + (g_cube_size - dy - 1) * video_stride + g_cube_size;
             for (dx = 0; dx < g_cube_size; dx++) {
               i--;
               dest[di] = src[i];
@@ -190,9 +196,9 @@ gst_dicetv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
           break;
         case DICE_RIGHT:
           for (dy = 0; dy < g_cube_size; dy++) {
-            i = base + (dy * video_width);
+            i = base + (dy * video_stride);
             for (dx = 0; dx < g_cube_size; dx++) {
-              di = base + dy + (g_cube_size - dx - 1) * video_width;
+              di = base + dy + (g_cube_size - dx - 1) * video_stride;
               dest[di] = src[i];
               i++;
             }
@@ -207,19 +213,26 @@ gst_dicetv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
   }
   GST_OBJECT_UNLOCK (filter);
 
-  return ret;
+  gst_video_frame_unmap (&in_frame);
+  gst_video_frame_unmap (&out_frame);
+
+  return GST_FLOW_OK;
 }
 
 static void
 gst_dicetv_create_map (GstDiceTV * filter)
 {
   gint x, y, i;
+  gint width, height;
 
-  if (filter->height <= 0 || filter->width <= 0)
+  width = GST_VIDEO_INFO_WIDTH (&filter->info);
+  height = GST_VIDEO_INFO_HEIGHT (&filter->info);
+
+  if (width <= 0 || height <= 0)
     return;
 
-  filter->g_map_height = filter->height >> filter->g_cube_bits;
-  filter->g_map_width = filter->width >> filter->g_cube_bits;
+  filter->g_map_height = height >> filter->g_cube_bits;
+  filter->g_map_width = width >> filter->g_cube_bits;
   filter->g_cube_size = 1 << filter->g_cube_bits;
 
   i = 0;
@@ -280,25 +293,10 @@ gst_dicetv_finalize (GObject * object)
 }
 
 static void
-gst_dicetv_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "DiceTV effect",
-      "Filter/Effect/Video",
-      "'Dices' the screen up into many small squares",
-      "Wim Taymans <wim.taymans@chello.be>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_dicetv_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_dicetv_src_template));
-}
-
-static void
 gst_dicetv_class_init (GstDiceTVClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
   gobject_class->set_property = gst_dicetv_set_property;
@@ -310,12 +308,22 @@ gst_dicetv_class_init (GstDiceTVClass * klass)
           MIN_CUBE_BITS, MAX_CUBE_BITS, DEFAULT_CUBE_BITS,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
 
+  gst_element_class_set_details_simple (gstelement_class, "DiceTV effect",
+      "Filter/Effect/Video",
+      "'Dices' the screen up into many small squares",
+      "Wim Taymans <wim.taymans@gmail.be>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_dicetv_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_dicetv_src_template));
+
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_dicetv_set_caps);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_dicetv_transform);
 }
 
 static void
-gst_dicetv_init (GstDiceTV * filter, GstDiceTVClass * klass)
+gst_dicetv_init (GstDiceTV * filter)
 {
   filter->dicemap = NULL;
   filter->g_cube_bits = DEFAULT_CUBE_BITS;
index 856e995..0a5c3e6 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -54,8 +55,7 @@ struct _GstDiceTV
   GstVideoFilter videofilter;
 
   /* < private > */
-
-  gint width, height;
+  GstVideoInfo info;
   guint8 *dicemap;
 
   gint g_cube_bits;
index f4b7762..eddac91 100644 (file)
@@ -33,7 +33,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! edgetv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! edgetv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of edgetv on a test stream.
  * </refsect2>
  */
 
 #include "gstedge.h"
 
-#include <gst/video/video.h>
-
-GST_BOILERPLATE (GstEdgeTV, gst_edgetv, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
+#define gst_edgetv_parent_class parent_class
+G_DEFINE_TYPE (GstEdgeTV, gst_edgetv, GST_TYPE_VIDEO_FILTER);
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define CAPS_STR GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_RGBx
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{  BGRx, RGBx }")
 #else
-#define CAPS_STR GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_xRGB
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{  xBGR, xRGB }")
 #endif
 
 static GstStaticPadTemplate gst_edgetv_src_template =
@@ -75,29 +74,35 @@ gst_edgetv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstEdgeTV *edgetv = GST_EDGETV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
+  guint map_size;
+  gint width, height;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  GST_OBJECT_LOCK (edgetv);
-  if (gst_structure_get_int (structure, "width", &edgetv->width) &&
-      gst_structure_get_int (structure, "height", &edgetv->height)) {
-    guint map_size;
+  edgetv->info = info;
 
-    edgetv->map_width = edgetv->width / 4;
-    edgetv->map_height = edgetv->height / 4;
-    edgetv->video_width_margin = edgetv->width % 4;
+  width = GST_VIDEO_INFO_WIDTH (&info);
+  height = GST_VIDEO_INFO_HEIGHT (&info);
 
-    map_size = edgetv->map_width * edgetv->map_height * sizeof (guint32) * 2;
+  edgetv->map_width = width / 4;
+  edgetv->map_height = height / 4;
+  edgetv->video_width_margin = width % 4;
 
-    g_free (edgetv->map);
-    edgetv->map = (guint32 *) g_malloc0 (map_size);
-    ret = TRUE;
-  }
-  GST_OBJECT_UNLOCK (edgetv);
+  map_size = edgetv->map_width * edgetv->map_height * sizeof (guint32) * 2;
 
-  return ret;
+  g_free (edgetv->map);
+  edgetv->map = (guint32 *) g_malloc0 (map_size);
+
+  return TRUE;
+
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (btrans, "could not parse caps");
+    return FALSE;
+  }
 }
 
 static GstFlowReturn
@@ -112,16 +117,21 @@ gst_edgetv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
   gint video_width_margin;
   guint32 *map;
   GstFlowReturn ret = GST_FLOW_OK;
+  GstVideoFrame in_frame, out_frame;
 
-  src = (guint32 *) GST_BUFFER_DATA (in);
-  dest = (guint32 *) GST_BUFFER_DATA (out);
-
-  GST_OBJECT_LOCK (filter);
   map = filter->map;
-  width = filter->width;
   map_height = filter->map_height;
   map_width = filter->map_width;
   video_width_margin = filter->video_width_margin;
+
+  gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ);
+  gst_video_frame_map (&out_frame, &filter->info, out, GST_MAP_WRITE);
+
+  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (&in_frame);
+
   src += width * 4 + 4;
   dest += width * 4 + 4;
 
@@ -198,7 +208,6 @@ gst_edgetv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
     src += width * 3 + 8 + video_width_margin;
     dest += width * 3 + 8 + video_width_margin;
   }
-  GST_OBJECT_UNLOCK (filter);
 
   return ret;
 }
@@ -226,27 +235,22 @@ gst_edgetv_finalize (GObject * object)
 }
 
 static void
-gst_edgetv_base_init (gpointer g_class)
+gst_edgetv_class_init (GstEdgeTVClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
+  GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
+
+  gobject_class->finalize = gst_edgetv_finalize;
 
-  gst_element_class_set_details_simple (element_class, "EdgeTV effect",
+  gst_element_class_set_details_simple (gstelement_class, "EdgeTV effect",
       "Filter/Effect/Video",
       "Apply edge detect on video", "Wim Taymans <wim.taymans@chello.be>");
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_edgetv_sink_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_edgetv_src_template));
-}
-
-static void
-gst_edgetv_class_init (GstEdgeTVClass * klass)
-{
-  GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
-  GObjectClass *gobject_class = (GObjectClass *) klass;
-
-  gobject_class->finalize = gst_edgetv_finalize;
 
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_edgetv_set_caps);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_edgetv_transform);
@@ -254,6 +258,6 @@ gst_edgetv_class_init (GstEdgeTVClass * klass)
 }
 
 static void
-gst_edgetv_init (GstEdgeTV * edgetv, GstEdgeTVClass * klass)
+gst_edgetv_init (GstEdgeTV * edgetv)
 {
 }
index 172d597..469dc68 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -52,8 +53,7 @@ struct _GstEdgeTV
   GstVideoFilter videofilter;
 
   /* < private > */
-
-  gint width, height;
+  GstVideoInfo info;
   gint map_width, map_height;
   guint32 *map;
   gint video_width_margin;
index de798dc..e3a6b2e 100644 (file)
@@ -34,7 +34,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! optv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! optv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of optv on a test stream.
  * </refsect2>
  */
@@ -95,12 +95,13 @@ enum
 
 static guint32 palette[256];
 
-GST_BOILERPLATE (GstOpTV, gst_optv, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
+#define gst_optv_parent_class parent_class
+G_DEFINE_TYPE (GstOpTV, gst_optv, GST_TYPE_VIDEO_FILTER);
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define CAPS_STR GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_RGBx
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ BGRx, RGBx }")
 #else
-#define CAPS_STR GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_xRGB
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ xBGR, xRGB }")
 #endif
 
 static GstStaticPadTemplate gst_optv_src_template =
@@ -203,7 +204,7 @@ gst_optv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
 {
   GstOpTV *filter = GST_OPTV (trans);
   guint32 *src, *dest;
-  GstFlowReturn ret = GST_FLOW_OK;
+  GstVideoFrame in_frame, out_frame;
   gint8 *p;
   guint8 *diff;
   gint x, y, width, height;
@@ -220,12 +221,21 @@ gst_optv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
-  src = (guint32 *) GST_BUFFER_DATA (in);
-  dest = (guint32 *) GST_BUFFER_DATA (out);
-
   if (G_UNLIKELY (filter->opmap[0] == NULL))
     return GST_FLOW_NOT_NEGOTIATED;
 
+  if (!gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ))
+    goto invalid_in;
+
+  if (!gst_video_frame_map (&out_frame, &filter->info, out, GST_MAP_WRITE))
+    goto invalid_out;
+
+  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (&in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (&in_frame);
+
   GST_OBJECT_LOCK (filter);
   switch (filter->mode) {
     default:
@@ -246,9 +256,7 @@ gst_optv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
   filter->phase -= filter->speed;
 
   diff = filter->diff;
-  image_y_over (src, diff, filter->threshold, filter->width * filter->height);
-  height = filter->height;
-  width = filter->width;
+  image_y_over (src, diff, filter->threshold, width * height);
   phase = filter->phase;
 
   for (y = 0; y < height; y++) {
@@ -259,7 +267,23 @@ gst_optv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
   }
   GST_OBJECT_UNLOCK (filter);
 
-  return ret;
+  gst_video_frame_unmap (&in_frame);
+  gst_video_frame_unmap (&out_frame);
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+invalid_in:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid input frame");
+    return GST_FLOW_ERROR;
+  }
+invalid_out:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid output frame");
+    gst_video_frame_unmap (&in_frame);
+    return GST_FLOW_ERROR;
+  }
 }
 
 static gboolean
@@ -267,32 +291,36 @@ gst_optv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstOpTV *filter = GST_OPTV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
+  gint i, width, height;
 
-  structure = gst_caps_get_structure (incaps, 0);
-
-  GST_OBJECT_LOCK (filter);
-  if (gst_structure_get_int (structure, "width", &filter->width) &&
-      gst_structure_get_int (structure, "height", &filter->height)) {
-    gint i;
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-    for (i = 0; i < 4; i++) {
-      if (filter->opmap[i])
-        g_free (filter->opmap[i]);
-      filter->opmap[i] = g_new (gint8, filter->width * filter->height);
-    }
-    setOpmap (filter->opmap, filter->width, filter->height);
+  filter->info = info;
 
-    if (filter->diff)
-      g_free (filter->diff);
-    filter->diff = g_new (guint8, filter->width * filter->height);
+  width = GST_VIDEO_INFO_WIDTH (&info);
+  height = GST_VIDEO_INFO_HEIGHT (&info);
 
-    ret = TRUE;
+  for (i = 0; i < 4; i++) {
+    if (filter->opmap[i])
+      g_free (filter->opmap[i]);
+    filter->opmap[i] = g_new (gint8, width * height);
   }
-  GST_OBJECT_UNLOCK (filter);
+  setOpmap (filter->opmap, width, height);
+
+  if (filter->diff)
+    g_free (filter->diff);
+  filter->diff = g_new (guint8, width * height);
+
+  return TRUE;
 
-  return ret;
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid caps received");
+    return FALSE;
+  }
 }
 
 static gboolean
@@ -374,26 +402,10 @@ gst_optv_get_property (GObject * object, guint prop_id, GValue * value,
 }
 
 static void
-gst_optv_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "OpTV effect",
-      "Filter/Effect/Video",
-      "Optical art meets real-time video effect",
-      "FUKUCHI, Kentarou <fukuchi@users.sourceforge.net>, "
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_optv_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_optv_src_template));
-}
-
-static void
 gst_optv_class_init (GstOpTVClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
   gobject_class->set_property = gst_optv_set_property;
@@ -416,6 +428,17 @@ gst_optv_class_init (GstOpTVClass * klass)
           "Luma threshold", 0, G_MAXINT, DEFAULT_THRESHOLD,
           GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "OpTV effect",
+      "Filter/Effect/Video",
+      "Optical art meets real-time video effect",
+      "FUKUCHI, Kentarou <fukuchi@users.sourceforge.net>, "
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_optv_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_optv_src_template));
+
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_optv_set_caps);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_optv_transform);
   trans_class->start = GST_DEBUG_FUNCPTR (gst_optv_start);
@@ -424,7 +447,7 @@ gst_optv_class_init (GstOpTVClass * klass)
 }
 
 static void
-gst_optv_init (GstOpTV * filter, GstOpTVClass * klass)
+gst_optv_init (GstOpTV * filter)
 {
   filter->speed = DEFAULT_SPEED;
   filter->mode = DEFAULT_MODE;
index e794603..d5e0fec 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -52,7 +53,7 @@ struct _GstOpTV
   GstVideoFilter element;
 
   /* < private > */
-  gint width, height;
+  GstVideoInfo info;
 
   gint mode;
   gint speed;
index 3b307f2..b9bb29e 100644 (file)
@@ -33,7 +33,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! quarktv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! quarktv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of quarktv on a test stream.
  * </refsect2>
  */
@@ -49,7 +49,6 @@
 #include "gsteffectv.h"
 
 #include <gst/controller/gstcontroller.h>
-#include <gst/video/video.h>
 
 /* number of frames of time-buffer. It should be as a configurable paramater */
 /* This number also must be 2^n just for the speed. */
@@ -61,25 +60,23 @@ enum
   PROP_PLANES
 };
 
-GST_BOILERPLATE (GstQuarkTV, gst_quarktv, GstVideoFilter,
-    GST_TYPE_VIDEO_FILTER);
+#define gst_quarktv_parent_class parent_class
+G_DEFINE_TYPE (GstQuarkTV, gst_quarktv, GST_TYPE_VIDEO_FILTER);
 
 static void gst_quarktv_planetable_clear (GstQuarkTV * filter);
 
 static GstStaticPadTemplate gst_quarktv_src_template =
-    GST_STATIC_PAD_TEMPLATE ("src",
+GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR ";"
-        GST_VIDEO_CAPS_BGRx "; " GST_VIDEO_CAPS_RGBx)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ xRGB, xBGR, BGRx, RGBx }"))
     );
 
 static GstStaticPadTemplate gst_quarktv_sink_template =
-    GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR ";"
-        GST_VIDEO_CAPS_BGRx "; " GST_VIDEO_CAPS_RGBx)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ xRGB, xBGR, BGRx, RGBx }"))
     );
 
 static gboolean
@@ -87,21 +84,28 @@ gst_quarktv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstQuarkTV *filter = GST_QUARKTV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
+  gint width, height;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  GST_OBJECT_LOCK (filter);
-  if (gst_structure_get_int (structure, "width", &filter->width) &&
-      gst_structure_get_int (structure, "height", &filter->height)) {
-    gst_quarktv_planetable_clear (filter);
-    filter->area = filter->width * filter->height;
-    ret = TRUE;
-  }
-  GST_OBJECT_UNLOCK (filter);
+  filter->info = info;
+
+  width = GST_VIDEO_INFO_WIDTH (&info);
+  height = GST_VIDEO_INFO_HEIGHT (&info);
+
+  gst_quarktv_planetable_clear (filter);
+  filter->area = width * height;
+
+  return TRUE;
 
-  return ret;
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid caps received");
+    return FALSE;
+  }
 }
 
 static GstFlowReturn
@@ -111,10 +115,10 @@ gst_quarktv_transform (GstBaseTransform * trans, GstBuffer * in,
   GstQuarkTV *filter = GST_QUARKTV (trans);
   gint area;
   guint32 *src, *dest;
-  GstFlowReturn ret = GST_FLOW_OK;
   GstClockTime timestamp;
   GstBuffer **planetable;
   gint planes, current_plane;
+  GstVideoFrame in_frame, out_frame;
 
   timestamp = GST_BUFFER_TIMESTAMP (in);
   timestamp =
@@ -129,10 +133,17 @@ gst_quarktv_transform (GstBaseTransform * trans, GstBuffer * in,
   if (G_UNLIKELY (filter->planetable == NULL))
     return GST_FLOW_WRONG_STATE;
 
+  if (!gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ))
+    goto invalid_in;
+
+  if (!gst_video_frame_map (&out_frame, &filter->info, out, GST_MAP_WRITE))
+    goto invalid_out;
+
+  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
+
   GST_OBJECT_LOCK (filter);
   area = filter->area;
-  src = (guint32 *) GST_BUFFER_DATA (in);
-  dest = (guint32 *) GST_BUFFER_DATA (out);
   planetable = filter->planetable;
   planes = filter->planes;
   current_plane = filter->current_plane;
@@ -148,9 +159,11 @@ gst_quarktv_transform (GstBaseTransform * trans, GstBuffer * in,
     /* pick a random buffer */
     rand = planetable[(current_plane + (fastrand () >> 24)) % planes];
 
-    /* Copy the pixel from the random buffer to dest */
-    dest[area] =
-        (rand ? ((guint32 *) GST_BUFFER_DATA (rand))[area] : src[area]);
+    /* Copy the pixel from the random buffer to dest, FIXME, slow */
+    if (rand)
+      gst_buffer_extract (rand, area * 4, &dest[area], 4);
+    else
+      dest[area] = src[area];
   }
 
   filter->current_plane--;
@@ -158,7 +171,23 @@ gst_quarktv_transform (GstBaseTransform * trans, GstBuffer * in,
     filter->current_plane = planes - 1;
   GST_OBJECT_UNLOCK (filter);
 
-  return ret;
+  gst_video_frame_unmap (&in_frame);
+  gst_video_frame_unmap (&out_frame);
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+invalid_in:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid input frame");
+    return GST_FLOW_ERROR;
+  }
+invalid_out:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid output frame");
+    gst_video_frame_unmap (&in_frame);
+    return GST_FLOW_ERROR;
+  }
 }
 
 static void
@@ -266,24 +295,10 @@ gst_quarktv_get_property (GObject * object, guint prop_id, GValue * value,
 }
 
 static void
-gst_quarktv_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "QuarkTV effect",
-      "Filter/Effect/Video",
-      "Motion dissolver", "FUKUCHI, Kentarou <fukuchi@users.sourceforge.net>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_quarktv_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_quarktv_src_template));
-}
-
-static void
 gst_quarktv_class_init (GstQuarkTVClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
   gobject_class->set_property = gst_quarktv_set_property;
@@ -296,13 +311,22 @@ gst_quarktv_class_init (GstQuarkTVClass * klass)
           "Number of planes", 0, 64, PLANES,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
 
+  gst_element_class_set_details_simple (gstelement_class, "QuarkTV effect",
+      "Filter/Effect/Video",
+      "Motion dissolver", "FUKUCHI, Kentarou <fukuchi@users.sourceforge.net>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_quarktv_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_quarktv_src_template));
+
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_quarktv_set_caps);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_quarktv_transform);
   trans_class->start = GST_DEBUG_FUNCPTR (gst_quarktv_start);
 }
 
 static void
-gst_quarktv_init (GstQuarkTV * filter, GstQuarkTVClass * klass)
+gst_quarktv_init (GstQuarkTV * filter)
 {
   filter->planes = PLANES;
   filter->current_plane = filter->planes - 1;
index 79a6107..e3fd17d 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -52,8 +53,8 @@ struct _GstQuarkTV
   GstVideoFilter element;
 
   /* < private > */
+  GstVideoInfo info;
 
-  gint width, height;
   gint area;
   gint planes;
   gint current_plane;
index 58c1b7b..15be676 100644 (file)
@@ -40,7 +40,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! radioactv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! radioactv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of radioactv on a test stream.
  * </refsect2>
  */
@@ -55,7 +55,6 @@
 #include "gstradioac.h"
 #include "gsteffectv.h"
 
-#include <gst/video/video.h>
 #include <gst/controller/gstcontroller.h>
 
 enum
@@ -135,13 +134,13 @@ enum
 
 static guint32 palettes[COLORS * PATTERN];
 
-GST_BOILERPLATE (GstRadioacTV, gst_radioactv, GstVideoFilter,
-    GST_TYPE_VIDEO_FILTER);
+#define gst_radioactv_parent_class parent_class
+G_DEFINE_TYPE (GstRadioacTV, gst_radioactv, GST_TYPE_VIDEO_FILTER);
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define CAPS_STR GST_VIDEO_CAPS_RGBx
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("RGBx")
 #else
-#define CAPS_STR GST_VIDEO_CAPS_xBGR
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("xBGR")
 #endif
 
 static GstStaticPadTemplate gst_radioactv_src_template =
@@ -235,7 +234,7 @@ blur (GstRadioacTV * filter)
   guint8 v;
 
   width = filter->buf_width;
-  p = filter->blurzoombuf + filter->width + 1;
+  p = filter->blurzoombuf + GST_VIDEO_INFO_WIDTH (&filter->info) + 1;
   q = p + filter->buf_area;
 
   for (y = filter->buf_height - 2; y > 0; y--) {
@@ -320,9 +319,9 @@ gst_radioactv_transform (GstBaseTransform * trans, GstBuffer * in,
 {
   GstRadioacTV *filter = GST_RADIOACTV (trans);
   guint32 *src, *dest;
-  GstFlowReturn ret = GST_FLOW_OK;
+  GstVideoFrame in_frame, out_frame;
   GstClockTime timestamp, stream_time;
-  gint x, y;
+  gint x, y, width, height;
   guint32 a, b;
   guint8 *diff, *p;
   guint32 *palette;
@@ -337,8 +336,17 @@ gst_radioactv_transform (GstBaseTransform * trans, GstBuffer * in,
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
-  src = (guint32 *) GST_BUFFER_DATA (in);
-  dest = (guint32 *) GST_BUFFER_DATA (out);
+  if (!gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ))
+    goto invalid_in;
+
+  if (!gst_video_frame_map (&out_frame, &filter->info, out, GST_MAP_WRITE))
+    goto invalid_out;
+
+  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (&in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (&in_frame);
 
   GST_OBJECT_LOCK (filter);
   palette = &palettes[COLORS * filter->color];
@@ -351,7 +359,7 @@ gst_radioactv_transform (GstBaseTransform * trans, GstBuffer * in,
 
   if (filter->mode != 2 || filter->snaptime <= 0) {
     image_bgsubtract_update_y (src, filter->background, diff,
-        filter->width * filter->height, MAGIC_THRESHOLD * 7);
+        width * height, MAGIC_THRESHOLD * 7);
     if (filter->mode == 0 || filter->snaptime <= 0) {
       diff += filter->buf_margin_left;
       p = filter->blurzoombuf;
@@ -359,11 +367,11 @@ gst_radioactv_transform (GstBaseTransform * trans, GstBuffer * in,
         for (x = 0; x < filter->buf_width; x++) {
           p[x] |= diff[x] >> 3;
         }
-        diff += filter->width;
+        diff += width;
         p += filter->buf_width;
       }
       if (filter->mode == 1 || filter->mode == 2) {
-        memcpy (filter->snapframe, src, filter->width * filter->height * 4);
+        memcpy (filter->snapframe, src, width * height * 4);
       }
     }
   }
@@ -373,7 +381,7 @@ gst_radioactv_transform (GstBaseTransform * trans, GstBuffer * in,
     src = filter->snapframe;
   }
   p = filter->blurzoombuf;
-  for (y = 0; y < filter->height; y++) {
+  for (y = 0; y < height; y++) {
     for (x = 0; x < filter->buf_margin_left; x++) {
       *dest++ = *src++;
     }
@@ -397,7 +405,23 @@ gst_radioactv_transform (GstBaseTransform * trans, GstBuffer * in,
   }
   GST_OBJECT_UNLOCK (filter);
 
-  return ret;
+  gst_video_frame_unmap (&in_frame);
+  gst_video_frame_unmap (&out_frame);
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+invalid_in:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid input frame");
+    return GST_FLOW_ERROR;
+  }
+invalid_out:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid output frame");
+    gst_video_frame_unmap (&in_frame);
+    return GST_FLOW_ERROR;
+  }
 }
 
 static gboolean
@@ -405,57 +429,67 @@ gst_radioactv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstRadioacTV *filter = GST_RADIOACTV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
+  gint width, height;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  GST_OBJECT_LOCK (filter);
-  if (gst_structure_get_int (structure, "width", &filter->width) &&
-      gst_structure_get_int (structure, "height", &filter->height)) {
-    filter->buf_width_blocks = filter->width / 32;
-    if (filter->buf_width_blocks > 255)
-      goto out;
-
-    filter->buf_width = filter->buf_width_blocks * 32;
-    filter->buf_height = filter->height;
-    filter->buf_area = filter->buf_height * filter->buf_width;
-    filter->buf_margin_left = (filter->width - filter->buf_width) / 2;
-    filter->buf_margin_right =
-        filter->height - filter->buf_width - filter->buf_margin_left;
-
-    if (filter->blurzoombuf)
-      g_free (filter->blurzoombuf);
-    filter->blurzoombuf = g_new0 (guint8, filter->buf_area * 2);
-
-    if (filter->blurzoomx)
-      g_free (filter->blurzoomx);
-    filter->blurzoomx = g_new0 (gint, filter->buf_width);
-
-    if (filter->blurzoomy)
-      g_free (filter->blurzoomy);
-    filter->blurzoomy = g_new0 (gint, filter->buf_height);
-
-    if (filter->snapframe)
-      g_free (filter->snapframe);
-    filter->snapframe = g_new (guint32, filter->width * filter->height);
-
-    if (filter->diff)
-      g_free (filter->diff);
-    filter->diff = g_new (guint8, filter->width * filter->height);
-
-    if (filter->background)
-      g_free (filter->background);
-    filter->background = g_new0 (gint16, filter->width * filter->height);
-
-    setTable (filter);
-
-    ret = TRUE;
-  }
-out:
-  GST_OBJECT_UNLOCK (filter);
+  filter->info = info;
+
+  width = GST_VIDEO_INFO_WIDTH (&info);
+  height = GST_VIDEO_INFO_HEIGHT (&info);
+
+  filter->buf_width_blocks = width / 32;
+  if (filter->buf_width_blocks > 255)
+    goto too_wide;
+
+  filter->buf_width = filter->buf_width_blocks * 32;
+  filter->buf_height = height;
+  filter->buf_area = filter->buf_height * filter->buf_width;
+  filter->buf_margin_left = (width - filter->buf_width) / 2;
+  filter->buf_margin_right =
+      height - filter->buf_width - filter->buf_margin_left;
+
+  if (filter->blurzoombuf)
+    g_free (filter->blurzoombuf);
+  filter->blurzoombuf = g_new0 (guint8, filter->buf_area * 2);
+
+  if (filter->blurzoomx)
+    g_free (filter->blurzoomx);
+  filter->blurzoomx = g_new0 (gint, filter->buf_width);
+
+  if (filter->blurzoomy)
+    g_free (filter->blurzoomy);
+  filter->blurzoomy = g_new0 (gint, filter->buf_height);
+
+  if (filter->snapframe)
+    g_free (filter->snapframe);
+  filter->snapframe = g_new (guint32, width * height);
+
+  if (filter->diff)
+    g_free (filter->diff);
+  filter->diff = g_new (guint8, width * height);
+
+  if (filter->background)
+    g_free (filter->background);
+  filter->background = g_new0 (gint16, width * height);
 
-  return ret;
+  setTable (filter);
+
+  return TRUE;
+
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid caps received");
+    return FALSE;
+  }
+too_wide:
+  {
+    GST_DEBUG_OBJECT (filter, "frame too wide");
+    return FALSE;
+  }
 }
 
 static gboolean
@@ -555,26 +589,10 @@ gst_radioactv_get_property (GObject * object, guint prop_id,
 }
 
 static void
-gst_radioactv_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "RadioacTV effect",
-      "Filter/Effect/Video",
-      "motion-enlightment effect",
-      "FUKUCHI, Kentarou <fukuchi@users.sourceforge.net>, "
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_radioactv_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_radioactv_src_template));
-}
-
-static void
 gst_radioactv_class_init (GstRadioacTVClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
   gobject_class->set_property = gst_radioactv_set_property;
@@ -602,6 +620,17 @@ gst_radioactv_class_init (GstRadioacTVClass * klass)
           "Trigger (in trigger mode)", DEFAULT_TRIGGER,
           GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "RadioacTV effect",
+      "Filter/Effect/Video",
+      "motion-enlightment effect",
+      "FUKUCHI, Kentarou <fukuchi@users.sourceforge.net>, "
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_radioactv_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_radioactv_src_template));
+
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_radioactv_set_caps);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_radioactv_transform);
   trans_class->start = GST_DEBUG_FUNCPTR (gst_radioactv_start);
@@ -610,7 +639,7 @@ gst_radioactv_class_init (GstRadioacTVClass * klass)
 }
 
 static void
-gst_radioactv_init (GstRadioacTV * filter, GstRadioacTVClass * klass)
+gst_radioactv_init (GstRadioacTV * filter)
 {
   filter->mode = DEFAULT_MODE;
   filter->color = DEFAULT_COLOR;
index 34ad8ed..a7a787a 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -52,7 +53,7 @@ struct _GstRadioacTV
   GstVideoFilter element;
 
   /* < private > */
-  gint width, height;
+  GstVideoInfo info;
 
   gint mode;
   gint color;
index ad58a8e..c5d1d63 100644 (file)
@@ -50,7 +50,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! revtv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! revtv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of revtv on a test stream.
  * </refsect2>
  */
@@ -64,7 +64,6 @@
 
 #include "gstrev.h"
 
-#include <gst/video/video.h>
 #include <gst/controller/gstcontroller.h>
 
 #define THE_COLOR 0xffffffff
@@ -77,12 +76,13 @@ enum
   PROP_GAIN
 };
 
-GST_BOILERPLATE (GstRevTV, gst_revtv, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
+#define gst_revtv_parent_class parent_class
+G_DEFINE_TYPE (GstRevTV, gst_revtv, GST_TYPE_VIDEO_FILTER);
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define CAPS_STR GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_RGBx
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ BGRx, RGBx }")
 #else
-#define CAPS_STR GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_xRGB
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ xBGR, xRGB }")
 #endif
 
 static GstStaticPadTemplate gst_revtv_src_template =
@@ -104,19 +104,21 @@ gst_revtv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstRevTV *filter = GST_REVTV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  GST_OBJECT_LOCK (filter);
-  if (gst_structure_get_int (structure, "width", &filter->width) &&
-      gst_structure_get_int (structure, "height", &filter->height)) {
-    ret = TRUE;
-  }
-  GST_OBJECT_UNLOCK (filter);
+  filter->info = info;
+
+  return TRUE;
 
-  return ret;
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid caps received");
+    return FALSE;
+  }
 }
 
 static GstFlowReturn
@@ -124,12 +126,12 @@ gst_revtv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
 {
   GstRevTV *filter = GST_REVTV (trans);
   guint32 *src, *dest;
-  gint width, height;
+  gint width, height, sstride, dstride;
   guint32 *nsrc;
   gint y, x, R, G, B, yval;
-  GstFlowReturn ret = GST_FLOW_OK;
   gint linespace, vscale;
   GstClockTime timestamp, stream_time;
+  GstVideoFrame in_frame, out_frame;
 
   timestamp = GST_BUFFER_TIMESTAMP (in);
   stream_time =
@@ -141,23 +143,31 @@ gst_revtv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
-  src = (guint32 *) GST_BUFFER_DATA (in);
-  dest = (guint32 *) GST_BUFFER_DATA (out);
+  if (!gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ))
+    goto invalid_in;
 
-  GST_OBJECT_LOCK (filter);
-  width = filter->width;
-  height = filter->height;
+  if (!gst_video_frame_map (&out_frame, &filter->info, out, GST_MAP_WRITE))
+    goto invalid_out;
+
+  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  sstride = GST_VIDEO_FRAME_PLANE_STRIDE (&in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
+  dstride = GST_VIDEO_FRAME_PLANE_STRIDE (&out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (&in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (&in_frame);
 
   /* Clear everything to black */
-  memset (dest, 0, width * height * sizeof (guint32));
+  memset (dest, 0, dstride * height * sizeof (guint32));
 
+  GST_OBJECT_LOCK (filter);
   linespace = filter->linespace;
   vscale = filter->vscale;
 
   /* draw the offset lines */
   for (y = 0; y < height; y += linespace) {
     for (x = 0; x <= width; x++) {
-      nsrc = src + (y * width) + x;
+      nsrc = src + (y * sstride) + x;
 
       /* Calc Y Value for curpix */
       R = ((*nsrc) & 0xff0000) >> (16 - 1);
@@ -167,13 +177,29 @@ gst_revtv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
       yval = y - ((short) (R + G + B) / vscale);
 
       if (yval > 0) {
-        dest[x + (yval * width)] = THE_COLOR;
+        dest[x + (yval * dstride)] = THE_COLOR;
       }
     }
   }
   GST_OBJECT_UNLOCK (filter);
 
-  return ret;
+  gst_video_frame_unmap (&in_frame);
+  gst_video_frame_unmap (&out_frame);
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+invalid_in:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid input frame");
+    return GST_FLOW_ERROR;
+  }
+invalid_out:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid output frame");
+    gst_video_frame_unmap (&in_frame);
+    return GST_FLOW_ERROR;
+  }
 }
 
 static void
@@ -223,25 +249,10 @@ gst_revtv_get_property (GObject * object, guint prop_id, GValue * value,
 }
 
 static void
-gst_revtv_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "RevTV effect",
-      "Filter/Effect/Video",
-      "A video waveform monitor for each line of video processed",
-      "Wim Taymans <wim.taymans@chello.be>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_revtv_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_revtv_src_template));
-}
-
-static void
 gst_revtv_class_init (GstRevTVClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
   gobject_class->set_property = gst_revtv_set_property;
@@ -259,12 +270,22 @@ gst_revtv_class_init (GstRevTVClass * klass)
       g_param_spec_int ("gain", "Gain", "Control gain", 1, 200, 50,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
 
+  gst_element_class_set_details_simple (gstelement_class, "RevTV effect",
+      "Filter/Effect/Video",
+      "A video waveform monitor for each line of video processed",
+      "Wim Taymans <wim.taymans@gmail.be>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_revtv_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_revtv_src_template));
+
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_revtv_set_caps);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_revtv_transform);
 }
 
 static void
-gst_revtv_init (GstRevTV * restv, GstRevTVClass * klass)
+gst_revtv_init (GstRevTV * restv)
 {
   restv->vgrabtime = 1;
   restv->vgrab = 0;
index 867f49a..deb8dd1 100644 (file)
@@ -45,6 +45,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -68,8 +69,8 @@ struct _GstRevTV
   GstVideoFilter videofilter;
 
   /* < private > */
+  GstVideoInfo info;
 
-  gint width, height;
   gint vgrabtime;
   gint vgrab;
   gint linespace;
index e002ad1..1c0d9cf 100644 (file)
@@ -37,7 +37,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! rippletv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! rippletv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of rippletv on a test stream.
  * </refsect2>
  */
@@ -52,7 +52,6 @@
 #include "gstripple.h"
 #include "gsteffectv.h"
 
-#include <gst/video/video.h>
 #include <gst/controller/gstcontroller.h>
 
 #define DEFAULT_MODE 0
@@ -84,24 +83,21 @@ gst_rippletv_mode_get_type (void)
   return type;
 }
 
-
-GST_BOILERPLATE (GstRippleTV, gst_rippletv, GstVideoFilter,
-    GST_TYPE_VIDEO_FILTER);
+#define gst_rippletv_parent_class parent_class
+G_DEFINE_TYPE (GstRippleTV, gst_rippletv, GST_TYPE_VIDEO_FILTER);
 
 static GstStaticPadTemplate gst_rippletv_src_template =
-    GST_STATIC_PAD_TEMPLATE ("src",
+GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx "; " GST_VIDEO_CAPS_RGBx ";"
-        GST_VIDEO_CAPS_xBGR "; " GST_VIDEO_CAPS_xRGB)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ BGRx, RGBx, xBGR, xRGB }"))
     );
 
 static GstStaticPadTemplate gst_rippletv_sink_template =
-    GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx "; " GST_VIDEO_CAPS_RGBx ";"
-        GST_VIDEO_CAPS_xBGR "; " GST_VIDEO_CAPS_xRGB)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ BGRx, RGBx, xBGR, xRGB }"))
     );
 
 static const gint point = 16;
@@ -145,7 +141,9 @@ image_bgset_y (guint32 * src, gint16 * background, gint video_area)
 static gint
 setBackground (GstRippleTV * filter, guint32 * src)
 {
-  image_bgset_y (src, filter->background, filter->width * filter->height);
+  image_bgset_y (src, filter->background,
+      GST_VIDEO_INFO_WIDTH (&filter->info) *
+      GST_VIDEO_INFO_HEIGHT (&filter->info));
   filter->bg_is_set = TRUE;
 
   return 0;
@@ -183,18 +181,21 @@ static void
 motiondetect (GstRippleTV * filter, guint32 * src)
 {
   guint8 *diff = filter->diff;
-  gint width = filter->width;
+  gint width, height;
   gint *p, *q;
   gint x, y, h;
 
+  width = GST_VIDEO_INFO_WIDTH (&filter->info);
+  height = GST_VIDEO_INFO_HEIGHT (&filter->info);
+
   if (!filter->bg_is_set)
     setBackground (filter, src);
 
   image_bgsubtract_update_y (src, filter->background, filter->diff,
-      filter->width * filter->height);
+      width * height);
   p = filter->map1 + filter->map_w + 1;
   q = filter->map2 + filter->map_w + 1;
-  diff += filter->width + 2;
+  diff += width + 2;
 
   for (y = filter->map_h - 2; y > 0; y--) {
     for (x = filter->map_w - 2; x > 0; x--) {
@@ -310,7 +311,7 @@ gst_rippletv_transform (GstBaseTransform * trans, GstBuffer * in,
 {
   GstRippleTV *filter = GST_RIPPLETV (trans);
   guint32 *src, *dest;
-  GstFlowReturn ret = GST_FLOW_OK;
+  GstVideoFrame in_frame, out_frame;
   gint x, y, i;
   gint dx, dy;
   gint h, v;
@@ -329,8 +330,14 @@ gst_rippletv_transform (GstBaseTransform * trans, GstBuffer * in,
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
-  src = (guint32 *) GST_BUFFER_DATA (in);
-  dest = (guint32 *) GST_BUFFER_DATA (out);
+  if (!gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ))
+    goto invalid_in;
+
+  if (!gst_video_frame_map (&out_frame, &filter->info, out, GST_MAP_WRITE))
+    goto invalid_out;
+
+  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
 
   GST_OBJECT_LOCK (filter);
   /* impact from the motion or rain drop */
@@ -402,8 +409,8 @@ gst_rippletv_transform (GstBaseTransform * trans, GstBuffer * in,
     vp += 2;
   }
 
-  height = filter->height;
-  width = filter->width;
+  width = GST_VIDEO_FRAME_WIDTH (&in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (&in_frame);
   vp = filter->vtable;
 
   /* draw refracted image. The vector table is stretched. */
@@ -443,12 +450,29 @@ gst_rippletv_transform (GstBaseTransform * trans, GstBuffer * in,
       dest += 2;
       vp += 2;
     }
-    dest += filter->width;
+    dest += width;
     vp += 2;
   }
   GST_OBJECT_UNLOCK (filter);
 
-  return ret;
+  gst_video_frame_unmap (&in_frame);
+  gst_video_frame_unmap (&out_frame);
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+invalid_in:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid input frame");
+    return GST_FLOW_ERROR;
+  }
+invalid_out:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid output frame");
+    gst_video_frame_unmap (&in_frame);
+    return GST_FLOW_ERROR;
+  }
+
 }
 
 static gboolean
@@ -456,43 +480,50 @@ gst_rippletv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstRippleTV *filter = GST_RIPPLETV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
+  gint width, height;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  GST_OBJECT_LOCK (filter);
-  if (gst_structure_get_int (structure, "width", &filter->width) &&
-      gst_structure_get_int (structure, "height", &filter->height)) {
+  filter->info = info;
 
-    filter->map_h = filter->height / 2 + 1;
-    filter->map_w = filter->width / 2 + 1;
+  width = GST_VIDEO_INFO_WIDTH (&info);
+  height = GST_VIDEO_INFO_HEIGHT (&info);
 
-    if (filter->map)
-      g_free (filter->map);
-    filter->map = g_new0 (gint, filter->map_h * filter->map_w * 3);
+  GST_OBJECT_LOCK (filter);
+  filter->map_h = height / 2 + 1;
+  filter->map_w = width / 2 + 1;
 
-    filter->map1 = filter->map;
-    filter->map2 = filter->map + filter->map_w * filter->map_h;
-    filter->map3 = filter->map + filter->map_w * filter->map_h * 2;
+  if (filter->map)
+    g_free (filter->map);
+  filter->map = g_new0 (gint, filter->map_h * filter->map_w * 3);
 
-    if (filter->vtable)
-      g_free (filter->vtable);
-    filter->vtable = g_new0 (gint8, filter->map_h * filter->map_w * 2);
+  filter->map1 = filter->map;
+  filter->map2 = filter->map + filter->map_w * filter->map_h;
+  filter->map3 = filter->map + filter->map_w * filter->map_h * 2;
 
-    if (filter->background)
-      g_free (filter->background);
-    filter->background = g_new0 (gint16, filter->width * filter->height);
+  if (filter->vtable)
+    g_free (filter->vtable);
+  filter->vtable = g_new0 (gint8, filter->map_h * filter->map_w * 2);
 
-    if (filter->diff)
-      g_free (filter->diff);
-    filter->diff = g_new0 (guint8, filter->width * filter->height);
+  if (filter->background)
+    g_free (filter->background);
+  filter->background = g_new0 (gint16, width * height);
 
-    ret = TRUE;
-  }
+  if (filter->diff)
+    g_free (filter->diff);
+  filter->diff = g_new0 (guint8, width * height);
   GST_OBJECT_UNLOCK (filter);
 
-  return ret;
+  return TRUE;
+
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid caps received");
+    return FALSE;
+  }
 }
 
 static gboolean
@@ -577,26 +608,10 @@ gst_rippletv_get_property (GObject * object, guint prop_id, GValue * value,
 }
 
 static void
-gst_rippletv_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "RippleTV effect",
-      "Filter/Effect/Video",
-      "RippleTV does ripple mark effect on the video input",
-      "FUKUCHI, Kentarou <fukuchi@users.sourceforge.net>, "
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rippletv_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rippletv_src_template));
-}
-
-static void
 gst_rippletv_class_init (GstRippleTVClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
   gobject_class->set_property = gst_rippletv_set_property;
@@ -614,6 +629,17 @@ gst_rippletv_class_init (GstRippleTVClass * klass)
           "Mode", GST_TYPE_RIPPLETV_MODE, DEFAULT_MODE,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
 
+  gst_element_class_set_details_simple (gstelement_class, "RippleTV effect",
+      "Filter/Effect/Video",
+      "RippleTV does ripple mark effect on the video input",
+      "FUKUCHI, Kentarou <fukuchi@users.sourceforge.net>, "
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rippletv_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rippletv_src_template));
+
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_rippletv_set_caps);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_rippletv_transform);
   trans_class->start = GST_DEBUG_FUNCPTR (gst_rippletv_start);
@@ -622,7 +648,7 @@ gst_rippletv_class_init (GstRippleTVClass * klass)
 }
 
 static void
-gst_rippletv_init (GstRippleTV * filter, GstRippleTVClass * klass)
+gst_rippletv_init (GstRippleTV * filter)
 {
   filter->mode = DEFAULT_MODE;
 
index 388ba56..571db51 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -52,7 +53,7 @@ struct _GstRippleTV
   GstVideoFilter element;
 
   /* < private > */
-  gint width, height;
+  GstVideoInfo info;
 
   gint mode;
 
index 650a563..f2af50f 100644 (file)
@@ -30,7 +30,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! shagadelictv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! shagadelictv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of shagadelictv on a test stream.
  * </refsect2>
  */
 #include "gstshagadelic.h"
 #include "gsteffectv.h"
 
-#include <gst/video/video.h>
-
 #ifndef M_PI
 #define M_PI  3.14159265358979323846
 #endif
 
-GST_BOILERPLATE (GstShagadelicTV, gst_shagadelictv, GstVideoFilter,
-    GST_TYPE_VIDEO_FILTER);
+#define gst_shagadelictv_parent_class parent_class
+G_DEFINE_TYPE (GstShagadelicTV, gst_shagadelictv, GST_TYPE_VIDEO_FILTER);
 
 static void gst_shagadelic_initialize (GstShagadelicTV * filter);
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define CAPS_STR GST_VIDEO_CAPS_BGRx
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("BGRx")
 #else
-#define CAPS_STR GST_VIDEO_CAPS_xRGB
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("xRGB")
 #endif
 
 static GstStaticPadTemplate gst_shagadelictv_src_template =
@@ -81,48 +79,57 @@ gst_shagadelictv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstShagadelicTV *filter = GST_SHAGADELICTV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
+  gint width, height, area;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  GST_OBJECT_LOCK (filter);
-  if (gst_structure_get_int (structure, "width", &filter->width) &&
-      gst_structure_get_int (structure, "height", &filter->height)) {
-    gint area = filter->width * filter->height;
+  filter->info = info;
 
-    g_free (filter->ripple);
-    g_free (filter->spiral);
+  width = GST_VIDEO_INFO_WIDTH (&info);
+  height = GST_VIDEO_INFO_HEIGHT (&info);
 
-    filter->ripple = (guint8 *) g_malloc (area * 4);
-    filter->spiral = (guint8 *) g_malloc (area);
+  area = width * height;
 
-    gst_shagadelic_initialize (filter);
-    ret = TRUE;
-  }
-  GST_OBJECT_UNLOCK (filter);
+  g_free (filter->ripple);
+  g_free (filter->spiral);
+  filter->ripple = (guint8 *) g_malloc (area * 4);
+  filter->spiral = (guint8 *) g_malloc (area);
 
-  return ret;
+  gst_shagadelic_initialize (filter);
+
+  return TRUE;
+
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid caps received");
+    return FALSE;
+  }
 }
 
 static void
 gst_shagadelic_initialize (GstShagadelicTV * filter)
 {
   int i, x, y;
-
 #ifdef PS2
   float xx, yy;
 #else
   double xx, yy;
 #endif
+  gint width, height;
+
+  width = GST_VIDEO_INFO_WIDTH (&filter->info);
+  height = GST_VIDEO_INFO_HEIGHT (&filter->info);
 
   i = 0;
-  for (y = 0; y < filter->height * 2; y++) {
-    yy = y - filter->height;
+  for (y = 0; y < height * 2; y++) {
+    yy = y - height;
     yy *= yy;
 
-    for (x = 0; x < filter->width * 2; x++) {
-      xx = x - filter->width;
+    for (x = 0; x < width * 2; x++) {
+      xx = x - width;
 #ifdef PS2
       filter->ripple[i++] = ((unsigned int) (sqrtf (xx * xx + yy) * 8)) & 255;
 #else
@@ -132,11 +139,11 @@ gst_shagadelic_initialize (GstShagadelicTV * filter)
   }
 
   i = 0;
-  for (y = 0; y < filter->height; y++) {
-    yy = y - filter->height / 2;
+  for (y = 0; y < height; y++) {
+    yy = y - height / 2;
 
-    for (x = 0; x < filter->width; x++) {
-      xx = x - filter->width / 2;
+    for (x = 0; x < width; x++) {
+      xx = x - width / 2;
 #ifdef PS2
       filter->spiral[i++] = ((unsigned int)
           ((atan2f (xx,
@@ -152,10 +159,10 @@ gst_shagadelic_initialize (GstShagadelicTV * filter)
  */
     }
   }
-  filter->rx = fastrand () % filter->width;
-  filter->ry = fastrand () % filter->height;
-  filter->bx = fastrand () % filter->width;
-  filter->by = fastrand () % filter->height;
+  filter->rx = fastrand () % width;
+  filter->ry = fastrand () % height;
+  filter->bx = fastrand () % width;
+  filter->by = fastrand () % height;
   filter->rvx = -2;
   filter->rvy = -2;
   filter->bvx = 2;
@@ -172,15 +179,20 @@ gst_shagadelictv_transform (GstBaseTransform * trans, GstBuffer * in,
   gint x, y;
   guint32 v;
   guint8 r, g, b;
+  GstVideoFrame in_frame, out_frame;
   gint width, height;
-  GstFlowReturn ret = GST_FLOW_OK;
 
-  src = (guint32 *) GST_BUFFER_DATA (in);
-  dest = (guint32 *) GST_BUFFER_DATA (out);
+  if (!gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ))
+    goto invalid_in;
 
-  GST_OBJECT_LOCK (filter);
-  width = filter->width;
-  height = filter->height;
+  if (!gst_video_frame_map (&out_frame, &filter->info, out, GST_MAP_WRITE))
+    goto invalid_out;
+
+  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (&in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (&in_frame);
 
   for (y = 0; y < height; y++) {
     for (x = 0; x < width; x++) {
@@ -213,9 +225,24 @@ gst_shagadelictv_transform (GstBaseTransform * trans, GstBuffer * in,
   filter->ry += filter->rvy;
   filter->bx += filter->bvx;
   filter->by += filter->bvy;
-  GST_OBJECT_UNLOCK (filter);
 
-  return ret;
+  gst_video_frame_unmap (&in_frame);
+  gst_video_frame_unmap (&out_frame);
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+invalid_in:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid input frame");
+    return GST_FLOW_ERROR;
+  }
+invalid_out:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid output frame");
+    gst_video_frame_unmap (&in_frame);
+    return GST_FLOW_ERROR;
+  }
 }
 
 static void
@@ -235,35 +262,30 @@ gst_shagadelictv_finalize (GObject * object)
 }
 
 static void
-gst_shagadelictv_base_init (gpointer g_class)
+gst_shagadelictv_class_init (GstShagadelicTVClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
+  GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
+
+  gobject_class->finalize = gst_shagadelictv_finalize;
 
-  gst_element_class_set_details_simple (element_class, "ShagadelicTV",
+  gst_element_class_set_details_simple (gstelement_class, "ShagadelicTV",
       "Filter/Effect/Video",
       "Oh behave, ShagedelicTV makes images shagadelic!",
       "Wim Taymans <wim.taymans@chello.be>");
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_shagadelictv_sink_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_shagadelictv_src_template));
-}
-
-static void
-gst_shagadelictv_class_init (GstShagadelicTVClass * klass)
-{
-  GObjectClass *gobject_class = (GObjectClass *) klass;
-  GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
-
-  gobject_class->finalize = gst_shagadelictv_finalize;
 
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_shagadelictv_set_caps);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_shagadelictv_transform);
 }
 
 static void
-gst_shagadelictv_init (GstShagadelicTV * filter, GstShagadelicTVClass * klass)
+gst_shagadelictv_init (GstShagadelicTV * filter)
 {
   filter->ripple = NULL;
   filter->spiral = NULL;
index d44faa7..b2731a2 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -50,9 +51,8 @@ struct _GstShagadelicTV
   GstVideoFilter videofilter;
 
   /* < private > */
+  GstVideoInfo info;
 
-  gint width, height;
-  gint stat;
   guint8 *ripple;
   guint8 *spiral;
   guint8 phase;
index bdda54d..45d71a2 100644 (file)
@@ -36,7 +36,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! streaktv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! streaktv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of streaktv on a test stream.
  * </refsect2>
  */
@@ -51,8 +51,6 @@
 #include "gststreak.h"
 #include "gsteffectv.h"
 
-#include <gst/video/video.h>
-
 #define DEFAULT_FEEDBACK FALSE
 
 enum
@@ -61,40 +59,51 @@ enum
   PROP_FEEDBACK
 };
 
-GST_BOILERPLATE (GstStreakTV, gst_streaktv, GstVideoFilter,
-    GST_TYPE_VIDEO_FILTER);
+#define gst_streaktv_parent_class parent_class
+G_DEFINE_TYPE (GstStreakTV, gst_streaktv, GST_TYPE_VIDEO_FILTER);
 
 static GstStaticPadTemplate gst_streaktv_src_template =
-    GST_STATIC_PAD_TEMPLATE ("src",
+GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx "; " GST_VIDEO_CAPS_RGBx ";"
-        GST_VIDEO_CAPS_xBGR "; " GST_VIDEO_CAPS_xRGB)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ BGRx, RGBx, xBGR, xRGB }"))
     );
 
 static GstStaticPadTemplate gst_streaktv_sink_template =
-    GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx "; " GST_VIDEO_CAPS_RGBx ";"
-        GST_VIDEO_CAPS_xBGR "; " GST_VIDEO_CAPS_xRGB)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ BGRx, RGBx, xBGR, xRGB }"))
     );
 
 
-
 static GstFlowReturn
 gst_streaktv_transform (GstBaseTransform * trans, GstBuffer * in,
     GstBuffer * out)
 {
   GstStreakTV *filter = GST_STREAKTV (trans);
   guint32 *src, *dest;
-  GstFlowReturn ret = GST_FLOW_OK;
+  GstVideoFrame in_frame, out_frame;
   gint i, cf;
-  gint video_area = filter->width * filter->height;
+  gint video_area, width, height;
   guint32 **planetable = filter->planetable;
   gint plane = filter->plane;
   guint stride_mask, stride_shift, stride;
 
+  if (!gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ))
+    goto invalid_in;
+
+  if (!gst_video_frame_map (&out_frame, &filter->info, out, GST_MAP_WRITE))
+    goto invalid_out;
+
+  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (&in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (&in_frame);
+
+  video_area = width * height;
+
   GST_OBJECT_LOCK (filter);
   if (filter->feedback) {
     stride_mask = 0xfcfcfcfc;
@@ -106,9 +115,6 @@ gst_streaktv_transform (GstBaseTransform * trans, GstBuffer * in,
     stride_shift = 3;
   }
 
-  src = (guint32 *) GST_BUFFER_DATA (in);
-  dest = (guint32 *) GST_BUFFER_DATA (out);
-
   for (i = 0; i < video_area; i++) {
     planetable[plane][i] = (src[i] & stride_mask) >> stride_shift;
   }
@@ -139,7 +145,23 @@ gst_streaktv_transform (GstBaseTransform * trans, GstBuffer * in,
   filter->plane = plane & (PLANES - 1);
   GST_OBJECT_UNLOCK (filter);
 
-  return ret;
+  gst_video_frame_unmap (&in_frame);
+  gst_video_frame_unmap (&out_frame);
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+invalid_in:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid input frame");
+    return GST_FLOW_ERROR;
+  }
+invalid_out:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid output frame");
+    gst_video_frame_unmap (&in_frame);
+    return GST_FLOW_ERROR;
+  }
 }
 
 static gboolean
@@ -147,30 +169,33 @@ gst_streaktv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstStreakTV *filter = GST_STREAKTV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
+  gint i, width, height;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  GST_OBJECT_LOCK (filter);
-  if (gst_structure_get_int (structure, "width", &filter->width) &&
-      gst_structure_get_int (structure, "height", &filter->height)) {
-    gint i;
+  filter->info = info;
 
-    if (filter->planebuffer)
-      g_free (filter->planebuffer);
+  width = GST_VIDEO_INFO_WIDTH (&info);
+  height = GST_VIDEO_INFO_HEIGHT (&info);
 
-    filter->planebuffer =
-        g_new0 (guint32, filter->width * filter->height * 4 * PLANES);
-    for (i = 0; i < PLANES; i++)
-      filter->planetable[i] =
-          &filter->planebuffer[filter->width * filter->height * i];
+  if (filter->planebuffer)
+    g_free (filter->planebuffer);
 
-    ret = TRUE;
-  }
-  GST_OBJECT_UNLOCK (filter);
+  filter->planebuffer = g_new0 (guint32, width * height * 4 * PLANES);
+
+  for (i = 0; i < PLANES; i++)
+    filter->planetable[i] = &filter->planebuffer[width * height * i];
 
-  return ret;
+  return TRUE;
+
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid caps received");
+    return FALSE;
+  }
 }
 
 static gboolean
@@ -235,26 +260,10 @@ gst_streaktv_get_property (GObject * object, guint prop_id, GValue * value,
 }
 
 static void
-gst_streaktv_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "StreakTV effect",
-      "Filter/Effect/Video",
-      "StreakTV makes after images of moving objects",
-      "FUKUCHI, Kentarou <fukuchi@users.sourceforge.net>, "
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_streaktv_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_streaktv_src_template));
-}
-
-static void
 gst_streaktv_class_init (GstStreakTVClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
   gobject_class->set_property = gst_streaktv_set_property;
@@ -267,13 +276,24 @@ gst_streaktv_class_init (GstStreakTVClass * klass)
           "Feedback", DEFAULT_FEEDBACK,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "StreakTV effect",
+      "Filter/Effect/Video",
+      "StreakTV makes after images of moving objects",
+      "FUKUCHI, Kentarou <fukuchi@users.sourceforge.net>, "
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_streaktv_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_streaktv_src_template));
+
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_streaktv_set_caps);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_streaktv_transform);
   trans_class->start = GST_DEBUG_FUNCPTR (gst_streaktv_start);
 }
 
 static void
-gst_streaktv_init (GstStreakTV * filter, GstStreakTVClass * klass)
+gst_streaktv_init (GstStreakTV * filter)
 {
   filter->feedback = DEFAULT_FEEDBACK;
 
index 0e49a00..fb96cad 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -54,7 +55,7 @@ struct _GstStreakTV
   GstVideoFilter element;
 
   /* < private > */
-  gint width, height;
+  GstVideoInfo info;
 
   gboolean feedback;
 
index 2f7ac7c..0e38275 100644 (file)
@@ -29,7 +29,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! vertigotv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! vertigotv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of vertigotv on a test stream.
  * </refsect2>
  */
 
 #include "gstvertigo.h"
 
-#include <gst/video/video.h>
 #include <gst/controller/gstcontroller.h>
 
-GST_BOILERPLATE (GstVertigoTV, gst_vertigotv, GstVideoFilter,
-    GST_TYPE_VIDEO_FILTER);
+#define gst_vertigotv_parent_class parent_class
+G_DEFINE_TYPE (GstVertigoTV, gst_vertigotv, GST_TYPE_VIDEO_FILTER);
 
 /* Filter signals and args */
 enum
@@ -58,9 +57,9 @@ enum
 };
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define CAPS_STR GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_BGRx
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ RGBx, BGRx }")
 #else
-#define CAPS_STR GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ xRGB, xBGR }")
 #endif
 
 static GstStaticPadTemplate gst_vertigotv_src_template =
@@ -82,28 +81,34 @@ gst_vertigotv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstVertigoTV *filter = GST_VERTIGOTV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
+  gint area, width, height;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  GST_OBJECT_LOCK (filter);
-  if (gst_structure_get_int (structure, "width", &filter->width) &&
-      gst_structure_get_int (structure, "height", &filter->height)) {
-    gint area = filter->width * filter->height;
+  filter->info = info;
 
-    g_free (filter->buffer);
-    filter->buffer = (guint32 *) g_malloc0 (area * 2 * sizeof (guint32));
+  width = GST_VIDEO_INFO_WIDTH (&info);
+  height = GST_VIDEO_INFO_HEIGHT (&info);
 
-    filter->current_buffer = filter->buffer;
-    filter->alt_buffer = filter->buffer + area;
-    filter->phase = 0;
+  area = width * height;
 
-    ret = TRUE;
-  }
-  GST_OBJECT_UNLOCK (filter);
+  g_free (filter->buffer);
+  filter->buffer = (guint32 *) g_malloc0 (area * 2 * sizeof (guint32));
+
+  filter->current_buffer = filter->buffer;
+  filter->alt_buffer = filter->buffer + area;
+  filter->phase = 0;
 
-  return ret;
+  return TRUE;
+
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid caps received");
+    return FALSE;
+  }
 }
 
 static void
@@ -113,15 +118,19 @@ gst_vertigotv_set_parms (GstVertigoTV * filter)
   double t;
   double x, y;
   double dizz;
+  gint width, height;
 
   dizz = sin (filter->phase) * 10 + sin (filter->phase * 1.9 + 5) * 5;
 
-  x = filter->width / 2;
-  y = filter->height / 2;
+  width = GST_VIDEO_INFO_WIDTH (&filter->info);
+  height = GST_VIDEO_INFO_HEIGHT (&filter->info);
+
+  x = width / 2;
+  y = height / 2;
 
   t = (x * x + y * y) * filter->zoomrate;
 
-  if (filter->width > filter->height) {
+  if (width > height) {
     if (dizz >= 0) {
       if (dizz > x)
         dizz = x;
@@ -161,9 +170,9 @@ gst_vertigotv_transform (GstBaseTransform * trans, GstBuffer * in,
   GstVertigoTV *filter = GST_VERTIGOTV (trans);
   guint32 *src, *dest, *p;
   guint32 v;
-  gint x, y, ox, oy, i, width, height, area;
-  GstFlowReturn ret = GST_FLOW_OK;
+  gint x, y, ox, oy, i, width, height, area, sstride, dstride;
   GstClockTime timestamp, stream_time;
+  GstVideoFrame in_frame, out_frame;
 
   timestamp = GST_BUFFER_TIMESTAMP (in);
   stream_time =
@@ -175,23 +184,33 @@ gst_vertigotv_transform (GstBaseTransform * trans, GstBuffer * in,
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
     gst_object_sync_values (G_OBJECT (filter), stream_time);
 
-  src = (guint32 *) GST_BUFFER_DATA (in);
-  dest = (guint32 *) GST_BUFFER_DATA (out);
+  if (!gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ))
+    goto invalid_in;
 
-  GST_OBJECT_LOCK (filter);
+  if (!gst_video_frame_map (&out_frame, &filter->info, out, GST_MAP_WRITE))
+    goto invalid_out;
+
+  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  sstride = GST_VIDEO_FRAME_PLANE_STRIDE (&in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
+  dstride = GST_VIDEO_FRAME_PLANE_STRIDE (&out_frame, 0);
+
+  width = GST_VIDEO_FRAME_WIDTH (&in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (&in_frame);
 
-  width = filter->width;
-  height = filter->height;
   area = width * height;
 
+  sstride /= 4;
+  dstride /= 4;
+
   gst_vertigotv_set_parms (filter);
   p = filter->alt_buffer;
 
-  for (y = height; y > 0; y--) {
+  for (y = 0; y < height; y++) {
     ox = filter->sx;
     oy = filter->sy;
 
-    for (x = width; x > 0; x--) {
+    for (x = 0; x < width; x++) {
       i = (oy >> 16) * width + (ox >> 16);
       if (i < 0)
         i = 0;
@@ -199,24 +218,38 @@ gst_vertigotv_transform (GstBaseTransform * trans, GstBuffer * in,
         i = area;
 
       v = filter->current_buffer[i] & 0xfcfcff;
-      v = (v * 3) + ((*src++) & 0xfcfcff);
+      v = (v * 3) + (src[x] & 0xfcfcff);
 
-      *p++ = (v >> 2);
+      *p++ = dest[x] = (v >> 2);
       ox += filter->dx;
       oy += filter->dy;
     }
     filter->sx -= filter->dy;
     filter->sy += filter->dx;
-  }
 
-  memcpy (dest, filter->alt_buffer, area * sizeof (guint32));
+    src += sstride;
+    dest += dstride;
+  }
 
   p = filter->current_buffer;
   filter->current_buffer = filter->alt_buffer;
   filter->alt_buffer = p;
-  GST_OBJECT_UNLOCK (filter);
 
-  return ret;
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+invalid_in:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid input frame");
+    return GST_FLOW_ERROR;
+  }
+invalid_out:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid output frame");
+    gst_video_frame_unmap (&in_frame);
+    return GST_FLOW_ERROR;
+  }
+
 }
 
 static gboolean
@@ -280,25 +313,10 @@ gst_vertigotv_finalize (GObject * object)
 }
 
 static void
-gst_vertigotv_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "VertigoTV effect",
-      "Filter/Effect/Video",
-      "A loopback alpha blending effector with rotating and scaling",
-      "Wim Taymans <wim.taymans@chello.be>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_vertigotv_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_vertigotv_src_template));
-}
-
-static void
 gst_vertigotv_class_init (GstVertigoTVClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
   gobject_class->set_property = gst_vertigotv_set_property;
@@ -313,13 +331,23 @@ gst_vertigotv_class_init (GstVertigoTVClass * klass)
           "Control the rate of zooming", 1.01, 1.1, 1.01,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "VertigoTV effect",
+      "Filter/Effect/Video",
+      "A loopback alpha blending effector with rotating and scaling",
+      "Wim Taymans <wim.taymans@gmail.be>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_vertigotv_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_vertigotv_src_template));
+
   trans_class->start = GST_DEBUG_FUNCPTR (gst_vertigotv_start);
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_vertigotv_set_caps);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_vertigotv_transform);
 }
 
 static void
-gst_vertigotv_init (GstVertigoTV * filter, GstVertigoTVClass * klass)
+gst_vertigotv_init (GstVertigoTV * filter)
 {
   filter->buffer = NULL;
   filter->phase = 0.0;
index efc63ec..8e03da2 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -49,8 +50,8 @@ struct _GstVertigoTV
   GstVideoFilter videofilter;
 
   /* < private > */
+  GstVideoInfo info;
 
-  gint width, height;
   guint32 *buffer;
   guint32 *current_buffer, *alt_buffer;
   gint dx, dy;
index e5eb758..72a45c0 100644 (file)
@@ -41,7 +41,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! warptv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! warptv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of warptv on a test stream.
  * </refsect2>
  */
 #include <math.h>
 
 #include "gstwarp.h"
-
-#include <gst/video/video.h>
+#include <gst/video/gstmetavideo.h>
+#include <gst/video/gstvideopool.h>
 
 #ifndef M_PI
 #define M_PI    3.14159265358979323846
 #endif
 
-GST_BOILERPLATE (GstWarpTV, gst_warptv, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
+#define gst_warptv_parent_class parent_class
+G_DEFINE_TYPE (GstWarpTV, gst_warptv, GST_TYPE_VIDEO_FILTER);
 
 static void initSinTable ();
-static void initOffsTable (GstWarpTV * filter);
-static void initDistTable (GstWarpTV * filter);
+static void initDistTable (GstWarpTV * filter, gint width, gint height);
 
 static GstStaticPadTemplate gst_warptv_src_template =
-    GST_STATIC_PAD_TEMPLATE ("src",
+GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_xRGB ";"
-        GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ RGBx, xRGB, BGRx, xBGR }"))
     );
 
 static GstStaticPadTemplate gst_warptv_sink_template =
-    GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_xRGB ";"
-        GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR)
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ RGBx, xRGB, BGRx, xBGR }"))
     );
 
 static gboolean
@@ -88,28 +86,29 @@ gst_warptv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstWarpTV *filter = GST_WARPTV (btrans);
-  GstStructure *structure;
-  gboolean ret = FALSE;
+  GstVideoInfo info;
+  gint width, height;
 
-  structure = gst_caps_get_structure (incaps, 0);
+  if (!gst_video_info_from_caps (&info, incaps))
+    goto invalid_caps;
 
-  GST_OBJECT_LOCK (filter);
-  if (gst_structure_get_int (structure, "width", &filter->width) &&
-      gst_structure_get_int (structure, "height", &filter->height)) {
-    g_free (filter->disttable);
-    g_free (filter->offstable);
+  filter->info = info;
 
-    filter->offstable = g_malloc (filter->height * sizeof (guint32));
-    filter->disttable =
-        g_malloc (filter->width * filter->height * sizeof (guint32));
+  width = GST_VIDEO_INFO_WIDTH (&info);
+  height = GST_VIDEO_INFO_HEIGHT (&info);
 
-    initOffsTable (filter);
-    initDistTable (filter);
-    ret = TRUE;
-  }
-  GST_OBJECT_UNLOCK (filter);
+  g_free (filter->disttable);
+  filter->disttable = g_malloc (width * height * sizeof (guint32));
+  initDistTable (filter, width, height);
 
-  return ret;
+  return TRUE;
+
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (filter, "invalid caps received");
+    return FALSE;
+  }
 }
 
 static gint32 sintable[1024 + 256];
@@ -130,17 +129,7 @@ initSinTable (void)
 }
 
 static void
-initOffsTable (GstWarpTV * filter)
-{
-  gint y;
-
-  for (y = 0; y < filter->height; y++) {
-    filter->offstable[y] = y * filter->width;
-  }
-}
-
-static void
-initDistTable (GstWarpTV * filter)
+initDistTable (GstWarpTV * filter, gint width, gint height)
 {
   gint32 halfw, halfh, *distptr;
   gint x, y;
@@ -150,8 +139,8 @@ initDistTable (GstWarpTV * filter)
   float m;
 #endif
 
-  halfw = filter->width >> 1;
-  halfh = filter->height >> 1;
+  halfw = width >> 1;
+  halfh = height >> 1;
 
   distptr = filter->disttable;
 
@@ -171,18 +160,27 @@ gst_warptv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
 {
   GstWarpTV *warptv = GST_WARPTV (trans);
   gint width, height;
-  guint32 *src = (guint32 *) GST_BUFFER_DATA (in);
-  guint32 *dest = (guint32 *) GST_BUFFER_DATA (out);
   gint xw, yw, cw;
   gint32 c, i, x, y, dx, dy, maxx, maxy;
-  gint32 skip, *ctptr, *distptr;
+  gint32 *ctptr, *distptr;
   gint32 *ctable;
-  GstFlowReturn ret = GST_FLOW_OK;
+  guint32 *src, *dest;
+  gint sstride, dstride;
+  GstVideoFrame in_frame, out_frame;
 
-  GST_OBJECT_LOCK (warptv);
-  width = warptv->width;
-  height = warptv->height;
+  gst_video_frame_map (&in_frame, &warptv->info, in, GST_MAP_READ);
+  gst_video_frame_map (&out_frame, &warptv->info, out, GST_MAP_WRITE);
+
+  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
+
+  sstride = GST_VIDEO_FRAME_PLANE_STRIDE (&in_frame, 0) / 4;
+  dstride = GST_VIDEO_FRAME_PLANE_STRIDE (&out_frame, 0) / 4;
+
+  width = GST_VIDEO_FRAME_WIDTH (&in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (&in_frame);
 
+  GST_OBJECT_LOCK (warptv);
   xw = (gint) (sin ((warptv->tval + 100) * M_PI / 128) * 30);
   yw = (gint) (sin ((warptv->tval) * M_PI / 256) * -35);
   cw = (gint) (sin ((warptv->tval - 70) * M_PI / 64) * 50);
@@ -193,7 +191,6 @@ gst_warptv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
   distptr = warptv->disttable;
   ctable = warptv->ctable;
 
-  skip = 0;                     /* video_width*sizeof(RGB32)/4 - video_width;; */
   c = 0;
 
   for (x = 0; x < 512; x++) {
@@ -220,15 +217,19 @@ gst_warptv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
         dy = 0;
       else if (dy > maxy)
         dy = maxy;
-      *dest++ = src[warptv->offstable[dy] + dx];
+
+      dest[x] = src[dy * sstride + dx];
     }
-    dest += skip;
+    dest += dstride;
   }
 
   warptv->tval = (warptv->tval + 1) & 511;
   GST_OBJECT_UNLOCK (warptv);
 
-  return ret;
+  gst_video_frame_unmap (&in_frame);
+  gst_video_frame_unmap (&out_frame);
+
+  return GST_FLOW_OK;
 }
 
 static gboolean
@@ -241,13 +242,31 @@ gst_warptv_start (GstBaseTransform * trans)
   return TRUE;
 }
 
+static gboolean
+gst_wraptv_decide_allocation (GstBaseTransform * trans, GstQuery * query)
+{
+  GstBufferPool *pool = NULL;
+  guint size, min, max, prefix, alignment;
+
+  gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
+      &alignment, &pool);
+
+  if (pool) {
+    GstStructure *config;
+
+    config = gst_buffer_pool_get_config (pool);
+    gst_buffer_pool_config_add_option (config,
+        GST_BUFFER_POOL_OPTION_META_VIDEO);
+    gst_buffer_pool_set_config (pool, config);
+  }
+  return TRUE;
+}
+
 static void
 gst_warptv_finalize (GObject * object)
 {
   GstWarpTV *warptv = GST_WARPTV (object);
 
-  g_free (warptv->offstable);
-  warptv->offstable = NULL;
   g_free (warptv->disttable);
   warptv->disttable = NULL;
 
@@ -255,38 +274,35 @@ gst_warptv_finalize (GObject * object)
 }
 
 static void
-gst_warptv_base_init (gpointer g_class)
+gst_warptv_class_init (GstWarpTVClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
+  GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
-  gst_element_class_set_details_simple (element_class, "WarpTV effect",
+  gobject_class->finalize = gst_warptv_finalize;
+
+  gst_element_class_set_details_simple (gstelement_class, "WarpTV effect",
       "Filter/Effect/Video",
       "WarpTV does realtime goo'ing of the video input",
       "Sam Lantinga <slouken@devolution.com>");
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_warptv_sink_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_warptv_src_template));
-}
-
-static void
-gst_warptv_class_init (GstWarpTVClass * klass)
-{
-  GObjectClass *gobject_class = (GObjectClass *) klass;
-  GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
-
-  gobject_class->finalize = gst_warptv_finalize;
 
   trans_class->start = GST_DEBUG_FUNCPTR (gst_warptv_start);
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_warptv_set_caps);
+  trans_class->decide_allocation =
+      GST_DEBUG_FUNCPTR (gst_wraptv_decide_allocation);
   trans_class->transform = GST_DEBUG_FUNCPTR (gst_warptv_transform);
 
   initSinTable ();
 }
 
 static void
-gst_warptv_init (GstWarpTV * warptv, GstWarpTVClass * klass)
+gst_warptv_init (GstWarpTV * warptv)
 {
   gst_pad_use_fixed_caps (GST_BASE_TRANSFORM_SRC_PAD (warptv));
   gst_pad_use_fixed_caps (GST_BASE_TRANSFORM_SINK_PAD (warptv));
index a987960..4c53499 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <gst/gst.h>
 
+#include <gst/video/video.h>
 #include <gst/video/gstvideofilter.h>
 
 G_BEGIN_DECLS
@@ -49,9 +50,8 @@ struct _GstWarpTV
   GstVideoFilter videofilter;
 
   /* < private > */
+  GstVideoInfo info;
 
-  gint width, height;
-  gint *offstable;
   gint32 *disttable;
   gint32 ctable[1024];
   gint tval;
index 0b76748..f7ef5c3 100644 (file)
@@ -43,39 +43,23 @@ static void gst_iir_equalizer_child_proxy_interface_init (gpointer g_iface,
 static void gst_iir_equalizer_finalize (GObject * object);
 
 static gboolean gst_iir_equalizer_setup (GstAudioFilter * filter,
-    GstRingBufferSpec * fmt);
+    const GstAudioInfo * info);
 static GstFlowReturn gst_iir_equalizer_transform_ip (GstBaseTransform * btrans,
     GstBuffer * buf);
 
 #define ALLOWED_CAPS \
-    "audio/x-raw-int,"                                                \
-    " depth=(int)16,"                                                 \
-    " width=(int)16,"                                                 \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " signed=(bool)TRUE,"                                             \
-    " rate=(int)[1000,MAX],"                                          \
-    " channels=(int)[1,MAX]; "                                        \
-    "audio/x-raw-float,"                                              \
-    " width=(int) { 32, 64 } ,"                                       \
-    " endianness=(int)BYTE_ORDER,"                                    \
-    " rate=(int)[1000,MAX],"                                          \
+    "audio/x-raw,"                                                \
+    " format=(string) {"GST_AUDIO_NE(S16)","GST_AUDIO_NE(F32)","  \
+                        GST_AUDIO_NE(F64)" }, "                   \
+    " rate=(int)[1000,MAX],"                                      \
     " channels=(int)[1,MAX]"
 
-static void
-_do_init (GType object_type)
-{
-  const GInterfaceInfo child_proxy_interface_info = {
-    (GInterfaceInitFunc) gst_iir_equalizer_child_proxy_interface_init,
-    NULL,                       /* interface_finalize */
-    NULL                        /* interface_data */
-  };
-
-  g_type_add_interface_static (object_type, GST_TYPE_CHILD_PROXY,
-      &child_proxy_interface_info);
-}
+#define gst_iir_equalizer_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstIirEqualizer, gst_iir_equalizer,
+    GST_TYPE_AUDIO_FILTER,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_CHILD_PROXY,
+        gst_iir_equalizer_child_proxy_interface_init));
 
-GST_BOILERPLATE_FULL (GstIirEqualizer, gst_iir_equalizer,
-    GstAudioFilter, GST_TYPE_AUDIO_FILTER, _do_init);
 
 /* child object */
 
@@ -364,30 +348,24 @@ gst_iir_equalizer_child_proxy_interface_init (gpointer g_iface,
 /* equalizer implementation */
 
 static void
-gst_iir_equalizer_base_init (gpointer g_class)
-{
-  GstAudioFilterClass *audiofilter_class = GST_AUDIO_FILTER_CLASS (g_class);
-  GstCaps *caps;
-
-  caps = gst_caps_from_string (ALLOWED_CAPS);
-  gst_audio_filter_class_add_pad_templates (audiofilter_class, caps);
-  gst_caps_unref (caps);
-}
-
-static void
 gst_iir_equalizer_class_init (GstIirEqualizerClass * klass)
 {
   GstAudioFilterClass *audio_filter_class = (GstAudioFilterClass *) klass;
   GstBaseTransformClass *btrans_class = (GstBaseTransformClass *) klass;
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstCaps *caps;
 
   gobject_class->finalize = gst_iir_equalizer_finalize;
   audio_filter_class->setup = gst_iir_equalizer_setup;
   btrans_class->transform_ip = gst_iir_equalizer_transform_ip;
+
+  caps = gst_caps_from_string (ALLOWED_CAPS);
+  gst_audio_filter_class_add_pad_templates (audio_filter_class, caps);
+  gst_caps_unref (caps);
 }
 
 static void
-gst_iir_equalizer_init (GstIirEqualizer * eq, GstIirEqualizerClass * g_class)
+gst_iir_equalizer_init (GstIirEqualizer * eq)
 {
   eq->bands_lock = g_mutex_new ();
   eq->need_new_coefficients = TRUE;
@@ -480,15 +458,17 @@ calculate_bw (GstIirEqualizerBand * band, gint rate)
 static void
 setup_peak_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
 {
-  g_return_if_fail (GST_AUDIO_FILTER (equ)->format.rate);
+  gint rate = GST_AUDIO_FILTER_RATE (equ);
+
+  g_return_if_fail (rate);
 
   {
     gdouble gain, omega, bw;
     gdouble alpha, alpha1, alpha2, b0;
 
     gain = arg_to_scale (band->gain);
-    omega = calculate_omega (band->freq, GST_AUDIO_FILTER (equ)->format.rate);
-    bw = calculate_bw (band, GST_AUDIO_FILTER (equ)->format.rate);
+    omega = calculate_omega (band->freq, rate);
+    bw = calculate_bw (band, rate);
     if (bw == 0.0)
       goto out;
 
@@ -516,7 +496,9 @@ setup_peak_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
 static void
 setup_low_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
 {
-  g_return_if_fail (GST_AUDIO_FILTER (equ)->format.rate);
+  gint rate = GST_AUDIO_FILTER_RATE (equ);
+
+  g_return_if_fail (rate);
 
   {
     gdouble gain, omega, bw;
@@ -524,8 +506,8 @@ setup_low_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
     gdouble egp, egm;
 
     gain = arg_to_scale (band->gain);
-    omega = calculate_omega (band->freq, GST_AUDIO_FILTER (equ)->format.rate);
-    bw = calculate_bw (band, GST_AUDIO_FILTER (equ)->format.rate);
+    omega = calculate_omega (band->freq, rate);
+    bw = calculate_bw (band, rate);
     if (bw == 0.0)
       goto out;
 
@@ -554,7 +536,9 @@ setup_low_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
 static void
 setup_high_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
 {
-  g_return_if_fail (GST_AUDIO_FILTER (equ)->format.rate);
+  gint rate = GST_AUDIO_FILTER_RATE (equ);
+
+  g_return_if_fail (rate);
 
   {
     gdouble gain, omega, bw;
@@ -562,8 +546,8 @@ setup_high_shelf_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
     gdouble egp, egm;
 
     gain = arg_to_scale (band->gain);
-    omega = calculate_omega (band->freq, GST_AUDIO_FILTER (equ)->format.rate);
-    bw = calculate_bw (band, GST_AUDIO_FILTER (equ)->format.rate);
+    omega = calculate_omega (band->freq, rate);
+    bw = calculate_bw (band, rate);
     if (bw == 0.0)
       goto out;
 
@@ -629,7 +613,7 @@ alloc_history (GstIirEqualizer * equ)
   /* free + alloc = no memcpy */
   g_free (equ->history);
   equ->history =
-      g_malloc0 (equ->history_size * GST_AUDIO_FILTER (equ)->format.channels *
+      g_malloc0 (equ->history_size * GST_AUDIO_FILTER_CHANNELS (equ) *
       equ->freq_band_count);
 }
 
@@ -832,8 +816,11 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
   GstAudioFilter *filter = GST_AUDIO_FILTER (btrans);
   GstIirEqualizer *equ = GST_IIR_EQUALIZER (btrans);
   GstClockTime timestamp;
+  guint8 *data;
+  gsize size;
+  gint channels = GST_AUDIO_FILTER_CHANNELS (filter);
 
-  if (G_UNLIKELY (filter->format.channels < 1 || equ->process == NULL))
+  if (G_UNLIKELY (channels < 1 || equ->process == NULL))
     return GST_FLOW_NOT_NEGOTIATED;
 
   BANDS_LOCK (equ);
@@ -853,41 +840,30 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
   if (GST_CLOCK_TIME_IS_VALID (timestamp))
     gst_object_sync_values (G_OBJECT (equ), timestamp);
 
-  equ->process (equ, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf),
-      filter->format.channels);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
+  equ->process (equ, data, size, channels);
+  gst_buffer_unmap (buf, data, size);
 
   return GST_FLOW_OK;
 }
 
 static gboolean
-gst_iir_equalizer_setup (GstAudioFilter * audio, GstRingBufferSpec * fmt)
+gst_iir_equalizer_setup (GstAudioFilter * audio, const GstAudioInfo * info)
 {
   GstIirEqualizer *equ = GST_IIR_EQUALIZER (audio);
 
-  switch (fmt->type) {
-    case GST_BUFTYPE_LINEAR:
-      switch (fmt->width) {
-        case 16:
-          equ->history_size = history_size_gint16;
-          equ->process = gst_iir_equ_process_gint16;
-          break;
-        default:
-          return FALSE;
-      }
+  switch (GST_AUDIO_INFO_FORMAT (info)) {
+    case GST_AUDIO_FORMAT_S16:
+      equ->history_size = history_size_gint16;
+      equ->process = gst_iir_equ_process_gint16;
       break;
-    case GST_BUFTYPE_FLOAT:
-      switch (fmt->width) {
-        case 32:
-          equ->history_size = history_size_gfloat;
-          equ->process = gst_iir_equ_process_gfloat;
-          break;
-        case 64:
-          equ->history_size = history_size_gdouble;
-          equ->process = gst_iir_equ_process_gdouble;
-          break;
-        default:
-          return FALSE;
-      }
+    case GST_AUDIO_FORMAT_F32:
+      equ->history_size = history_size_gfloat;
+      equ->process = gst_iir_equ_process_gfloat;
+      break;
+    case GST_AUDIO_FORMAT_F64:
+      equ->history_size = history_size_gdouble;
+      equ->process = gst_iir_equ_process_gdouble;
       break;
     default:
       return FALSE;
index b39515c..5dc790b 100644 (file)
@@ -62,39 +62,17 @@ GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
 #define GST_CAT_DEFAULT equalizer_debug
 
 
-static void
-_do_init (GType object_type)
-{
-  const GInterfaceInfo preset_interface_info = {
-    NULL,                       /* interface_init */
-    NULL,                       /* interface_finalize */
-    NULL                        /* interface_data */
-  };
-
-  g_type_add_interface_static (object_type, GST_TYPE_PRESET,
-      &preset_interface_info);
-}
-
-GST_BOILERPLATE_FULL (GstIirEqualizer10Bands, gst_iir_equalizer_10bands,
-    GstIirEqualizer, GST_TYPE_IIR_EQUALIZER, _do_init);
+#define gst_iir_equalizer_10bands_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstIirEqualizer10Bands, gst_iir_equalizer_10bands,
+    GST_TYPE_IIR_EQUALIZER, G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL));
 
 /* equalizer implementation */
 
 static void
-gst_iir_equalizer_10bands_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "10 Band Equalizer",
-      "Filter/Effect/Audio",
-      "Direct Form 10 band IIR equalizer",
-      "Stefan Kost <ensonic@users.sf.net>");
-}
-
-static void
 gst_iir_equalizer_10bands_class_init (GstIirEqualizer10BandsClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
 
   gobject_class->set_property = gst_iir_equalizer_10bands_set_property;
   gobject_class->get_property = gst_iir_equalizer_10bands_get_property;
@@ -149,11 +127,15 @@ gst_iir_equalizer_10bands_class_init (GstIirEqualizer10BandsClass * klass)
           "gain for the frequency band 15011 Hz, ranging from -24 dB to +12 dB",
           -24.0, 12.0, 0.0,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
+
+  gst_element_class_set_details_simple (gstelement_class, "10 Band Equalizer",
+      "Filter/Effect/Audio",
+      "Direct Form 10 band IIR equalizer",
+      "Stefan Kost <ensonic@users.sf.net>");
 }
 
 static void
-gst_iir_equalizer_10bands_init (GstIirEqualizer10Bands * equ_n,
-    GstIirEqualizer10BandsClass * g_class)
+gst_iir_equalizer_10bands_init (GstIirEqualizer10Bands * equ_n)
 {
   GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n);
 
index 733c5b8..513b920 100644 (file)
@@ -53,39 +53,17 @@ static void gst_iir_equalizer_3bands_get_property (GObject * object,
 GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
 #define GST_CAT_DEFAULT equalizer_debug
 
-
-static void
-_do_init (GType object_type)
-{
-  const GInterfaceInfo preset_interface_info = {
-    NULL,                       /* interface_init */
-    NULL,                       /* interface_finalize */
-    NULL                        /* interface_data */
-  };
-
-  g_type_add_interface_static (object_type, GST_TYPE_PRESET,
-      &preset_interface_info);
-}
-
-GST_BOILERPLATE_FULL (GstIirEqualizer3Bands, gst_iir_equalizer_3bands,
-    GstIirEqualizer, GST_TYPE_IIR_EQUALIZER, _do_init);
+#define gst_iir_equalizer_3bands_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstIirEqualizer3Bands, gst_iir_equalizer_3bands,
+    GST_TYPE_IIR_EQUALIZER, G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL));
 
 /* equalizer implementation */
 
 static void
-gst_iir_equalizer_3bands_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "3 Band Equalizer",
-      "Filter/Effect/Audio",
-      "Direct Form 3 band IIR equalizer", "Stefan Kost <ensonic@users.sf.net>");
-}
-
-static void
 gst_iir_equalizer_3bands_class_init (GstIirEqualizer3BandsClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
 
   gobject_class->set_property = gst_iir_equalizer_3bands_set_property;
   gobject_class->get_property = gst_iir_equalizer_3bands_get_property;
@@ -105,11 +83,14 @@ gst_iir_equalizer_3bands_class_init (GstIirEqualizer3BandsClass * klass)
           "gain for the frequency band 11 kHz, ranging from -24.0 to +12.0",
           -24.0, 12.0, 0.0,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
+
+  gst_element_class_set_details_simple (gstelement_class, "3 Band Equalizer",
+      "Filter/Effect/Audio",
+      "Direct Form 3 band IIR equalizer", "Stefan Kost <ensonic@users.sf.net>");
 }
 
 static void
-gst_iir_equalizer_3bands_init (GstIirEqualizer3Bands * equ_n,
-    GstIirEqualizer3BandsClass * g_class)
+gst_iir_equalizer_3bands_init (GstIirEqualizer3Bands * equ_n)
 {
   GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n);
 
index b507195..3ea40a2 100644 (file)
@@ -97,26 +97,17 @@ static void gst_iir_equalizer_nbands_get_property (GObject * object,
 GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
 #define GST_CAT_DEFAULT equalizer_debug
 
-GST_BOILERPLATE (GstIirEqualizerNBands, gst_iir_equalizer_nbands,
-    GstIirEqualizer, GST_TYPE_IIR_EQUALIZER);
+#define gst_iir_equalizer_nbands_parent_class parent_class
+G_DEFINE_TYPE (GstIirEqualizerNBands, gst_iir_equalizer_nbands,
+    GST_TYPE_IIR_EQUALIZER);
 
 /* equalizer implementation */
 
 static void
-gst_iir_equalizer_nbands_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "N Band Equalizer",
-      "Filter/Effect/Audio",
-      "Direct Form IIR equalizer",
-      "Benjamin Otte <otte@gnome.org>," " Stefan Kost <ensonic@users.sf.net>");
-}
-
-static void
 gst_iir_equalizer_nbands_class_init (GstIirEqualizerNBandsClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
 
   gobject_class->set_property = gst_iir_equalizer_nbands_set_property;
   gobject_class->get_property = gst_iir_equalizer_nbands_get_property;
@@ -125,11 +116,15 @@ gst_iir_equalizer_nbands_class_init (GstIirEqualizerNBandsClass * klass)
       g_param_spec_uint ("num-bands", "num-bands",
           "number of different bands to use", 1, 64, 10,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT));
+
+  gst_element_class_set_details_simple (gstelement_class, "N Band Equalizer",
+      "Filter/Effect/Audio",
+      "Direct Form IIR equalizer",
+      "Benjamin Otte <otte@gnome.org>," " Stefan Kost <ensonic@users.sf.net>");
 }
 
 static void
-gst_iir_equalizer_nbands_init (GstIirEqualizerNBands * equ_n,
-    GstIirEqualizerNBandsClass * g_class)
+gst_iir_equalizer_nbands_init (GstIirEqualizerNBands * equ_n)
 {
   GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n);
 
index 7432520..bc3413a 100644 (file)
@@ -77,7 +77,8 @@ static GstStaticPadTemplate video_src_template =
 GST_DEBUG_CATEGORY_STATIC (flvdemux_debug);
 #define GST_CAT_DEFAULT flvdemux_debug
 
-GST_BOILERPLATE (GstFlvDemux, gst_flv_demux, GstElement, GST_TYPE_ELEMENT);
+#define gst_flv_demux_parent_class parent_class
+G_DEFINE_TYPE (GstFlvDemux, gst_flv_demux, GST_TYPE_ELEMENT);
 
 /* 9 bytes of header + 4 bytes of first previous tag size */
 #define FLV_HEADER_SIZE 13
@@ -213,10 +214,8 @@ gst_flv_demux_check_seekability (GstFlvDemux * demux)
 
   /* try harder to query upstream size if we didn't get it the first time */
   if (demux->upstream_seekable && stop == -1) {
-    GstFormat fmt = GST_FORMAT_BYTES;
-
     GST_DEBUG_OBJECT (demux, "doing duration query to fix up unset stop");
-    gst_pad_query_peer_duration (demux->sinkpad, &fmt, &stop);
+    gst_pad_query_peer_duration (demux->sinkpad, GST_FORMAT_BYTES, &stop);
   }
 
   /* if upstream doesn't know the size, it's likely that it's not seekable in
@@ -527,17 +526,22 @@ static GstFlowReturn
 gst_flv_demux_parse_tag_script (GstFlvDemux * demux, GstBuffer * buffer)
 {
   GstFlowReturn ret = GST_FLOW_OK;
-  GstByteReader reader = GST_BYTE_READER_INIT_FROM_BUFFER (buffer);
+  GstByteReader reader;
   guint8 type = 0;
+  guint8 *data;
+  gsize size;
+
+  g_return_val_if_fail (gst_buffer_get_size (buffer) >= 7, GST_FLOW_ERROR);
 
-  g_return_val_if_fail (GST_BUFFER_SIZE (buffer) >= 7, GST_FLOW_ERROR);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+  gst_byte_reader_init (&reader, data, size);
 
   gst_byte_reader_skip (&reader, 7);
 
   GST_LOG_OBJECT (demux, "parsing a script tag");
 
   if (!gst_byte_reader_get_uint8 (&reader, &type))
-    return GST_FLOW_OK;
+    goto cleanup;
 
   /* Must be string */
   if (type == 2) {
@@ -554,7 +558,7 @@ gst_flv_demux_parse_tag_script (GstFlvDemux * demux, GstBuffer * buffer)
 
       if (!gst_byte_reader_get_uint8 (&reader, &type)) {
         g_free (function_name);
-        return GST_FLOW_OK;
+        goto cleanup;
       }
 
       switch (type) {
@@ -565,7 +569,7 @@ gst_flv_demux_parse_tag_script (GstFlvDemux * demux, GstBuffer * buffer)
           /* ECMA array */
           if (!gst_byte_reader_get_uint32_be (&reader, &nb_elems)) {
             g_free (function_name);
-            return GST_FLOW_OK;
+            goto cleanup;
           }
 
           /* The number of elements is just a hint, some files have
@@ -591,7 +595,7 @@ gst_flv_demux_parse_tag_script (GstFlvDemux * demux, GstBuffer * buffer)
         default:
           GST_DEBUG_OBJECT (demux, "Unhandled script data type : %d", type);
           g_free (function_name);
-          return GST_FLOW_OK;
+          goto cleanup;
       }
 
       demux->push_tags = TRUE;
@@ -616,6 +620,9 @@ gst_flv_demux_parse_tag_script (GstFlvDemux * demux, GstBuffer * buffer)
     }
   }
 
+cleanup:
+  gst_buffer_unmap (buffer, data, -1);
+
   return ret;
 }
 
@@ -656,13 +663,17 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
       break;
     case 10:
     {
+      guint8 *data = NULL;
+      gsize size;
+
+      if (demux->audio_codec_data)
+        data = gst_buffer_map (demux->audio_codec_data, &size, NULL,
+            GST_MAP_READ);
       /* use codec-data to extract and verify samplerate */
-      if (demux->audio_codec_data &&
-          GST_BUFFER_SIZE (demux->audio_codec_data) >= 2) {
+      if (demux->audio_codec_data && size >= 2) {
         gint freq_index;
 
-        freq_index =
-            ((GST_READ_UINT16_BE (GST_BUFFER_DATA (demux->audio_codec_data))));
+        freq_index = GST_READ_UINT16_BE (data);
         freq_index = (freq_index & 0x0780) >> 7;
         adjusted_rate =
             gst_codec_utils_aac_get_sample_rate_from_index (freq_index);
@@ -674,6 +685,8 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
           adjusted_rate = rate;
         }
       }
+      if (data)
+        gst_buffer_unmap (demux->audio_codec_data, data, -1);
       caps = gst_caps_new_simple ("audio/mpeg",
           "mpegversion", G_TYPE_INT, 4, "framed", G_TYPE_BOOLEAN, TRUE,
           "stream-format", G_TYPE_STRING, "raw", NULL);
@@ -766,20 +779,30 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
   guint32 pts = 0, codec_tag = 0, rate = 5512, width = 8, channels = 1;
   guint32 codec_data = 0, pts_ext = 0;
   guint8 flags = 0;
-  guint8 *data = GST_BUFFER_DATA (buffer);
+  guint8 *data;
   GstBuffer *outbuf;
+  gsize size;
 
   GST_LOG_OBJECT (demux, "parsing an audio tag");
 
   if (demux->no_more_pads && !demux->audio_pad) {
     GST_WARNING_OBJECT (demux,
         "Signaled no-more-pads already but had no audio pad -- ignoring");
-    goto beach;
+    return GST_FLOW_OK;
   }
 
-  g_return_val_if_fail (GST_BUFFER_SIZE (buffer) == demux->tag_size,
+  g_return_val_if_fail (gst_buffer_get_size (buffer) == demux->tag_size,
       GST_FLOW_ERROR);
 
+  /* Error out on tags with too small headers */
+  if (gst_buffer_get_size (buffer) < 11) {
+    GST_ERROR_OBJECT (demux, "Too small tag size (%d)",
+        gst_buffer_get_size (buffer));
+    return GST_FLOW_ERROR;
+  }
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
   /* Grab information about audio tag */
   pts = GST_READ_UINT24_BE (data);
   /* read the pts extension to 32 bits integer */
@@ -790,20 +813,13 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
   GST_LOG_OBJECT (demux, "pts bytes %02X %02X %02X %02X (%d)", data[0], data[1],
       data[2], data[3], pts);
 
-  /* Error out on tags with too small headers */
-  if (GST_BUFFER_SIZE (buffer) < 11) {
-    GST_ERROR_OBJECT (demux, "Too small tag size (%d)",
-        GST_BUFFER_SIZE (buffer));
-    return GST_FLOW_ERROR;
-  }
-
-  /* Silently skip buffers with no data */
-  if (GST_BUFFER_SIZE (buffer) == 11)
-    return GST_FLOW_OK;
-
   /* Skip the stream id and go directly to the flags */
   flags = GST_READ_UINT8 (data + 7);
 
+  /* Silently skip buffers with no data */
+  if (size == 11)
+    goto beach;
+
   /* Channels */
   if (flags & 0x01) {
     channels = 2;
@@ -858,9 +874,17 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
       ret = GST_FLOW_ERROR;
       goto beach;
     }
+#ifndef GST_DISABLE_GST_DEBUG
+    {
+      GstCaps *caps;
 
-    GST_DEBUG_OBJECT (demux, "created audio pad with caps %" GST_PTR_FORMAT,
-        GST_PAD_CAPS (demux->audio_pad));
+      caps = gst_pad_get_current_caps (demux->audio_pad);
+      GST_DEBUG_OBJECT (demux, "created audio pad with caps %" GST_PTR_FORMAT,
+          caps);
+      if (caps)
+        gst_caps_unref (caps);
+    }
+#endif
 
     /* Set functions on the pad */
     gst_pad_set_query_type_function (demux->audio_pad,
@@ -914,9 +938,8 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
   }
 
   /* Create buffer from pad */
-  outbuf =
-      gst_buffer_create_sub (buffer, 7 + codec_data,
-      demux->tag_data_size - codec_data);
+  outbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY,
+      7 + codec_data, demux->tag_data_size - codec_data);
 
   if (demux->audio_codec_tag == 10) {
     guint8 aac_packet_type = GST_READ_UINT8 (data + 8);
@@ -950,7 +973,6 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
   GST_BUFFER_DURATION (outbuf) = GST_CLOCK_TIME_NONE;
   GST_BUFFER_OFFSET (outbuf) = demux->audio_offset++;
   GST_BUFFER_OFFSET_END (outbuf) = demux->audio_offset;
-  gst_buffer_set_caps (outbuf, GST_PAD_CAPS (demux->audio_pad));
 
   if (demux->duration == GST_CLOCK_TIME_NONE ||
       demux->duration < GST_BUFFER_TIMESTAMP (outbuf))
@@ -968,24 +990,18 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
     demux->audio_need_discont = FALSE;
   }
 
-  gst_segment_set_last_stop (&demux->segment, GST_FORMAT_TIME,
-      GST_BUFFER_TIMESTAMP (outbuf));
+  demux->segment.position = GST_BUFFER_TIMESTAMP (outbuf);
 
   /* Do we need a newsegment event ? */
   if (G_UNLIKELY (demux->audio_need_segment)) {
-    if (demux->close_seg_event)
-      gst_pad_push_event (demux->audio_pad,
-          gst_event_ref (demux->close_seg_event));
-
+    /* FIXME need one segment sent for all stream to maintain a/v sync */
     if (!demux->new_seg_event) {
       GST_DEBUG_OBJECT (demux, "pushing newsegment from %"
           GST_TIME_FORMAT " to %" GST_TIME_FORMAT,
-          GST_TIME_ARGS (demux->segment.last_stop),
+          GST_TIME_ARGS (demux->segment.position),
           GST_TIME_ARGS (demux->segment.stop));
-      demux->new_seg_event =
-          gst_event_new_new_segment (FALSE, demux->segment.rate,
-          demux->segment.format, demux->segment.last_stop,
-          demux->segment.stop, demux->segment.last_stop);
+      demux->segment.start = demux->segment.time = demux->segment.position;
+      demux->new_seg_event = gst_event_new_segment (&demux->segment);
     } else {
       GST_DEBUG_OBJECT (demux, "pushing pre-generated newsegment event");
     }
@@ -997,7 +1013,8 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
 
   GST_LOG_OBJECT (demux, "pushing %d bytes buffer at pts %" GST_TIME_FORMAT
       " with duration %" GST_TIME_FORMAT ", offset %" G_GUINT64_FORMAT,
-      GST_BUFFER_SIZE (outbuf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
+      gst_buffer_get_size (outbuf),
+      GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
       GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)), GST_BUFFER_OFFSET (outbuf));
 
   if (!GST_CLOCK_TIME_IS_VALID (demux->audio_start)) {
@@ -1022,7 +1039,7 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
   ret = gst_pad_push (demux->audio_pad, outbuf);
   if (G_UNLIKELY (ret != GST_FLOW_OK)) {
     if (demux->segment.rate < 0.0 && ret == GST_FLOW_UNEXPECTED &&
-        demux->segment.last_stop > demux->segment.stop) {
+        demux->segment.position > demux->segment.stop) {
       /* In reverse playback we can get a GST_FLOW_UNEXPECTED when
        * we are at the end of the segment, so we just need to jump
        * back to the previous section. */
@@ -1043,6 +1060,8 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
   demux->audio_linked = TRUE;
 
 beach:
+  gst_buffer_unmap (buffer, data, -1);
+
   return ret;
 }
 
@@ -1144,21 +1163,28 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
   guint32 pts = 0, codec_data = 1, pts_ext = 0;
   gboolean keyframe = FALSE;
   guint8 flags = 0, codec_tag = 0;
-  guint8 *data = GST_BUFFER_DATA (buffer);
+  guint8 *data;
   GstBuffer *outbuf;
+  gsize size;
 
-  g_return_val_if_fail (GST_BUFFER_SIZE (buffer) == demux->tag_size,
+  g_return_val_if_fail (gst_buffer_get_size (buffer) == demux->tag_size,
       GST_FLOW_ERROR);
 
   GST_LOG_OBJECT (demux, "parsing a video tag");
 
-
   if (demux->no_more_pads && !demux->video_pad) {
     GST_WARNING_OBJECT (demux,
         "Signaled no-more-pads already but had no audio pad -- ignoring");
-    goto beach;
+    return GST_FLOW_OK;
+  }
+
+  if (gst_buffer_get_size (buffer) < 12) {
+    GST_ERROR_OBJECT (demux, "Too small tag size");
+    return GST_FLOW_ERROR;
   }
 
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
   /* Grab information about video tag */
   pts = GST_READ_UINT24_BE (data);
   /* read the pts extension to 32 bits integer */
@@ -1169,11 +1195,6 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
   GST_LOG_OBJECT (demux, "pts bytes %02X %02X %02X %02X (%d)", data[0], data[1],
       data[2], data[3], pts);
 
-  if (GST_BUFFER_SIZE (buffer) < 12) {
-    GST_ERROR_OBJECT (demux, "Too small tag size");
-    return GST_FLOW_ERROR;
-  }
-
   /* Skip the stream id and go directly to the flags */
   flags = GST_READ_UINT8 (data + 7);
 
@@ -1223,8 +1244,17 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
      * metadata tag that would come later and trigger a caps change */
     demux->got_par = FALSE;
 
-    GST_DEBUG_OBJECT (demux, "created video pad with caps %" GST_PTR_FORMAT,
-        GST_PAD_CAPS (demux->video_pad));
+#ifndef GST_DISABLE_GST_DEBUG
+    {
+      GstCaps *caps;
+
+      caps = gst_pad_get_current_caps (demux->video_pad);
+      GST_DEBUG_OBJECT (demux, "created video pad with caps %" GST_PTR_FORMAT,
+          caps);
+      if (caps)
+        gst_caps_unref (caps);
+    }
+#endif
 
     /* Set functions on the pad */
     gst_pad_set_query_type_function (demux->video_pad,
@@ -1280,9 +1310,8 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
   }
 
   /* Create buffer from pad */
-  outbuf =
-      gst_buffer_create_sub (buffer, 7 + codec_data,
-      demux->tag_data_size - codec_data);
+  outbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY,
+      7 + codec_data, demux->tag_data_size - codec_data);
 
   if (demux->video_codec_tag == 7) {
     guint8 avc_packet_type = GST_READ_UINT8 (data + 8);
@@ -1316,7 +1345,6 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
   GST_BUFFER_DURATION (outbuf) = GST_CLOCK_TIME_NONE;
   GST_BUFFER_OFFSET (outbuf) = demux->video_offset++;
   GST_BUFFER_OFFSET_END (outbuf) = demux->video_offset;
-  gst_buffer_set_caps (outbuf, GST_PAD_CAPS (demux->video_pad));
 
   if (demux->duration == GST_CLOCK_TIME_NONE ||
       demux->duration < GST_BUFFER_TIMESTAMP (outbuf))
@@ -1335,24 +1363,18 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
     demux->video_need_discont = FALSE;
   }
 
-  gst_segment_set_last_stop (&demux->segment, GST_FORMAT_TIME,
-      GST_BUFFER_TIMESTAMP (outbuf));
+  demux->segment.position = GST_BUFFER_TIMESTAMP (outbuf);
 
   /* Do we need a newsegment event ? */
   if (G_UNLIKELY (demux->video_need_segment)) {
-    if (demux->close_seg_event)
-      gst_pad_push_event (demux->video_pad,
-          gst_event_ref (demux->close_seg_event));
-
+    /* FIXME need one segment sent for all stream to maintain a/v sync */
     if (!demux->new_seg_event) {
       GST_DEBUG_OBJECT (demux, "pushing newsegment from %"
           GST_TIME_FORMAT " to %" GST_TIME_FORMAT,
-          GST_TIME_ARGS (demux->segment.last_stop),
+          GST_TIME_ARGS (demux->segment.position),
           GST_TIME_ARGS (demux->segment.stop));
-      demux->new_seg_event =
-          gst_event_new_new_segment (FALSE, demux->segment.rate,
-          demux->segment.format, demux->segment.last_stop,
-          demux->segment.stop, demux->segment.last_stop);
+      demux->segment.start = demux->segment.time = demux->segment.position;
+      demux->new_seg_event = gst_event_new_segment (&demux->segment);
     } else {
       GST_DEBUG_OBJECT (demux, "pushing pre-generated newsegment event");
     }
@@ -1364,7 +1386,7 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
 
   GST_LOG_OBJECT (demux, "pushing %d bytes buffer at pts %" GST_TIME_FORMAT
       " with duration %" GST_TIME_FORMAT ", offset %" G_GUINT64_FORMAT
-      ", keyframe (%d)", GST_BUFFER_SIZE (outbuf),
+      ", keyframe (%d)", gst_buffer_get_size (outbuf),
       GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
       GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)), GST_BUFFER_OFFSET (outbuf),
       keyframe);
@@ -1392,7 +1414,7 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
 
   if (G_UNLIKELY (ret != GST_FLOW_OK)) {
     if (demux->segment.rate < 0.0 && ret == GST_FLOW_UNEXPECTED &&
-        demux->segment.last_stop > demux->segment.stop) {
+        demux->segment.position > demux->segment.stop) {
       /* In reverse playback we can get a GST_FLOW_UNEXPECTED when
        * we are at the end of the segment, so we just need to jump
        * back to the previous section. */
@@ -1413,6 +1435,7 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
   demux->video_linked = TRUE;
 
 beach:
+  gst_buffer_unmap (buffer, data, -1);
   return ret;
 }
 
@@ -1424,16 +1447,20 @@ gst_flv_demux_parse_tag_timestamp (GstFlvDemux * demux, gboolean index,
   guint32 tag_data_size;
   guint8 type;
   gboolean keyframe = TRUE;
-  GstClockTime ret;
-  guint8 *data = GST_BUFFER_DATA (buffer);
+  GstClockTime ret = GST_CLOCK_TIME_NONE;
+  guint8 *data, *bdata;
+  gsize size;
 
-  g_return_val_if_fail (GST_BUFFER_SIZE (buffer) >= 12, GST_CLOCK_TIME_NONE);
+  g_return_val_if_fail (gst_buffer_get_size (buffer) >= 12,
+      GST_CLOCK_TIME_NONE);
+
+  data = bdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   type = data[0];
 
   if (type != 9 && type != 8 && type != 18) {
     GST_WARNING_OBJECT (demux, "Unsupported tag type %u", data[0]);
-    return GST_CLOCK_TIME_NONE;
+    goto exit;
   }
 
   if (type == 9)
@@ -1443,10 +1470,10 @@ gst_flv_demux_parse_tag_timestamp (GstFlvDemux * demux, gboolean index,
 
   tag_data_size = GST_READ_UINT24_BE (data + 1);
 
-  if (GST_BUFFER_SIZE (buffer) >= tag_data_size + 11 + 4) {
+  if (size >= tag_data_size + 11 + 4) {
     if (GST_READ_UINT32_BE (data + tag_data_size + 11) != tag_data_size + 11) {
       GST_WARNING_OBJECT (demux, "Invalid tag size");
-      return GST_CLOCK_TIME_NONE;
+      goto exit;
     }
   }
 
@@ -1483,6 +1510,8 @@ gst_flv_demux_parse_tag_timestamp (GstFlvDemux * demux, gboolean index,
   if (demux->duration == GST_CLOCK_TIME_NONE || demux->duration < ret)
     demux->duration = ret;
 
+exit:
+  gst_buffer_unmap (buffer, bdata, -1);
   return ret;
 }
 
@@ -1491,9 +1520,11 @@ gst_flv_demux_parse_tag_type (GstFlvDemux * demux, GstBuffer * buffer)
 {
   GstFlowReturn ret = GST_FLOW_OK;
   guint8 tag_type = 0;
-  guint8 *data = GST_BUFFER_DATA (buffer);
+  guint8 *data;
+
+  g_return_val_if_fail (gst_buffer_get_size (buffer) >= 4, GST_FLOW_ERROR);
 
-  g_return_val_if_fail (GST_BUFFER_SIZE (buffer) >= 4, GST_FLOW_ERROR);
+  data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
 
   tag_type = data[0];
 
@@ -1521,6 +1552,8 @@ gst_flv_demux_parse_tag_type (GstFlvDemux * demux, GstBuffer * buffer)
   GST_LOG_OBJECT (demux, "tag data size is %" G_GUINT64_FORMAT,
       demux->tag_data_size);
 
+  gst_buffer_unmap (buffer, data, -1);
+
   return ret;
 }
 
@@ -1528,9 +1561,11 @@ static GstFlowReturn
 gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer)
 {
   GstFlowReturn ret = GST_FLOW_OK;
-  guint8 *data = GST_BUFFER_DATA (buffer);
+  guint8 *data;
+
+  g_return_val_if_fail (gst_buffer_get_size (buffer) >= 9, GST_FLOW_ERROR);
 
-  g_return_val_if_fail (GST_BUFFER_SIZE (buffer) >= 9, GST_FLOW_ERROR);
+  data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
 
   /* Check for the FLV tag */
   if (data[0] == 'F' && data[1] == 'L' && data[2] == 'V') {
@@ -1543,12 +1578,9 @@ gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer)
     }
   }
 
-  /* Jump over the 4 first bytes */
-  data += 4;
-
   /* Now look at audio/video flags */
   {
-    guint8 flags = data[0];
+    guint8 flags = data[4];
 
     demux->has_video = demux->has_audio = FALSE;
 
@@ -1569,6 +1601,7 @@ gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer)
   demux->need_header = FALSE;
 
 beach:
+  gst_buffer_unmap (buffer, data, -1);
   return ret;
 }
 
@@ -1644,11 +1677,6 @@ gst_flv_demux_cleanup (GstFlvDemux * demux)
     demux->new_seg_event = NULL;
   }
 
-  if (demux->close_seg_event) {
-    gst_event_unref (demux->close_seg_event);
-    demux->close_seg_event = NULL;
-  }
-
   gst_adapter_clear (demux->adapter);
 
   if (demux->audio_codec_data) {
@@ -1716,7 +1744,8 @@ gst_flv_demux_chain (GstPad * pad, GstBuffer * buffer)
   demux = GST_FLV_DEMUX (gst_pad_get_parent (pad));
 
   GST_LOG_OBJECT (demux, "received buffer of %d bytes at offset %"
-      G_GUINT64_FORMAT, GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer));
+      G_GUINT64_FORMAT, gst_buffer_get_size (buffer),
+      GST_BUFFER_OFFSET (buffer));
 
   if (G_UNLIKELY (GST_BUFFER_OFFSET (buffer) == 0)) {
     GST_DEBUG_OBJECT (demux, "beginning of file, expect header");
@@ -1876,20 +1905,16 @@ parse:
 
       if (!demux->indexed) {
         if (demux->offset == demux->file_size - sizeof (guint32)) {
-          GstBuffer *buffer =
-              gst_adapter_take_buffer (demux->adapter, sizeof (guint32));
-          GstByteReader *reader = gst_byte_reader_new_from_buffer (buffer);
           guint64 seek_offset;
+          guint8 *data;
 
-          if (!gst_adapter_available (demux->adapter) >= sizeof (guint32)) {
-            /* error */
-          }
+          data = gst_adapter_take (demux->adapter, 4);
+          if (!data)
+            goto no_index;
 
-          seek_offset =
-              demux->file_size - sizeof (guint32) -
-              gst_byte_reader_peek_uint32_be_unchecked (reader);
-          gst_byte_reader_free (reader);
-          gst_buffer_unref (buffer);
+          seek_offset = demux->file_size - sizeof (guint32) -
+              GST_READ_UINT32_BE (data);
+          g_free (data);
 
           GST_INFO_OBJECT (demux,
               "Seeking to beginning of last tag at %" G_GUINT64_FORMAT,
@@ -1966,10 +1991,10 @@ gst_flv_demux_pull_range (GstFlvDemux * demux, GstPad * pad, guint64 offset,
     return ret;
   }
 
-  if (G_UNLIKELY (*buffer && GST_BUFFER_SIZE (*buffer) != size)) {
+  if (G_UNLIKELY (*buffer && gst_buffer_get_size (*buffer) != size)) {
     GST_WARNING_OBJECT (demux,
         "partial pull got %d when expecting %d from offset %" G_GUINT64_FORMAT,
-        GST_BUFFER_SIZE (*buffer), size, offset);
+        gst_buffer_get_size (*buffer), size, offset);
     gst_buffer_unref (*buffer);
     ret = GST_FLOW_UNEXPECTED;
     *buffer = NULL;
@@ -2167,15 +2192,13 @@ static GstFlowReturn
 gst_flv_demux_create_index (GstFlvDemux * demux, gint64 pos, GstClockTime ts)
 {
   gint64 size;
-  GstFormat fmt = GST_FORMAT_BYTES;
   size_t tag_size;
   guint64 old_offset;
   GstBuffer *buffer;
   GstClockTime tag_time;
   GstFlowReturn ret = GST_FLOW_OK;
 
-  if (G_UNLIKELY (!gst_pad_query_peer_duration (demux->sinkpad, &fmt, &size) ||
-          fmt != GST_FORMAT_BYTES))
+  if (!gst_pad_query_peer_duration (demux->sinkpad, GST_FORMAT_BYTES, &size))
     return GST_FLOW_OK;
 
   GST_DEBUG_OBJECT (demux, "building index at %" G_GINT64_FORMAT
@@ -2213,12 +2236,11 @@ static gint64
 gst_flv_demux_get_metadata (GstFlvDemux * demux)
 {
   gint64 ret = 0, offset;
-  GstFormat fmt = GST_FORMAT_BYTES;
   size_t tag_size, size;
   GstBuffer *buffer = NULL;
+  guint8 *data;
 
-  if (G_UNLIKELY (!gst_pad_query_peer_duration (demux->sinkpad, &fmt, &offset)
-          || fmt != GST_FORMAT_BYTES))
+  if (!gst_pad_query_peer_duration (demux->sinkpad, GST_FORMAT_BYTES, &offset))
     goto exit;
 
   ret = offset;
@@ -2231,7 +2253,9 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
           4, &buffer))
     goto exit;
 
-  tag_size = GST_READ_UINT32_BE (GST_BUFFER_DATA (buffer));
+  data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
+  tag_size = GST_READ_UINT32_BE (data);
+  gst_buffer_unmap (buffer, data, -1);
   GST_DEBUG_OBJECT (demux, "last tag size: %" G_GSIZE_FORMAT, tag_size);
   gst_buffer_unref (buffer);
   buffer = NULL;
@@ -2242,8 +2266,10 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
     goto exit;
 
   /* a consistency check */
-  size = GST_READ_UINT24_BE (GST_BUFFER_DATA (buffer) + 1);
+  data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
+  size = GST_READ_UINT24_BE (data + 1);
   if (size != tag_size - 11) {
+    gst_buffer_unmap (buffer, data, -1);
     GST_DEBUG_OBJECT (demux,
         "tag size %" G_GSIZE_FORMAT ", expected %" G_GSIZE_FORMAT
         ", corrupt or truncated file", size, tag_size - 11);
@@ -2254,7 +2280,8 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
   gst_flv_demux_parse_tag_timestamp (demux, FALSE, buffer, &size);
 
   /* maybe get some more metadata */
-  if (GST_BUFFER_DATA (buffer)[0] == 18) {
+  if (data[0] == 18) {
+    gst_buffer_unmap (buffer, data, -1);
     gst_buffer_unref (buffer);
     buffer = NULL;
     GST_DEBUG_OBJECT (demux, "script tag, pulling it to parse");
@@ -2262,6 +2289,8 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
     if (GST_FLOW_OK == gst_flv_demux_pull_range (demux, demux->sinkpad, offset,
             tag_size, &buffer))
       gst_flv_demux_parse_tag_script (demux, buffer);
+  } else {
+    gst_buffer_unmap (buffer, data, -1);
   }
 
 exit:
@@ -2319,13 +2348,13 @@ gst_flv_demux_loop (GstPad * pad)
   if (demux->segment.rate < 0.0) {
     /* check end of section */
     if ((gint64) demux->offset >= demux->to_offset ||
-        demux->segment.last_stop >= demux->segment.stop + 2 * GST_SECOND ||
+        demux->segment.position >= demux->segment.stop + 2 * GST_SECOND ||
         (demux->audio_done && demux->video_done))
       ret = gst_flv_demux_seek_to_prev_keyframe (demux);
   } else {
     /* check EOS condition */
     if ((demux->segment.stop != -1) &&
-        (demux->segment.last_stop >= demux->segment.stop)) {
+        (demux->segment.position >= demux->segment.stop)) {
       ret = GST_FLOW_UNEXPECTED;
     }
   }
@@ -2346,6 +2375,15 @@ pause:
     gst_pad_pause_task (pad);
 
     if (ret == GST_FLOW_UNEXPECTED) {
+      /* handle end-of-stream/segment */
+      /* so align our position with the end of it, if there is one
+       * this ensures a subsequent will arrive at correct base/acc time */
+      if (demux->segment.rate > 0.0 &&
+          GST_CLOCK_TIME_IS_VALID (demux->segment.stop))
+        demux->segment.position = demux->segment.stop;
+      else if (demux->segment.rate < 0.0)
+        demux->segment.position = demux->segment.start;
+
       /* perform EOS logic */
       if (!demux->no_more_pads) {
         gst_element_no_more_pads (GST_ELEMENT_CAST (demux));
@@ -2403,7 +2441,7 @@ gst_flv_demux_find_offset (GstFlvDemux * demux, GstSegment * segment)
 
   g_return_val_if_fail (segment != NULL, 0);
 
-  time = segment->last_stop;
+  time = segment->position;
 
   if (demux->index) {
     /* Let's check if we have an index entry for that seek time */
@@ -2417,7 +2455,7 @@ gst_flv_demux_find_offset (GstFlvDemux * demux, GstSegment * segment)
 
       GST_DEBUG_OBJECT (demux, "found index entry for %" GST_TIME_FORMAT
           " at %" GST_TIME_FORMAT ", seeking to %" G_GINT64_FORMAT,
-          GST_TIME_ARGS (segment->last_stop), GST_TIME_ARGS (time), bytes);
+          GST_TIME_ARGS (segment->position), GST_TIME_ARGS (time), bytes);
 
       /* Key frame seeking */
       if (segment->flags & GST_SEEK_FLAG_KEY_UNIT) {
@@ -2425,7 +2463,7 @@ gst_flv_demux_find_offset (GstFlvDemux * demux, GstSegment * segment)
         if (time < segment->start) {
           segment->start = segment->time = time;
         }
-        segment->last_stop = time;
+        segment->position = time;
       }
     } else {
       GST_DEBUG_OBJECT (demux, "no index entry found for %" GST_TIME_FORMAT,
@@ -2463,13 +2501,13 @@ flv_demux_handle_seek_push (GstFlvDemux * demux, GstEvent * event)
       &demux->segment);
 
   /* Apply the seek to our segment */
-  gst_segment_set_seek (&seeksegment, rate, format, flags,
+  gst_segment_do_seek (&seeksegment, rate, format, flags,
       start_type, start, stop_type, stop, &update);
 
   GST_DEBUG_OBJECT (demux, "segment configured %" GST_SEGMENT_FORMAT,
       &seeksegment);
 
-  if (flush || seeksegment.last_stop != demux->segment.last_stop) {
+  if (flush || seeksegment.position != demux->segment.position) {
     /* Do the actual seeking */
     guint64 offset = gst_flv_demux_find_offset (demux, &seeksegment);
 
@@ -2542,7 +2580,6 @@ gst_flv_demux_handle_seek_push (GstFlvDemux * demux, GstEvent * event)
   if (!demux->indexed) {
     guint64 seek_offset = 0;
     gboolean building_index;
-    GstFormat fmt;
 
     GST_OBJECT_LOCK (demux);
     /* handle the seek in the chain function */
@@ -2559,13 +2596,10 @@ gst_flv_demux_handle_seek_push (GstFlvDemux * demux, GstEvent * event)
     building_index = demux->building_index;
     if (!building_index) {
       demux->building_index = TRUE;
-      fmt = GST_FORMAT_BYTES;
       if (!demux->file_size
-          && !gst_pad_query_peer_duration (demux->sinkpad, &fmt,
+          && !gst_pad_query_peer_duration (demux->sinkpad, GST_FORMAT_BYTES,
               &demux->file_size)) {
-        GST_WARNING_OBJECT (demux,
-            "Cannot obtain file size - %" G_GINT64_FORMAT ", format %u",
-            demux->file_size, fmt);
+        GST_WARNING_OBJECT (demux, "Failed to query upstream file size");
         GST_OBJECT_UNLOCK (demux);
         return FALSE;
       }
@@ -2636,7 +2670,7 @@ gst_flv_demux_handle_seek_pull (GstFlvDemux * demux, GstEvent * event,
 
   if (flush) {
     /* Stop flushing upstream we need to pull */
-    gst_pad_push_event (demux->sinkpad, gst_event_new_flush_stop ());
+    gst_pad_push_event (demux->sinkpad, gst_event_new_flush_stop (TRUE));
   }
 
   /* Work on a copy until we are sure the seek succeeded. */
@@ -2646,29 +2680,29 @@ gst_flv_demux_handle_seek_pull (GstFlvDemux * demux, GstEvent * event,
       &demux->segment);
 
   /* Apply the seek to our segment */
-  gst_segment_set_seek (&seeksegment, rate, format, flags,
+  gst_segment_do_seek (&seeksegment, rate, format, flags,
       start_type, start, stop_type, stop, &update);
 
   GST_DEBUG_OBJECT (demux, "segment configured %" GST_SEGMENT_FORMAT,
       &seeksegment);
 
-  if (flush || seeksegment.last_stop != demux->segment.last_stop) {
+  if (flush || seeksegment.position != demux->segment.position) {
     /* Do the actual seeking */
     /* index is reliable if it is complete or we do not go to far ahead */
     if (seeking && !demux->indexed &&
-        seeksegment.last_stop > demux->index_max_time + 10 * GST_SECOND) {
+        seeksegment.position > demux->index_max_time + 10 * GST_SECOND) {
       GST_DEBUG_OBJECT (demux, "delaying seek to post-scan; "
           " index only up to %" GST_TIME_FORMAT,
           GST_TIME_ARGS (demux->index_max_time));
       /* stop flushing for now */
       if (flush)
-        gst_flv_demux_push_src_event (demux, gst_event_new_flush_stop ());
+        gst_flv_demux_push_src_event (demux, gst_event_new_flush_stop (TRUE));
       /* delegate scanning and index building to task thread to avoid
        * occupying main (UI) loop */
       if (demux->seek_event)
         gst_event_unref (demux->seek_event);
       demux->seek_event = gst_event_ref (event);
-      demux->seek_time = seeksegment.last_stop;
+      demux->seek_time = seeksegment.position;
       demux->state = FLV_STATE_SEEK;
       /* do not know about succes yet, but we did care and handled it */
       ret = TRUE;
@@ -2682,35 +2716,9 @@ gst_flv_demux_handle_seek_pull (GstFlvDemux * demux, GstEvent * event,
     ret = TRUE;
   }
 
-  if (G_UNLIKELY (demux->close_seg_event)) {
-    gst_event_unref (demux->close_seg_event);
-    demux->close_seg_event = NULL;
-  }
-
   if (flush) {
     /* Stop flushing, the sinks are at time 0 now */
-    gst_flv_demux_push_src_event (demux, gst_event_new_flush_stop ());
-  } else {
-    GST_DEBUG_OBJECT (demux, "closing running segment %" GST_SEGMENT_FORMAT,
-        &demux->segment);
-
-    /* Close the current segment for a linear playback */
-    if (demux->segment.rate >= 0) {
-      /* for forward playback, we played from start to last_stop */
-      demux->close_seg_event = gst_event_new_new_segment (TRUE,
-          demux->segment.rate, demux->segment.format,
-          demux->segment.start, demux->segment.last_stop, demux->segment.time);
-    } else {
-      gint64 stop;
-
-      if ((stop = demux->segment.stop) == -1)
-        stop = demux->segment.duration;
-
-      /* for reverse playback, we played from stop to last_stop. */
-      demux->close_seg_event = gst_event_new_new_segment (TRUE,
-          demux->segment.rate, demux->segment.format,
-          demux->segment.last_stop, stop, demux->segment.last_stop);
-    }
+    gst_flv_demux_push_src_event (demux, gst_event_new_flush_stop (TRUE));
   }
 
   if (ret) {
@@ -2721,7 +2729,7 @@ gst_flv_demux_handle_seek_pull (GstFlvDemux * demux, GstEvent * event,
     if (demux->segment.flags & GST_SEEK_FLAG_SEGMENT) {
       gst_element_post_message (GST_ELEMENT (demux),
           gst_message_new_segment_start (GST_OBJECT (demux),
-              demux->segment.format, demux->segment.last_stop));
+              demux->segment.format, demux->segment.position));
     }
 
     /* Tell all the stream a new segment is needed */
@@ -2740,10 +2748,7 @@ gst_flv_demux_handle_seek_pull (GstFlvDemux * demux, GstEvent * event,
           GST_TIME_FORMAT " to %" GST_TIME_FORMAT,
           GST_TIME_ARGS (demux->segment.start),
           GST_TIME_ARGS (demux->segment.stop));
-      demux->new_seg_event =
-          gst_event_new_new_segment (FALSE, demux->segment.rate,
-          demux->segment.format, demux->segment.start,
-          demux->segment.stop, demux->segment.start);
+      demux->new_seg_event = gst_event_new_segment (&demux->segment);
     }
   }
 
@@ -2781,9 +2786,28 @@ wrong_format:
 static gboolean
 gst_flv_demux_sink_activate (GstPad * sinkpad)
 {
-  if (gst_pad_check_pull_range (sinkpad)) {
-    return gst_pad_activate_pull (sinkpad, TRUE);
-  } else {
+  GstQuery *query;
+  gboolean pull_mode;
+
+  query = gst_query_new_scheduling ();
+
+  if (!gst_pad_peer_query (sinkpad, query)) {
+    gst_query_unref (query);
+    goto activate_push;
+  }
+
+  gst_query_parse_scheduling (query, &pull_mode, NULL, NULL, NULL, NULL, NULL);
+  gst_query_unref (query);
+
+  if (!pull_mode)
+    goto activate_push;
+
+  GST_DEBUG_OBJECT (sinkpad, "activating pull");
+  return gst_pad_activate_pull (sinkpad, TRUE);
+
+activate_push:
+  {
+    GST_DEBUG_OBJECT (sinkpad, "activating push");
     return gst_pad_activate_push (sinkpad, TRUE);
   }
 }
@@ -2862,22 +2886,17 @@ gst_flv_demux_sink_event (GstPad * pad, GstEvent * event)
         GST_WARNING_OBJECT (demux, "failed pushing EOS on streams");
       ret = TRUE;
       break;
-    case GST_EVENT_NEWSEGMENT:
+    case GST_EVENT_SEGMENT:
     {
-      GstFormat format;
-      gdouble rate;
-      gint64 start, stop, time;
-      gboolean update;
+      GstSegment in_segment;
 
       GST_DEBUG_OBJECT (demux, "received new segment");
 
-      gst_event_parse_new_segment (event, &update, &rate, &format, &start,
-          &stop, &time);
+      gst_event_copy_segment (event, &in_segment);
 
-      if (format == GST_FORMAT_TIME) {
+      if (in_segment.format == GST_FORMAT_TIME) {
         /* time segment, this is perfect, copy over the values. */
-        gst_segment_set_newsegment (&demux->segment, update, rate, format,
-            start, stop, time);
+        memcpy (&demux->segment, &in_segment, sizeof (in_segment));
 
         GST_DEBUG_OBJECT (demux, "NEWSEGMENT: %" GST_SEGMENT_FORMAT,
             &demux->segment);
@@ -2976,9 +2995,9 @@ gst_flv_demux_query (GstPad * pad, GstQuery * query)
       }
 
       GST_DEBUG_OBJECT (pad, "position query, replying %" GST_TIME_FORMAT,
-          GST_TIME_ARGS (demux->segment.last_stop));
+          GST_TIME_ARGS (demux->segment.position));
 
-      gst_query_set_position (query, GST_FORMAT_TIME, demux->segment.last_stop);
+      gst_query_set_position (query, GST_FORMAT_TIME, demux->segment.position);
 
       break;
     }
@@ -3152,11 +3171,6 @@ gst_flv_demux_dispose (GObject * object)
     demux->new_seg_event = NULL;
   }
 
-  if (demux->close_seg_event) {
-    gst_event_unref (demux->close_seg_event);
-    demux->close_seg_event = NULL;
-  }
-
   if (demux->audio_codec_data) {
     gst_buffer_unref (demux->audio_codec_data);
     demux->audio_codec_data = NULL;
@@ -3196,23 +3210,6 @@ gst_flv_demux_dispose (GObject * object)
 }
 
 static void
-gst_flv_demux_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&flv_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&audio_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&video_src_template));
-  gst_element_class_set_details_simple (element_class, "FLV Demuxer",
-      "Codec/Demuxer",
-      "Demux FLV feeds into digital streams",
-      "Julien Moutte <julien@moutte.net>");
-}
-
-static void
 gst_flv_demux_class_init (GstFlvDemuxClass * klass)
 {
   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
@@ -3224,10 +3221,21 @@ gst_flv_demux_class_init (GstFlvDemuxClass * klass)
       GST_DEBUG_FUNCPTR (gst_flv_demux_change_state);
   gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_flv_demux_set_index);
   gstelement_class->get_index = GST_DEBUG_FUNCPTR (gst_flv_demux_get_index);
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&flv_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&audio_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&video_src_template));
+  gst_element_class_set_details_simple (gstelement_class, "FLV Demuxer",
+      "Codec/Demuxer",
+      "Demux FLV feeds into digital streams",
+      "Julien Moutte <julien@moutte.net>");
 }
 
 static void
-gst_flv_demux_init (GstFlvDemux * demux, GstFlvDemuxClass * g_class)
+gst_flv_demux_init (GstFlvDemux * demux)
 {
   demux->sinkpad =
       gst_pad_new_from_static_template (&flv_sink_template, "sink");
index 60083e8..3b50f96 100644 (file)
@@ -71,7 +71,6 @@ struct _GstFlvDemux
 
   GstSegment segment;
 
-  GstEvent *close_seg_event;
   GstEvent *new_seg_event;
 
   GstTagList *taglist;
index f1612a4..69e2622 100644 (file)
@@ -82,19 +82,9 @@ static GstStaticPadTemplate audiosink_templ = GST_STATIC_PAD_TEMPLATE ("audio",
         "audio/x-speex, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 };")
     );
 
-#define _do_init(type)                                                          \
-  G_STMT_START{                                                                 \
-    static const GInterfaceInfo tag_setter_info = {                             \
-      NULL,                                                                     \
-      NULL,                                                                     \
-      NULL                                                                      \
-    };                                                                          \
-    g_type_add_interface_static (type, GST_TYPE_TAG_SETTER,                     \
-                                 &tag_setter_info);                             \
-  }G_STMT_END
-
-GST_BOILERPLATE_FULL (GstFlvMux, gst_flv_mux, GstElement, GST_TYPE_ELEMENT,
-    _do_init);
+#define gst_flv_mux_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstFlvMux, gst_flv_mux, GST_TYPE_ELEMENT,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
 
 static void gst_flv_mux_finalize (GObject * object);
 static GstFlowReturn
@@ -102,9 +92,12 @@ gst_flv_mux_collected (GstCollectPads * pads, gpointer user_data);
 
 static gboolean gst_flv_mux_handle_src_event (GstPad * pad, GstEvent * event);
 static GstPad *gst_flv_mux_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name);
+    GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps);
 static void gst_flv_mux_release_pad (GstElement * element, GstPad * pad);
 
+static gboolean gst_flv_mux_video_pad_setcaps (GstPad * pad, GstCaps * caps);
+static gboolean gst_flv_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps);
+
 static void gst_flv_mux_get_property (GObject * object,
     guint prop_id, GValue * value, GParamSpec * pspec);
 static void gst_flv_mux_set_property (GObject * object,
@@ -127,23 +120,27 @@ gst_flv_mux_index_entry_free (GstFlvMuxIndexEntry * entry)
   g_slice_free (GstFlvMuxIndexEntry, entry);
 }
 
-static void
-gst_flv_mux_base_init (gpointer g_class)
+static GstBuffer *
+_gst_buffer_new_wrapped (gpointer mem, gsize size, GFreeFunc free_func)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  GstBuffer *buf;
 
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&videosink_templ));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&audiosink_templ));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_templ));
-  gst_element_class_set_details_simple (element_class, "FLV muxer",
-      "Codec/Muxer",
-      "Muxes video/audio streams into a FLV stream",
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+  buf = gst_buffer_new ();
+  gst_buffer_take_memory (buf, -1,
+      gst_memory_new_wrapped (free_func ? 0 : GST_MEMORY_FLAG_READONLY,
+          mem, free_func, size, 0, size));
 
-  GST_DEBUG_CATEGORY_INIT (flvmux_debug, "flvmux", 0, "FLV muxer");
+  return buf;
+}
+
+static void
+_gst_buffer_new_and_alloc (gsize size, GstBuffer ** buffer, guint8 ** data)
+{
+  g_return_if_fail (data != NULL);
+  g_return_if_fail (buffer != NULL);
+
+  *data = g_malloc (size);
+  *buffer = _gst_buffer_new_wrapped (*data, size, g_free);
 }
 
 static void
@@ -181,10 +178,23 @@ gst_flv_mux_class_init (GstFlvMuxClass * klass)
   gstelement_class->request_new_pad =
       GST_DEBUG_FUNCPTR (gst_flv_mux_request_new_pad);
   gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_flv_mux_release_pad);
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&videosink_templ));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&audiosink_templ));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_templ));
+  gst_element_class_set_details_simple (gstelement_class, "FLV muxer",
+      "Codec/Muxer",
+      "Muxes video/audio streams into a FLV stream",
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+  GST_DEBUG_CATEGORY_INIT (flvmux_debug, "flvmux", 0, "FLV muxer");
 }
 
 static void
-gst_flv_mux_init (GstFlvMux * mux, GstFlvMuxClass * g_class)
+gst_flv_mux_init (GstFlvMux * mux)
 {
   mux->srcpad = gst_pad_new_from_static_template (&src_templ, "src");
   gst_pad_set_event_function (mux->srcpad, gst_flv_mux_handle_src_event);
@@ -264,6 +274,27 @@ gst_flv_mux_handle_sink_event (GstPad * pad, GstEvent * event)
   gboolean ret = TRUE;
 
   switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+      GstFlvPad *flvpad;
+
+      gst_event_parse_caps (event, &caps);
+
+      /* find stream data */
+      flvpad = (GstFlvPad *) gst_pad_get_element_private (pad);
+      g_assert (flvpad);
+
+      if (flvpad->video) {
+        ret = gst_flv_mux_video_pad_setcaps (pad, caps);
+      } else {
+        ret = gst_flv_mux_audio_pad_setcaps (pad, caps);
+      }
+      /* and eat */
+      ret = FALSE;
+      gst_event_unref (event);
+      break;
+    }
     case GST_EVENT_TAG:{
       GstTagList *list;
       GstTagSetter *setter = GST_TAG_SETTER (mux);
@@ -474,14 +505,13 @@ gst_flv_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
 
 static GstPad *
 gst_flv_mux_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * pad_name)
+    GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps)
 {
   GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
   GstFlvMux *mux = GST_FLV_MUX (element);
   GstFlvPad *cpad;
   GstPad *pad = NULL;
   const gchar *name = NULL;
-  GstPadSetCapsFunction setcapsfunc = NULL;
   gboolean video;
 
   if (mux->state != GST_FLV_MUX_STATE_HEADER) {
@@ -497,7 +527,6 @@ gst_flv_mux_request_new_pad (GstElement * element,
     mux->have_audio = TRUE;
     name = "audio";
     video = FALSE;
-    setcapsfunc = GST_DEBUG_FUNCPTR (gst_flv_mux_audio_pad_setcaps);
   } else if (templ == gst_element_class_get_pad_template (klass, "video")) {
     if (mux->have_video) {
       GST_WARNING_OBJECT (mux, "Already have a video pad");
@@ -506,7 +535,6 @@ gst_flv_mux_request_new_pad (GstElement * element,
     mux->have_video = TRUE;
     name = "video";
     video = TRUE;
-    setcapsfunc = GST_DEBUG_FUNCPTR (gst_flv_mux_video_pad_setcaps);
   } else {
     GST_WARNING_OBJECT (mux, "Invalid template");
     return NULL;
@@ -537,7 +565,6 @@ gst_flv_mux_request_new_pad (GstElement * element,
   gst_pad_set_event_function (pad,
       GST_DEBUG_FUNCPTR (gst_flv_mux_handle_sink_event));
 
-  gst_pad_set_setcaps_function (pad, setcapsfunc);
   gst_pad_set_active (pad, TRUE);
   gst_element_add_pad (element, pad);
 
@@ -562,10 +589,9 @@ gst_flv_mux_release_pad (GstElement * element, GstPad * pad)
 static GstFlowReturn
 gst_flv_mux_push (GstFlvMux * mux, GstBuffer * buffer)
 {
-  gst_buffer_set_caps (buffer, GST_PAD_CAPS (mux->srcpad));
   /* pushing the buffer that rewrites the header will make it no longer be the
    * total output size in bytes, but it doesn't matter at that point */
-  mux->byte_count += GST_BUFFER_SIZE (buffer);
+  mux->byte_count += gst_buffer_get_size (buffer);
 
   return gst_pad_push (mux->srcpad, buffer);
 }
@@ -576,8 +602,7 @@ gst_flv_mux_create_header (GstFlvMux * mux)
   GstBuffer *header;
   guint8 *data;
 
-  header = gst_buffer_new_and_alloc (9 + 4);
-  data = GST_BUFFER_DATA (header);
+  _gst_buffer_new_and_alloc (9 + 4, &header, &data);
 
   data[0] = 'F';
   data[1] = 'L';
@@ -609,8 +634,7 @@ gst_flv_mux_preallocate_index (GstFlvMux * mux)
   GST_DEBUG_OBJECT (mux, "preallocating %d bytes for the index",
       preallocate_size);
 
-  tmp = gst_buffer_new_and_alloc (preallocate_size);
-  data = GST_BUFFER_DATA (tmp);
+  _gst_buffer_new_and_alloc (preallocate_size, &tmp, &data);
 
   /* prefill the space with a gstfiller: <spaces> script tag variable */
   GST_WRITE_UINT16_BE (data, 9);        /* 9 characters */
@@ -624,8 +648,10 @@ gst_flv_mux_preallocate_index (GstFlvMux * mux)
 static GstBuffer *
 gst_flv_mux_create_number_script_value (const gchar * name, gdouble value)
 {
-  GstBuffer *tmp = gst_buffer_new_and_alloc (2 + strlen (name) + 1 + 8);
-  guint8 *data = GST_BUFFER_DATA (tmp);
+  GstBuffer *tmp;
+  guint8 *data;
+
+  _gst_buffer_new_and_alloc (2 + strlen (name) + 1 + 8, &tmp, &data);
 
   GST_WRITE_UINT16_BE (data, strlen (name));    /* name length */
   memcpy (&data[2], name, strlen (name));
@@ -647,8 +673,9 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
 
   GST_DEBUG_OBJECT (mux, "tags = %" GST_PTR_FORMAT, tags);
 
-  script_tag = gst_buffer_new_and_alloc (11);
-  data = GST_BUFFER_DATA (script_tag);
+  /* FIXME perhaps some bytewriter'ing here ... */
+
+  _gst_buffer_new_and_alloc (11, &script_tag, &data);
 
   data[0] = 18;
 
@@ -663,8 +690,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
   /* Stream ID */
   data[8] = data[9] = data[10] = 0;
 
-  tmp = gst_buffer_new_and_alloc (13);
-  data = GST_BUFFER_DATA (tmp);
+  _gst_buffer_new_and_alloc (13, &tmp, &data);
   data[0] = 2;                  /* string */
   data[1] = 0;
   data[2] = 10;                 /* length 10 */
@@ -673,8 +699,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
   script_tag = gst_buffer_join (script_tag, tmp);
 
   n_tags = (tags) ? gst_structure_n_fields ((GstStructure *) tags) : 0;
-  tmp = gst_buffer_new_and_alloc (5);
-  data = GST_BUFFER_DATA (tmp);
+  _gst_buffer_new_and_alloc (5, &tmp, &data);
   data[0] = 8;                  /* ECMA array */
   GST_WRITE_UINT32_BE (data + 1, n_tags);
   script_tag = gst_buffer_join (script_tag, tmp);
@@ -724,8 +749,8 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
       if (!gst_tag_list_get_string (tags, tag_name, &s))
         continue;
 
-      tmp = gst_buffer_new_and_alloc (2 + strlen (t) + 1 + 2 + strlen (s));
-      data = GST_BUFFER_DATA (tmp);
+      _gst_buffer_new_and_alloc (2 + strlen (t) + 1 + 2 + strlen (s),
+          &tmp, &data);
       data[0] = 0;              /* tag name length */
       data[1] = strlen (t);
       memcpy (&data[2], t, strlen (t));
@@ -742,17 +767,13 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
 
   if (mux->duration == GST_CLOCK_TIME_NONE) {
     GSList *l;
-
-    GstFormat fmt = GST_FORMAT_TIME;
     guint64 dur;
 
     for (l = mux->collect->data; l; l = l->next) {
       GstCollectData *cdata = l->data;
 
-      fmt = GST_FORMAT_TIME;
-
-      if (gst_pad_query_peer_duration (cdata->pad, &fmt, (gint64 *) & dur) &&
-          fmt == GST_FORMAT_TIME && dur != GST_CLOCK_TIME_NONE) {
+      if (gst_pad_query_peer_duration (cdata->pad, GST_FORMAT_TIME,
+              (gint64 *) & dur) && dur != GST_CLOCK_TIME_NONE) {
         if (mux->duration == GST_CLOCK_TIME_NONE)
           mux->duration = dur;
         else
@@ -767,8 +788,9 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
     d /= (gdouble) GST_SECOND;
 
     GST_DEBUG_OBJECT (mux, "determined the duration to be %f", d);
-    data = GST_BUFFER_DATA (script_tag);
+    data = gst_buffer_map (script_tag, NULL, NULL, GST_MAP_WRITE);
     GST_WRITE_DOUBLE_BE (data + 29 + 2 + 8 + 1, d);
+    gst_buffer_unmap (script_tag, data, -1);
   }
 
   if (mux->have_video) {
@@ -784,8 +806,9 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
       }
     }
 
-    if (video_pad && GST_PAD_CAPS (video_pad)) {
-      GstStructure *s = gst_caps_get_structure (GST_PAD_CAPS (video_pad), 0);
+    if (video_pad && gst_pad_has_current_caps (video_pad)) {
+      GstCaps *caps;
+      GstStructure *s;
       gint size;
       gint num, den;
 
@@ -797,6 +820,10 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
       script_tag = gst_buffer_join (script_tag, tmp);
       tags_written++;
 
+      caps = gst_pad_get_current_caps (video_pad);
+      s = gst_caps_get_structure (caps, 0);
+      gst_caps_unref (caps);
+
       if (gst_structure_get_int (s, "width", &size)) {
         GST_DEBUG_OBJECT (mux, "putting width %d in the metadata", size);
 
@@ -871,8 +898,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
   {
     const gchar *s = "GStreamer FLV muxer";
 
-    tmp = gst_buffer_new_and_alloc (2 + 15 + 1 + 2 + strlen (s));
-    data = GST_BUFFER_DATA (tmp);
+    _gst_buffer_new_and_alloc (2 + 15 + 1 + 2 + strlen (s), &tmp, &data);
     data[0] = 0;                /* 15 bytes name */
     data[1] = 15;
     memcpy (&data[2], "metadatacreator", 15);
@@ -906,8 +932,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
         months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
         tm->tm_year + 1900);
 
-    tmp = gst_buffer_new_and_alloc (2 + 12 + 1 + 2 + strlen (s));
-    data = GST_BUFFER_DATA (tmp);
+    _gst_buffer_new_and_alloc (2 + 12 + 1 + 2 + strlen (s), &tmp, &data);
     data[0] = 0;                /* 12 bytes name */
     data[1] = 12;
     memcpy (&data[2], "creationdate", 12);
@@ -921,25 +946,24 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
     tags_written++;
   }
 
-  tmp = gst_buffer_new_and_alloc (2 + 0 + 1);
-  data = GST_BUFFER_DATA (tmp);
+  _gst_buffer_new_and_alloc (2 + 0 + 1, &tmp, &data);
   data[0] = 0;                  /* 0 byte size */
   data[1] = 0;
   data[2] = 9;                  /* end marker */
   script_tag = gst_buffer_join (script_tag, tmp);
   tags_written++;
 
-  tmp = gst_buffer_new_and_alloc (4);
-  data = GST_BUFFER_DATA (tmp);
-  GST_WRITE_UINT32_BE (data, GST_BUFFER_SIZE (script_tag));
+  _gst_buffer_new_and_alloc (4, &tmp, &data);
+  GST_WRITE_UINT32_BE (data, gst_buffer_get_size (script_tag));
   script_tag = gst_buffer_join (script_tag, tmp);
 
-  data = GST_BUFFER_DATA (script_tag);
-  data[1] = ((GST_BUFFER_SIZE (script_tag) - 11 - 4) >> 16) & 0xff;
-  data[2] = ((GST_BUFFER_SIZE (script_tag) - 11 - 4) >> 8) & 0xff;
-  data[3] = ((GST_BUFFER_SIZE (script_tag) - 11 - 4) >> 0) & 0xff;
+  data = gst_buffer_map (script_tag, NULL, NULL, GST_MAP_WRITE);
+  data[1] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 16) & 0xff;
+  data[2] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 8) & 0xff;
+  data[3] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 0) & 0xff;
 
   GST_WRITE_UINT32_BE (data + 11 + 13 + 1, tags_written);
+  gst_buffer_unmap (script_tag, data, -1);
 
   return script_tag;
 }
@@ -954,26 +978,29 @@ gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
   guint32 timestamp =
       (GST_BUFFER_TIMESTAMP_IS_VALID (buffer)) ? GST_BUFFER_TIMESTAMP (buffer) /
       GST_MSECOND : cpad->last_timestamp / GST_MSECOND;
+  guint8 *bdata;
+  gsize bsize;
+
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
 
   size = 11;
   if (cpad->video) {
     size += 1;
     if (cpad->video_codec == 7)
-      size += 4 + GST_BUFFER_SIZE (buffer);
+      size += 4 + bsize;
     else
-      size += GST_BUFFER_SIZE (buffer);
+      size += bsize;
   } else {
     size += 1;
     if (cpad->audio_codec == 10)
-      size += 1 + GST_BUFFER_SIZE (buffer);
+      size += 1 + bsize;
     else
-      size += GST_BUFFER_SIZE (buffer);
+      size += bsize;
   }
   size += 4;
 
-  tag = gst_buffer_new_and_alloc (size);
+  _gst_buffer_new_and_alloc (size, &tag, &data);
   GST_BUFFER_TIMESTAMP (tag) = timestamp * GST_MSECOND;
-  data = GST_BUFFER_DATA (tag);
   memset (data, 0, size);
 
   data[0] = (cpad->video) ? 9 : 8;
@@ -1005,11 +1032,9 @@ gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
       /* FIXME: what to do about composition time */
       data[13] = data[14] = data[15] = 0;
 
-      memcpy (data + 11 + 1 + 4, GST_BUFFER_DATA (buffer),
-          GST_BUFFER_SIZE (buffer));
+      memcpy (data + 11 + 1 + 4, bdata, bsize);
     } else {
-      memcpy (data + 11 + 1, GST_BUFFER_DATA (buffer),
-          GST_BUFFER_SIZE (buffer));
+      memcpy (data + 11 + 1, bdata, bsize);
     }
   } else {
     data[11] |= (cpad->audio_codec << 4) & 0xf0;
@@ -1020,17 +1045,21 @@ gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
     if (cpad->audio_codec == 10) {
       data[12] = is_codec_data ? 0 : 1;
 
-      memcpy (data + 11 + 1 + 1, GST_BUFFER_DATA (buffer),
-          GST_BUFFER_SIZE (buffer));
+      memcpy (data + 11 + 1 + 1, bdata, bsize);
     } else {
-      memcpy (data + 11 + 1, GST_BUFFER_DATA (buffer),
-          GST_BUFFER_SIZE (buffer));
+      memcpy (data + 11 + 1, bdata, bsize);
     }
   }
 
+  gst_buffer_unmap (buffer, bdata, -1);
+
   GST_WRITE_UINT32_BE (data + size - 4, size - 4);
 
-  gst_buffer_copy_metadata (tag, buffer, GST_BUFFER_COPY_TIMESTAMPS);
+  GST_BUFFER_TIMESTAMP (tag) = GST_BUFFER_TIMESTAMP (buffer);
+  GST_BUFFER_DURATION (tag) = GST_BUFFER_DURATION (buffer);
+  GST_BUFFER_OFFSET (tag) = GST_BUFFER_OFFSET (buffer);
+  GST_BUFFER_OFFSET_END (tag) = GST_BUFFER_OFFSET_END (buffer);
+
   /* mark the buffer if it's an audio buffer and there's also video being muxed
    * or it's a video interframe */
   if ((mux->have_video && !cpad->video) ||
@@ -1140,7 +1169,7 @@ gst_flv_mux_write_header (GstFlvMux * mux)
   gst_structure_set_value (structure, "streamheader", &streamheader);
   g_value_unset (&streamheader);
 
-  if (GST_PAD_CAPS (mux->srcpad) == NULL)
+  if (!gst_pad_has_current_caps (mux->srcpad))
     gst_pad_set_caps (mux->srcpad, caps);
 
   gst_caps_unref (caps);
@@ -1196,7 +1225,7 @@ gst_flv_mux_write_buffer (GstFlvMux * mux, GstFlvPad * cpad)
   GstFlowReturn ret;
 
   /* arrange downstream running time */
-  buffer = gst_buffer_make_metadata_writable (buffer);
+  buffer = gst_buffer_make_writable (buffer);
   GST_BUFFER_TIMESTAMP (buffer) =
       gst_segment_to_running_time (&cpad->collect.segment,
       GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buffer));
@@ -1255,13 +1284,15 @@ gst_flv_mux_rewrite_header (GstFlvMux * mux)
   GList *l;
   guint32 index_len, allocate_size;
   guint32 i, index_skip;
+  GstSegment segment;
 
   if (mux->streamable)
     return GST_FLOW_OK;
 
   /* seek back to the preallocated index space */
-  event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
-      13 + 29, GST_CLOCK_TIME_NONE, 13 + 29);
+  gst_segment_init (&segment, GST_FORMAT_BYTES);
+  segment.start = segment.time = 13 + 29;
+  event = gst_event_new_segment (&segment);
   if (!gst_pad_push_event (mux->srcpad, event)) {
     GST_WARNING_OBJECT (mux, "Seek to rewrite header failed");
     return GST_FLOW_OK;
@@ -1308,8 +1339,7 @@ gst_flv_mux_rewrite_header (GstFlvMux * mux)
   /* see size calculation in gst_flv_mux_preallocate_index */
   allocate_size = 11 + 8 + 22 + 10 + index_len * 18;
   GST_DEBUG_OBJECT (mux, "Allocating %d bytes for index", allocate_size);
-  index = gst_buffer_new_and_alloc (allocate_size);
-  data = GST_BUFFER_DATA (index);
+  _gst_buffer_new_and_alloc (allocate_size, &index, &data);
 
   GST_WRITE_UINT16_BE (data, 9);        /* the 'keyframes' key */
   memcpy (data + 2, "keyframes", 9);
@@ -1358,8 +1388,7 @@ gst_flv_mux_rewrite_header (GstFlvMux * mux)
     guint8 *data;
     guint32 remaining_filler_size;
 
-    tmp = gst_buffer_new_and_alloc (14);
-    data = GST_BUFFER_DATA (tmp);
+    _gst_buffer_new_and_alloc (14, &tmp, &data);
     GST_WRITE_UINT16_BE (data, 9);
     memcpy (data + 2, "gstfiller", 9);
     GST_WRITE_UINT8 (data + 11, 2);     /* string */
@@ -1376,7 +1405,6 @@ gst_flv_mux_rewrite_header (GstFlvMux * mux)
 
   rewrite = gst_buffer_join (rewrite, index);
 
-  gst_buffer_set_caps (rewrite, GST_PAD_CAPS (mux->srcpad));
   return gst_flv_mux_push (mux, rewrite);
 }
 
@@ -1391,14 +1419,16 @@ gst_flv_mux_collected (GstCollectPads * pads, gpointer user_data)
   gboolean eos = TRUE;
 
   if (mux->state == GST_FLV_MUX_STATE_HEADER) {
+    GstSegment segment;
+
     if (mux->collect->data == NULL) {
       GST_ELEMENT_ERROR (mux, STREAM, MUX, (NULL),
           ("No input streams configured"));
       return GST_FLOW_ERROR;
     }
 
-    if (gst_pad_push_event (mux->srcpad,
-            gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0)))
+    gst_segment_init (&segment, GST_FORMAT_BYTES);
+    if (gst_pad_push_event (mux->srcpad, gst_event_new_segment (&segment)))
       ret = gst_flv_mux_write_header (mux);
     else
       ret = GST_FLOW_ERROR;
index c8e13ed..73eeb0a 100644 (file)
@@ -1,6 +1,7 @@
 /* gstgoom.c: implementation of goom drawing element
  * Copyright (C) <2001> Richard Boulton <richard@tartarus.org>
  *           (C) <2006> Wim Taymans <wim at fluendo dot com>
+ *           (C) <2011> Wim Taymans <wim.taymans at gmail dot com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -41,6 +42,7 @@
 #include <gst/gst.h>
 #include "gstgoom.h"
 #include <gst/video/video.h>
+#include <gst/audio/audio.h>
 #include "goom.h"
 
 #if HAVE_ORC
@@ -71,24 +73,22 @@ enum
 static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN)
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("xRGB"))
+#else
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("BGRx"))
+#endif
     );
 
 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",    /* the name of the pads */
     GST_PAD_SINK,               /* type of the pad */
     GST_PAD_ALWAYS,             /* ALWAYS/SOMETIMES */
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "endianness = (int) BYTE_ORDER, "
-        "signed = (boolean) TRUE, "
-        "width = (int) 16, "
-        "depth = (int) 16, "
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " GST_AUDIO_NE (S16) ", "
         "rate = (int) [ 8000, 96000 ], " "channels = (int) { 1, 2 }")
     );
 
 
-static void gst_goom_class_init (GstGoomClass * klass);
-static void gst_goom_base_init (GstGoomClass * klass);
-static void gst_goom_init (GstGoom * goom);
 static void gst_goom_finalize (GObject * object);
 
 static GstStateChangeReturn gst_goom_change_state (GstElement * element,
@@ -100,48 +100,8 @@ static gboolean gst_goom_sink_event (GstPad * pad, GstEvent * event);
 
 static gboolean gst_goom_src_query (GstPad * pad, GstQuery * query);
 
-static gboolean gst_goom_sink_setcaps (GstPad * pad, GstCaps * caps);
-static gboolean gst_goom_src_setcaps (GstPad * pad, GstCaps * caps);
-
-static GstElementClass *parent_class = NULL;
-
-GType
-gst_goom_get_type (void)
-{
-  static GType type = 0;
-
-  if (!type) {
-    static const GTypeInfo info = {
-      sizeof (GstGoomClass),
-      (GBaseInitFunc) gst_goom_base_init,
-      NULL,
-      (GClassInitFunc) gst_goom_class_init,
-      NULL,
-      NULL,
-      sizeof (GstGoom),
-      0,
-      (GInstanceInitFunc) gst_goom_init,
-    };
-
-    type = g_type_register_static (GST_TYPE_ELEMENT, "GstGoom", &info, 0);
-  }
-  return type;
-}
-
-static void
-gst_goom_base_init (GstGoomClass * klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_set_details_simple (element_class, "GOOM: what a GOOM!",
-      "Visualization",
-      "Takes frames of data and outputs video frames using the GOOM filter",
-      "Wim Taymans <wim@fluendo.com>");
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_template));
-}
+#define gst_goom_parent_class parent_class
+G_DEFINE_TYPE (GstGoom, gst_goom, GST_TYPE_ELEMENT);
 
 static void
 gst_goom_class_init (GstGoomClass * klass)
@@ -152,10 +112,17 @@ gst_goom_class_init (GstGoomClass * klass)
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
 
-  parent_class = g_type_class_peek_parent (klass);
-
   gobject_class->finalize = gst_goom_finalize;
 
+  gst_element_class_set_details_simple (gstelement_class, "GOOM: what a GOOM!",
+      "Visualization",
+      "Takes frames of data and outputs video frames using the GOOM filter",
+      "Wim Taymans <wim@fluendo.com>");
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_template));
+
   gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_goom_change_state);
 }
 
@@ -168,13 +135,9 @@ gst_goom_init (GstGoom * goom)
       GST_DEBUG_FUNCPTR (gst_goom_chain));
   gst_pad_set_event_function (goom->sinkpad,
       GST_DEBUG_FUNCPTR (gst_goom_sink_event));
-  gst_pad_set_setcaps_function (goom->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_goom_sink_setcaps));
   gst_element_add_pad (GST_ELEMENT (goom), goom->sinkpad);
 
   goom->srcpad = gst_pad_new_from_static_template (&src_template, "src");
-  gst_pad_set_setcaps_function (goom->srcpad,
-      GST_DEBUG_FUNCPTR (gst_goom_src_setcaps));
   gst_pad_set_event_function (goom->srcpad,
       GST_DEBUG_FUNCPTR (gst_goom_src_event));
   gst_pad_set_query_function (goom->srcpad,
@@ -203,6 +166,8 @@ gst_goom_finalize (GObject * object)
   goom->plugin = NULL;
 
   g_object_unref (goom->adapter);
+  if (goom->pool)
+    gst_object_unref (goom->pool);
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -220,39 +185,32 @@ gst_goom_reset (GstGoom * goom)
 }
 
 static gboolean
-gst_goom_sink_setcaps (GstPad * pad, GstCaps * caps)
+gst_goom_sink_setcaps (GstGoom * goom, GstCaps * caps)
 {
-  GstGoom *goom;
   GstStructure *structure;
-  gboolean res;
-
-  goom = GST_GOOM (GST_PAD_PARENT (pad));
 
   structure = gst_caps_get_structure (caps, 0);
 
-  res = gst_structure_get_int (structure, "channels", &goom->channels);
-  res &= gst_structure_get_int (structure, "rate", &goom->rate);
+  gst_structure_get_int (structure, "channels", &goom->channels);
+  gst_structure_get_int (structure, "rate", &goom->rate);
 
   goom->bps = goom->channels * sizeof (gint16);
 
-  return res;
+  return TRUE;
 }
 
 static gboolean
-gst_goom_src_setcaps (GstPad * pad, GstCaps * caps)
+gst_goom_src_setcaps (GstGoom * goom, GstCaps * caps)
 {
-  GstGoom *goom;
   GstStructure *structure;
-
-  goom = GST_GOOM (GST_PAD_PARENT (pad));
+  gboolean res;
 
   structure = gst_caps_get_structure (caps, 0);
-
   if (!gst_structure_get_int (structure, "width", &goom->width) ||
       !gst_structure_get_int (structure, "height", &goom->height) ||
       !gst_structure_get_fraction (structure, "framerate", &goom->fps_n,
           &goom->fps_d))
-    return FALSE;
+    goto error;
 
   goom_set_resolution (goom->plugin, goom->width, goom->height);
 
@@ -266,7 +224,16 @@ gst_goom_src_setcaps (GstPad * pad, GstCaps * caps)
   GST_DEBUG_OBJECT (goom, "dimension %dx%d, framerate %d/%d, spf %d",
       goom->width, goom->height, goom->fps_n, goom->fps_d, goom->spf);
 
-  return TRUE;
+  res = gst_pad_push_event (goom->srcpad, gst_event_new_caps (caps));
+
+  return res;
+
+  /* ERRORS */
+error:
+  {
+    GST_DEBUG_OBJECT (goom, "error parsing caps");
+    return FALSE;
+  }
 }
 
 static gboolean
@@ -274,24 +241,28 @@ gst_goom_src_negotiate (GstGoom * goom)
 {
   GstCaps *othercaps, *target;
   GstStructure *structure;
-  const GstCaps *templ;
+  GstCaps *templ;
+  GstQuery *query;
+  GstBufferPool *pool = NULL;
+  guint size, min, max, prefix, alignment;
 
   templ = gst_pad_get_pad_template_caps (goom->srcpad);
 
   GST_DEBUG_OBJECT (goom, "performing negotiation");
 
   /* see what the peer can do */
-  othercaps = gst_pad_peer_get_caps (goom->srcpad);
+  othercaps = gst_pad_peer_get_caps (goom->srcpad, NULL);
   if (othercaps) {
     target = gst_caps_intersect (othercaps, templ);
     gst_caps_unref (othercaps);
+    gst_caps_unref (templ);
 
     if (gst_caps_is_empty (target))
       goto no_format;
 
     gst_caps_truncate (target);
   } else {
-    target = gst_caps_ref ((GstCaps *) templ);
+    target = templ;
   }
 
   structure = gst_caps_get_structure (target, 0);
@@ -300,7 +271,42 @@ gst_goom_src_negotiate (GstGoom * goom)
   gst_structure_fixate_field_nearest_fraction (structure, "framerate",
       DEFAULT_FPS_N, DEFAULT_FPS_D);
 
-  gst_pad_set_caps (goom->srcpad, target);
+  gst_goom_src_setcaps (goom, target);
+
+  /* try to get a bufferpool now */
+  /* find a pool for the negotiated caps now */
+  query = gst_query_new_allocation (target, TRUE);
+
+  if (gst_pad_peer_query (goom->srcpad, query)) {
+    /* we got configuration from our peer, parse them */
+    gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
+        &alignment, &pool);
+  } else {
+    size = goom->outsize;
+    min = max = 0;
+    prefix = 0;
+    alignment = 0;
+  }
+
+  if (pool == NULL) {
+    GstStructure *config;
+
+    /* we did not get a pool, make one ourselves then */
+    pool = gst_buffer_pool_new ();
+
+    config = gst_buffer_pool_get_config (pool);
+    gst_buffer_pool_config_set (config, target, size, min, max, prefix,
+        alignment);
+    gst_buffer_pool_set_config (pool, config);
+  }
+
+  if (goom->pool)
+    gst_object_unref (goom->pool);
+  goom->pool = pool;
+
+  /* and activate */
+  gst_buffer_pool_set_active (pool, TRUE);
+
   gst_caps_unref (target);
 
   return TRUE;
@@ -327,7 +333,7 @@ gst_goom_src_event (GstPad * pad, GstEvent * event)
       GstClockTimeDiff diff;
       GstClockTime timestamp;
 
-      gst_event_parse_qos (event, &proportion, &diff, &timestamp);
+      gst_event_parse_qos (event, NULL, &proportion, &diff, &timestamp);
 
       /* save stuff for the _chain() function */
       GST_OBJECT_LOCK (goom);
@@ -361,6 +367,14 @@ gst_goom_sink_event (GstPad * pad, GstEvent * event)
   goom = GST_GOOM (gst_pad_get_parent (pad));
 
   switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+
+      gst_event_parse_caps (event, &caps);
+      res = gst_goom_sink_setcaps (goom, caps);
+      break;
+    }
     case GST_EVENT_FLUSH_START:
       res = gst_pad_push_event (goom->srcpad, event);
       break;
@@ -368,22 +382,12 @@ gst_goom_sink_event (GstPad * pad, GstEvent * event)
       gst_goom_reset (goom);
       res = gst_pad_push_event (goom->srcpad, event);
       break;
-    case GST_EVENT_NEWSEGMENT:
+    case GST_EVENT_SEGMENT:
     {
-      GstFormat format;
-      gdouble rate, arate;
-      gint64 start, stop, time;
-      gboolean update;
-
       /* the newsegment values are used to clip the input samples
        * and to convert the incomming timestamps to running time so
        * we can do QoS */
-      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
-          &start, &stop, &time);
-
-      /* now configure the values */
-      gst_segment_set_newsegment_full (&goom->segment, update,
-          rate, arate, format, start, stop, time);
+      gst_event_copy_segment (event, &goom->segment);
 
       res = gst_pad_push_event (goom->srcpad, event);
       break;
@@ -457,29 +461,26 @@ gst_goom_src_query (GstPad * pad, GstQuery * query)
   return res;
 }
 
+/* make sure we are negotiated */
 static GstFlowReturn
-get_buffer (GstGoom * goom, GstBuffer ** outbuf)
+ensure_negotiated (GstGoom * goom)
 {
-  GstFlowReturn ret;
+  gboolean reconfigure;
+
+  GST_OBJECT_LOCK (goom->srcpad);
+  reconfigure = GST_PAD_NEEDS_RECONFIGURE (goom->srcpad);
+  GST_OBJECT_FLAG_UNSET (goom->srcpad, GST_PAD_NEED_RECONFIGURE);
+  GST_OBJECT_UNLOCK (goom->srcpad);
 
-  if (GST_PAD_CAPS (goom->srcpad) == NULL) {
+  /* we don't know an output format yet, pick one */
+  if (reconfigure || !gst_pad_has_current_caps (goom->srcpad)) {
     if (!gst_goom_src_negotiate (goom))
       return GST_FLOW_NOT_NEGOTIATED;
   }
-
-  GST_DEBUG_OBJECT (goom, "allocating output buffer with caps %"
-      GST_PTR_FORMAT, GST_PAD_CAPS (goom->srcpad));
-
-  ret =
-      gst_pad_alloc_buffer_and_set_caps (goom->srcpad,
-      GST_BUFFER_OFFSET_NONE, goom->outsize,
-      GST_PAD_CAPS (goom->srcpad), outbuf);
-  if (ret != GST_FLOW_OK)
-    return ret;
-
   return GST_FLOW_OK;
 }
 
+
 static GstFlowReturn
 gst_goom_chain (GstPad * pad, GstBuffer * buffer)
 {
@@ -493,14 +494,11 @@ gst_goom_chain (GstPad * pad, GstBuffer * buffer)
     goto beach;
   }
 
-  /* If we don't have an output format yet, preallocate a buffer to try and
-   * set one */
-  if (GST_PAD_CAPS (goom->srcpad) == NULL) {
-    ret = get_buffer (goom, &outbuf);
-    if (ret != GST_FLOW_OK) {
-      gst_buffer_unref (buffer);
-      goto beach;
-    }
+  /* Make sure have an output format */
+  ret = ensure_negotiated (goom);
+  if (ret != GST_FLOW_OK) {
+    gst_buffer_unref (buffer);
+    goto beach;
   }
 
   /* don't try to combine samples from discont buffer */
@@ -510,7 +508,7 @@ gst_goom_chain (GstPad * pad, GstBuffer * buffer)
 
   GST_DEBUG_OBJECT (goom,
       "Input buffer has %d samples, time=%" G_GUINT64_FORMAT,
-      GST_BUFFER_SIZE (buffer) / goom->bps, GST_BUFFER_TIMESTAMP (buffer));
+      gst_buffer_get_size (buffer) / goom->bps, GST_BUFFER_TIMESTAMP (buffer));
 
   /* Collect samples until we have enough for an output frame */
   gst_adapter_push (goom->adapter, buffer);
@@ -568,7 +566,7 @@ gst_goom_chain (GstPad * pad, GstBuffer * buffer)
 
     /* get next GOOM_SAMPLES, we have at least this amount of samples */
     data =
-        (const guint16 *) gst_adapter_peek (goom->adapter,
+        (const guint16 *) gst_adapter_map (goom->adapter,
         GOOM_SAMPLES * goom->bps);
 
     if (goom->channels == 2) {
@@ -586,18 +584,21 @@ gst_goom_chain (GstPad * pad, GstBuffer * buffer)
     /* alloc a buffer if we don't have one yet, this happens
      * when we pushed a buffer in this while loop before */
     if (outbuf == NULL) {
-      ret = get_buffer (goom, &outbuf);
+      GST_DEBUG_OBJECT (goom, "allocating output buffer");
+      ret = gst_buffer_pool_acquire_buffer (goom->pool, &outbuf, NULL);
       if (ret != GST_FLOW_OK) {
+        gst_adapter_unmap (goom->adapter, 0);
         goto beach;
       }
     }
 
     GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
     GST_BUFFER_DURATION (outbuf) = goom->duration;
-    GST_BUFFER_SIZE (outbuf) = goom->outsize;
 
     out_frame = (guchar *) goom_update (goom->plugin, goom->datain, 0, 0);
-    memcpy (GST_BUFFER_DATA (outbuf), out_frame, goom->outsize);
+    gst_buffer_fill (outbuf, 0, out_frame, goom->outsize);
+
+    gst_adapter_unmap (goom->adapter, 0);
 
     GST_DEBUG ("Pushing frame with time=%" GST_TIME_FORMAT ", duration=%"
         GST_TIME_FORMAT, GST_TIME_ARGS (timestamp),
@@ -648,6 +649,11 @@ gst_goom_change_state (GstElement * element, GstStateChange transition)
 
   switch (transition) {
     case GST_STATE_CHANGE_PAUSED_TO_READY:
+      if (goom->pool) {
+        gst_buffer_pool_set_active (goom->pool, FALSE);
+        gst_object_unref (goom->pool);
+        goom->pool = NULL;
+      }
       break;
     case GST_STATE_CHANGE_READY_TO_NULL:
       break;
index 382d053..16e745d 100644 (file)
@@ -57,6 +57,7 @@ struct _GstGoom
   gint height;
   GstClockTime duration;
   guint outsize;
+  GstBufferPool *pool;
 
   /* samples per frame */
   guint spf;
index 080d275..3e122ad 100644 (file)
@@ -608,7 +608,7 @@ gst_image_freeze_src_event (GstPad * pad, GstEvent * event)
           &stop_type, &stop);
       gst_event_unref (event);
 
-      flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
+      flush = !!(flags & GST_SEEK_FLAG_FLUSH);
 
       if (format != GST_FORMAT_TIME && format != GST_FORMAT_DEFAULT) {
         GST_ERROR_OBJECT (pad, "Seek in invalid format: %s",
index 010e09c..f3f3718 100644 (file)
@@ -6,6 +6,7 @@ libgstisomp4_la_LIBADD = \
     $(GST_PLUGINS_BASE_LIBS) \
     -lgstriff-@GST_MAJORMINOR@ \
     -lgstaudio-@GST_MAJORMINOR@ \
+    -lgstvideo-@GST_MAJORMINOR@ \
     -lgstrtp-@GST_MAJORMINOR@ \
     -lgsttag-@GST_MAJORMINOR@ \
     -lgstpbutils-@GST_MAJORMINOR@ \
index 5aebd6b..4ab097d 100644 (file)
@@ -206,9 +206,10 @@ static AtomData *
 atom_data_new_from_gst_buffer (guint32 fourcc, const GstBuffer * buf)
 {
   AtomData *data = atom_data_new (fourcc);
+  gsize size = gst_buffer_get_size ((GstBuffer *) buf);
 
-  atom_data_alloc_mem (data, GST_BUFFER_SIZE (buf));
-  g_memmove (data->data, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  atom_data_alloc_mem (data, size);
+  gst_buffer_extract ((GstBuffer *) buf, 0, data->data, size);
   return data;
 }
 
@@ -2825,6 +2826,19 @@ atom_moov_add_uint_tag (AtomMOOV * moov, guint32 fourcc, guint32 flags,
   }
 }
 
+static GstBuffer *
+_gst_buffer_new_wrapped (gpointer mem, gsize size, GFreeFunc free_func)
+{
+  GstBuffer *buf;
+
+  buf = gst_buffer_new ();
+  gst_buffer_take_memory (buf, -1,
+      gst_memory_new_wrapped (free_func ? 0 : GST_MEMORY_FLAG_READONLY,
+          mem, free_func, size, 0, size));
+
+  return buf;
+}
+
 void
 atom_moov_add_blob_tag (AtomMOOV * moov, guint8 * data, guint size)
 {
@@ -2843,10 +2857,7 @@ atom_moov_add_blob_tag (AtomMOOV * moov, guint8 * data, guint size)
   if (len > size)
     return;
 
-  buf = gst_buffer_new ();
-  GST_BUFFER_SIZE (buf) = len - 8;
-  GST_BUFFER_DATA (buf) = data + 8;
-
+  buf = _gst_buffer_new_wrapped (data + 8, len - 8, NULL);
   data_atom = atom_data_new_from_gst_buffer (fourcc, buf);
   gst_buffer_unref (buf);
 
@@ -2864,12 +2875,12 @@ atom_moov_add_3gp_tag (AtomMOOV * moov, guint32 fourcc, guint8 * data,
   guint8 *bdata;
 
   /* need full atom */
-  buf = gst_buffer_new_and_alloc (size + 4);
-  bdata = GST_BUFFER_DATA (buf);
+  bdata = g_malloc (size + 4);
   /* full atom: version and flags */
   GST_WRITE_UINT32_BE (bdata, 0);
   memcpy (bdata + 4, data, size);
 
+  buf = _gst_buffer_new_wrapped (bdata, size + 4, g_free);
   data_atom = atom_data_new_from_gst_buffer (fourcc, buf);
   gst_buffer_unref (buf);
 
@@ -3188,13 +3199,12 @@ build_pasp_extension (AtomTRAK * trak, gint par_width, gint par_height)
   GstBuffer *buf;
   guint8 *data;
 
-  buf = gst_buffer_new_and_alloc (8);
-  data = GST_BUFFER_DATA (buf);
-
+  data = g_malloc (8);
   /* ihdr = image header box */
   GST_WRITE_UINT32_BE (data, par_width);
   GST_WRITE_UINT32_BE (data + 4, par_height);
 
+  buf = _gst_buffer_new_wrapped (data, 8, g_free);
   atom_data = atom_data_new_from_gst_buffer (FOURCC_pasp, buf);
   gst_buffer_unref (buf);
 
@@ -3942,13 +3952,13 @@ build_esds_extension (AtomTRAK * trak, guint8 object_type, guint8 stream_type,
   /* optional DecoderSpecificInfo */
   if (codec_data) {
     DecoderSpecificInfoDescriptor *desc;
+    gsize size;
 
     esds->es.dec_conf_desc.dec_specific_info = desc =
         desc_dec_specific_info_new ();
-    desc_dec_specific_info_alloc_data (desc, GST_BUFFER_SIZE (codec_data));
-
-    memcpy (desc->data, GST_BUFFER_DATA (codec_data),
-        GST_BUFFER_SIZE (codec_data));
+    size = gst_buffer_get_size ((GstBuffer *) codec_data);
+    desc_dec_specific_info_alloc_data (desc, size);
+    gst_buffer_extract ((GstBuffer *) codec_data, 0, desc->data, size);
   }
 
   return build_atom_info_wrapper ((Atom *) esds, atom_esds_copy_data,
@@ -3961,16 +3971,17 @@ build_btrt_extension (guint32 buffer_size_db, guint32 avg_bitrate,
 {
   AtomData *atom_data;
   GstBuffer *buf;
+  guint8 *data;
 
   if (buffer_size_db == 0 && avg_bitrate == 0 && max_bitrate == 0)
     return 0;
 
-  buf = gst_buffer_new_and_alloc (12);
-
-  GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf), buffer_size_db);
-  GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + 4, max_bitrate);
-  GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + 8, avg_bitrate);
+  data = g_malloc (12);
+  GST_WRITE_UINT32_BE (data, buffer_size_db);
+  GST_WRITE_UINT32_BE (data + 4, max_bitrate);
+  GST_WRITE_UINT32_BE (data + 8, avg_bitrate);
 
+  buf = _gst_buffer_new_wrapped (data, 12, g_free);
   atom_data =
       atom_data_new_from_gst_buffer (GST_MAKE_FOURCC ('b', 't', 'r', 't'), buf);
   gst_buffer_unref (buf);
@@ -4022,6 +4033,7 @@ build_mov_aac_extension (AtomTRAK * trak, const GstBuffer * codec_data,
 {
   AtomInfo *esds, *mp4a;
   GstBuffer *buf;
+  guint32 tmp = 0;
 
   /* Add ESDS atom to WAVE */
   esds = build_esds_extension (trak, ESDS_OBJECT_TYPE_MPEG4_P3,
@@ -4029,8 +4041,7 @@ build_mov_aac_extension (AtomTRAK * trak, const GstBuffer * codec_data,
 
   /* Add MP4A atom to the WAVE:
    * not really in spec, but makes offset based players happy */
-  buf = gst_buffer_new_and_alloc (4);
-  *((guint32 *) GST_BUFFER_DATA (buf)) = 0;
+  buf = _gst_buffer_new_wrapped (&tmp, 4, NULL);
   mp4a = build_codec_data_extension (FOURCC_mp4a, buf);
   gst_buffer_unref (buf);
 
@@ -4052,14 +4063,13 @@ build_fiel_extension (gint fields)
 {
   AtomData *atom_data;
   GstBuffer *buf;
+  guint8 f = fields;
 
   if (fields == 1) {
     return NULL;
   }
 
-  buf = gst_buffer_new_and_alloc (1);
-  GST_BUFFER_DATA (buf)[0] = (guint8) fields;
-
+  buf = _gst_buffer_new_wrapped (&f, 1, NULL);
   atom_data =
       atom_data_new_from_gst_buffer (GST_MAKE_FOURCC ('f', 'i', 'e', 'l'), buf);
   gst_buffer_unref (buf);
@@ -4086,8 +4096,9 @@ build_jp2x_extension (const GstBuffer * prefix)
 }
 
 AtomInfo *
-build_jp2h_extension (AtomTRAK * trak, gint width, gint height, guint32 fourcc,
-    gint ncomp, const GValue * cmap_array, const GValue * cdef_array)
+build_jp2h_extension (AtomTRAK * trak, gint width, gint height,
+    const gchar * colorspace, gint ncomp, const GValue * cmap_array,
+    const GValue * cdef_array)
 {
   AtomData *atom_data;
   GstBuffer *buf;
@@ -4105,15 +4116,15 @@ build_jp2h_extension (AtomTRAK * trak, gint width, gint height, guint32 fourcc,
   g_return_val_if_fail (cdef_array == NULL ||
       GST_VALUE_HOLDS_ARRAY (cdef_array), NULL);
 
-  if (fourcc == GST_MAKE_FOURCC ('s', 'R', 'G', 'B')) {
+  if (g_str_equal (colorspace, "sRGB")) {
     cenum = 0x10;
     if (ncomp == 0)
       ncomp = 3;
-  } else if (fourcc == GST_MAKE_FOURCC ('G', 'R', 'A', 'Y')) {
+  } else if (g_str_equal (colorspace, "GRAY")) {
     cenum = 0x11;
     if (ncomp == 0)
       ncomp = 1;
-  } else if (fourcc == GST_MAKE_FOURCC ('s', 'Y', 'U', 'V')) {
+  } else if (g_str_equal (colorspace, "sYUV")) {
     cenum = 0x12;
     if (ncomp == 0)
       ncomp = 3;
@@ -4129,9 +4140,8 @@ build_jp2h_extension (AtomTRAK * trak, gint width, gint height, guint32 fourcc,
     cdef_size = 8 + 2 + cdef_array_size * 6;
   }
 
-  buf = gst_buffer_new_and_alloc (idhr_size + colr_size + cmap_size +
-      cdef_size);
-  gst_byte_writer_init_with_buffer (&writer, buf, FALSE);
+  gst_byte_writer_init_with_size (&writer,
+      idhr_size + colr_size + cmap_size + cdef_size, TRUE);
 
   /* ihdr = image header box */
   gst_byte_writer_put_uint32_be (&writer, 22);
@@ -4215,6 +4225,7 @@ build_jp2h_extension (AtomTRAK * trak, gint width, gint height, guint32 fourcc,
   }
 
   g_assert (gst_byte_writer_get_remaining (&writer) == 0);
+  buf = gst_byte_writer_reset_and_get_buffer (&writer);
 
   atom_data = atom_data_new_from_gst_buffer (FOURCC_jp2h, buf);
   gst_buffer_unref (buf);
@@ -4245,10 +4256,6 @@ build_amr_extension (void)
   GstBuffer *buf;
   AtomInfo *res;
 
-  buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = ext;
-  GST_BUFFER_SIZE (buf) = sizeof (ext);
-
   /* vendor */
   GST_WRITE_UINT32_LE (ext, 0);
   /* decoder version */
@@ -4260,6 +4267,7 @@ build_amr_extension (void)
   /* frames per sample */
   GST_WRITE_UINT8 (ext + 8, 1);
 
+  buf = _gst_buffer_new_wrapped (ext, sizeof (ext), NULL);
   res = build_codec_data_extension (GST_MAKE_FOURCC ('d', 'a', 'm', 'r'), buf);
   gst_buffer_unref (buf);
   return res;
@@ -4272,10 +4280,6 @@ build_h263_extension (void)
   GstBuffer *buf;
   AtomInfo *res;
 
-  buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = ext;
-  GST_BUFFER_SIZE (buf) = sizeof (ext);
-
   /* vendor */
   GST_WRITE_UINT32_LE (ext, 0);
   /* decoder version */
@@ -4285,6 +4289,7 @@ build_h263_extension (void)
   GST_WRITE_UINT8 (ext + 5, 10);
   GST_WRITE_UINT8 (ext + 6, 0);
 
+  buf = _gst_buffer_new_wrapped (ext, sizeof (ext), NULL);
   res = build_codec_data_extension (GST_MAKE_FOURCC ('d', '2', '6', '3'), buf);
   gst_buffer_unref (buf);
   return res;
@@ -4300,8 +4305,8 @@ build_gama_atom (gdouble gamma)
   /* convert to uint32 from fixed point */
   gamma_fp = (guint32) 65536 *gamma;
 
-  buf = gst_buffer_new_and_alloc (4);
-  GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf), gamma_fp);
+  gamma_fp = GUINT32_TO_BE (gamma_fp);
+  buf = _gst_buffer_new_wrapped (&gamma_fp, 4, NULL);
   res = build_codec_data_extension (FOURCC_gama, buf);
   gst_buffer_unref (buf);
   return res;
@@ -4312,14 +4317,17 @@ build_SMI_atom (const GstBuffer * seqh)
 {
   AtomInfo *res;
   GstBuffer *buf;
+  gsize size;
+  guint8 *data;
 
   /* the seqh plus its size and fourcc */
-  buf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (seqh) + 8);
+  size = gst_buffer_get_size ((GstBuffer *) seqh);
+  data = g_malloc (size + 8);
 
-  GST_WRITE_UINT32_LE (GST_BUFFER_DATA (buf), FOURCC_SEQH);
-  GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + 4, GST_BUFFER_SIZE (seqh));
-  memcpy (GST_BUFFER_DATA (buf) + 8, GST_BUFFER_DATA (seqh),
-      GST_BUFFER_SIZE (seqh));
+  GST_WRITE_UINT32_LE (data, FOURCC_SEQH);
+  GST_WRITE_UINT32_BE (data + 4, size + 8);
+  gst_buffer_extract ((GstBuffer *) seqh, 0, data + 8, size);
+  buf = _gst_buffer_new_wrapped (data, size + 8, g_free);
   res = build_codec_data_extension (FOURCC_SMI_, buf);
   gst_buffer_unref (buf);
   return res;
@@ -4341,8 +4349,7 @@ build_ima_adpcm_atom (gint channels, gint rate, gint blocksize)
      within the WAVE header (below), it's little endian. */
   fourcc = MS_WAVE_FOURCC (0x11);
 
-  buf = gst_buffer_new_and_alloc (ima_adpcm_atom_size);
-  data = GST_BUFFER_DATA (buf);
+  data = g_malloc (ima_adpcm_atom_size);
 
   /* This atom's content is a WAVE header, including 2 bytes of extra data.
      Note that all of this is little-endian, unlike most stuff in qt. */
@@ -4359,6 +4366,7 @@ build_ima_adpcm_atom (gint channels, gint rate, gint blocksize)
   GST_WRITE_UINT16_LE (data + 16, 2);   /* Two extra bytes */
   GST_WRITE_UINT16_LE (data + 18, samplesperblock);
 
+  buf = _gst_buffer_new_wrapped (data, ima_adpcm_atom_size, g_free);
   atom_data = atom_data_new_from_gst_buffer (fourcc, buf);
   gst_buffer_unref (buf);
 
@@ -4402,6 +4410,7 @@ AtomInfo *
 build_uuid_xmp_atom (GstBuffer * xmp_data)
 {
   AtomUUID *uuid;
+  gsize size;
   static guint8 xmp_uuid[] = { 0xBE, 0x7A, 0xCF, 0xCB,
     0x97, 0xA9, 0x42, 0xE8,
     0x9C, 0x71, 0x99, 0x94,
@@ -4414,9 +4423,10 @@ build_uuid_xmp_atom (GstBuffer * xmp_data)
   uuid = atom_uuid_new ();
   memcpy (uuid->uuid, xmp_uuid, 16);
 
-  uuid->data = g_malloc (GST_BUFFER_SIZE (xmp_data));
-  uuid->datalen = GST_BUFFER_SIZE (xmp_data);
-  memcpy (uuid->data, GST_BUFFER_DATA (xmp_data), GST_BUFFER_SIZE (xmp_data));
+  size = gst_buffer_get_size (xmp_data);
+  uuid->data = g_malloc (size);
+  uuid->datalen = size;
+  gst_buffer_extract (xmp_data, 0, uuid->data, size);
 
   return build_atom_info_wrapper ((Atom *) uuid, atom_uuid_copy_data,
       atom_uuid_free);
index 5aeb5f8..336fa38 100644 (file)
@@ -916,7 +916,7 @@ AtomInfo *   build_esds_extension        (AtomTRAK * trak, guint8 object_type,
 AtomInfo *   build_btrt_extension        (guint32 buffer_size_db, guint32 avg_bitrate,
                                           guint32 max_bitrate);
 AtomInfo *   build_jp2h_extension        (AtomTRAK * trak, gint width, gint height,
-                                          guint32 fourcc, gint ncomp,
+                                          const gchar *colorspace, gint ncomp,
                                           const GValue * cmap_array,
                                           const GValue * cdef_array);
 
index 1f5a287..5ade82b 100644 (file)
@@ -108,10 +108,15 @@ atoms_recov_write_ftyp_info (FILE * f, AtomFTYP * ftyp, GstBuffer * prefix)
   guint64 size = 0;
 
   if (prefix) {
-    if (fwrite (GST_BUFFER_DATA (prefix), 1, GST_BUFFER_SIZE (prefix), f) !=
-        GST_BUFFER_SIZE (prefix)) {
+    guint8 *bdata;
+    gsize bsize;
+
+    bdata = gst_buffer_map (prefix, &bsize, NULL, GST_MAP_READ);
+    if (fwrite (bdata, 1, bsize, f) != bsize) {
+      gst_buffer_unmap (prefix, bdata, bsize);
       return FALSE;
     }
+    gst_buffer_unmap (prefix, bdata, bsize);
   }
   if (!atom_ftyp_copy_data (ftyp, &data, &size, &offset)) {
     return FALSE;
index 8079972..b54eee8 100644 (file)
@@ -89,8 +89,8 @@ enum
   PROP_FAST_START_MODE
 };
 
-GST_BOILERPLATE (GstQTMoovRecover, gst_qt_moov_recover, GstPipeline,
-    GST_TYPE_PIPELINE);
+#define gst_qt_moov_recover_parent_class parent_class
+G_DEFINE_TYPE (GstQTMoovRecover, gst_qt_moov_recover, GST_TYPE_PIPELINE);
 
 /* property functions */
 static void gst_qt_moov_recover_set_property (GObject * object,
@@ -104,18 +104,6 @@ static GstStateChangeReturn gst_qt_moov_recover_change_state (GstElement *
 static void gst_qt_moov_recover_finalize (GObject * object);
 
 static void
-gst_qt_moov_recover_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-#if 0
-  GstQTMoovRecoverClass *klass = (GstQTMoovRecoverClass *) g_class;
-#endif
-  gst_element_class_set_details_simple (element_class, "QT Moov Recover",
-      "Util", "Recovers unfinished qtmux files",
-      "Thiago Santos <thiago.sousa.santos@collabora.co.uk>");
-}
-
-static void
 gst_qt_moov_recover_class_init (GstQTMoovRecoverClass * klass)
 {
   GObjectClass *gobject_class;
@@ -156,11 +144,14 @@ gst_qt_moov_recover_class_init (GstQTMoovRecoverClass * klass)
 
   GST_DEBUG_CATEGORY_INIT (gst_qt_moov_recover_debug, "qtmoovrecover", 0,
       "QT Moovie Recover");
+
+  gst_element_class_set_details_simple (gstelement_class, "QT Moov Recover",
+      "Util", "Recovers unfinished qtmux files",
+      "Thiago Santos <thiago.sousa.santos@collabora.co.uk>");
 }
 
 static void
-gst_qt_moov_recover_init (GstQTMoovRecover * qtmr,
-    GstQTMoovRecoverClass * qtmr_klass)
+gst_qt_moov_recover_init (GstQTMoovRecover * qtmr)
 {
 }
 
index 33ea5ca..9dc9fba 100644 (file)
 
 #include <gst/gst.h>
 #include <gst/base/gstcollectpads.h>
+#include <gst/video/video.h>
 #include <gst/tag/xmpwriter.h>
 
 #include <sys/types.h>
@@ -220,7 +221,7 @@ static void gst_qt_mux_get_property (GObject * object,
 
 /* pad functions */
 static GstPad *gst_qt_mux_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name);
+    GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
 static void gst_qt_mux_release_pad (GstElement * element, GstPad * pad);
 
 /* event */
@@ -515,20 +516,23 @@ gst_qt_mux_prepare_jpc_buffer (GstQTPad * qtpad, GstBuffer * buf,
     GstQTMux * qtmux)
 {
   GstBuffer *newbuf;
+  guint8 *data;
+  gsize size;
 
   GST_LOG_OBJECT (qtmux, "Preparing jpc buffer");
 
   if (buf == NULL)
     return NULL;
 
-  newbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buf) + 8);
-  gst_buffer_copy_metadata (newbuf, buf, GST_BUFFER_COPY_ALL);
+  size = gst_buffer_get_size (buf);
+  newbuf = gst_buffer_new_and_alloc (size + 8);
+  gst_buffer_copy_into (newbuf, buf, GST_BUFFER_COPY_ALL, 8, size);
 
-  GST_WRITE_UINT32_BE (GST_BUFFER_DATA (newbuf), GST_BUFFER_SIZE (newbuf));
-  GST_WRITE_UINT32_LE (GST_BUFFER_DATA (newbuf) + 4, FOURCC_jp2c);
+  data = gst_buffer_map (newbuf, &size, NULL, GST_MAP_WRITE);
+  GST_WRITE_UINT32_BE (data, size);
+  GST_WRITE_UINT32_LE (data + 4, FOURCC_jp2c);
 
-  memcpy (GST_BUFFER_DATA (newbuf) + 8, GST_BUFFER_DATA (buf),
-      GST_BUFFER_SIZE (buf));
+  gst_buffer_unmap (buf, data, size);
   gst_buffer_unref (buf);
 
   return newbuf;
@@ -637,6 +641,8 @@ gst_qt_mux_add_mp4_cover (GstQTMux * qtmux, const GstTagList * list,
   GstCaps *caps;
   GstStructure *structure;
   gint flags = 0;
+  guint8 *data;
+  gsize size;
 
   g_return_if_fail (gst_tag_get_type (tag) == GST_TYPE_BUFFER);
 
@@ -647,7 +653,9 @@ gst_qt_mux_add_mp4_cover (GstQTMux * qtmux, const GstTagList * list,
   if (!buf)
     goto done;
 
-  caps = gst_buffer_get_caps (buf);
+  /* FIXME-0.11 caps metadata ? */
+  /* caps = gst_buffer_get_caps (buf); */
+  caps = NULL;
   if (!caps) {
     GST_WARNING_OBJECT (qtmux, "preview image without caps");
     goto done;
@@ -667,10 +675,11 @@ gst_qt_mux_add_mp4_cover (GstQTMux * qtmux, const GstTagList * list,
     goto done;
   }
 
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
   GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT
-      " -> image size %d", GST_FOURCC_ARGS (fourcc), GST_BUFFER_SIZE (buf));
-  atom_moov_add_tag (qtmux->moov, fourcc, flags, GST_BUFFER_DATA (buf),
-      GST_BUFFER_SIZE (buf));
+      " -> image size %d", GST_FOURCC_ARGS (fourcc), size);
+  atom_moov_add_tag (qtmux->moov, fourcc, flags, data, size);
+  gst_buffer_unmap (buf, data, size);
 done:
   g_value_unset (&value);
 }
@@ -1097,14 +1106,18 @@ gst_qt_mux_add_metadata_tags (GstQTMux * qtmux, const GstTagList * list)
       GstCaps *caps = NULL;
 
       val = gst_tag_list_get_value_index (list, GST_QT_DEMUX_PRIVATE_TAG, i);
-      buf = (GstBuffer *) gst_value_get_mini_object (val);
+      buf = (GstBuffer *) gst_value_get_buffer (val);
 
-      if (buf && (caps = gst_buffer_get_caps (buf))) {
+      /* FIXME-0.11 */
+      if (buf && (caps = NULL /*gst_buffer_get_caps (buf) */ )) {
         GstStructure *s;
         const gchar *style = NULL;
+        guint8 *data;
+        gsize size;
 
+        data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
         GST_DEBUG_OBJECT (qtmux, "Found private tag %d/%d; size %d, caps %"
-            GST_PTR_FORMAT, i, num_tags, GST_BUFFER_SIZE (buf), caps);
+            GST_PTR_FORMAT, i, num_tags, size, caps);
         s = gst_caps_get_structure (caps, 0);
         if (s && (style = gst_structure_get_string (s, "style"))) {
           /* try to prevent some style tag ending up into another variant
@@ -1114,10 +1127,10 @@ gst_qt_mux_add_metadata_tags (GstQTMux * qtmux, const GstTagList * list)
               (strcmp (style, "iso") == 0 &&
                   qtmux_klass->format == GST_QT_MUX_FORMAT_3GP)) {
             GST_DEBUG_OBJECT (qtmux, "Adding private tag");
-            atom_moov_add_blob_tag (qtmux->moov, GST_BUFFER_DATA (buf),
-                GST_BUFFER_SIZE (buf));
+            atom_moov_add_blob_tag (qtmux->moov, data, size);
           }
         }
+        gst_buffer_unmap (buf, data, size);
         gst_caps_unref (caps);
       }
     }
@@ -1164,8 +1177,8 @@ _gst_buffer_new_take_data (guint8 * data, guint size)
   GstBuffer *buf;
 
   buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
-  GST_BUFFER_SIZE (buf) = size;
+  gst_buffer_take_memory (buf, -1,
+      gst_memory_new_wrapped (0, data, g_free, size, 0, size));
 
   return buf;
 }
@@ -1175,21 +1188,21 @@ gst_qt_mux_send_buffer (GstQTMux * qtmux, GstBuffer * buf, guint64 * offset,
     gboolean mind_fast)
 {
   GstFlowReturn res;
-  guint8 *data;
-  guint size;
+  gsize size;
 
   g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
 
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
-
+  size = gst_buffer_get_size (buf);
   GST_LOG_OBJECT (qtmux, "sending buffer size %d", size);
 
   if (mind_fast && qtmux->fast_start_file) {
     gint ret;
+    guint8 *data;
 
     GST_LOG_OBJECT (qtmux, "to temporary file");
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
     ret = fwrite (data, sizeof (guint8), size, qtmux->fast_start_file);
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     if (ret != size)
       goto write_error;
@@ -1197,9 +1210,6 @@ gst_qt_mux_send_buffer (GstQTMux * qtmux, GstBuffer * buf, guint64 * offset,
       res = GST_FLOW_OK;
   } else {
     GST_LOG_OBJECT (qtmux, "downstream");
-
-    buf = gst_buffer_make_metadata_writable (buf);
-    gst_buffer_set_caps (buf, GST_PAD_CAPS (qtmux->srcpad));
     res = gst_pad_push (qtmux->srcpad, buf);
   }
 
@@ -1250,16 +1260,19 @@ gst_qt_mux_send_buffered_data (GstQTMux * qtmux, guint64 * offset)
    * (somehow optimize copy?) */
   GST_DEBUG_OBJECT (qtmux, "Sending buffered data");
   while (ret == GST_FLOW_OK) {
-    gint r;
     const int bufsize = 4096;
+    guint8 *data;
+    gsize size;
 
     buf = gst_buffer_new_and_alloc (bufsize);
-    r = fread (GST_BUFFER_DATA (buf), sizeof (guint8), bufsize,
-        qtmux->fast_start_file);
-    if (r == 0)
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
+    size = fread (data, sizeof (guint8), bufsize, qtmux->fast_start_file);
+    if (size == 0) {
+      gst_buffer_unmap (buf, data, -1);
       break;
-    GST_BUFFER_SIZE (buf) = r;
-    GST_LOG_OBJECT (qtmux, "Pushing buffered buffer of size %d", r);
+    }
+    gst_buffer_unmap (buf, data, size);
+    GST_LOG_OBJECT (qtmux, "Pushing buffered buffer of size %d", (gint) size);
     ret = gst_qt_mux_send_buffer (qtmux, buf, offset, FALSE);
     buf = NULL;
   }
@@ -1356,9 +1369,11 @@ static GstFlowReturn
 gst_qt_mux_update_mdat_size (GstQTMux * qtmux, guint64 mdat_pos,
     guint64 mdat_size, guint64 * offset)
 {
-  GstEvent *event;
   GstBuffer *buf;
   gboolean large_file;
+  GstSegment segment;
+  guint8 *data;
+  gsize size;
 
   large_file = (mdat_size > MDAT_LARGE_FILE_LIMIT);
 
@@ -1366,23 +1381,23 @@ gst_qt_mux_update_mdat_size (GstQTMux * qtmux, guint64 mdat_pos,
     mdat_pos += 8;
 
   /* seek and rewrite the header */
-  event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
-      mdat_pos, GST_CLOCK_TIME_NONE, 0);
-  gst_pad_push_event (qtmux->srcpad, event);
+  gst_segment_init (&segment, GST_FORMAT_BYTES);
+  segment.start = mdat_pos;
+  gst_pad_push_event (qtmux->srcpad, gst_event_new_segment (&segment));
 
   if (large_file) {
     buf = gst_buffer_new_and_alloc (sizeof (guint64));
-    GST_WRITE_UINT64_BE (GST_BUFFER_DATA (buf), mdat_size + 16);
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
+    GST_WRITE_UINT64_BE (data, mdat_size + 16);
   } else {
-    guint8 *data;
-
     buf = gst_buffer_new_and_alloc (16);
-    data = GST_BUFFER_DATA (buf);
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
     GST_WRITE_UINT32_BE (data, 8);
     GST_WRITE_UINT32_LE (data + 4, FOURCC_free);
     GST_WRITE_UINT32_BE (data + 8, mdat_size + 8);
     GST_WRITE_UINT32_LE (data + 12, FOURCC_mdat);
   }
+  gst_buffer_unmap (buf, data, size);
 
   return gst_qt_mux_send_buffer (qtmux, buf, offset, FALSE);
 }
@@ -1469,9 +1484,12 @@ gst_qt_mux_set_header_on_caps (GstQTMux * mux, GstBuffer * buf)
   GstStructure *structure;
   GValue array = { 0 };
   GValue value = { 0 };
-  GstCaps *caps = GST_PAD_CAPS (mux->srcpad);
+  GstCaps *caps, *tcaps;
+
+  tcaps = gst_pad_get_current_caps (mux->srcpad);
+  caps = gst_caps_copy (tcaps);
+  gst_caps_unref (tcaps);
 
-  caps = gst_caps_copy (GST_PAD_CAPS (mux->srcpad));
   structure = gst_caps_get_structure (caps, 0);
 
   g_value_init (&array, GST_TYPE_ARRAY);
@@ -1591,6 +1609,7 @@ gst_qt_mux_start_file (GstQTMux * qtmux)
 {
   GstFlowReturn ret = GST_FLOW_OK;
   GstCaps *caps;
+  GstSegment segment;
 
   GST_DEBUG_OBJECT (qtmux, "starting file");
 
@@ -1602,8 +1621,8 @@ gst_qt_mux_start_file (GstQTMux * qtmux)
   gst_caps_unref (caps);
 
   /* let downstream know we think in BYTES and expect to do seeking later on */
-  gst_pad_push_event (qtmux->srcpad,
-      gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
+  gst_segment_init (&segment, GST_FORMAT_BYTES);
+  gst_pad_push_event (qtmux->srcpad, gst_event_new_segment (&segment));
 
   /* initialize our moov recovery file */
   GST_OBJECT_LOCK (qtmux);
@@ -1762,7 +1781,7 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
   }
 
   if (qtmux->fragment_sequence) {
-    GstEvent *event;
+    GstSegment segment;
 
     if (qtmux->mfra) {
       guint8 *data = NULL;
@@ -1782,7 +1801,6 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
       return GST_FLOW_OK;
     }
 
-
     timescale = qtmux->timescale;
     /* only mvex duration is updated,
      * mvhd should be consistent with empty moov
@@ -1792,9 +1810,9 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
     GST_DEBUG_OBJECT (qtmux, "rewriting moov with mvex duration %"
         GST_TIME_FORMAT, GST_TIME_ARGS (first_ts));
     /* seek and rewrite the header */
-    event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
-        qtmux->mdat_pos, GST_CLOCK_TIME_NONE, 0);
-    gst_pad_push_event (qtmux->srcpad, event);
+    gst_segment_init (&segment, GST_FORMAT_BYTES);
+    segment.start = qtmux->mdat_pos;
+    gst_pad_push_event (qtmux->srcpad, gst_event_new_segment (&segment));
     /* no need to seek back */
     return gst_qt_mux_send_moov (qtmux, NULL, FALSE);
   }
@@ -1950,14 +1968,15 @@ flush:
     pad->traf = NULL;
     atom_moof_copy_data (moof, &data, &size, &offset);
     buffer = _gst_buffer_new_take_data (data, offset);
-    GST_LOG_OBJECT (qtmux, "writing moof size %d", GST_BUFFER_SIZE (buffer));
+    GST_LOG_OBJECT (qtmux, "writing moof size %d",
+        gst_buffer_get_size (buffer));
     ret = gst_qt_mux_send_buffer (qtmux, buffer, &qtmux->header_size, FALSE);
 
     /* and actual data */
     total_size = 0;
     for (i = 0; i < atom_array_get_len (&pad->fragment_buffers); i++) {
       total_size +=
-          GST_BUFFER_SIZE (atom_array_index (&pad->fragment_buffers, i));
+          gst_buffer_get_size (atom_array_index (&pad->fragment_buffers, i));
     }
 
     GST_LOG_OBJECT (qtmux, "writing %d buffers, total_size %d",
@@ -2048,7 +2067,7 @@ gst_qt_mux_get_asc_buffer_ts (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
     buf = pad->buf_entries[pad->buf_head];
     pad->buf_entries[pad->buf_head++] = NULL;
     pad->buf_head %= wrap;
-    buf = gst_buffer_make_metadata_writable (buf);
+    buf = gst_buffer_make_writable (buf);
     /* track original ts (= pts ?) for later */
     GST_BUFFER_OFFSET_END (buf) = GST_BUFFER_TIMESTAMP (buf);
     GST_BUFFER_TIMESTAMP (buf) = ts;
@@ -2226,7 +2245,7 @@ again:
        buffer (= chunk)), but can also be fixed-packet-size codecs like ADPCM
      */
     sample_size = pad->sample_size;
-    if (GST_BUFFER_SIZE (last_buf) % sample_size != 0)
+    if (gst_buffer_get_size (last_buf) % sample_size != 0)
       goto fragmented_sample;
     /* note: qt raw audio storage warps it implicitly into a timewise
      * perfect stream, discarding buffer times */
@@ -2234,7 +2253,7 @@ again:
       nsamples = gst_util_uint64_scale_round (GST_BUFFER_DURATION (last_buf),
           atom_trak_get_timescale (pad->trak), GST_SECOND);
     } else {
-      nsamples = GST_BUFFER_SIZE (last_buf) / sample_size;
+      nsamples = gst_buffer_get_size (last_buf) / sample_size;
     }
     duration = GST_BUFFER_DURATION (last_buf) / nsamples;
 
@@ -2243,7 +2262,7 @@ again:
     pad->last_dts += duration * nsamples;
   } else {
     nsamples = 1;
-    sample_size = GST_BUFFER_SIZE (last_buf);
+    sample_size = gst_buffer_get_size (last_buf);
     if (pad->have_dts) {
       gint64 scaled_dts;
       pad->last_dts = GST_BUFFER_OFFSET_END (last_buf);
@@ -2475,7 +2494,7 @@ gst_qt_mux_collected (GstCollectPads * pads, gpointer user_data)
     GST_LOG_OBJECT (qtmux, "selected pad %s with time %" GST_TIME_FORMAT,
         GST_PAD_NAME (best_pad->collect.pad), GST_TIME_ARGS (best_time));
     buf = gst_collect_pads_pop (pads, &best_pad->collect);
-    buf = gst_buffer_make_metadata_writable (buf);
+    buf = gst_buffer_make_writable (buf);
     GST_BUFFER_TIMESTAMP (buf) = best_time;
     ret = gst_qt_mux_add_buffer (qtmux, best_pad, buf);
   } else {
@@ -2530,7 +2549,6 @@ gst_qt_mux_audio_sink_set_caps (GstPad * pad, GstCaps * caps)
   AtomInfo *ext_atom = NULL;
   gint constant_size = 0;
   const gchar *stream_format;
-  GstCaps *current_caps = NULL;
 
   /* find stream data */
   qtpad = (GstQTPad *) gst_pad_get_element_private (pad);
@@ -2542,15 +2560,19 @@ gst_qt_mux_audio_sink_set_caps (GstPad * pad, GstCaps * caps)
    * the old caps are a subset of the new one (this means upstream
    * added more info to the caps, as both should be 'fixed' caps) */
   if (qtpad->fourcc) {
-    g_object_get (pad, "caps", &current_caps, NULL);
+    GstCaps *current_caps;
+
+    current_caps = gst_pad_get_current_caps (pad);
     g_assert (caps != NULL);
 
     if (!gst_qtmux_caps_is_subset_full (qtmux, current_caps, caps)) {
+      gst_caps_unref (current_caps);
       goto refuse_renegotiation;
     }
     GST_DEBUG_OBJECT (qtmux,
         "pad %s accepted renegotiation to %" GST_PTR_FORMAT " from %"
-        GST_PTR_FORMAT, GST_PAD_NAME (pad), caps, GST_PAD_CAPS (pad));
+        GST_PTR_FORMAT, GST_PAD_NAME (pad), caps, current_caps);
+    gst_caps_unref (current_caps);
   }
 
   GST_DEBUG_OBJECT (qtmux, "%s:%s, caps=%" GST_PTR_FORMAT,
@@ -2627,11 +2649,12 @@ gst_qt_mux_audio_sink_set_caps (GstPad * pad, GstCaps * caps)
               "assuming 'raw'");
         }
 
-        if (!codec_data || GST_BUFFER_SIZE (codec_data) < 2)
+        if (!codec_data || gst_buffer_get_size ((GstBuffer *) codec_data) < 2)
           GST_WARNING_OBJECT (qtmux, "no (valid) codec_data for AAC audio");
         else {
-          guint8 profile = GST_READ_UINT8 (GST_BUFFER_DATA (codec_data));
+          guint8 profile;
 
+          gst_buffer_extract ((GstBuffer *) codec_data, 0, &profile, 1);
           /* warn if not Low Complexity profile */
           profile >>= 3;
           if (profile != 2)
@@ -2758,19 +2781,25 @@ gst_qt_mux_audio_sink_set_caps (GstPad * pad, GstCaps * caps)
   } else if (strcmp (mimetype, "audio/x-alac") == 0) {
     GstBuffer *codec_config;
     gint len;
+    guint8 *data;
+    gsize size;
 
     entry.fourcc = FOURCC_alac;
+    data = gst_buffer_map ((GstBuffer *) codec_data, &size, NULL, GST_MAP_READ);
     /* let's check if codec data already comes with 'alac' atom prefix */
-    if (!codec_data || (len = GST_BUFFER_SIZE (codec_data)) < 28) {
+    if (!codec_data || (len = size) < 28) {
       GST_DEBUG_OBJECT (qtmux, "broken caps, codec data missing");
+      gst_buffer_unmap ((GstBuffer *) codec_data, data, size);
       goto refuse_caps;
     }
-    if (GST_READ_UINT32_LE (GST_BUFFER_DATA (codec_data) + 4) == FOURCC_alac) {
+    if (GST_READ_UINT32_LE (data + 4) == FOURCC_alac) {
       len -= 8;
-      codec_config = gst_buffer_create_sub ((GstBuffer *) codec_data, 8, len);
+      codec_config =
+          gst_buffer_copy_region ((GstBuffer *) codec_data, 0, 8, len);
     } else {
       codec_config = gst_buffer_ref ((GstBuffer *) codec_data);
     }
+    gst_buffer_unmap ((GstBuffer *) codec_data, data, size);
     if (len != 28) {
       /* does not look good, but perhaps some trailing unneeded stuff */
       GST_WARNING_OBJECT (qtmux, "unexpected codec-data size, possibly broken");
@@ -2780,9 +2809,10 @@ gst_qt_mux_audio_sink_set_caps (GstPad * pad, GstCaps * caps)
     else
       ext_atom = build_codec_data_extension (FOURCC_alac, codec_config);
     /* set some more info */
+    data = gst_buffer_map (codec_config, &size, NULL, GST_MAP_READ);
     entry.bytes_per_sample = 2;
-    entry.samples_per_packet =
-        GST_READ_UINT32_BE (GST_BUFFER_DATA (codec_config) + 4);
+    entry.samples_per_packet = GST_READ_UINT32_BE (data + 4);
+    gst_buffer_unmap (codec_config, data, size);
     gst_buffer_unref (codec_config);
   }
 
@@ -2852,7 +2882,6 @@ gst_qt_mux_video_sink_set_caps (GstPad * pad, GstCaps * caps)
   GList *ext_atom_list = NULL;
   gboolean sync = FALSE;
   int par_num, par_den;
-  GstCaps *current_caps = NULL;
 
   /* find stream data */
   qtpad = (GstQTPad *) gst_pad_get_element_private (pad);
@@ -2864,15 +2893,19 @@ gst_qt_mux_video_sink_set_caps (GstPad * pad, GstCaps * caps)
    * the old caps are a subset of the new one (this means upstream
    * added more info to the caps, as both should be 'fixed' caps) */
   if (qtpad->fourcc) {
-    g_object_get (pad, "caps", &current_caps, NULL);
+    GstCaps *current_caps;
+
+    current_caps = gst_pad_get_current_caps (pad);
     g_assert (caps != NULL);
 
     if (!gst_qtmux_caps_is_subset_full (qtmux, current_caps, caps)) {
+      gst_caps_unref (current_caps);
       goto refuse_renegotiation;
     }
     GST_DEBUG_OBJECT (qtmux,
         "pad %s accepted renegotiation to %" GST_PTR_FORMAT " from %"
-        GST_PTR_FORMAT, GST_PAD_NAME (pad), caps, GST_PAD_CAPS (pad));
+        GST_PTR_FORMAT, GST_PAD_NAME (pad), caps, current_caps);
+    gst_caps_unref (current_caps);
   }
 
   GST_DEBUG_OBJECT (qtmux, "%s:%s, caps=%" GST_PTR_FORMAT,
@@ -2927,24 +2960,29 @@ gst_qt_mux_video_sink_set_caps (GstPad * pad, GstCaps * caps)
   sync = TRUE;
 
   /* now map onto a fourcc, and some extra properties */
-  if (strcmp (mimetype, "video/x-raw-rgb") == 0) {
-    gint bpp;
+  if (strcmp (mimetype, "video/x-raw") == 0) {
+    const gchar *format;
+    GstVideoFormat fmt;
+    const GstVideoFormatInfo *vinfo;
 
-    entry.fourcc = FOURCC_raw_;
-    gst_structure_get_int (structure, "bpp", &bpp);
-    entry.depth = bpp;
-    sync = FALSE;
-  } else if (strcmp (mimetype, "video/x-raw-yuv") == 0) {
-    guint32 format = 0;
+    format = gst_structure_get_string (structure, "format");
+    fmt = gst_video_format_from_string (format);
+    vinfo = gst_video_format_get_info (fmt);
 
-    sync = FALSE;
-    gst_structure_get_fourcc (structure, "format", &format);
-    switch (format) {
-      case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
+    switch (fmt) {
+      case GST_VIDEO_FORMAT_UYVY:
         if (depth == -1)
           depth = 24;
         entry.fourcc = FOURCC_2vuy;
         entry.depth = depth;
+        sync = FALSE;
+        break;
+      default:
+        if (GST_VIDEO_FORMAT_INFO_FLAGS (vinfo) & GST_VIDEO_FORMAT_FLAG_RGB) {
+          entry.fourcc = FOURCC_raw_;
+          entry.depth = GST_VIDEO_FORMAT_INFO_PSTRIDE (vinfo, 0) * 8;
+          sync = FALSE;
+        }
         break;
     }
   } else if (strcmp (mimetype, "video/x-h263") == 0) {
@@ -3082,7 +3120,7 @@ gst_qt_mux_video_sink_set_caps (GstPad * pad, GstCaps * caps)
     sync = FALSE;
   } else if (strcmp (mimetype, "image/x-j2c") == 0 ||
       strcmp (mimetype, "image/x-jpc") == 0) {
-    guint32 fourcc;
+    const gchar *colorspace;
     const GValue *cmap_array;
     const GValue *cdef_array;
     gint ncomp = 0;
@@ -3100,9 +3138,11 @@ gst_qt_mux_video_sink_set_caps (GstPad * pad, GstCaps * caps)
     ext_atom = NULL;
     entry.fourcc = FOURCC_mjp2;
     sync = FALSE;
-    if (gst_structure_get_fourcc (structure, "fourcc", &fourcc) &&
+
+    colorspace = gst_structure_get_string (structure, "colorspace");
+    if (colorspace &&
         (ext_atom =
-            build_jp2h_extension (qtpad->trak, width, height, fourcc, ncomp,
+            build_jp2h_extension (qtpad->trak, width, height, colorspace, ncomp,
                 cmap_array, cdef_array)) != NULL) {
       ext_atom_list = g_list_append (ext_atom_list, ext_atom);
 
@@ -3126,13 +3166,13 @@ gst_qt_mux_video_sink_set_caps (GstPad * pad, GstCaps * caps)
   } else if (strcmp (mimetype, "video/x-qt-part") == 0) {
     guint32 fourcc;
 
-    gst_structure_get_fourcc (structure, "format", &fourcc);
+    gst_structure_get_uint (structure, "format", &fourcc);
     entry.fourcc = fourcc;
     qtpad->have_dts = TRUE;
   } else if (strcmp (mimetype, "video/x-mp4-part") == 0) {
     guint32 fourcc;
 
-    gst_structure_get_fourcc (structure, "format", &fourcc);
+    gst_structure_get_uint (structure, "format", &fourcc);
     entry.fourcc = fourcc;
     qtpad->have_dts = TRUE;
   }
@@ -3160,8 +3200,8 @@ refuse_caps:
 refuse_renegotiation:
   {
     GST_WARNING_OBJECT (qtmux,
-        "pad %s refused renegotiation to %" GST_PTR_FORMAT " from %"
-        GST_PTR_FORMAT, GST_PAD_NAME (pad), caps, GST_PAD_CAPS (pad));
+        "pad %s refused renegotiation to %" GST_PTR_FORMAT, GST_PAD_NAME (pad),
+        caps);
     gst_object_unref (qtmux);
     return FALSE;
   }
@@ -3175,7 +3215,23 @@ gst_qt_mux_sink_event (GstPad * pad, GstEvent * event)
   guint32 avg_bitrate = 0, max_bitrate = 0;
 
   qtmux = GST_QT_MUX_CAST (gst_pad_get_parent (pad));
+
   switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+      GstQTPad *collect_pad;
+
+      gst_event_parse_caps (event, &caps);
+
+      /* find stream data */
+      collect_pad = (GstQTPad *) gst_pad_get_element_private (pad);
+      g_assert (collect_pad);
+      g_assert (collect_pad->set_caps);
+
+      collect_pad->set_caps (pad, caps);
+      break;
+    }
     case GST_EVENT_TAG:{
       GstTagList *list;
       GstTagSetter *setter = GST_TAG_SETTER (qtmux);
@@ -3237,7 +3293,7 @@ gst_qt_mux_release_pad (GstElement * element, GstPad * pad)
 
 static GstPad *
 gst_qt_mux_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * req_name)
+    GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps)
 {
   GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
   GstQTMux *qtmux = GST_QT_MUX_CAST (element);
@@ -3245,6 +3301,7 @@ gst_qt_mux_request_new_pad (GstElement * element,
   GstPad *newpad;
   gboolean audio;
   gchar *name;
+  gint pad_id;
 
   if (templ->direction != GST_PAD_SINK)
     goto wrong_direction;
@@ -3254,10 +3311,18 @@ gst_qt_mux_request_new_pad (GstElement * element,
 
   if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
     audio = TRUE;
-    name = g_strdup_printf ("audio_%02d", qtmux->audio_pads++);
+    if (req_name != NULL && sscanf (req_name, "audio_%02d", &pad_id) == 1) {
+      name = g_strdup (req_name);
+    } else {
+      name = g_strdup_printf ("audio_%02d", qtmux->audio_pads++);
+    }
   } else if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
     audio = FALSE;
-    name = g_strdup_printf ("video_%02d", qtmux->video_pads++);
+    if (req_name != NULL && sscanf (req_name, "video_%02d", &pad_id) == 1) {
+      name = g_strdup (req_name);
+    } else {
+      name = g_strdup_printf ("video_%02d", qtmux->video_pads++);
+    }
   } else
     goto wrong_template;
 
@@ -3278,11 +3343,9 @@ gst_qt_mux_request_new_pad (GstElement * element,
 
   /* set up pad functions */
   if (audio)
-    gst_pad_set_setcaps_function (newpad,
-        GST_DEBUG_FUNCPTR (gst_qt_mux_audio_sink_set_caps));
+    collect_pad->set_caps = GST_DEBUG_FUNCPTR (gst_qt_mux_audio_sink_set_caps);
   else
-    gst_pad_set_setcaps_function (newpad,
-        GST_DEBUG_FUNCPTR (gst_qt_mux_video_sink_set_caps));
+    collect_pad->set_caps = GST_DEBUG_FUNCPTR (gst_qt_mux_video_sink_set_caps);
 
   /* FIXME: hacked way to override/extend the event function of
    * GstCollectPads; because it sets its own event function giving the
index 3a2cb49..f1c205b 100644 (file)
@@ -125,6 +125,7 @@ struct _GstQTPad
 
   /* if nothing is set, it won't be called */
   GstQTPadPrepareBufferFunc prepare_buf_func;
+  gboolean (*set_caps) (GstPad * pad, GstCaps * caps);
 };
 
 typedef enum _GstQTMuxState
index 7872f0c..a595c22 100644 (file)
@@ -153,10 +153,8 @@ GstQTMuxFormatProp gst_qt_mux_format_list[] = {
         "GstQTMux",
         GST_STATIC_CAPS ("video/quicktime, variant = (string) apple; "
             "video/quicktime"),
-        GST_STATIC_CAPS ("video/x-raw-rgb, "
-            COMMON_VIDEO_CAPS "; "
-            "video/x-raw-yuv, "
-            "format = (fourcc) UYVY, "
+        GST_STATIC_CAPS ("video/x-raw, "
+            "format = (string) { RGB, UYVY }, "
             COMMON_VIDEO_CAPS "; "
             MPEG4V_CAPS "; "
             H263_CAPS "; "
@@ -363,12 +361,18 @@ gst_qt_mux_map_format_to_header (GstQTMuxFormat format, GstBuffer ** _prefix,
       break;
     }
     case GST_QT_MUX_FORMAT_MJ2:
+    {
+      guint8 *bdata;
+
       major = FOURCC_mjp2;
       comp = mjp2_brands;
       version = 0;
       prefix = gst_buffer_new_and_alloc (sizeof (mjp2_prefix));
-      memcpy (GST_BUFFER_DATA (prefix), mjp2_prefix, GST_BUFFER_SIZE (prefix));
+      bdata = gst_buffer_map (prefix, NULL, NULL, GST_MAP_WRITE);
+      memcpy (bdata, mjp2_prefix, sizeof (mjp2_prefix));
+      gst_buffer_unmap (prefix, bdata, -1);
       break;
+    }
     default:
       g_assert_not_reached ();
       break;
index 66a9219..4a34143 100644 (file)
@@ -91,8 +91,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
         "encoding-name = (string) { \"X-QT\", \"X-QUICKTIME\" }")
     );
 
-GST_BOILERPLATE (GstRtpXQTDepay, gst_rtp_xqt_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_xqt_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpXQTDepay, gst_rtp_xqt_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void gst_rtp_xqt_depay_finalize (GObject * object);
 
@@ -104,21 +104,6 @@ static GstBuffer *gst_rtp_xqt_depay_process (GstBaseRTPDepayload * depayload,
 static GstStateChangeReturn gst_rtp_xqt_depay_change_state (GstElement *
     element, GstStateChange transition);
 
-static void
-gst_rtp_xqt_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_xqt_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_xqt_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP packet depayloader",
-      "Codec/Depayloader/Network",
-      "Extracts Quicktime audio/video from RTP packets",
-      "Wim Taymans <wim@fluendo.com>");
-}
 
 static void
 gst_rtp_xqt_depay_class_init (GstRtpXQTDepayClass * klass)
@@ -142,11 +127,20 @@ gst_rtp_xqt_depay_class_init (GstRtpXQTDepayClass * klass)
 
   GST_DEBUG_CATEGORY_INIT (rtpxqtdepay_debug, "rtpxqtdepay", 0,
       "QT Media RTP Depayloader");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_xqt_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_xqt_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP packet depayloader", "Codec/Depayloader/Network",
+      "Extracts Quicktime audio/video from RTP packets",
+      "Wim Taymans <wim@fluendo.com>");
 }
 
 static void
-gst_rtp_xqt_depay_init (GstRtpXQTDepay * rtpxqtdepay,
-    GstRtpXQTDepayClass * klass)
+gst_rtp_xqt_depay_init (GstRtpXQTDepay * rtpxqtdepay)
 {
   rtpxqtdepay->adapter = gst_adapter_new ();
 }
@@ -201,6 +195,7 @@ gst_rtp_quicktime_parse_sd (GstRtpXQTDepay * rtpxqtdepay, guint8 * data,
           GstBuffer *buf;
           gint size;
           GstCaps *caps;
+          guint8 *bdata;
 
           GST_DEBUG_OBJECT (rtpxqtdepay, "found avcC codec_data in sd, %u",
               chlen);
@@ -212,7 +207,9 @@ gst_rtp_quicktime_parse_sd (GstRtpXQTDepay * rtpxqtdepay, guint8 * data,
             size = len - 8;
 
           buf = gst_buffer_new_and_alloc (size);
-          memcpy (GST_BUFFER_DATA (buf), data + 8, size);
+          bdata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+          memcpy (bdata, data + 8, size);
+          gst_buffer_unmap (buf, bdata, -1);
           caps = gst_caps_new_simple ("video/x-h264",
               "codec_data", GST_TYPE_BUFFER, buf, NULL);
           gst_buffer_unref (buf);
@@ -255,11 +252,14 @@ static GstBuffer *
 gst_rtp_xqt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstRtpXQTDepay *rtpxqtdepay;
-  GstBuffer *outbuf;
+  GstBuffer *outbuf = NULL;
   gboolean m;
+  GstRTPBuffer rtp;
 
   rtpxqtdepay = GST_RTP_XQT_DEPAY (depayload);
 
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
   if (!gst_rtp_buffer_validate (buf))
     goto bad_packet;
 
@@ -270,7 +270,7 @@ gst_rtp_xqt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     GST_DEBUG_OBJECT (rtpxqtdepay, "we need resync");
   }
 
-  m = gst_rtp_buffer_get_marker (buf);
+  m = gst_rtp_buffer_get_marker (&rtp);
   GST_LOG_OBJECT (rtpxqtdepay, "marker: %d", m);
 
   {
@@ -279,9 +279,11 @@ gst_rtp_xqt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     guint8 *payload;
     guint8 ver, pck;
     gboolean s, q, l, d;
+    guint8 *bdata;
+    gsize bsize;
 
-    payload_len = gst_rtp_buffer_get_payload_len (buf);
-    payload = gst_rtp_buffer_get_payload (buf);
+    payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+    payload = gst_rtp_buffer_get_payload (&rtp);
 
     /*                      1                   2                   3 
      *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -545,8 +547,11 @@ gst_rtp_xqt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
       {
         /* multiple samples per packet. */
         outbuf = gst_buffer_new_and_alloc (payload_len);
-        memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
-        return outbuf;
+        bdata = gst_buffer_map (outbuf, &bsize, NULL, GST_MAP_WRITE);
+        memcpy (bdata, payload, payload_len);
+        gst_buffer_unmap (outbuf, bdata, bsize);
+
+        goto done;
       }
       case 2:
       {
@@ -586,7 +591,9 @@ gst_rtp_xqt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
             slen = payload_len;
 
           outbuf = gst_buffer_new_and_alloc (slen);
-          memcpy (GST_BUFFER_DATA (outbuf), payload, slen);
+          bdata = gst_buffer_map (outbuf, &bsize, NULL, GST_MAP_WRITE);
+          memcpy (bdata, payload, slen);
+          gst_buffer_unmap (outbuf, bdata, bsize);
           if (!s)
             GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
 
@@ -604,7 +611,9 @@ gst_rtp_xqt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
       {
         /* one sample per packet, use adapter to combine based on marker bit. */
         outbuf = gst_buffer_new_and_alloc (payload_len);
-        memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
+        bdata = gst_buffer_map (outbuf, &bsize, NULL, GST_MAP_WRITE);
+        memcpy (bdata, payload, payload_len);
+        gst_buffer_unmap (outbuf, bdata, bsize);
 
         gst_adapter_push (rtpxqtdepay->adapter, outbuf);
 
@@ -617,48 +626,49 @@ gst_rtp_xqt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
         GST_DEBUG_OBJECT (rtpxqtdepay,
             "gst_rtp_xqt_depay_chain: pushing buffer of size %u", avail);
 
-        return outbuf;
+        goto done;
       }
     }
   }
 
 done:
-  return NULL;
+  gst_rtp_buffer_unmap (&rtp);
+  return outbuf;
 
 bad_packet:
   {
     GST_ELEMENT_WARNING (rtpxqtdepay, STREAM, DECODE,
         ("Packet did not validate."), (NULL));
-    return NULL;
+    goto done;
   }
 need_resync:
   {
     GST_DEBUG_OBJECT (rtpxqtdepay, "waiting for marker");
-    return NULL;
+    goto done;
   }
 wrong_version:
   {
     GST_ELEMENT_WARNING (rtpxqtdepay, STREAM, DECODE,
         ("Unknown payload version."), (NULL));
-    return NULL;
+    goto done;
   }
 pck_reserved:
   {
     GST_ELEMENT_WARNING (rtpxqtdepay, STREAM, DECODE,
         ("PCK reserved 0."), (NULL));
-    return NULL;
+    goto done;
   }
 wrong_length:
   {
     GST_ELEMENT_WARNING (rtpxqtdepay, STREAM, DECODE,
         ("Wrong payload length."), (NULL));
-    return NULL;
+    goto done;
   }
 unknown_format:
   {
     GST_ELEMENT_WARNING (rtpxqtdepay, STREAM, DECODE,
         ("Unknown payload format."), (NULL));
-    return NULL;
+    goto done;
   }
 }
 
index 036e509..057d03d 100644 (file)
@@ -51,6 +51,7 @@
 
 #include <glib/gprintf.h>
 #include <gst/tag/tag.h>
+#include <gst/audio/audio.h>
 
 #include "qtatomparser.h"
 #include "qtdemux_types.h"
@@ -383,7 +384,8 @@ GST_STATIC_PAD_TEMPLATE ("subtitle_%02d",
     GST_PAD_SOMETIMES,
     GST_STATIC_CAPS_ANY);
 
-GST_BOILERPLATE (GstQTDemux, gst_qtdemux, GstQTDemux, GST_TYPE_ELEMENT);
+#define gst_qtdemux_parent_class parent_class
+G_DEFINE_TYPE (GstQTDemux, gst_qtdemux, GST_TYPE_ELEMENT);
 
 static void gst_qtdemux_dispose (GObject * object);
 
@@ -428,27 +430,6 @@ static gboolean qtdemux_parse_samples (GstQTDemux * qtdemux,
 static GstFlowReturn qtdemux_expose_streams (GstQTDemux * qtdemux);
 
 static void
-gst_qtdemux_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_qtdemux_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_qtdemux_videosrc_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_qtdemux_audiosrc_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_qtdemux_subsrc_template));
-  gst_element_class_set_details_simple (element_class, "QuickTime demuxer",
-      "Codec/Demuxer",
-      "Demultiplex a QuickTime file into audio and video streams",
-      "David Schleef <ds@schleef.org>, Wim Taymans <wim@fluendo.com>");
-
-  GST_DEBUG_CATEGORY_INIT (qtdemux_debug, "qtdemux", 0, "qtdemux plugin");
-}
-
-static void
 gst_qtdemux_class_init (GstQTDemuxClass * klass)
 {
   GObjectClass *gobject_class;
@@ -467,10 +448,26 @@ gst_qtdemux_class_init (GstQTDemuxClass * klass)
   gstelement_class->get_index = GST_DEBUG_FUNCPTR (gst_qtdemux_get_index);
 
   gst_tag_register_musicbrainz_tags ();
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_qtdemux_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_qtdemux_videosrc_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_qtdemux_audiosrc_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_qtdemux_subsrc_template));
+  gst_element_class_set_details_simple (gstelement_class, "QuickTime demuxer",
+      "Codec/Demuxer",
+      "Demultiplex a QuickTime file into audio and video streams",
+      "David Schleef <ds@schleef.org>, Wim Taymans <wim@fluendo.com>");
+
+  GST_DEBUG_CATEGORY_INIT (qtdemux_debug, "qtdemux", 0, "qtdemux plugin");
+
 }
 
 static void
-gst_qtdemux_init (GstQTDemux * qtdemux, GstQTDemuxClass * klass)
+gst_qtdemux_init (GstQTDemux * qtdemux)
 {
   qtdemux->sinkpad =
       gst_pad_new_from_static_template (&gst_qtdemux_sink_template, "sink");
@@ -524,11 +521,43 @@ gst_qtdemux_post_no_playable_stream_error (GstQTDemux * qtdemux)
   }
 }
 
+static void
+_gst_buffer_copy_into_mem (GstBuffer * dest, const guint8 * src,
+    gsize offset, gsize size)
+{
+  guint8 *bdata;
+  gsize bsize;
+
+  g_return_if_fail (gst_buffer_is_writable (dest));
+
+  bsize = gst_buffer_get_size (dest);
+  g_return_if_fail (bsize >= offset + size);
+
+  bdata = gst_buffer_map (dest, &bsize, NULL, GST_MAP_WRITE);
+  memcpy (bdata + offset, src, size);
+  gst_buffer_unmap (dest, bdata, bsize);
+}
+
+static GstBuffer *
+_gst_buffer_new_wrapped (gpointer mem, gsize size, GFreeFunc free_func)
+{
+  GstBuffer *buf;
+
+  buf = gst_buffer_new ();
+  gst_buffer_take_memory (buf, -1,
+      gst_memory_new_wrapped (free_func ? 0 : GST_MEMORY_FLAG_READONLY,
+          mem, free_func, size, 0, size));
+
+  return buf;
+}
+
 static GstFlowReturn
 gst_qtdemux_pull_atom (GstQTDemux * qtdemux, guint64 offset, guint64 size,
     GstBuffer ** buf)
 {
   GstFlowReturn flow;
+  guint8 *bdata;
+  gsize bsize;
 
   if (G_UNLIKELY (size == 0)) {
     GstFlowReturn ret;
@@ -538,9 +567,11 @@ gst_qtdemux_pull_atom (GstQTDemux * qtdemux, guint64 offset, guint64 size,
     if (ret != GST_FLOW_OK)
       return ret;
 
-    size = QT_UINT32 (GST_BUFFER_DATA (tmp));
+    bdata = gst_buffer_map (tmp, &bsize, NULL, GST_MAP_READ);
+    size = QT_UINT32 (bdata);
     GST_DEBUG_OBJECT (qtdemux, "size 0x%08" G_GINT64_MODIFIER "x", size);
 
+    gst_buffer_unmap (tmp, bdata, bsize);
     gst_buffer_unref (tmp);
   }
 
@@ -565,10 +596,11 @@ gst_qtdemux_pull_atom (GstQTDemux * qtdemux, guint64 offset, guint64 size,
   if (G_UNLIKELY (flow != GST_FLOW_OK))
     return flow;
 
+  bsize = gst_buffer_get_size (*buf);
   /* Catch short reads - we don't want any partial atoms */
-  if (G_UNLIKELY (GST_BUFFER_SIZE (*buf) < size)) {
+  if (G_UNLIKELY (bsize < size)) {
     GST_WARNING_OBJECT (qtdemux, "short read: %u < %" G_GUINT64_FORMAT,
-        GST_BUFFER_SIZE (*buf), size);
+        bsize, size);
     gst_buffer_unref (*buf);
     *buf = NULL;
     return GST_FLOW_UNEXPECTED;
@@ -687,9 +719,9 @@ gst_qtdemux_handle_src_query (GstPad * pad, GstQuery * query)
 
   switch (GST_QUERY_TYPE (query)) {
     case GST_QUERY_POSITION:
-      if (GST_CLOCK_TIME_IS_VALID (qtdemux->segment.last_stop)) {
+      if (GST_CLOCK_TIME_IS_VALID (qtdemux->segment.position)) {
         gst_query_set_position (query, GST_FORMAT_TIME,
-            qtdemux->segment.last_stop);
+            qtdemux->segment.position);
         res = TRUE;
       }
       break;
@@ -1153,7 +1185,6 @@ gst_qtdemux_convert_seek (GstPad * pad, GstFormat * format,
     GstSeekType cur_type, gint64 * cur, GstSeekType stop_type, gint64 * stop)
 {
   gboolean res;
-  GstFormat fmt;
 
   g_return_val_if_fail (format != NULL, FALSE);
   g_return_val_if_fail (cur != NULL, FALSE);
@@ -1162,12 +1193,11 @@ gst_qtdemux_convert_seek (GstPad * pad, GstFormat * format,
   if (*format == GST_FORMAT_TIME)
     return TRUE;
 
-  fmt = GST_FORMAT_TIME;
   res = TRUE;
   if (cur_type != GST_SEEK_TYPE_NONE)
-    res = gst_pad_query_convert (pad, *format, *cur, &fmt, cur);
+    res = gst_pad_query_convert (pad, *format, *cur, GST_FORMAT_TIME, cur);
   if (res && stop_type != GST_SEEK_TYPE_NONE)
-    res = gst_pad_query_convert (pad, *format, *stop, &fmt, stop);
+    res = gst_pad_query_convert (pad, *format, *stop, GST_FORMAT_TIME, stop);
 
   if (res)
     *format = GST_FORMAT_TIME;
@@ -1276,7 +1306,7 @@ gst_qtdemux_perform_seek (GstQTDemux * qtdemux, GstSegment * segment)
   gint64 desired_offset;
   gint n;
 
-  desired_offset = segment->last_stop;
+  desired_offset = segment->position;
 
   GST_DEBUG_OBJECT (qtdemux, "seeking to %" GST_TIME_FORMAT,
       GST_TIME_ARGS (desired_offset));
@@ -1299,8 +1329,11 @@ gst_qtdemux_perform_seek (GstQTDemux * qtdemux, GstSegment * segment)
     stream->segment_index = -1;
     stream->last_ret = GST_FLOW_OK;
     stream->sent_eos = FALSE;
+
+    if (segment->flags & GST_SEEK_FLAG_FLUSH)
+      gst_segment_init (&stream->segment, GST_FORMAT_TIME);
   }
-  segment->last_stop = desired_offset;
+  segment->position = desired_offset;
   segment->time = desired_offset;
 
   /* we stop at the end */
@@ -1365,7 +1398,7 @@ gst_qtdemux_do_seek (GstQTDemux * qtdemux, GstPad * pad, GstEvent * event)
   if (event) {
     /* configure the segment with the seek variables */
     GST_DEBUG_OBJECT (qtdemux, "configuring seek");
-    gst_segment_set_seek (&seeksegment, rate, format, flags,
+    gst_segment_do_seek (&seeksegment, rate, format, flags,
         cur_type, cur, stop_type, stop, &update);
   }
 
@@ -1374,32 +1407,8 @@ gst_qtdemux_do_seek (GstQTDemux * qtdemux, GstPad * pad, GstEvent * event)
 
   /* prepare for streaming again */
   if (flush) {
-    gst_pad_push_event (qtdemux->sinkpad, gst_event_new_flush_stop ());
-    gst_qtdemux_push_event (qtdemux, gst_event_new_flush_stop ());
-  } else if (qtdemux->segment_running) {
-    /* we are running the current segment and doing a non-flushing seek,
-     * close the segment first based on the last_stop. */
-    GST_DEBUG_OBJECT (qtdemux, "closing running segment %" G_GINT64_FORMAT
-        " to %" G_GINT64_FORMAT, qtdemux->segment.start,
-        qtdemux->segment.last_stop);
-
-    if (qtdemux->segment.rate >= 0) {
-      /* FIXME, rate is the product of the global rate and the (quicktime)
-       * segment rate. */
-      qtdemux->pending_newsegment = gst_event_new_new_segment (TRUE,
-          qtdemux->segment.rate, qtdemux->segment.format,
-          qtdemux->segment.start, qtdemux->segment.last_stop,
-          qtdemux->segment.time);
-    } else {                    /* For Reverse Playback */
-      guint64 stop;
-
-      if ((stop = qtdemux->segment.stop) == -1)
-        stop = qtdemux->segment.duration;
-      /* for reverse playback, we played from stop to last_stop. */
-      qtdemux->pending_newsegment = gst_event_new_new_segment (TRUE,
-          qtdemux->segment.rate, qtdemux->segment.format,
-          qtdemux->segment.last_stop, stop, qtdemux->segment.last_stop);
-    }
+    gst_pad_push_event (qtdemux->sinkpad, gst_event_new_flush_stop (TRUE));
+    gst_qtdemux_push_event (qtdemux, gst_event_new_flush_stop (TRUE));
   }
 
   /* commit the new segment */
@@ -1408,12 +1417,10 @@ gst_qtdemux_do_seek (GstQTDemux * qtdemux, GstPad * pad, GstEvent * event)
   if (qtdemux->segment.flags & GST_SEEK_FLAG_SEGMENT) {
     gst_element_post_message (GST_ELEMENT_CAST (qtdemux),
         gst_message_new_segment_start (GST_OBJECT_CAST (qtdemux),
-            qtdemux->segment.format, qtdemux->segment.last_stop));
+            qtdemux->segment.format, qtdemux->segment.position));
   }
 
-  /* restart streaming, NEWSEGMENT will be sent from the streaming
-   * thread. */
-  qtdemux->segment_running = TRUE;
+  /* restart streaming, NEWSEGMENT will be sent from the streaming thread. */
   for (i = 0; i < qtdemux->n_streams; i++)
     qtdemux->streams[i]->last_ret = GST_FLOW_OK;
 
@@ -1598,24 +1605,16 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
   GST_LOG_OBJECT (demux, "handling %s event", GST_EVENT_TYPE_NAME (event));
 
   switch (GST_EVENT_TYPE (event)) {
-    case GST_EVENT_NEWSEGMENT:
+    case GST_EVENT_SEGMENT:
     {
-      GstFormat format;
-      gdouble rate, arate;
-      gint64 start, stop, time, offset = 0;
+      gint64 offset = 0;
       QtDemuxStream *stream;
       gint idx;
-      gboolean update;
       GstSegment segment;
 
       /* some debug output */
-      gst_segment_init (&segment, GST_FORMAT_UNDEFINED);
-      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
-          &start, &stop, &time);
-      gst_segment_set_newsegment_full (&segment, update, rate, arate, format,
-          start, stop, time);
-      GST_DEBUG_OBJECT (demux,
-          "received format %d newsegment %" GST_SEGMENT_FORMAT, format,
+      gst_event_copy_segment (event, &segment);
+      GST_DEBUG_OBJECT (demux, "received newsegment %" GST_SEGMENT_FORMAT,
           &segment);
 
       /* chain will send initial newsegment after pads have been added */
@@ -1625,12 +1624,12 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
       }
 
       /* we only expect a BYTE segment, e.g. following a seek */
-      if (format == GST_FORMAT_BYTES) {
-        if (start > 0) {
+      if (segment.format == GST_FORMAT_BYTES) {
+        if (GST_CLOCK_TIME_IS_VALID (segment.start)) {
           gint64 requested_seek_time;
           guint64 seek_offset;
 
-          offset = start;
+          offset = segment.start;
 
           GST_OBJECT_LOCK (demux);
           requested_seek_time = demux->requested_seek_time;
@@ -1640,19 +1639,20 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
           GST_OBJECT_UNLOCK (demux);
 
           if (offset == seek_offset) {
-            start = requested_seek_time;
+            segment.start = requested_seek_time;
           } else {
-            gst_qtdemux_find_sample (demux, start, TRUE, FALSE, NULL, NULL,
-                &start);
-            start = MAX (start, 0);
+            gst_qtdemux_find_sample (demux, segment.start, TRUE, FALSE, NULL,
+                NULL, (gint64 *) & segment.start);
+            if ((gint64) segment.start < 0)
+              segment.start = 0;
           }
         }
-        if (stop > 0) {
-          gst_qtdemux_find_sample (demux, stop, FALSE, FALSE, NULL, NULL,
-              &stop);
+        if (GST_CLOCK_TIME_IS_VALID (segment.stop)) {
+          gst_qtdemux_find_sample (demux, segment.stop, FALSE, FALSE, NULL,
+              NULL, (gint64 *) & segment.stop);
           /* keyframe seeking should already arrange for start >= stop,
            * but make sure in other rare cases */
-          stop = MAX (stop, start);
+          segment.stop = MAX (segment.stop, segment.start);
         }
       } else {
         GST_DEBUG_OBJECT (demux, "unsupported segment format, ignoring");
@@ -1660,16 +1660,14 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
       }
 
       /* accept upstream's notion of segment and distribute along */
-      gst_segment_set_newsegment_full (&demux->segment, update, rate, arate,
-          GST_FORMAT_TIME, start, stop, start);
-      GST_DEBUG_OBJECT (demux, "Pushing newseg update %d, rate %g, "
-          "applied rate %g, format %d, start %" GST_TIME_FORMAT ", "
-          "stop %" GST_TIME_FORMAT, update, rate, arate, GST_FORMAT_TIME,
-          GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
+      segment.time = segment.start;
+      segment.duration = demux->segment.duration;
+      segment.base = gst_segment_to_running_time (&demux->segment,
+          GST_FORMAT_TIME, demux->segment.position);
 
-      gst_qtdemux_push_event (demux,
-          gst_event_new_new_segment_full (update, rate, arate, GST_FORMAT_TIME,
-              start, stop, start));
+      gst_segment_copy_into (&segment, &demux->segment);
+      GST_DEBUG_OBJECT (demux, "Pushing newseg %" GST_SEGMENT_FORMAT, &segment);
+      gst_qtdemux_push_event (demux, gst_event_new_segment (&segment));
 
       /* clear leftover in current segment, if any */
       gst_adapter_clear (demux->adapter);
@@ -1693,6 +1691,7 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
     case GST_EVENT_FLUSH_STOP:
     {
       gint i;
+      GstClockTime dur;
 
       /* clean up, force EOS if no more info follows */
       gst_adapter_clear (demux->adapter);
@@ -1703,6 +1702,9 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
         demux->streams[i]->last_ret = GST_FLOW_OK;
         demux->streams[i]->sent_eos = FALSE;
       }
+      dur = demux->segment.duration;
+      gst_segment_init (&demux->segment, GST_FORMAT_TIME);
+      demux->segment.duration = dur;
       break;
     }
     case GST_EVENT_EOS:
@@ -1899,7 +1901,7 @@ qtdemux_parse_ftyp (GstQTDemux * qtdemux, const guint8 * buffer, gint length)
     GST_DEBUG_OBJECT (qtdemux, "major brand: %" GST_FOURCC_FORMAT,
         GST_FOURCC_ARGS (qtdemux->major_brand));
     buf = qtdemux->comp_brands = gst_buffer_new_and_alloc (length - 16);
-    memcpy (GST_BUFFER_DATA (buf), buffer + 16, GST_BUFFER_SIZE (buf));
+    _gst_buffer_copy_into_mem (buf, buffer + 16, 0, length - 16);
   }
 }
 
@@ -1945,10 +1947,8 @@ qtdemux_parse_uuid (GstQTDemux * qtdemux, const guint8 * buffer, gint length)
     GstBuffer *buf;
     GstTagList *taglist;
 
-    buf = gst_buffer_new ();
-    GST_BUFFER_DATA (buf) = (guint8 *) buffer + offset + 16;
-    GST_BUFFER_SIZE (buf) = length - offset - 16;
-
+    buf = _gst_buffer_new_wrapped ((guint8 *) buffer + offset + 16,
+        length - offset - 16, NULL);
     taglist = gst_tag_list_from_xmp_buffer (buf);
     gst_buffer_unref (buf);
 
@@ -2638,13 +2638,16 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
   GstBuffer *buf = NULL;
   GstFlowReturn ret = GST_FLOW_OK;
   guint64 cur_offset = qtdemux->offset;
+  guint8 *data;
+  gsize size;
 
   ret = gst_pad_pull_range (qtdemux->sinkpad, cur_offset, 16, &buf);
   if (G_UNLIKELY (ret != GST_FLOW_OK))
     goto beach;
-  if (G_LIKELY (GST_BUFFER_SIZE (buf) >= 8))
-    extract_initial_length_and_fourcc (GST_BUFFER_DATA (buf),
-        GST_BUFFER_SIZE (buf), &length, &fourcc);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  if (G_LIKELY (size >= 8))
+    extract_initial_length_and_fourcc (data, size, &length, &fourcc);
+  gst_buffer_unmap (buf, data, size);
   gst_buffer_unref (buf);
 
   /* maybe we already got most we needed, so only consider this eof */
@@ -2689,51 +2692,48 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
       ret = gst_pad_pull_range (qtdemux->sinkpad, cur_offset, length, &moov);
       if (ret != GST_FLOW_OK)
         goto beach;
-      if (length != GST_BUFFER_SIZE (moov)) {
+      data = gst_buffer_map (moov, &size, NULL, GST_MAP_READ);
+      if (length != size) {
         /* Some files have a 'moov' atom at the end of the file which contains
          * a terminal 'free' atom where the body of the atom is missing.
          * Check for, and permit, this special case.
          */
-        if (GST_BUFFER_SIZE (moov) >= 8) {
-          guint8 *final_data = GST_BUFFER_DATA (moov) +
-              (GST_BUFFER_SIZE (moov) - 8);
+        if (size >= 8) {
+          guint8 *final_data = data + (size - 8);
           guint32 final_length = QT_UINT32 (final_data);
           guint32 final_fourcc = QT_FOURCC (final_data + 4);
-          if (final_fourcc == FOURCC_free &&
-              GST_BUFFER_SIZE (moov) + final_length - 8 == length) {
+          gst_buffer_unmap (moov, data, size);
+          if (final_fourcc == FOURCC_free && size + final_length - 8 == length) {
             /* Ok, we've found that special case. Allocate a new buffer with
              * that free atom actually present. */
             GstBuffer *newmoov = gst_buffer_new_and_alloc (length);
-            gst_buffer_copy_metadata (newmoov, moov,
-                GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS |
-                GST_BUFFER_COPY_CAPS);
-            memcpy (GST_BUFFER_DATA (newmoov), GST_BUFFER_DATA (moov),
-                GST_BUFFER_SIZE (moov));
-            memset (GST_BUFFER_DATA (newmoov) + GST_BUFFER_SIZE (moov), 0,
-                final_length - 8);
+            gst_buffer_copy_into (newmoov, moov, 0, 0, size);
+            data = gst_buffer_map (newmoov, &size, NULL, GST_MAP_WRITE);
+            memset (data + length - final_length + 8, 0, final_length - 8);
             gst_buffer_unref (moov);
             moov = newmoov;
           }
         }
       }
 
-      if (length != GST_BUFFER_SIZE (moov)) {
+      if (length != size) {
         GST_ELEMENT_ERROR (qtdemux, STREAM, DEMUX,
             (_("This file is incomplete and cannot be played.")),
             ("We got less than expected (received %u, wanted %u, offset %"
-                G_GUINT64_FORMAT ")",
-                GST_BUFFER_SIZE (moov), (guint) length, cur_offset));
+                G_GUINT64_FORMAT ")", size, (guint) length, cur_offset));
+        gst_buffer_unmap (moov, data, size);
         gst_buffer_unref (moov);
         ret = GST_FLOW_ERROR;
         goto beach;
       }
       qtdemux->offset += length;
 
-      qtdemux_parse_moov (qtdemux, GST_BUFFER_DATA (moov), length);
+      qtdemux_parse_moov (qtdemux, data, length);
       qtdemux_node_dump (qtdemux, qtdemux->moov_node);
 
       qtdemux_parse_tree (qtdemux);
       g_node_destroy (qtdemux->moov_node);
+      gst_buffer_unmap (moov, data, size);
       gst_buffer_unref (moov);
       qtdemux->moov_node = NULL;
       qtdemux->got_moov = TRUE;
@@ -2749,8 +2749,9 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
       if (ret != GST_FLOW_OK)
         goto beach;
       qtdemux->offset += length;
-      qtdemux_parse_ftyp (qtdemux, GST_BUFFER_DATA (ftyp),
-          GST_BUFFER_SIZE (ftyp));
+      data = gst_buffer_map (ftyp, &size, NULL, GST_MAP_READ);
+      qtdemux_parse_ftyp (qtdemux, data, size);
+      gst_buffer_unmap (ftyp, data, size);
       gst_buffer_unref (ftyp);
       break;
     }
@@ -2763,8 +2764,9 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
       if (ret != GST_FLOW_OK)
         goto beach;
       qtdemux->offset += length;
-      qtdemux_parse_uuid (qtdemux, GST_BUFFER_DATA (uuid),
-          GST_BUFFER_SIZE (uuid));
+      data = gst_buffer_map (uuid, &size, NULL, GST_MAP_READ);
+      qtdemux_parse_uuid (qtdemux, data, size);
+      gst_buffer_unmap (uuid, data, size);
       gst_buffer_unref (uuid);
       break;
     }
@@ -2779,8 +2781,9 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
       ret = gst_qtdemux_pull_atom (qtdemux, cur_offset, length, &unknown);
       if (ret != GST_FLOW_OK)
         goto beach;
-      GST_MEMDUMP ("Unknown tag", GST_BUFFER_DATA (unknown),
-          GST_BUFFER_SIZE (unknown));
+      data = gst_buffer_map (unknown, &size, NULL, GST_MAP_READ);
+      GST_MEMDUMP ("Unknown tag", data, size);
+      gst_buffer_unmap (unknown, data, size);
       gst_buffer_unref (unknown);
       qtdemux->offset += length;
       break;
@@ -2825,7 +2828,7 @@ gst_qtdemux_seek_to_previous_keyframe (GstQTDemux * qtdemux)
     QtDemuxStream *str = qtdemux->streams[n];
 
     seg_idx = gst_qtdemux_find_segment (qtdemux, str,
-        qtdemux->segment.last_stop);
+        qtdemux->segment.position);
 
     /* segment not found, continue with normal flow */
     if (seg_idx == -1)
@@ -2901,7 +2904,7 @@ gst_qtdemux_seek_to_previous_keyframe (GstQTDemux * qtdemux)
       k_index, GST_TIME_ARGS (k_pos));
 
   /* Set last_stop with the keyframe timestamp we pushed of that stream */
-  gst_segment_set_last_stop (&qtdemux->segment, GST_FORMAT_TIME, last_stop);
+  qtdemux->segment.position = last_stop;
   GST_DEBUG_OBJECT (qtdemux, "last_stop now is %" GST_TIME_FORMAT,
       GST_TIME_ARGS (last_stop));
 
@@ -3065,13 +3068,18 @@ gst_qtdemux_activate_segment (GstQTDemux * qtdemux, QtDemuxStream * stream,
 
   /* update the segment values used for clipping */
   gst_segment_init (&stream->segment, GST_FORMAT_TIME);
-  gst_segment_set_newsegment (&stream->segment, FALSE, rate, GST_FORMAT_TIME,
-      start, stop, time);
+  /* accumulate previous segments */
+  if (GST_CLOCK_TIME_IS_VALID (stream->segment.stop))
+    stream->segment.base += (stream->segment.stop - stream->segment.start) /
+        ABS (stream->segment.rate);
+  stream->segment.rate = rate;
+  stream->segment.start = start;
+  stream->segment.stop = stop;
+  stream->segment.time = time;
 
   /* now prepare and send the segment */
   if (stream->pad) {
-    event = gst_event_new_new_segment (FALSE, rate, GST_FORMAT_TIME,
-        start, stop, time);
+    event = gst_event_new_segment (&stream->segment);
     gst_pad_push_event (stream->pad, event);
     /* assume we can send more data now */
     stream->last_ret = GST_FLOW_OK;
@@ -3333,8 +3341,8 @@ gst_qtdemux_sync_streams (GstQTDemux * demux)
     end_time = stream->segments[stream->n_segments - 1].stop_time;
     GST_LOG_OBJECT (demux, "current position: %" GST_TIME_FORMAT
         ", stream end: %" GST_TIME_FORMAT,
-        GST_TIME_ARGS (demux->segment.last_stop), GST_TIME_ARGS (end_time));
-    if (end_time + 2 * GST_SECOND < demux->segment.last_stop) {
+        GST_TIME_ARGS (demux->segment.position), GST_TIME_ARGS (end_time));
+    if (end_time + 2 * GST_SECOND < demux->segment.position) {
       GST_DEBUG_OBJECT (demux, "sending EOS for stream %s",
           GST_PAD_NAME (stream->pad));
       stream->sent_eos = TRUE;
@@ -3395,16 +3403,16 @@ static GstBuffer *
 gst_qtdemux_clip_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
     GstBuffer * buf)
 {
-  gint64 start, stop, cstart, cstop, diff;
+  guint64 start, stop, cstart, cstop, diff;
   GstClockTime timestamp = GST_CLOCK_TIME_NONE, duration = GST_CLOCK_TIME_NONE;
-  guint8 *data;
   guint size;
   gint num_rate, denom_rate;
   gint frame_size;
   gboolean clip_data;
+  guint offset;
 
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
+  size = gst_buffer_get_size (buf);
+  offset = 0;
 
   /* depending on the type, setup the clip parameters */
   if (stream->subtype == FOURCC_soun) {
@@ -3454,7 +3462,7 @@ gst_qtdemux_clip_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
           "clipping start to %" GST_TIME_FORMAT " %"
           G_GUINT64_FORMAT " bytes", GST_TIME_ARGS (cstart), diff);
 
-      data += diff;
+      offset = diff;
       size -= diff;
     }
   }
@@ -3473,10 +3481,9 @@ gst_qtdemux_clip_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
     }
   }
 
+  gst_buffer_resize (buf, offset, size);
   GST_BUFFER_TIMESTAMP (buf) = timestamp;
   GST_BUFFER_DURATION (buf) = duration;
-  GST_BUFFER_SIZE (buf) = size;
-  GST_BUFFER_DATA (buf) = data;
 
   return buf;
 
@@ -3506,12 +3513,10 @@ gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
     GstBuffer * buf)
 {
   guint8 *data;
-  guint size, nsize = 0;
+  guint nsize = 0;
+  gsize size;
   gchar *str;
 
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
-
   /* not many cases for now */
   if (G_UNLIKELY (stream->fourcc == FOURCC_mp4s)) {
     /* send a one time dvd clut event */
@@ -3526,6 +3531,8 @@ gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
     return buf;
   }
 
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+
   if (G_LIKELY (size >= 2)) {
     nsize = GST_READ_UINT16_BE (data);
     nsize = MIN (nsize, size - 2);
@@ -3536,15 +3543,13 @@ gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
   /* takes care of UTF-8 validation or UTF-16 recognition,
    * no other encoding expected */
   str = gst_tag_freeform_string_to_utf8 ((gchar *) data + 2, nsize, NULL);
+  gst_buffer_unmap (buf, data, size);
   if (str) {
     gst_buffer_unref (buf);
-    buf = gst_buffer_new ();
-    GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = (guint8 *) str;
-    GST_BUFFER_SIZE (buf) = strlen (str);
+    buf = _gst_buffer_new_wrapped (str, strlen (str), g_free);
   } else {
     /* may be 0-size subtitle, which is also sent to keep pipeline going */
-    GST_BUFFER_DATA (buf) = data + 2;
-    GST_BUFFER_SIZE (buf) = nsize;
+    gst_buffer_resize (buf, 2, nsize);
   }
 
   /* FIXME ? convert optional subsequent style info to markup */
@@ -3566,8 +3571,12 @@ gst_qtdemux_decorate_and_push_buffer (GstQTDemux * qtdemux,
 
   if (G_UNLIKELY (stream->fourcc == FOURCC_rtsp)) {
     gchar *url;
+    guint8 *bdata;
+    gsize bsize;
 
-    url = g_strndup ((gchar *) GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+    bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+    url = g_strndup ((gchar *) bdata, bsize);
+    gst_buffer_unmap (buf, bdata, bsize);
     if (url != NULL && strlen (url) != 0) {
       /* we have RTSP redirect now */
       gst_element_post_message (GST_ELEMENT_CAST (qtdemux),
@@ -3584,7 +3593,7 @@ gst_qtdemux_decorate_and_push_buffer (GstQTDemux * qtdemux,
 
   /* position reporting */
   if (qtdemux->segment.rate >= 0) {
-    gst_segment_set_last_stop (&qtdemux->segment, GST_FORMAT_TIME, position);
+    qtdemux->segment.position = position;
     gst_qtdemux_sync_streams (qtdemux);
   }
 
@@ -3603,7 +3612,6 @@ gst_qtdemux_decorate_and_push_buffer (GstQTDemux * qtdemux,
       GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
       stream->discont = FALSE;
     }
-    gst_buffer_set_caps (buffer, stream->caps);
 
     gst_pad_push (stream->pad, buffer);
 
@@ -3611,7 +3619,7 @@ gst_qtdemux_decorate_and_push_buffer (GstQTDemux * qtdemux,
   }
 
   /* we're going to modify the metadata */
-  buf = gst_buffer_make_metadata_writable (buf);
+  buf = gst_buffer_make_writable (buf);
 
   if (G_UNLIKELY (stream->need_process))
     buf = gst_qtdemux_process_buffer (qtdemux, stream, buf);
@@ -3622,8 +3630,7 @@ gst_qtdemux_decorate_and_push_buffer (GstQTDemux * qtdemux,
   GST_BUFFER_OFFSET_END (buf) = -1;
 
   if (G_UNLIKELY (stream->padding)) {
-    GST_BUFFER_DATA (buf) += stream->padding;
-    GST_BUFFER_SIZE (buf) -= stream->padding;
+    gst_buffer_resize (buf, stream->padding, -1);
   }
 
   if (G_UNLIKELY (qtdemux->element_index)) {
@@ -3659,8 +3666,6 @@ gst_qtdemux_decorate_and_push_buffer (GstQTDemux * qtdemux,
   if (!keyframe)
     GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
 
-  gst_buffer_set_caps (buf, stream->caps);
-
   GST_LOG_OBJECT (qtdemux,
       "Pushing buffer with time %" GST_TIME_FORMAT ", duration %"
       GST_TIME_FORMAT " on pad %s", GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
@@ -3819,7 +3824,6 @@ invalid_state:
   {
     GST_ELEMENT_ERROR (qtdemux, STREAM, FAILED,
         (NULL), ("streaming stopped, invalid state"));
-    qtdemux->segment_running = FALSE;
     gst_pad_pause_task (pad);
     gst_qtdemux_push_event (qtdemux, gst_event_new_eos ());
     goto done;
@@ -3830,7 +3834,6 @@ pause:
 
     GST_LOG_OBJECT (qtdemux, "pausing task, reason %s", reason);
 
-    qtdemux->segment_running = FALSE;
     gst_pad_pause_task (pad);
 
     /* fatal errors need special actions */
@@ -3843,11 +3846,6 @@ pause:
       if (qtdemux->segment.flags & GST_SEEK_FLAG_SEGMENT) {
         gint64 stop;
 
-        /* FIXME: I am not sure this is the right fix. If the sinks are
-         * supposed to detect the segment is complete and accumulate
-         * automatically, it does not seem to work here. Need more work */
-        qtdemux->segment_running = TRUE;
-
         if ((stop = qtdemux->segment.stop) == -1)
           stop = qtdemux->segment.duration;
 
@@ -4004,11 +4002,13 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
         guint32 fourcc;
         guint64 size;
 
-        data = gst_adapter_peek (demux->adapter, demux->neededbytes);
+        data = gst_adapter_map (demux->adapter, demux->neededbytes);
 
         /* get fourcc/length, set neededbytes */
         extract_initial_length_and_fourcc ((guint8 *) data, demux->neededbytes,
             &size, &fourcc);
+        gst_adapter_unmap (demux->adapter, 0);
+        data = NULL;
         GST_DEBUG_OBJECT (demux, "Peeking found [%" GST_FOURCC_FORMAT "] "
             "size: %" G_GUINT64_FORMAT, GST_FOURCC_ARGS (fourcc), size);
         if (size == 0) {
@@ -4062,7 +4062,7 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
               /* there may be multiple mdat (or alike) buffers */
               /* sanity check */
               if (demux->mdatbuffer)
-                bs = GST_BUFFER_SIZE (demux->mdatbuffer);
+                bs = gst_buffer_get_size (demux->mdatbuffer);
               else
                 bs = 0;
               if (size + bs > 10 * (1 << 20))
@@ -4096,7 +4096,7 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
 
         GST_DEBUG_OBJECT (demux, "In header");
 
-        data = gst_adapter_peek (demux->adapter, demux->neededbytes);
+        data = gst_adapter_map (demux->adapter, demux->neededbytes);
 
         /* parse the header */
         extract_initial_length_and_fourcc (data, demux->neededbytes, NULL,
@@ -4107,11 +4107,8 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
           demux->got_moov = TRUE;
 
           /* prepare newsegment to send when streaming actually starts */
-          if (!demux->pending_newsegment) {
-            demux->pending_newsegment =
-                gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
-                0, GST_CLOCK_TIME_NONE, 0);
-          }
+          if (!demux->pending_newsegment)
+            demux->pending_newsegment = gst_event_new_segment (&demux->segment);
 
           qtdemux_parse_moov (demux, data, demux->neededbytes);
           qtdemux_node_dump (demux, demux->moov_node);
@@ -4126,6 +4123,7 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
             GST_DEBUG_OBJECT (demux, "Parsing [moof]");
             if (!qtdemux_parse_moof (demux, data, demux->neededbytes,
                     demux->offset, NULL)) {
+              gst_adapter_unmap (demux->adapter, 0);
               ret = GST_FLOW_ERROR;
               goto done;
             }
@@ -4144,6 +4142,8 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
               GST_FOURCC_ARGS (fourcc));
           /* Let's jump that one and go back to initial state */
         }
+        gst_adapter_unmap (demux->adapter, 0);
+        data = NULL;
 
         if (demux->mdatbuffer && demux->n_streams) {
           /* the mdat was before the header */
@@ -4187,12 +4187,14 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
       }
       case QTDEMUX_STATE_BUFFER_MDAT:{
         GstBuffer *buf;
+        guint8 fourcc[4];
 
         GST_DEBUG_OBJECT (demux, "Got our buffer at offset %" G_GUINT64_FORMAT,
             demux->offset);
         buf = gst_adapter_take_buffer (demux->adapter, demux->neededbytes);
+        gst_buffer_extract (buf, 0, fourcc, 4);
         GST_DEBUG_OBJECT (demux, "mdatbuffer starts with %" GST_FOURCC_FORMAT,
-            GST_FOURCC_ARGS (QT_FOURCC (GST_BUFFER_DATA (buf) + 4)));
+            GST_FOURCC_ARGS (QT_FOURCC (fourcc)));
         if (demux->mdatbuffer)
           demux->mdatbuffer = gst_buffer_join (demux->mdatbuffer, buf);
         else
@@ -4368,10 +4370,30 @@ no_moov:
 static gboolean
 qtdemux_sink_activate (GstPad * sinkpad)
 {
-  if (gst_pad_check_pull_range (sinkpad))
-    return gst_pad_activate_pull (sinkpad, TRUE);
-  else
+  GstQuery *query;
+  gboolean pull_mode;
+
+  query = gst_query_new_scheduling ();
+
+  if (!gst_pad_peer_query (sinkpad, query)) {
+    gst_query_unref (query);
+    goto activate_push;
+  }
+
+  gst_query_parse_scheduling (query, &pull_mode, NULL, NULL, NULL, NULL, NULL);
+  gst_query_unref (query);
+
+  if (!pull_mode)
+    goto activate_push;
+
+  GST_DEBUG_OBJECT (sinkpad, "activating pull");
+  return gst_pad_activate_pull (sinkpad, TRUE);
+
+activate_push:
+  {
+    GST_DEBUG_OBJECT (sinkpad, "activating push");
     return gst_pad_activate_push (sinkpad, TRUE);
+  }
 }
 
 static gboolean
@@ -4381,11 +4403,9 @@ qtdemux_sink_activate_pull (GstPad * sinkpad, gboolean active)
 
   if (active) {
     demux->pullbased = TRUE;
-    demux->segment_running = TRUE;
     return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_qtdemux_loop,
         sinkpad);
   } else {
-    demux->segment_running = FALSE;
     return gst_pad_stop_task (sinkpad);
   }
 }
@@ -4585,19 +4605,19 @@ qtdemux_parse_theora_extension (GstQTDemux * qtdemux, QtDemuxStream * stream,
     switch (type) {
       case FOURCC_tCtH:
         buffer = gst_buffer_new_and_alloc (size);
-        memcpy (GST_BUFFER_DATA (buffer), buf, size);
+        _gst_buffer_copy_into_mem (buffer, buf, 0, size);
         stream->buffers = g_slist_append (stream->buffers, buffer);
         GST_LOG_OBJECT (qtdemux, "parsing theora header");
         break;
       case FOURCC_tCt_:
         buffer = gst_buffer_new_and_alloc (size);
-        memcpy (GST_BUFFER_DATA (buffer), buf, size);
+        _gst_buffer_copy_into_mem (buffer, buf, 0, size);
         stream->buffers = g_slist_append (stream->buffers, buffer);
         GST_LOG_OBJECT (qtdemux, "parsing theora comment");
         break;
       case FOURCC_tCtC:
         buffer = gst_buffer_new_and_alloc (size);
-        memcpy (GST_BUFFER_DATA (buffer), buf, size);
+        _gst_buffer_copy_into_mem (buffer, buf, 0, size);
         stream->buffers = g_slist_append (stream->buffers, buffer);
         GST_LOG_OBJECT (qtdemux, "parsing theora codebook");
         break;
@@ -4906,8 +4926,6 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux,
 {
   /* consistent default for push based mode */
   gst_segment_init (&stream->segment, GST_FORMAT_TIME);
-  gst_segment_set_newsegment (&stream->segment, FALSE, 1.0, GST_FORMAT_TIME,
-      0, GST_CLOCK_TIME_NONE, 0);
 
   if (stream->subtype == FOURCC_vide) {
     gchar *name = g_strdup_printf ("video_%02d", qtdemux->n_video_streams);
@@ -5010,10 +5028,8 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux,
 
         /* make sure it's not writable. We leave MALLOCDATA to NULL so that we
          * don't free any of the buffer data. */
-        palette = gst_buffer_new ();
-        GST_BUFFER_FLAG_SET (palette, GST_BUFFER_FLAG_READONLY);
-        GST_BUFFER_DATA (palette) = (guint8 *) palette_data;
-        GST_BUFFER_SIZE (palette) = sizeof (guint32) * palette_count;
+        palette = _gst_buffer_new_wrapped ((gpointer) palette_data,
+            palette_count, NULL);
 
         gst_caps_set_simple (stream->caps, "palette_data",
             GST_TYPE_BUFFER, palette, NULL);
@@ -5072,13 +5088,6 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux,
     if (stream->pending_tags)
       gst_tag_list_free (stream->pending_tags);
     stream->pending_tags = list;
-    if (list) {
-      /* post now, send event on pad later */
-      GST_DEBUG_OBJECT (qtdemux, "Posting tags %" GST_PTR_FORMAT, list);
-      gst_element_post_message (GST_ELEMENT (qtdemux),
-          gst_message_new_tag_full (GST_OBJECT (qtdemux), stream->pad,
-              gst_tag_list_copy (list)));
-    }
     /* global tags go on each pad anyway */
     stream->send_global_tags = TRUE;
   }
@@ -5099,17 +5108,21 @@ qtdemux_find_atom (GstQTDemux * qtdemux, guint64 * offset,
       G_GUINT64_FORMAT, GST_FOURCC_ARGS (fourcc), *offset);
 
   while (TRUE) {
+    guint8 *bdata;
+    gsize bsize;
+
     ret = gst_pad_pull_range (qtdemux->sinkpad, *offset, 16, &buf);
     if (G_UNLIKELY (ret != GST_FLOW_OK))
       goto locate_failed;
-    if (G_LIKELY (GST_BUFFER_SIZE (buf) != 16)) {
+    if (G_UNLIKELY (gst_buffer_get_size (buf) != 16)) {
       /* likely EOF */
       ret = GST_FLOW_UNEXPECTED;
       gst_buffer_unref (buf);
       goto locate_failed;
     }
-    extract_initial_length_and_fourcc (GST_BUFFER_DATA (buf), 16, length,
-        &lfourcc);
+    bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+    extract_initial_length_and_fourcc (bdata, 16, length, &lfourcc);
+    gst_buffer_unmap (buf, bdata, bsize);
     gst_buffer_unref (buf);
 
     if (G_UNLIKELY (*length == 0)) {
@@ -5148,7 +5161,9 @@ qtdemux_add_fragmented_samples (GstQTDemux * qtdemux)
   guint64 length, offset;
   GstBuffer *buf = NULL;
   GstFlowReturn ret = GST_FLOW_OK;
-  GstFlowReturn res = TRUE;
+  GstFlowReturn res = GST_FLOW_OK;
+  guint8 *bdata;
+  gsize bsize;
 
   offset = qtdemux->moof_offset;
   GST_DEBUG_OBJECT (qtdemux, "next moof at offset %" G_GUINT64_FORMAT, offset);
@@ -5168,13 +5183,15 @@ qtdemux_add_fragmented_samples (GstQTDemux * qtdemux)
   ret = gst_qtdemux_pull_atom (qtdemux, offset, length, &buf);
   if (G_UNLIKELY (ret != GST_FLOW_OK))
     goto flow_failed;
-  if (!qtdemux_parse_moof (qtdemux, GST_BUFFER_DATA (buf),
-          GST_BUFFER_SIZE (buf), offset, NULL)) {
+  bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+  if (!qtdemux_parse_moof (qtdemux, bdata, bsize, offset, NULL)) {
+    gst_buffer_unmap (buf, bdata, bsize);
     gst_buffer_unref (buf);
     buf = NULL;
     goto parse_failed;
   }
 
+  gst_buffer_unmap (buf, bdata, bsize);
   gst_buffer_unref (buf);
   buf = NULL;
 
@@ -6011,7 +6028,7 @@ qtdemux_parse_svq3_stsd_data (GstQTDemux * qtdemux, GNode * stsd,
                 seqh_size = QT_UINT32 (data + 4);
                 if (seqh_size > 0) {
                   _seqh = gst_buffer_new_and_alloc (seqh_size);
-                  memcpy (GST_BUFFER_DATA (_seqh), data + 8, seqh_size);
+                  _gst_buffer_copy_into_mem (_seqh, data + 8, 0, seqh_size);
                 }
               }
             }
@@ -6168,11 +6185,13 @@ qtdemux_parse_amr_bitrate (GstBuffer * buf, gboolean wb)
   static const guint wb_bitrates[] = {
     6600, 8850, 12650, 14250, 15850, 18250, 19850, 23050, 23850
   };
-  const guint8 *data = GST_BUFFER_DATA (buf);
-  guint size = QT_UINT32 (data), max_mode;
+  guint8 *data;
+  gsize size, max_mode;
   guint16 mode_set;
 
-  if (GST_BUFFER_SIZE (buf) != 0x11) {
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+
+  if (size != 0x11) {
     GST_DEBUG ("Atom should have size 0x11, not %u", size);
     goto bad_data;
   }
@@ -6197,9 +6216,11 @@ qtdemux_parse_amr_bitrate (GstBuffer * buf, gboolean wb)
     goto bad_data;
   }
 
+  gst_buffer_unmap (buf, data, size);
   return wb ? wb_bitrates[max_mode] : nb_bitrates[max_mode];
 
 bad_data:
+  gst_buffer_unmap (buf, data, size);
   return 0;
 }
 
@@ -6467,7 +6488,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
                     avc_data + 8 + 1, size - 1);
 
                 buf = gst_buffer_new_and_alloc (size);
-                memcpy (GST_BUFFER_DATA (buf), avc_data + 0x8, size);
+                _gst_buffer_copy_into_mem (buf, avc_data + 0x8, 0, size);
                 gst_caps_set_simple (stream->caps,
                     "codec_data", GST_TYPE_BUFFER, buf, NULL);
                 gst_buffer_unref (buf);
@@ -6546,7 +6567,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
             if (len > 0x8) {
               len -= 0x8;
               buf = gst_buffer_new_and_alloc (len);
-              memcpy (GST_BUFFER_DATA (buf), data + 8, len);
+              _gst_buffer_copy_into_mem (buf, data + 8, 0, len);
               gst_caps_set_simple (stream->caps,
                   "codec_data", GST_TYPE_BUFFER, buf, NULL);
               gst_buffer_unref (buf);
@@ -6559,7 +6580,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
           /* see annex I of the jpeg2000 spec */
           GNode *jp2h, *ihdr, *colr, *mjp2, *field, *prefix, *cmap, *cdef;
           const guint8 *data;
-          guint32 fourcc = 0;
+          const gchar *colorspace;
           gint ncomp = 0;
           guint32 ncomp_map = 0;
           gint32 *comp_map = NULL;
@@ -6590,21 +6611,22 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
           if (QT_UINT8 ((guint8 *) colr->data + 8) == 1) {
             switch (QT_UINT32 ((guint8 *) colr->data + 11)) {
               case 16:
-                fourcc = GST_MAKE_FOURCC ('s', 'R', 'G', 'B');
+                colorspace = "sRGB";
                 break;
               case 17:
-                fourcc = GST_MAKE_FOURCC ('G', 'R', 'A', 'Y');
+                colorspace = "GRAY";
                 break;
               case 18:
-                fourcc = GST_MAKE_FOURCC ('s', 'Y', 'U', 'V');
+                colorspace = "sYUV";
                 break;
               default:
+                colorspace = NULL;
                 break;
             }
           }
-          if (!fourcc)
+          if (!colorspace)
             /* colr is required, and only values 16, 17, and 18 are specified,
-               so error if we have no fourcc */
+               so error if we have no colorspace */
             break;
 
           /* extract component mapping */
@@ -6671,7 +6693,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
           gst_caps_set_simple (stream->caps,
               "num-components", G_TYPE_INT, ncomp, NULL);
           gst_caps_set_simple (stream->caps,
-              "fourcc", GST_TYPE_FOURCC, fourcc, NULL);
+              "colorspace", G_TYPE_STRING, colorspace, NULL);
 
           if (comp_map) {
             GValue arr = { 0, };
@@ -6729,7 +6751,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
             if (len > 0x8) {
               len -= 0x8;
               buf = gst_buffer_new_and_alloc (len);
-              memcpy (GST_BUFFER_DATA (buf), data + 8, len);
+              _gst_buffer_copy_into_mem (buf, data + 8, 0, len);
               gst_caps_set_simple (stream->caps,
                   "codec_data", GST_TYPE_BUFFER, buf, NULL);
               gst_buffer_unref (buf);
@@ -6759,7 +6781,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
 
           GST_DEBUG_OBJECT (qtdemux, "found codec_data in stsd");
           buf = gst_buffer_new_and_alloc (len);
-          memcpy (GST_BUFFER_DATA (buf), stsd_data, len);
+          _gst_buffer_copy_into_mem (buf, stsd_data, 0, len);
           gst_caps_set_simple (stream->caps,
               "codec_data", GST_TYPE_BUFFER, buf, NULL);
           gst_buffer_unref (buf);
@@ -6793,7 +6815,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
         case FOURCC_ovc1:
         {
           GNode *ovc1;
-          gchar *ovc1_data;
+          guint8 *ovc1_data;
           guint ovc1_len;
           GstBuffer *buf;
 
@@ -6808,7 +6830,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
             break;
           }
           buf = gst_buffer_new_and_alloc (ovc1_len - 198);
-          memcpy (GST_BUFFER_DATA (buf), ovc1_data + 198, ovc1_len - 198);
+          _gst_buffer_copy_into_mem (buf, ovc1_data + 198, 0, ovc1_len - 198);
           gst_caps_set_simple (stream->caps,
               "codec_data", GST_TYPE_BUFFER, buf, NULL);
           gst_buffer_unref (buf);
@@ -6983,14 +7005,15 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
         }
         if (enda) {
           gst_caps_set_simple (stream->caps,
-              "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, NULL);
+              "format", G_TYPE_STRING, "S24_3LE", NULL);
         }
         break;
       }
       case FOURCC_owma:
       {
         GNode *owma;
-        const gchar *owma_data, *codec_name = NULL;
+        const guint8 *owma_data;
+        const gchar *codec_name = NULL;
         guint owma_len;
         GstBuffer *buf;
         gint version = 1;
@@ -7021,7 +7044,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
         }
         wfex = (WAVEFORMATEX *) (owma_data + 36);
         buf = gst_buffer_new_and_alloc (owma_len - 54);
-        memcpy (GST_BUFFER_DATA (buf), owma_data + 54, owma_len - 54);
+        _gst_buffer_copy_into_mem (buf, owma_data + 54, 0, owma_len - 54);
         if (wfex->wFormatTag == 0x0161) {
           codec_name = "Windows Media Audio";
           version = 2;
@@ -7119,9 +7142,8 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
               waveheader += 8;
               headerlen -= 8;
 
-              headerbuf = gst_buffer_new ();
-              GST_BUFFER_DATA (headerbuf) = (guint8 *) waveheader;
-              GST_BUFFER_SIZE (headerbuf) = headerlen;
+              headerbuf = gst_buffer_new_and_alloc (headerlen);
+              _gst_buffer_copy_into_mem (headerbuf, waveheader, 0, headerlen);
 
               if (gst_riff_parse_strf_auds (GST_ELEMENT_CAST (qtdemux),
                       headerbuf, &header, &extra)) {
@@ -7159,7 +7181,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
           if (len > 0x4C) {
             GstBuffer *buf = gst_buffer_new_and_alloc (len - 0x4C);
 
-            memcpy (GST_BUFFER_DATA (buf), stsd_data + 0x4C, len - 0x4C);
+            _gst_buffer_copy_into_mem (buf, stsd_data + 0x4C, 0, len - 0x4C);
             gst_caps_set_simple (stream->caps,
                 "codec_data", GST_TYPE_BUFFER, buf, NULL);
             gst_buffer_unref (buf);
@@ -7194,7 +7216,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
               /* codec-data contains alac atom size and prefix,
                * ffmpeg likes it that way, not quite gst-ish though ...*/
               buf = gst_buffer_new_and_alloc (len);
-              memcpy (GST_BUFFER_DATA (buf), alac->data, len);
+              _gst_buffer_copy_into_mem (buf, alac->data, 0, len);
               gst_caps_set_simple (stream->caps,
                   "codec_data", GST_TYPE_BUFFER, buf, NULL);
               gst_buffer_unref (buf);
@@ -7215,7 +7237,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
             GstBuffer *buf = gst_buffer_new_and_alloc (len - 0x34);
             guint bitrate;
 
-            memcpy (GST_BUFFER_DATA (buf), stsd_data + 0x34, len - 0x34);
+            _gst_buffer_copy_into_mem (buf, stsd_data + 0x34, 0, len - 0x34);
 
             /* If we have enough data, let's try to get the 'damr' atom. See
              * the 3GPP container spec (26.244) for more details. */
@@ -7437,7 +7459,6 @@ too_many_streams:
 static void
 gst_qtdemux_guess_bitrate (GstQTDemux * qtdemux)
 {
-  GstFormat format = GST_FORMAT_BYTES;
   QtDemuxStream *stream = NULL;
   gint64 size, duration, sys_bitrate, sum_bitrate = 0;
   gint i;
@@ -7448,8 +7469,7 @@ gst_qtdemux_guess_bitrate (GstQTDemux * qtdemux)
 
   GST_DEBUG_OBJECT (qtdemux, "Looking for streams with unknown bitrate");
 
-  if (!gst_pad_query_peer_duration (qtdemux->sinkpad, &format, &size) ||
-      format != GST_FORMAT_BYTES) {
+  if (!gst_pad_query_peer_duration (qtdemux->sinkpad, GST_FORMAT_BYTES, &size)) {
     GST_DEBUG_OBJECT (qtdemux,
         "Size in bytes of the stream not known - bailing");
     return;
@@ -7629,16 +7649,18 @@ qtdemux_is_brand_3gp (GstQTDemux * qtdemux, gboolean major)
     return ((qtdemux->major_brand & GST_MAKE_FOURCC (255, 255, 0, 0)) ==
         GST_MAKE_FOURCC ('3', 'g', 0, 0));
   } else if (qtdemux->comp_brands != NULL) {
-    guint8 *data = GST_BUFFER_DATA (qtdemux->comp_brands);
-    guint size = GST_BUFFER_SIZE (qtdemux->comp_brands);
+    guint8 *data;
+    gsize size;
     gboolean res = FALSE;
 
+    data = gst_buffer_map (qtdemux->comp_brands, &size, NULL, GST_MAP_READ);
     while (size >= 4) {
       res = res || ((QT_FOURCC (data) & GST_MAKE_FOURCC (255, 255, 0, 0)) ==
           GST_MAKE_FOURCC ('3', 'g', 0, 0));
       data += 4;
       size -= 4;
     }
+    gst_buffer_unmap (qtdemux->comp_brands, data, size);
     return res;
   } else {
     return FALSE;
@@ -8379,7 +8401,7 @@ qtdemux_tag_add_blob (GNode * node, GstQTDemux * demux)
   data = node->data;
   len = QT_UINT32 (data);
   buf = gst_buffer_new_and_alloc (len);
-  memcpy (GST_BUFFER_DATA (buf), data, len);
+  _gst_buffer_copy_into_mem (buf, data, 0, len);
 
   /* heuristic to determine style of tag */
   if (QT_FOURCC (data + 4) == FOURCC_____ ||
@@ -8405,12 +8427,13 @@ qtdemux_tag_add_blob (GNode * node, GstQTDemux * demux)
   GST_DEBUG_OBJECT (demux, "media type %s", media_type);
 
   caps = gst_caps_new_simple (media_type, "style", G_TYPE_STRING, style, NULL);
-  gst_buffer_set_caps (buf, caps);
+  // TODO conver to metadata or ???
+//   gst_buffer_set_caps (buf, caps);
   gst_caps_unref (caps);
   g_free (media_type);
 
   GST_DEBUG_OBJECT (demux, "adding private tag; size %d, caps %" GST_PTR_FORMAT,
-      GST_BUFFER_SIZE (buf), caps);
+      len, caps);
 
   gst_tag_list_add (demux->tag_list, GST_TAG_MERGE_APPEND,
       GST_QT_DEMUX_PRIVATE_TAG, buf, NULL);
@@ -8472,10 +8495,8 @@ qtdemux_parse_udta (GstQTDemux * qtdemux, GNode * udta)
     GstBuffer *buf;
     GstTagList *taglist;
 
-    buf = gst_buffer_new ();
-    GST_BUFFER_DATA (buf) = ((guint8 *) xmp_->data) + 8;
-    GST_BUFFER_SIZE (buf) = QT_UINT32 ((guint8 *) xmp_->data) - 8;
-
+    buf = _gst_buffer_new_wrapped (((guint8 *) xmp_->data) + 8,
+        QT_UINT32 ((guint8 *) xmp_->data) - 8, NULL);
     taglist = gst_tag_list_from_xmp_buffer (buf);
     gst_buffer_unref (buf);
 
@@ -8759,7 +8780,7 @@ qtdemux_parse_tree (GstQTDemux * qtdemux)
   /* set duration in the segment info */
   gst_qtdemux_get_duration (qtdemux, &duration);
   if (duration)
-    gst_segment_set_duration (&qtdemux->segment, GST_FORMAT_TIME, duration);
+    qtdemux->segment.duration = duration;
 
   /* parse all traks */
   trak = qtdemux_tree_get_child_by_type (qtdemux->moov_node, FOURCC_trak);
@@ -8995,7 +9016,7 @@ gst_qtdemux_handle_esds (GstQTDemux * qtdemux, QtDemuxStream * stream,
     GstBuffer *buffer;
 
     buffer = gst_buffer_new_and_alloc (data_len);
-    memcpy (GST_BUFFER_DATA (buffer), data_ptr, data_len);
+    _gst_buffer_copy_into_mem (buffer, data_ptr, 0, data_len);
 
     GST_DEBUG_OBJECT (qtdemux, "setting codec_data from esds");
     GST_MEMDUMP_OBJECT (qtdemux, "codec_data from esds", data_ptr, data_len);
@@ -9066,43 +9087,20 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
       _codec ("Raw RGB video");
       bps = QT_UINT16 (stsd_data + 98);
       /* set common stuff */
-      caps = gst_caps_new_simple ("video/x-raw-rgb",
-          "endianness", G_TYPE_INT, G_BYTE_ORDER, "depth", G_TYPE_INT, bps,
-          NULL);
+      caps = gst_caps_new_simple ("video/x-raw", NULL);
 
       switch (bps) {
         case 15:
-          gst_caps_set_simple (caps,
-              "bpp", G_TYPE_INT, 16,
-              "endianness", G_TYPE_INT, G_BIG_ENDIAN,
-              "red_mask", G_TYPE_INT, 0x7c00,
-              "green_mask", G_TYPE_INT, 0x03e0,
-              "blue_mask", G_TYPE_INT, 0x001f, NULL);
+          gst_caps_set_simple (caps, "format", G_TYPE_STRING, "RGB15", NULL);
           break;
         case 16:
-          gst_caps_set_simple (caps,
-              "bpp", G_TYPE_INT, 16,
-              "endianness", G_TYPE_INT, G_BIG_ENDIAN,
-              "red_mask", G_TYPE_INT, 0xf800,
-              "green_mask", G_TYPE_INT, 0x07e0,
-              "blue_mask", G_TYPE_INT, 0x001f, NULL);
+          gst_caps_set_simple (caps, "format", G_TYPE_STRING, "RGB16", NULL);
           break;
         case 24:
-          gst_caps_set_simple (caps,
-              "bpp", G_TYPE_INT, 24,
-              "endianness", G_TYPE_INT, G_BIG_ENDIAN,
-              "red_mask", G_TYPE_INT, 0xff0000,
-              "green_mask", G_TYPE_INT, 0x00ff00,
-              "blue_mask", G_TYPE_INT, 0x0000ff, NULL);
+          gst_caps_set_simple (caps, "format", G_TYPE_STRING, "RGB", NULL);
           break;
         case 32:
-          gst_caps_set_simple (caps,
-              "bpp", G_TYPE_INT, 32,
-              "endianness", G_TYPE_INT, G_BIG_ENDIAN,
-              "alpha_mask", G_TYPE_INT, 0xff000000,
-              "red_mask", G_TYPE_INT, 0x00ff0000,
-              "green_mask", G_TYPE_INT, 0x0000ff00,
-              "blue_mask", G_TYPE_INT, 0x000000ff, NULL);
+          gst_caps_set_simple (caps, "format", G_TYPE_STRING, "ARGB", NULL);
           break;
         default:
           /* unknown */
@@ -9112,39 +9110,30 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
     }
     case GST_MAKE_FOURCC ('y', 'v', '1', '2'):
       _codec ("Raw planar YUV 4:2:0");
-      caps = gst_caps_new_simple ("video/x-raw-yuv",
-          "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
-          NULL);
+      caps = gst_caps_new_simple ("video/x-raw",
+          "format", G_TYPE_STRING, "I420", NULL);
       break;
     case GST_MAKE_FOURCC ('y', 'u', 'v', '2'):
     case GST_MAKE_FOURCC ('Y', 'u', 'v', '2'):
       _codec ("Raw packed YUV 4:2:2");
-      caps = gst_caps_new_simple ("video/x-raw-yuv",
-          "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
-          NULL);
+      caps = gst_caps_new_simple ("video/x-raw",
+          "format", G_TYPE_STRING, "YUY2", NULL);
       break;
     case GST_MAKE_FOURCC ('2', 'v', 'u', 'y'):
     case GST_MAKE_FOURCC ('2', 'V', 'u', 'y'):
       _codec ("Raw packed YUV 4:2:2");
-      caps = gst_caps_new_simple ("video/x-raw-yuv",
-          "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'),
-          NULL);
+      caps = gst_caps_new_simple ("video/x-raw",
+          "format", G_TYPE_STRING, "UYVY", NULL);
       break;
     case GST_MAKE_FOURCC ('v', '2', '1', '0'):
       _codec ("Raw packed YUV 10-bit 4:2:2");
-      caps = gst_caps_new_simple ("video/x-raw-yuv",
-          "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('v', '2', '1', '0'),
-          NULL);
+      caps = gst_caps_new_simple ("video/x-raw",
+          "format", G_TYPE_STRING, "v210", NULL);
       break;
     case GST_MAKE_FOURCC ('r', '2', '1', '0'):
       _codec ("Raw packed RGB 10-bit 4:4:4");
-      caps = gst_caps_new_simple ("video/x-raw-rgb",
-          "endianness", G_TYPE_INT, G_BIG_ENDIAN, "depth", G_TYPE_INT, 30,
-          "bpp", G_TYPE_INT, 32,
-          "endianness", G_TYPE_INT, G_BIG_ENDIAN,
-          "red_mask", G_TYPE_INT, 0x3ff00000,
-          "green_mask", G_TYPE_INT, 0x000ffc00,
-          "blue_mask", G_TYPE_INT, 0x000003ff, NULL);
+      caps = gst_caps_new_simple ("video/x-raw",
+          "format", G_TYPE_STRING, "r210", NULL);
       break;
     case GST_MAKE_FOURCC ('m', 'p', 'e', 'g'):
     case GST_MAKE_FOURCC ('m', 'p', 'g', '1'):
@@ -9326,9 +9315,7 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
     case FOURCC_ovc1:
       _codec ("VC-1");
       caps = gst_caps_new_simple ("video/x-wmv",
-          "wmvversion", G_TYPE_INT, 3,
-          "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('W', 'V', 'C', '1'),
-          NULL);
+          "wmvversion", G_TYPE_INT, 3, "format", G_TYPE_STRING, "WVC1", NULL);
       break;
     case GST_MAKE_FOURCC ('k', 'p', 'c', 'd'):
     default:
@@ -9345,7 +9332,7 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
   /* enable clipping for raw video streams */
   s = gst_caps_get_structure (caps, 0);
   name = gst_structure_get_name (s);
-  if (g_str_has_prefix (name, "video/x-raw-")) {
+  if (g_str_has_prefix (name, "video/x-raw")) {
     stream->need_clip = TRUE;
   }
   return caps;
@@ -9366,8 +9353,8 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
     case GST_MAKE_FOURCC ('N', 'O', 'N', 'E'):
     case GST_MAKE_FOURCC ('r', 'a', 'w', ' '):
       _codec ("Raw 8-bit PCM audio");
-      caps = gst_caps_new_simple ("audio/x-raw-int", "width", G_TYPE_INT, 8,
-          "depth", G_TYPE_INT, 8, "signed", G_TYPE_BOOLEAN, FALSE, NULL);
+      caps = gst_caps_new_simple ("audio/x-raw",
+          "format", G_TYPE_STRING, "U8", NULL);
       break;
     case GST_MAKE_FOURCC ('t', 'w', 'o', 's'):
       endian = G_BIG_ENDIAN;
@@ -9376,45 +9363,43 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
     {
       gchar *str;
       gint depth;
+      GstAudioFormat format;
 
       if (!endian)
         endian = G_LITTLE_ENDIAN;
 
       depth = stream->bytes_per_packet * 8;
+      format = gst_audio_format_build_integer (TRUE, endian, depth, depth);
+
       str = g_strdup_printf ("Raw %d-bit PCM audio", depth);
       _codec (str);
       g_free (str);
-      caps = gst_caps_new_simple ("audio/x-raw-int",
-          "width", G_TYPE_INT, depth, "depth", G_TYPE_INT, depth,
-          "endianness", G_TYPE_INT, endian,
-          "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+
+      caps = gst_caps_new_simple ("audio/x-raw",
+          "format", G_TYPE_STRING, gst_audio_format_to_string (format), NULL);
       break;
     }
     case GST_MAKE_FOURCC ('f', 'l', '6', '4'):
       _codec ("Raw 64-bit floating-point audio");
-      caps = gst_caps_new_simple ("audio/x-raw-float", "width", G_TYPE_INT, 64,
-          "endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL);
+      caps = gst_caps_new_simple ("audio/x-raw",
+          "format", G_TYPE_STRING, "F64_BE", NULL);
       break;
     case GST_MAKE_FOURCC ('f', 'l', '3', '2'):
       _codec ("Raw 32-bit floating-point audio");
-      caps = gst_caps_new_simple ("audio/x-raw-float", "width", G_TYPE_INT, 32,
-          "endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL);
+      caps = gst_caps_new_simple ("audio/x-raw",
+          "format", G_TYPE_STRING, "F32_BE", NULL);
       break;
     case FOURCC_in24:
       _codec ("Raw 24-bit PCM audio");
       /* we assume BIG ENDIAN, an enda box will tell us to change this to little
        * endian later */
-      caps = gst_caps_new_simple ("audio/x-raw-int", "width", G_TYPE_INT, 24,
-          "depth", G_TYPE_INT, 24,
-          "endianness", G_TYPE_INT, G_BIG_ENDIAN,
-          "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+      caps = gst_caps_new_simple ("audio/x-raw",
+          "format", G_TYPE_STRING, "S24_3BE", NULL);
       break;
     case GST_MAKE_FOURCC ('i', 'n', '3', '2'):
       _codec ("Raw 32-bit PCM audio");
-      caps = gst_caps_new_simple ("audio/x-raw-int", "width", G_TYPE_INT, 32,
-          "depth", G_TYPE_INT, 32,
-          "endianness", G_TYPE_INT, G_BIG_ENDIAN,
-          "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+      caps = gst_caps_new_simple ("audio/x-raw",
+          "format", G_TYPE_STRING, "S32_BE", NULL);
       break;
     case GST_MAKE_FOURCC ('u', 'l', 'a', 'w'):
       _codec ("Mu-law audio");
@@ -9551,7 +9536,7 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
   /* enable clipping for raw audio streams */
   s = gst_caps_get_structure (caps, 0);
   name = gst_structure_get_name (s);
-  if (g_str_has_prefix (name, "audio/x-raw-")) {
+  if (g_str_has_prefix (name, "audio/x-raw")) {
     stream->need_clip = TRUE;
   }
   return caps;
index d2b43bd..6967cfb 100644 (file)
@@ -100,7 +100,6 @@ struct _GstQTDemux {
 
   /* configured playback region */
   GstSegment segment;
-  gboolean segment_running;
   GstEvent *pending_newsegment;
 
   /* gst index support */
index 047e196..63cdfae 100644 (file)
@@ -2,7 +2,7 @@ plugin_LTLIBRARIES = libgstlevel.la
 
 libgstlevel_la_SOURCES = gstlevel.c
 libgstlevel_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
-libgstlevel_la_LIBADD = $(GST_BASE_LIBS) $(LIBM)
+libgstlevel_la_LIBADD = $(GST_BASE_LIBS) $(LIBM) -lgstaudio-$(GST_MAJORMINOR)
 libgstlevel_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstlevel_la_LIBTOOLFLAGS = --tag=disable-static
 
index 2563eb5..16efded 100644 (file)
@@ -117,37 +117,23 @@ GST_DEBUG_CATEGORY_STATIC (level_debug);
 #define EPSILON 1e-35f
 
 static GstStaticPadTemplate sink_template_factory =
-    GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "rate = (int) [ 1, MAX ], "
-        "channels = (int) [ 1, MAX ], "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) { 8, 16, 32 }, "
-        "depth = (int) { 8, 16, 32 }, "
-        "signed = (boolean) true; "
-        "audio/x-raw-float, "
-        "rate = (int) [ 1, MAX ], "
-        "channels = (int) [ 1, MAX ], "
-        "endianness = (int) BYTE_ORDER, " "width = (int) {32, 64} ")
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) { S8, " GST_AUDIO_NE (S16) ", " GST_AUDIO_NE (S32)
+        GST_AUDIO_NE (F32) "," GST_AUDIO_NE (F64) " },"
+        "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
     );
 
 static GstStaticPadTemplate src_template_factory =
-    GST_STATIC_PAD_TEMPLATE ("src",
+GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "rate = (int) [ 1, MAX ], "
-        "channels = (int) [ 1, MAX ], "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) { 8, 16, 32 }, "
-        "depth = (int) { 8, 16, 32 }, "
-        "signed = (boolean) true; "
-        "audio/x-raw-float, "
-        "rate = (int) [ 1, MAX ], "
-        "channels = (int) [ 1, MAX ], "
-        "endianness = (int) BYTE_ORDER, " "width = (int) {32, 64} ")
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) { S8, " GST_AUDIO_NE (S16) ", " GST_AUDIO_NE (S32)
+        GST_AUDIO_NE (F32) "," GST_AUDIO_NE (F64) " },"
+        "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
     );
 
 enum
@@ -159,8 +145,8 @@ enum
   PROP_PEAK_FALLOFF
 };
 
-GST_BOILERPLATE (GstLevel, gst_level, GstBaseTransform,
-    GST_TYPE_BASE_TRANSFORM);
+#define gst_level_parent_class parent_class
+G_DEFINE_TYPE (GstLevel, gst_level, GST_TYPE_BASE_TRANSFORM);
 
 static void gst_level_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -176,24 +162,10 @@ static GstFlowReturn gst_level_transform_ip (GstBaseTransform * trans,
 
 
 static void
-gst_level_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = g_class;
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_template_factory));
-  gst_element_class_set_details_simple (element_class, "Level",
-      "Filter/Analyzer/Audio",
-      "RMS/Peak/Decaying Peak Level messager for audio/raw",
-      "Thomas Vander Stichele <thomas at apestaart dot org>");
-}
-
-static void
 gst_level_class_init (GstLevelClass * klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
   GstBaseTransformClass *trans_class = GST_BASE_TRANSFORM_CLASS (klass);
 
   gobject_class->set_property = gst_level_set_property;
@@ -221,6 +193,15 @@ gst_level_class_init (GstLevelClass * klass)
 
   GST_DEBUG_CATEGORY_INIT (level_debug, "level", 0, "Level calculation");
 
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&sink_template_factory));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&src_template_factory));
+  gst_element_class_set_details_simple (element_class, "Level",
+      "Filter/Analyzer/Audio",
+      "RMS/Peak/Decaying Peak Level messager for audio/raw",
+      "Thomas Vander Stichele <thomas at apestaart dot org>");
+
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_level_set_caps);
   trans_class->start = GST_DEBUG_FUNCPTR (gst_level_start);
   trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_level_transform_ip);
@@ -228,14 +209,12 @@ gst_level_class_init (GstLevelClass * klass)
 }
 
 static void
-gst_level_init (GstLevel * filter, GstLevelClass * g_class)
+gst_level_init (GstLevel * filter)
 {
   filter->CS = NULL;
   filter->peak = NULL;
 
-  filter->rate = 0;
-  filter->width = 0;
-  filter->channels = 0;
+  gst_audio_info_init (&filter->info);
 
   filter->interval = GST_SECOND / 10;
   filter->decay_peak_ttl = GST_SECOND / 10 * 3;
@@ -282,9 +261,10 @@ gst_level_set_property (GObject * object, guint prop_id,
       break;
     case PROP_SIGNAL_INTERVAL:
       filter->interval = g_value_get_uint64 (value);
-      if (filter->rate) {
+      if (GST_AUDIO_INFO_RATE (&filter->info)) {
         filter->interval_frames =
-            GST_CLOCK_TIME_TO_FRAMES (filter->interval, filter->rate);
+            GST_CLOCK_TIME_TO_FRAMES (filter->interval,
+            GST_AUDIO_INFO_RATE (&filter->info));
       }
       break;
     case PROP_PEAK_TTL:
@@ -415,58 +395,42 @@ gst_level_calculate_gdouble (gpointer data, guint num, guint channels,
 */
 
 
-static gint
-structure_get_int (GstStructure * structure, const gchar * field)
-{
-  gint ret;
-
-  if (!gst_structure_get_int (structure, field, &ret))
-    g_assert_not_reached ();
-
-  return ret;
-}
-
 static gboolean
 gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
 {
   GstLevel *filter = GST_LEVEL (trans);
-  const gchar *mimetype;
-  GstStructure *structure;
-  gint i;
+  GstAudioInfo info;
+  gint i, channels, rate;
 
-  structure = gst_caps_get_structure (in, 0);
-  filter->rate = structure_get_int (structure, "rate");
-  filter->width = structure_get_int (structure, "width");
-  filter->channels = structure_get_int (structure, "channels");
-  mimetype = gst_structure_get_name (structure);
+  if (!gst_audio_info_from_caps (&info, in))
+    return FALSE;
 
-  /* FIXME: set calculator func depending on caps */
-  filter->process = NULL;
-  if (strcmp (mimetype, "audio/x-raw-int") == 0) {
-    GST_DEBUG_OBJECT (filter, "use int: %u", filter->width);
-    switch (filter->width) {
-      case 8:
-        filter->process = gst_level_calculate_gint8;
-        break;
-      case 16:
-        filter->process = gst_level_calculate_gint16;
-        break;
-      case 32:
-        filter->process = gst_level_calculate_gint32;
-        break;
-    }
-  } else if (strcmp (mimetype, "audio/x-raw-float") == 0) {
-    GST_DEBUG_OBJECT (filter, "use float, %u", filter->width);
-    switch (filter->width) {
-      case 32:
-        filter->process = gst_level_calculate_gfloat;
-        break;
-      case 64:
-        filter->process = gst_level_calculate_gdouble;
-        break;
-    }
+  switch (GST_AUDIO_INFO_FORMAT (&info)) {
+    case GST_AUDIO_FORMAT_S8:
+      filter->process = gst_level_calculate_gint8;
+      break;
+    case GST_AUDIO_FORMAT_S16:
+      filter->process = gst_level_calculate_gint16;
+      break;
+    case GST_AUDIO_FORMAT_S32:
+      filter->process = gst_level_calculate_gint32;
+      break;
+    case GST_AUDIO_FORMAT_F32:
+      filter->process = gst_level_calculate_gfloat;
+      break;
+    case GST_AUDIO_FORMAT_F64:
+      filter->process = gst_level_calculate_gdouble;
+      break;
+    default:
+      filter->process = NULL;
+      break;
   }
 
+  filter->info = info;
+
+  channels = GST_AUDIO_INFO_CHANNELS (&info);
+  rate = GST_AUDIO_INFO_RATE (&info);
+
   /* allocate channel variable arrays */
   g_free (filter->CS);
   g_free (filter->peak);
@@ -474,22 +438,21 @@ gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
   g_free (filter->decay_peak);
   g_free (filter->decay_peak_base);
   g_free (filter->decay_peak_age);
-  filter->CS = g_new (gdouble, filter->channels);
-  filter->peak = g_new (gdouble, filter->channels);
-  filter->last_peak = g_new (gdouble, filter->channels);
-  filter->decay_peak = g_new (gdouble, filter->channels);
-  filter->decay_peak_base = g_new (gdouble, filter->channels);
+  filter->CS = g_new (gdouble, channels);
+  filter->peak = g_new (gdouble, channels);
+  filter->last_peak = g_new (gdouble, channels);
+  filter->decay_peak = g_new (gdouble, channels);
+  filter->decay_peak_base = g_new (gdouble, channels);
 
-  filter->decay_peak_age = g_new (GstClockTime, filter->channels);
+  filter->decay_peak_age = g_new (GstClockTime, channels);
 
-  for (i = 0; i < filter->channels; ++i) {
+  for (i = 0; i < channels; ++i) {
     filter->CS[i] = filter->peak[i] = filter->last_peak[i] =
         filter->decay_peak[i] = filter->decay_peak_base[i] = 0.0;
     filter->decay_peak_age[i] = G_GUINT64_CONSTANT (0);
   }
 
-  filter->interval_frames =
-      GST_CLOCK_TIME_TO_FRAMES (filter->interval, filter->rate);
+  filter->interval_frames = GST_CLOCK_TIME_TO_FRAMES (filter->interval, rate);
 
   return TRUE;
 }
@@ -569,42 +532,46 @@ static GstFlowReturn
 gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
 {
   GstLevel *filter;
-  guint8 *in_data;
+  guint8 *in_data, *data;
+  gsize in_size;
   gdouble CS;
   guint i;
   guint num_frames = 0;
   guint num_int_samples = 0;    /* number of interleaved samples
                                  * ie. total count for all channels combined */
   GstClockTimeDiff falloff_time;
+  gint channels, rate, bps;
 
   filter = GST_LEVEL (trans);
 
-  in_data = GST_BUFFER_DATA (in);
-  num_int_samples = GST_BUFFER_SIZE (in) / (filter->width / 8);
+  channels = GST_AUDIO_INFO_CHANNELS (&filter->info);
+  bps = GST_AUDIO_INFO_BPS (&filter->info);
+  rate = GST_AUDIO_INFO_RATE (&filter->info);
+
+  in_data = data = gst_buffer_map (in, &in_size, NULL, GST_MAP_READ);
+  num_int_samples = in_size / bps;
 
   GST_LOG_OBJECT (filter, "analyzing %u sample frames at ts %" GST_TIME_FORMAT,
       num_int_samples, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (in)));
 
-  g_return_val_if_fail (num_int_samples % filter->channels == 0,
-      GST_FLOW_ERROR);
+  g_return_val_if_fail (num_int_samples % channels == 0, GST_FLOW_ERROR);
 
-  num_frames = num_int_samples / filter->channels;
+  num_frames = num_int_samples / channels;
 
-  for (i = 0; i < filter->channels; ++i) {
+  for (i = 0; i < channels; ++i) {
     if (!GST_BUFFER_FLAG_IS_SET (in, GST_BUFFER_FLAG_GAP)) {
-      filter->process (in_data, num_int_samples, filter->channels, &CS,
+      filter->process (in_data, num_int_samples, channels, &CS,
           &filter->peak[i]);
       GST_LOG_OBJECT (filter,
           "channel %d, cumulative sum %f, peak %f, over %d samples/%d channels",
-          i, CS, filter->peak[i], num_int_samples, filter->channels);
+          i, CS, filter->peak[i], num_int_samples, channels);
       filter->CS[i] += CS;
     } else {
       filter->peak[i] = 0.0;
     }
-    in_data += (filter->width / 8);
+    in_data += bps;
 
-    filter->decay_peak_age[i] +=
-        GST_FRAMES_TO_CLOCK_TIME (num_frames, filter->rate);
+    filter->decay_peak_age[i] += GST_FRAMES_TO_CLOCK_TIME (num_frames, rate);
     GST_LOG_OBJECT (filter, "filter peak info [%d]: decay peak %f, age %"
         GST_TIME_FORMAT, i,
         filter->decay_peak[i], GST_TIME_ARGS (filter->decay_peak_age[i]));
@@ -660,7 +627,7 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
     if (filter->message) {
       GstMessage *m;
       GstClockTime duration =
-          GST_FRAMES_TO_CLOCK_TIME (filter->num_frames, filter->rate);
+          GST_FRAMES_TO_CLOCK_TIME (filter->num_frames, rate);
 
       m = gst_level_message_new (filter, filter->message_ts, duration);
 
@@ -668,7 +635,7 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
           "message: ts %" GST_TIME_FORMAT ", num_frames %d",
           GST_TIME_ARGS (filter->message_ts), filter->num_frames);
 
-      for (i = 0; i < filter->channels; ++i) {
+      for (i = 0; i < channels; ++i) {
         gdouble RMS;
         gdouble RMSdB, lastdB, decaydB;
 
@@ -709,6 +676,8 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
     filter->num_frames = 0;
   }
 
+  gst_buffer_unmap (in, data, in_size);
+
   return GST_FLOW_OK;
 }
 
index 32d4c9e..ae9ba3a 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <gst/gst.h>
 #include <gst/base/gstbasetransform.h>
-
+#include <gst/audio/audio.h>
 
 G_BEGIN_DECLS
 
@@ -59,9 +59,7 @@ struct _GstLevel {
   gboolean message;             /* whether or not to post messages */
   guint64 interval;             /* how many seconds between emits */
 
-  gint rate;                    /* caps variables */
-  gint width;
-  gint channels;
+  GstAudioInfo info;
 
   gdouble decay_peak_ttl;       /* time to live for peak in seconds */
   gdouble decay_peak_falloff;   /* falloff in dB/sec */
@@ -79,7 +77,7 @@ struct _GstLevel {
   gdouble *MS;                  /* normalized Mean Square of buffer */
   gdouble *RMS_dB;              /* RMS in dB to emit */
   GstClockTime *decay_peak_age; /* age of last peak */
-  
+
   void (*process)(gpointer, guint, guint, gdouble*, gdouble*);
 };
 
index 416f30e..5a0b90a 100644 (file)
@@ -1924,8 +1924,8 @@ gst_matroska_demux_handle_seek_event (GstMatroskaDemux * demux,
         entry->pos + demux->common.ebml_segment_start);
   }
 
-  flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
-  keyunit = ! !(flags & GST_SEEK_FLAG_KEY_UNIT);
+  flush = !!(flags & GST_SEEK_FLAG_FLUSH);
+  keyunit = !!(flags & GST_SEEK_FLAG_KEY_UNIT);
 
   if (flush) {
     GST_DEBUG_OBJECT (demux, "Starting flush");
index 4d454e6..a692682 100644 (file)
@@ -179,29 +179,14 @@ gst_multi_file_sink_next_get_type (void)
   return multi_file_sync_next_type;
 }
 
-GST_BOILERPLATE (GstMultiFileSink, gst_multi_file_sink, GstBaseSink,
-    GST_TYPE_BASE_SINK);
-
-static void
-gst_multi_file_sink_base_init (gpointer g_class)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
-  GST_DEBUG_CATEGORY_INIT (gst_multi_file_sink_debug, "multifilesink", 0,
-      "multifilesink element");
-
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&sinktemplate));
-  gst_element_class_set_details_simple (gstelement_class, "Multi-File Sink",
-      "Sink/File",
-      "Write buffers to a sequentially named set of files",
-      "David Schleef <ds@schleef.org>");
-}
+#define gst_multi_file_sink_parent_class parent_class
+G_DEFINE_TYPE (GstMultiFileSink, gst_multi_file_sink, GST_TYPE_BASE_SINK);
 
 static void
 gst_multi_file_sink_class_init (GstMultiFileSinkClass * klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
   GstBaseSinkClass *gstbasesink_class = GST_BASE_SINK_CLASS (klass);
 
   gobject_class->set_property = gst_multi_file_sink_set_property;
@@ -265,11 +250,20 @@ gst_multi_file_sink_class_init (GstMultiFileSinkClass * klass)
   gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_multi_file_sink_render);
   gstbasesink_class->set_caps =
       GST_DEBUG_FUNCPTR (gst_multi_file_sink_set_caps);
+
+  GST_DEBUG_CATEGORY_INIT (gst_multi_file_sink_debug, "multifilesink", 0,
+      "multifilesink element");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sinktemplate));
+  gst_element_class_set_details_simple (gstelement_class, "Multi-File Sink",
+      "Sink/File",
+      "Write buffers to a sequentially named set of files",
+      "David Schleef <ds@schleef.org>");
 }
 
 static void
-gst_multi_file_sink_init (GstMultiFileSink * multifilesink,
-    GstMultiFileSinkClass * g_class)
+gst_multi_file_sink_init (GstMultiFileSink * multifilesink)
 {
   multifilesink->filename = g_strdup (DEFAULT_LOCATION);
   multifilesink->index = DEFAULT_INDEX;
@@ -429,14 +423,13 @@ static GstFlowReturn
 gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
 {
   GstMultiFileSink *multifilesink;
-  guint size;
+  gsize size;
   guint8 *data;
   gchar *filename;
   gboolean ret;
   GError *error = NULL;
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   multifilesink = GST_MULTI_FILE_SINK (sink);
 
@@ -468,8 +461,7 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
           goto stdio_write_error;
       }
 
-      ret = fwrite (GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer), 1,
-          multifilesink->file);
+      ret = fwrite (data, size, 1, multifilesink->file);
       if (ret != 1)
         goto stdio_write_error;
 
@@ -499,17 +491,20 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
 
         if (multifilesink->streamheaders) {
           for (i = 0; i < multifilesink->n_streamheaders; i++) {
-            ret = fwrite (GST_BUFFER_DATA (multifilesink->streamheaders[i]),
-                GST_BUFFER_SIZE (multifilesink->streamheaders[i]), 1,
-                multifilesink->file);
+            guint8 *sdata;
+            gsize ssize;
+
+            sdata = gst_buffer_map (multifilesink->streamheaders[i], &ssize,
+                NULL, GST_MAP_READ);
+            ret = fwrite (data, ssize, 1, multifilesink->file);
+            gst_buffer_unmap (multifilesink->streamheaders[i], sdata, ssize);
             if (ret != 1)
               goto stdio_write_error;
           }
         }
       }
 
-      ret = fwrite (GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer), 1,
-          multifilesink->file);
+      ret = fwrite (data, size, 1, multifilesink->file);
       if (ret != 1)
         goto stdio_write_error;
 
@@ -518,6 +513,7 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
       g_assert_not_reached ();
   }
 
+  gst_buffer_unmap (buffer, data, size);
   return GST_FLOW_OK;
 
   /* ERRORS */
@@ -538,12 +534,16 @@ write_error:
     g_error_free (error);
     g_free (filename);
 
+    gst_buffer_unmap (buffer, data, size);
     return GST_FLOW_ERROR;
   }
 stdio_write_error:
-  GST_ELEMENT_ERROR (multifilesink, RESOURCE, WRITE,
-      ("Error while writing to file."), (NULL));
-  return GST_FLOW_ERROR;
+  {
+    GST_ELEMENT_ERROR (multifilesink, RESOURCE, WRITE,
+        ("Error while writing to file."), (NULL));
+    gst_buffer_unmap (buffer, data, size);
+    return GST_FLOW_ERROR;
+  }
 }
 
 static gboolean
index ea1ae98..b42d963 100644 (file)
@@ -56,7 +56,7 @@ static void gst_multi_file_src_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
 static void gst_multi_file_src_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
-static GstCaps *gst_multi_file_src_getcaps (GstBaseSrc * src);
+static GstCaps *gst_multi_file_src_getcaps (GstBaseSrc * src, GstCaps * filter);
 static gboolean gst_multi_file_src_query (GstBaseSrc * src, GstQuery * query);
 
 
@@ -83,30 +83,15 @@ enum
 #define DEFAULT_LOCATION "%05d"
 #define DEFAULT_INDEX 0
 
+#define gst_multi_file_src_parent_class parent_class
+G_DEFINE_TYPE (GstMultiFileSrc, gst_multi_file_src, GST_TYPE_PUSH_SRC);
 
-GST_BOILERPLATE (GstMultiFileSrc, gst_multi_file_src, GstPushSrc,
-    GST_TYPE_PUSH_SRC);
-
-static void
-gst_multi_file_src_base_init (gpointer g_class)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
-  GST_DEBUG_CATEGORY_INIT (gst_multi_file_src_debug, "multifilesrc", 0,
-      "multifilesrc element");
-
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&gst_multi_file_src_pad_template));
-  gst_element_class_set_details_simple (gstelement_class, "Multi-File Source",
-      "Source/File",
-      "Read a sequentially named set of files into buffers",
-      "David Schleef <ds@schleef.org>");
-}
 
 static void
 gst_multi_file_src_class_init (GstMultiFileSrcClass * klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
   GstPushSrcClass *gstpushsrc_class = GST_PUSH_SRC_CLASS (klass);
   GstBaseSrcClass *gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
 
@@ -157,11 +142,20 @@ gst_multi_file_src_class_init (GstMultiFileSrcClass * klass)
     GST_LOG ("No large file support, sizeof (off_t) = %" G_GSIZE_FORMAT,
         sizeof (off_t));
   }
+
+  GST_DEBUG_CATEGORY_INIT (gst_multi_file_src_debug, "multifilesrc", 0,
+      "multifilesrc element");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_multi_file_src_pad_template));
+  gst_element_class_set_details_simple (gstelement_class, "Multi-File Source",
+      "Source/File",
+      "Read a sequentially named set of files into buffers",
+      "David Schleef <ds@schleef.org>");
 }
 
 static void
-gst_multi_file_src_init (GstMultiFileSrc * multifilesrc,
-    GstMultiFileSrcClass * g_class)
+gst_multi_file_src_init (GstMultiFileSrc * multifilesrc)
 {
   multifilesrc->start_index = DEFAULT_INDEX;
   multifilesrc->index = DEFAULT_INDEX;
@@ -184,16 +178,23 @@ gst_multi_file_src_dispose (GObject * object)
 }
 
 static GstCaps *
-gst_multi_file_src_getcaps (GstBaseSrc * src)
+gst_multi_file_src_getcaps (GstBaseSrc * src, GstCaps * filter)
 {
   GstMultiFileSrc *multi_file_src = GST_MULTI_FILE_SRC (src);
 
   GST_DEBUG_OBJECT (src, "returning %" GST_PTR_FORMAT, multi_file_src->caps);
 
   if (multi_file_src->caps) {
-    return gst_caps_ref (multi_file_src->caps);
+    if (filter)
+      return gst_caps_intersect_full (filter, multi_file_src->caps,
+          GST_CAPS_INTERSECT_FIRST);
+    else
+      return gst_caps_ref (multi_file_src->caps);
   } else {
-    return gst_caps_new_any ();
+    if (filter)
+      return gst_caps_ref (filter);
+    else
+      return gst_caps_new_any ();
   }
 }
 
@@ -385,13 +386,11 @@ gst_multi_file_src_create (GstPushSrc * src, GstBuffer ** buffer)
   }
 
   buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = (unsigned char *) data;
-  GST_BUFFER_MALLOCDATA (buf) = GST_BUFFER_DATA (buf);
-  GST_BUFFER_SIZE (buf) = size;
+  gst_buffer_take_memory (buf, -1,
+      gst_memory_new_wrapped (0, data, g_free, size, 0, size));
   GST_BUFFER_OFFSET (buf) = multifilesrc->offset;
   GST_BUFFER_OFFSET_END (buf) = multifilesrc->offset + size;
   multifilesrc->offset += size;
-  gst_buffer_set_caps (buf, multifilesrc->caps);
 
   GST_DEBUG_OBJECT (multifilesrc, "read file \"%s\".", filename);
 
index a0d6eff..b99c0fc 100644 (file)
@@ -126,23 +126,8 @@ static void gst_multipart_get_property (GObject * object, guint prop_id,
 
 static void gst_multipart_demux_finalize (GObject * object);
 
-GST_BOILERPLATE (GstMultipartDemux, gst_multipart_demux, GstElement,
-    GST_TYPE_ELEMENT);
-
-static void
-gst_multipart_demux_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&multipart_demux_sink_template_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&multipart_demux_src_template_factory));
-  gst_element_class_set_details_simple (element_class, "Multipart demuxer",
-      "Codec/Demuxer",
-      "demux multipart streams",
-      "Wim Taymans <wim.taymans@gmail.com>, Sjoerd Simons <sjoerd@luon.net>");
-}
+#define gst_multipart_demux_parent_class parent_class
+G_DEFINE_TYPE (GstMultipartDemux, gst_multipart_demux, GST_TYPE_ELEMENT);
 
 static void
 gst_multipart_demux_class_init (GstMultipartDemuxClass * klass)
@@ -189,11 +174,19 @@ gst_multipart_demux_class_init (GstMultipartDemuxClass * klass)
   }
 
   gstelement_class->change_state = gst_multipart_demux_change_state;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&multipart_demux_sink_template_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&multipart_demux_src_template_factory));
+  gst_element_class_set_details_simple (gstelement_class, "Multipart demuxer",
+      "Codec/Demuxer",
+      "demux multipart streams",
+      "Wim Taymans <wim.taymans@gmail.com>, Sjoerd Simons <sjoerd@luon.net>");
 }
 
 static void
-gst_multipart_demux_init (GstMultipartDemux * multipart,
-    GstMultipartDemuxClass * g_class)
+gst_multipart_demux_init (GstMultipartDemux * multipart)
 {
   /* create the sink pad */
   multipart->sinkpad =
@@ -392,7 +385,7 @@ multipart_parse_header (GstMultipartDemux * multipart)
   guint8 *end, *next;
 
   datalen = gst_adapter_available (multipart->adapter);
-  data = gst_adapter_peek (multipart->adapter, datalen);
+  data = gst_adapter_map (multipart->adapter, datalen);
   dataend = data + datalen;
 
   /* Skip leading whitespace, pos endposition should at least leave space for
@@ -400,9 +393,8 @@ multipart_parse_header (GstMultipartDemux * multipart)
   for (pos = (guint8 *) data; pos < dataend - 4 && g_ascii_isspace (*pos);
       pos++);
 
-  if (pos >= dataend - 4) {
-    return MULTIPART_NEED_MORE_DATA;
-  }
+  if (pos >= dataend - 4)
+    goto need_more_data;
 
   if (G_UNLIKELY (pos[0] != '-' || pos[1] != '-')) {
     GST_DEBUG_OBJECT (multipart, "No boundary available");
@@ -411,7 +403,7 @@ multipart_parse_header (GstMultipartDemux * multipart)
 
   /* First the boundary */
   if (!get_line_end (pos, dataend, &end, &next))
-    return MULTIPART_NEED_MORE_DATA;
+    goto need_more_data;
 
   /* Ignore the leading -- */
   boundary_len = end - pos - 2;
@@ -430,9 +422,9 @@ multipart_parse_header (GstMultipartDemux * multipart)
      * invalid */
     if (G_UNLIKELY (boundary_len == multipart->boundary_len + 2 &&
             !strncmp (boundary, multipart->boundary, multipart->boundary_len) &&
-            !strncmp (boundary + multipart->boundary_len, "--", 2))) {
-      return MULTIPART_DATA_EOS;
-    }
+            !strncmp (boundary + multipart->boundary_len, "--", 2)))
+      goto eos;
+
     GST_DEBUG_OBJECT (multipart,
         "Boundary length doesn't match detected boundary (%d <> %d",
         boundary_len, multipart->boundary_len);
@@ -442,7 +434,6 @@ multipart_parse_header (GstMultipartDemux * multipart)
     goto wrong_header;
   }
 
-
   pos = next;
   while (get_line_end (pos, dataend, &end, &next)) {
     guint len = end - pos;
@@ -452,6 +443,7 @@ multipart_parse_header (GstMultipartDemux * multipart)
       GST_DEBUG_OBJECT (multipart,
           "Parsed the header - boundary: %s, mime-type: %s, content-length: %d",
           multipart->boundary, multipart->mime_type, multipart->content_length);
+      gst_adapter_unmap (multipart->adapter, 0);
       return next - data;
     }
 
@@ -471,15 +463,26 @@ multipart_parse_header (GstMultipartDemux * multipart)
     }
     pos = next;
   }
+
+need_more_data:
   GST_DEBUG_OBJECT (multipart, "Need more data for the header");
+  gst_adapter_unmap (multipart->adapter, 0);
+
   return MULTIPART_NEED_MORE_DATA;
 
 wrong_header:
   {
     GST_ELEMENT_ERROR (multipart, STREAM, DEMUX, (NULL),
         ("Boundary not found in the multipart header"));
+    gst_adapter_unmap (multipart->adapter, 0);
     return MULTIPART_DATA_ERROR;
   }
+eos:
+  {
+    GST_DEBUG_OBJECT (multipart, "we are EOS");
+    gst_adapter_unmap (multipart->adapter, 0);
+    return MULTIPART_DATA_EOS;
+  }
 }
 
 static gint
@@ -495,14 +498,16 @@ multipart_find_boundary (GstMultipartDemux * multipart, gint * datalen)
     len = multipart->content_length;
     if (gst_adapter_available (multipart->adapter) >= len + 2) {
       *datalen = len;
-      data = gst_adapter_peek (multipart->adapter, len + 1);
+      data = gst_adapter_map (multipart->adapter, len + 1);
 
       /* If data[len] contains \r then assume a newline is \r\n */
       if (data[len] == '\r')
         len += 2;
       else if (data[len] == '\n')
         len += 1;
-      /* Don't check if boundary is actually there, but let the header parsing 
+
+      gst_adapter_unmap (multipart->adapter, 0);
+      /* Don't check if boundary is actually there, but let the header parsing
        * bail out if it isn't */
       return len;
     } else {
@@ -514,7 +519,7 @@ multipart_find_boundary (GstMultipartDemux * multipart, gint * datalen)
   len = gst_adapter_available (multipart->adapter);
   if (len == 0)
     return MULTIPART_NEED_MORE_DATA;
-  data = gst_adapter_peek (multipart->adapter, len);
+  data = gst_adapter_map (multipart->adapter, len);
   dataend = data + len;
 
   for (pos = data + multipart->scanpos;
@@ -530,10 +535,12 @@ multipart_find_boundary (GstMultipartDemux * multipart, gint * datalen)
         len -= 1;
       *datalen = len;
 
+      gst_adapter_unmap (multipart->adapter, 0);
       multipart->scanpos = 0;
       return pos - data;
     }
   }
+  gst_adapter_unmap (multipart->adapter, 0);
   multipart->scanpos = pos - data;
   return MULTIPART_NEED_MORE_DATA;
 }
@@ -591,13 +598,14 @@ gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf)
       outbuf = gst_adapter_take_buffer (adapter, datalen);
       gst_adapter_flush (adapter, size - datalen);
 
-      gst_buffer_set_caps (outbuf, GST_PAD_CAPS (srcpad->pad));
       if (created) {
         GstTagList *tags;
+        GstSegment segment;
+
+        gst_segment_init (&segment, GST_FORMAT_TIME);
 
         /* Push new segment, first buffer has 0 timestamp */
-        gst_pad_push_event (srcpad->pad,
-            gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, 0));
+        gst_pad_push_event (srcpad->pad, gst_event_new_segment (&segment));
 
         tags =
             gst_tag_list_new_full (GST_TAG_CONTAINER_FORMAT, "Multipart", NULL);
@@ -610,8 +618,6 @@ gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf)
       GST_DEBUG_OBJECT (multipart,
           "pushing buffer with timestamp %" GST_TIME_FORMAT,
           GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
-      GST_DEBUG_OBJECT (multipart, "buffer has caps %" GST_PTR_FORMAT,
-          GST_BUFFER_CAPS (outbuf));
       res = gst_pad_push (srcpad->pad, outbuf);
       res = gst_multipart_combine_flows (multipart, srcpad, res);
       if (res != GST_FLOW_OK)
index 77af23e..d2a7906 100644 (file)
@@ -75,16 +75,12 @@ static const MimeTypeMap mimetypes[] = {
   {NULL, NULL}
 };
 
-static void gst_multipart_mux_base_init (gpointer g_class);
-static void gst_multipart_mux_class_init (GstMultipartMuxClass * klass);
-static void gst_multipart_mux_init (GstMultipartMux * multipart_mux);
-
 static void gst_multipart_mux_finalize (GObject * object);
 
 static gboolean gst_multipart_mux_handle_src_event (GstPad * pad,
     GstEvent * event);
 static GstPad *gst_multipart_mux_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name);
+    GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
 static GstStateChangeReturn gst_multipart_mux_change_state (GstElement *
     element, GstStateChange transition);
 
@@ -96,46 +92,8 @@ static void gst_multipart_mux_set_property (GObject * object, guint prop_id,
 static void gst_multipart_mux_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-static GstElementClass *parent_class = NULL;
-
-GType
-gst_multipart_mux_get_type (void)
-{
-  static GType multipart_mux_type = 0;
-
-  if (!multipart_mux_type) {
-    static const GTypeInfo multipart_mux_info = {
-      sizeof (GstMultipartMuxClass),
-      gst_multipart_mux_base_init,
-      NULL,
-      (GClassInitFunc) gst_multipart_mux_class_init,
-      NULL,
-      NULL,
-      sizeof (GstMultipartMux),
-      0,
-      (GInstanceInitFunc) gst_multipart_mux_init,
-    };
-
-    multipart_mux_type =
-        g_type_register_static (GST_TYPE_ELEMENT, "GstMultipartMux",
-        &multipart_mux_info, 0);
-  }
-  return multipart_mux_type;
-}
-
-static void
-gst_multipart_mux_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_factory));
-
-  gst_element_class_set_details_simple (element_class, "Multipart muxer",
-      "Codec/Muxer", "mux multipart streams", "Wim Taymans <wim@fluendo.com>");
-}
+#define gst_multipart_mux_parent_class parent_class
+G_DEFINE_TYPE (GstMultipartMux, gst_multipart_mux, GST_TYPE_ELEMENT);
 
 static void
 gst_multipart_mux_class_init (GstMultipartMuxClass * klass)
@@ -160,6 +118,14 @@ gst_multipart_mux_class_init (GstMultipartMuxClass * klass)
   gstelement_class->request_new_pad = gst_multipart_mux_request_new_pad;
   gstelement_class->change_state = gst_multipart_mux_change_state;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_factory));
+
+  gst_element_class_set_details_simple (gstelement_class, "Multipart muxer",
+      "Codec/Muxer", "mux multipart streams", "Wim Taymans <wim@fluendo.com>");
+
   /* populate mime types */
   klass->mimetypes = g_hash_table_new (g_str_hash, g_str_equal);
   for (i = 0; mimetypes[i].key; i++) {
@@ -205,7 +171,7 @@ gst_multipart_mux_finalize (GObject * object)
 
 static GstPad *
 gst_multipart_mux_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * req_name)
+    GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps)
 {
   GstMultipartMux *multipart_mux;
   GstPad *newpad;
@@ -232,6 +198,7 @@ gst_multipart_mux_request_new_pad (GstElement * element,
         sizeof (GstMultipartPadData));
 
     /* save a pointer to our data in the pad */
+    multipartpad->pad = newpad;
     gst_pad_set_element_private (newpad, multipartpad);
     multipart_mux->numpads++;
   }
@@ -430,6 +397,7 @@ gst_multipart_mux_collected (GstCollectPads * pads, GstMultipartMux * mux)
   GstBuffer *footerbuf = NULL;
   GstBuffer *databuf = NULL;
   GstStructure *structure = NULL;
+  GstCaps *caps;
   const gchar *mime;
 
   GST_DEBUG_OBJECT (mux, "all pads are collected");
@@ -460,8 +428,8 @@ gst_multipart_mux_collected (GstCollectPads * pads, GstMultipartMux * mux)
 
   /* see if we need to push a segment */
   if (mux->need_segment) {
-    GstEvent *event;
     GstClockTime time;
+    GstSegment segment;
 
     if (best->timestamp != -1)
       time = best->timestamp;
@@ -470,32 +438,35 @@ gst_multipart_mux_collected (GstCollectPads * pads, GstMultipartMux * mux)
 
     /* for the segment, we take the first timestamp we see, we don't know the
      * length and the position is 0 */
-    event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
-        time, -1, 0);
+    gst_segment_init (&segment, GST_FORMAT_TIME);
+    segment.start = time;
 
-    gst_pad_push_event (mux->srcpad, event);
+    gst_pad_push_event (mux->srcpad, gst_event_new_segment (&segment));
 
     mux->need_segment = FALSE;
   }
 
-  structure = gst_caps_get_structure (GST_BUFFER_CAPS (best->buffer), 0);
-  if (!structure)
+  caps = gst_pad_get_current_caps (best->pad);
+  if (caps == NULL)
     goto no_caps;
 
+  structure = gst_caps_get_structure (caps, 0);
+  if (!structure) {
+    gst_caps_unref (caps);
+    goto no_caps;
+  }
+
   /* get the mime type for the structure */
   mime = gst_multipart_mux_get_mime (mux, structure);
+  gst_caps_unref (caps);
 
   header = g_strdup_printf ("--%s\r\nContent-Type: %s\r\n"
-      "Content-Length: %u\r\n\r\n",
-      mux->boundary, mime, GST_BUFFER_SIZE (best->buffer));
+      "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n",
+      mux->boundary, mime, gst_buffer_get_size (best->buffer));
   headerlen = strlen (header);
 
-  ret = gst_pad_alloc_buffer_and_set_caps (mux->srcpad, GST_BUFFER_OFFSET_NONE,
-      headerlen, GST_PAD_CAPS (mux->srcpad), &headerbuf);
-  if (ret != GST_FLOW_OK)
-    goto alloc_failed;
-
-  memcpy (GST_BUFFER_DATA (headerbuf), header, headerlen);
+  headerbuf = gst_buffer_new_allocate (NULL, headerlen, 1);
+  gst_buffer_fill (headerbuf, 0, header, headerlen);
   g_free (header);
 
   /* the header has the same timestamp as the data buffer (which we will push
@@ -516,31 +487,26 @@ gst_multipart_mux_collected (GstCollectPads * pads, GstMultipartMux * mux)
 
   /* take best->buffer, we don't need to unref it later as we will push it
    * now. */
-  databuf = gst_buffer_make_metadata_writable (best->buffer);
+  databuf = gst_buffer_make_writable (best->buffer);
   best->buffer = NULL;
 
-  gst_buffer_set_caps (databuf, GST_PAD_CAPS (mux->srcpad));
   /* we need to updated the timestamp to match the running_time */
   GST_BUFFER_TIMESTAMP (databuf) = best->timestamp;
   GST_BUFFER_OFFSET (databuf) = mux->offset;
-  mux->offset += GST_BUFFER_SIZE (databuf);
+  mux->offset += gst_buffer_get_size (databuf);
   GST_BUFFER_OFFSET_END (databuf) = mux->offset;
   GST_BUFFER_FLAG_SET (databuf, GST_BUFFER_FLAG_DELTA_UNIT);
 
-  GST_DEBUG_OBJECT (mux, "pushing %u bytes data buffer",
-      GST_BUFFER_SIZE (databuf));
+  GST_DEBUG_OBJECT (mux, "pushing %" G_GSIZE_FORMAT " bytes data buffer",
+      gst_buffer_get_size (databuf));
   ret = gst_pad_push (mux->srcpad, databuf);
   if (ret != GST_FLOW_OK)
     /* push always takes ownership of the buffer, even after an error, so we
      * don't need to unref headerbuf here. */
     goto beach;
 
-  ret = gst_pad_alloc_buffer_and_set_caps (mux->srcpad, GST_BUFFER_OFFSET_NONE,
-      2, GST_PAD_CAPS (mux->srcpad), &footerbuf);
-  if (ret != GST_FLOW_OK)
-    goto alloc_failed;
-
-  memcpy (GST_BUFFER_DATA (footerbuf), "\r\n", 2);
+  footerbuf = gst_buffer_new_allocate (NULL, 2, 1);
+  gst_buffer_fill (footerbuf, 0, "\r\n", 2);
 
   /* the footer has the same timestamp as the data buffer and has a
    * duration of 0 */
@@ -590,13 +556,6 @@ no_caps:
     ret = GST_FLOW_NOT_NEGOTIATED;
     goto beach;
   }
-alloc_failed:
-  {
-    GST_WARNING_OBJECT (mux,
-        "failed allocating a %" G_GSIZE_FORMAT " bytes buffer", headerlen);
-    g_free (header);
-    goto beach;
-  }
 }
 
 static void
index a52db36..d2711ac 100644 (file)
@@ -47,6 +47,7 @@ typedef struct
   GstBuffer *buffer;            /* the queued buffer for this pad */
   GstClockTime timestamp;       /* its timestamp, converted to running_time so that we can
                                    correctly sort over multiple segments. */
+  GstPad *pad;
 }
 GstMultipartPadData;
 
index 90e84fe..b7e9487 100644 (file)
@@ -9,7 +9,7 @@ libgstreplaygain_la_SOURCES = \
 libgstreplaygain_la_CFLAGS  = \
        $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
 libgstreplaygain_la_LIBADD  = \
-       $(GST_PLUGINS_BASE_LIBS) -lgstpbutils-0.10 \
+       $(GST_PLUGINS_BASE_LIBS) -lgstpbutils-$(GST_MAJORMINOR) -lgstaudio-$(GST_MAJORMINOR)\
        $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM)
 libgstreplaygain_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstreplaygain_la_LIBTOOLFLAGS = --tag=disable-static
index 8a277c3..9bd445a 100644 (file)
@@ -79,6 +79,7 @@
 
 #include <gst/gst.h>
 #include <gst/base/gstbasetransform.h>
+#include <gst/audio/audio.h>
 
 #include "gstrganalysis.h"
 #include "replaygain.h"
@@ -102,31 +103,24 @@ enum
 /* The ReplayGain algorithm is intended for use with mono and stereo
  * audio.  The used implementation has filter coefficients for the
  * "usual" sample rates in the 8000 to 48000 Hz range. */
-#define REPLAY_GAIN_CAPS                                                \
+#define REPLAY_GAIN_CAPS "audio/x-raw," \
+  "format = (string) { "GST_AUDIO_NE(F32)","GST_AUDIO_NE(S16)" }, "     \
   "channels = (int) { 1, 2 }, "                                         \
   "rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, "     \
   "44100, 48000 }"
 
 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
-    GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, "
-        "width = (int) 32, " "endianness = (int) BYTE_ORDER, "
-        REPLAY_GAIN_CAPS "; "
-        "audio/x-raw-int, "
-        "width = (int) 16, " "depth = (int) [ 1, 16 ], "
-        "signed = (boolean) true, " "endianness = (int) BYTE_ORDER, "
-        REPLAY_GAIN_CAPS));
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS (REPLAY_GAIN_CAPS));
 
 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
-    GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, "
-        "width = (int) 32, " "endianness = (int) BYTE_ORDER, "
-        REPLAY_GAIN_CAPS "; "
-        "audio/x-raw-int, "
-        "width = (int) 16, " "depth = (int) [ 1, 16 ], "
-        "signed = (boolean) true, " "endianness = (int) BYTE_ORDER, "
-        REPLAY_GAIN_CAPS));
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS (REPLAY_GAIN_CAPS));
 
-GST_BOILERPLATE (GstRgAnalysis, gst_rg_analysis, GstBaseTransform,
-    GST_TYPE_BASE_TRANSFORM);
+#define gst_rg_analysis_parent_class parent_class
+G_DEFINE_TYPE (GstRgAnalysis, gst_rg_analysis, GST_TYPE_BASE_TRANSFORM);
 
 static void gst_rg_analysis_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -138,7 +132,7 @@ static gboolean gst_rg_analysis_set_caps (GstBaseTransform * base,
     GstCaps * incaps, GstCaps * outcaps);
 static GstFlowReturn gst_rg_analysis_transform_ip (GstBaseTransform * base,
     GstBuffer * buf);
-static gboolean gst_rg_analysis_event (GstBaseTransform * base,
+static gboolean gst_rg_analysis_sink_event (GstBaseTransform * base,
     GstEvent * event);
 static gboolean gst_rg_analysis_stop (GstBaseTransform * base);
 
@@ -151,30 +145,15 @@ static gboolean gst_rg_analysis_album_result (GstRgAnalysis * filter,
     GstTagList ** tag_list);
 
 static void
-gst_rg_analysis_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_factory));
-  gst_element_class_set_details_simple (element_class, "ReplayGain analysis",
-      "Filter/Analyzer/Audio",
-      "Perform the ReplayGain analysis",
-      "Ren\xc3\xa9 Stadler <mail@renestadler.de>");
-
-  GST_DEBUG_CATEGORY_INIT (gst_rg_analysis_debug, "rganalysis", 0,
-      "ReplayGain analysis element");
-}
-
-static void
 gst_rg_analysis_class_init (GstRgAnalysisClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *element_class;
   GstBaseTransformClass *trans_class;
 
   gobject_class = (GObjectClass *) klass;
+  element_class = (GstElementClass *) klass;
+
   gobject_class->set_property = gst_rg_analysis_set_property;
   gobject_class->get_property = gst_rg_analysis_get_property;
 
@@ -276,13 +255,25 @@ gst_rg_analysis_class_init (GstRgAnalysisClass * klass)
   trans_class->start = GST_DEBUG_FUNCPTR (gst_rg_analysis_start);
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_rg_analysis_set_caps);
   trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_rg_analysis_transform_ip);
-  trans_class->event = GST_DEBUG_FUNCPTR (gst_rg_analysis_event);
+  trans_class->sink_event = GST_DEBUG_FUNCPTR (gst_rg_analysis_sink_event);
   trans_class->stop = GST_DEBUG_FUNCPTR (gst_rg_analysis_stop);
   trans_class->passthrough_on_same_caps = TRUE;
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&src_factory));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&sink_factory));
+  gst_element_class_set_details_simple (element_class, "ReplayGain analysis",
+      "Filter/Analyzer/Audio",
+      "Perform the ReplayGain analysis",
+      "Ren\xc3\xa9 Stadler <mail@renestadler.de>");
+
+  GST_DEBUG_CATEGORY_INIT (gst_rg_analysis_debug, "rganalysis", 0,
+      "ReplayGain analysis element");
 }
 
 static void
-gst_rg_analysis_init (GstRgAnalysis * filter, GstRgAnalysisClass * gclass)
+gst_rg_analysis_init (GstRgAnalysis * filter)
 {
   GstBaseTransform *base = GST_BASE_TRANSFORM (filter);
 
@@ -399,9 +390,8 @@ gst_rg_analysis_set_caps (GstBaseTransform * base, GstCaps * in_caps,
     GstCaps * out_caps)
 {
   GstRgAnalysis *filter = GST_RG_ANALYSIS (base);
-  GstStructure *structure;
-  const gchar *name;
-  gint n_channels, sample_rate, sample_bit_size, sample_size;
+  GstAudioInfo info;
+  gint rate, channels;
 
   g_return_val_if_fail (filter->ctx != NULL, FALSE);
 
@@ -409,58 +399,42 @@ gst_rg_analysis_set_caps (GstBaseTransform * base, GstCaps * in_caps,
       "set_caps in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT,
       in_caps, out_caps);
 
-  structure = gst_caps_get_structure (in_caps, 0);
-  name = gst_structure_get_name (structure);
-
-  if (!gst_structure_get_int (structure, "width", &sample_bit_size)
-      || !gst_structure_get_int (structure, "channels", &n_channels)
-      || !gst_structure_get_int (structure, "rate", &sample_rate))
+  if (!gst_audio_info_from_caps (&info, in_caps))
     goto invalid_format;
 
-  if (!rg_analysis_set_sample_rate (filter->ctx, sample_rate))
-    goto invalid_format;
+  rate = GST_AUDIO_INFO_RATE (&info);
 
-  if (sample_bit_size % 8 != 0)
+  if (!rg_analysis_set_sample_rate (filter->ctx, rate))
     goto invalid_format;
-  sample_size = sample_bit_size / 8;
-
-  if (g_str_equal (name, "audio/x-raw-float")) {
 
-    if (sample_size != sizeof (gfloat))
-      goto invalid_format;
+  channels = GST_AUDIO_INFO_CHANNELS (&info);
 
-    /* The depth is not variable for float formats of course.  It just
-     * makes the transform function nice and simple if the
-     * rg_analysis_analyze_* functions have a common signature. */
-    filter->depth = sizeof (gfloat) * 8;
+  if (channels < 1 || channels > 2)
+    goto invalid_format;
 
-    if (n_channels == 1)
-      filter->analyze = rg_analysis_analyze_mono_float;
-    else if (n_channels == 2)
-      filter->analyze = rg_analysis_analyze_stereo_float;
-    else
-      goto invalid_format;
+  switch (GST_AUDIO_INFO_FORMAT (&info)) {
+    case GST_AUDIO_FORMAT_F32:
+      /* The depth is not variable for float formats of course.  It just
+       * makes the transform function nice and simple if the
+       * rg_analysis_analyze_* functions have a common signature. */
+      filter->depth = sizeof (gfloat) * 8;
 
-  } else if (g_str_equal (name, "audio/x-raw-int")) {
+      if (channels == 1)
+        filter->analyze = rg_analysis_analyze_mono_float;
+      else
+        filter->analyze = rg_analysis_analyze_stereo_float;
 
-    if (sample_size != sizeof (gint16))
-      goto invalid_format;
-
-    if (!gst_structure_get_int (structure, "depth", &filter->depth))
-      goto invalid_format;
-    if (filter->depth < 1 || filter->depth > 16)
-      goto invalid_format;
+      break;
+    case GST_AUDIO_FORMAT_S16:
+      filter->depth = sizeof (gint16) * 8;
 
-    if (n_channels == 1)
-      filter->analyze = rg_analysis_analyze_mono_int16;
-    else if (n_channels == 2)
-      filter->analyze = rg_analysis_analyze_stereo_int16;
-    else
+      if (channels == 1)
+        filter->analyze = rg_analysis_analyze_mono_int16;
+      else
+        filter->analyze = rg_analysis_analyze_stereo_int16;
+      break;
+    default:
       goto invalid_format;
-
-  } else {
-
-    goto invalid_format;
   }
 
   return TRUE;
@@ -479,6 +453,8 @@ static GstFlowReturn
 gst_rg_analysis_transform_ip (GstBaseTransform * base, GstBuffer * buf)
 {
   GstRgAnalysis *filter = GST_RG_ANALYSIS (base);
+  guint8 *data;
+  gsize size;
 
   g_return_val_if_fail (filter->ctx != NULL, GST_FLOW_WRONG_STATE);
   g_return_val_if_fail (filter->analyze != NULL, GST_FLOW_NOT_NEGOTIATED);
@@ -486,18 +462,19 @@ gst_rg_analysis_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   if (filter->skip)
     return GST_FLOW_OK;
 
-  GST_LOG_OBJECT (filter, "processing buffer of size %u",
-      GST_BUFFER_SIZE (buf));
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  GST_LOG_OBJECT (filter, "processing buffer of size %" G_GSIZE_FORMAT, size);
 
   rg_analysis_start_buffer (filter->ctx, GST_BUFFER_TIMESTAMP (buf));
-  filter->analyze (filter->ctx, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf),
-      filter->depth);
+  filter->analyze (filter->ctx, data, size, filter->depth);
+
+  gst_buffer_unmap (buf, data, size);
 
   return GST_FLOW_OK;
 }
 
 static gboolean
-gst_rg_analysis_event (GstBaseTransform * base, GstEvent * event)
+gst_rg_analysis_sink_event (GstBaseTransform * base, GstEvent * event)
 {
   GstRgAnalysis *filter = GST_RG_ANALYSIS (base);
 
@@ -529,7 +506,7 @@ gst_rg_analysis_event (GstBaseTransform * base, GstEvent * event)
       break;
   }
 
-  return GST_BASE_TRANSFORM_CLASS (parent_class)->event (base, event);
+  return GST_BASE_TRANSFORM_CLASS (parent_class)->sink_event (base, event);
 }
 
 static gboolean
index 2201eca..3291f6d 100644 (file)
@@ -45,6 +45,7 @@
 
 #include <gst/gst.h>
 #include <math.h>
+#include <gst/audio/audio.h>
 
 #include "gstrglimiter.h"
 
@@ -58,17 +59,21 @@ enum
 };
 
 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
-    GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, "
-        "width = (int) 32, channels = (int) [1, MAX], "
-        "rate = (int) [1, MAX], endianness = (int) BYTE_ORDER"));
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " GST_AUDIO_NE (F32) ", "
+        "channels = (int) [1, MAX], " "rate = (int) [1, MAX]"));
 
 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
-    GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, "
-        "width = (int) 32, channels = (int) [1, MAX], "
-        "rate = (int) [1, MAX], endianness = (int) BYTE_ORDER"));
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " GST_AUDIO_NE (F32) ", "
+        "channels = (int) [1, MAX], " "rate = (int) [1, MAX]"));
 
-GST_BOILERPLATE (GstRgLimiter, gst_rg_limiter, GstBaseTransform,
-    GST_TYPE_BASE_TRANSFORM);
+#define gst_rg_limiter_parent_class parent_class
+G_DEFINE_TYPE (GstRgLimiter, gst_rg_limiter, GST_TYPE_BASE_TRANSFORM);
 
 static void gst_rg_limiter_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -79,30 +84,14 @@ static GstFlowReturn gst_rg_limiter_transform_ip (GstBaseTransform * base,
     GstBuffer * buf);
 
 static void
-gst_rg_limiter_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = g_class;
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_factory));
-  gst_element_class_set_details_simple (element_class, "ReplayGain limiter",
-      "Filter/Effect/Audio",
-      "Apply signal compression to raw audio data",
-      "Ren\xc3\xa9 Stadler <mail@renestadler.de>");
-
-  GST_DEBUG_CATEGORY_INIT (gst_rg_limiter_debug, "rglimiter", 0,
-      "ReplayGain limiter element");
-}
-
-static void
 gst_rg_limiter_class_init (GstRgLimiterClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *element_class;
   GstBaseTransformClass *trans_class;
 
   gobject_class = (GObjectClass *) klass;
+  element_class = (GstElementClass *) klass;
 
   gobject_class->set_property = gst_rg_limiter_set_property;
   gobject_class->get_property = gst_rg_limiter_get_property;
@@ -114,10 +103,22 @@ gst_rg_limiter_class_init (GstRgLimiterClass * klass)
   trans_class = GST_BASE_TRANSFORM_CLASS (klass);
   trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_rg_limiter_transform_ip);
   trans_class->passthrough_on_same_caps = FALSE;
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&src_factory));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&sink_factory));
+  gst_element_class_set_details_simple (element_class, "ReplayGain limiter",
+      "Filter/Effect/Audio",
+      "Apply signal compression to raw audio data",
+      "Ren\xc3\xa9 Stadler <mail@renestadler.de>");
+
+  GST_DEBUG_CATEGORY_INIT (gst_rg_limiter_debug, "rglimiter", 0,
+      "ReplayGain limiter element");
 }
 
 static void
-gst_rg_limiter_init (GstRgLimiter * filter, GstRgLimiterClass * gclass)
+gst_rg_limiter_init (GstRgLimiter * filter)
 {
   GstBaseTransform *base = GST_BASE_TRANSFORM (filter);
 
@@ -170,6 +171,7 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
 {
   GstRgLimiter *filter = GST_RG_LIMITER (base);
   gfloat *input;
+  guint8 *data;
   guint count;
   guint i;
 
@@ -179,8 +181,9 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
   if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP))
     return GST_FLOW_OK;
 
-  input = (gfloat *) GST_BUFFER_DATA (buf);
-  count = GST_BUFFER_SIZE (buf) / sizeof (gfloat);
+  data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
+  input = (gfloat *) data;
+  count = gst_buffer_get_size (buf) / sizeof (gfloat);
 
   for (i = count; i--;) {
     if (*input > THRES)
@@ -190,5 +193,7 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
     input++;
   }
 
+  gst_buffer_unmap (buf, data, -1);
+
   return GST_FLOW_OK;
 }
index b75cbde..bd2cf18 100644 (file)
@@ -61,6 +61,7 @@
 
 #include <gst/gst.h>
 #include <gst/pbutils/pbutils.h>
+#include <gst/audio/audio.h>
 #include <math.h>
 
 #include "gstrgvolume.h"
@@ -96,31 +97,24 @@ enum
 
 /* Same template caps as GstVolume, for I don't like having just ANY caps. */
 
+#define FORMAT "{ "GST_AUDIO_NE(F32)","GST_AUDIO_NE(S16)" }"
+
 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
-    GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, "
-        "rate = (int) [ 1, MAX ], "
-        "channels = (int) [ 1, MAX ], "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) 32; "
-        "audio/x-raw-int, "
-        "channels = (int) [ 1, MAX ], "
-        "rate = (int) [ 1,  MAX ], "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE"));
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " FORMAT ", "
+        "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]"));
 
 static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
-    GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, "
-        "rate = (int) [ 1, MAX ], "
-        "channels = (int) [ 1, MAX ], "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) 32; "
-        "audio/x-raw-int, "
-        "channels = (int) [ 1, MAX ], "
-        "rate = (int) [ 1,  MAX ], "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE"));
-
-GST_BOILERPLATE (GstRgVolume, gst_rg_volume, GstBin, GST_TYPE_BIN);
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " FORMAT ", "
+        "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]"));
+
+#define gst_rg_volume_parent_class parent_class
+G_DEFINE_TYPE (GstRgVolume, gst_rg_volume, GST_TYPE_BIN);
 
 static void gst_rg_volume_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -139,24 +133,6 @@ static inline void gst_rg_volume_determine_gain (GstRgVolume * self,
     gdouble * target_gain, gdouble * result_gain);
 
 static void
-gst_rg_volume_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = g_class;
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template));
-  gst_element_class_set_details_simple (element_class, "ReplayGain volume",
-      "Filter/Effect/Audio",
-      "Apply ReplayGain volume adjustment",
-      "Ren\xc3\xa9 Stadler <mail@renestadler.de>");
-
-  GST_DEBUG_CATEGORY_INIT (gst_rg_volume_debug, "rgvolume", 0,
-      "ReplayGain volume element");
-}
-
-static void
 gst_rg_volume_class_init (GstRgVolumeClass * klass)
 {
   GObjectClass *gobject_class;
@@ -203,7 +179,7 @@ gst_rg_volume_class_init (GstRgVolumeClass * klass)
    * This element internally uses a volume element, which also supports
    * operating on integer audio formats.  These formats do not allow exceeding
    * digital full scale.  If extra headroom is used, make sure that the raw
-   * audio data format is floating point (audio/x-raw-float).  Otherwise,
+   * audio data format is floating point (F32).  Otherwise,
    * clipping distortion might be introduced as part of the volume adjustment
    * itself.
    */
@@ -298,10 +274,22 @@ gst_rg_volume_class_init (GstRgVolumeClass * klass)
    * mess with our internals. */
   bin_class->add_element = NULL;
   bin_class->remove_element = NULL;
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&src_template));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&sink_template));
+  gst_element_class_set_details_simple (element_class, "ReplayGain volume",
+      "Filter/Effect/Audio",
+      "Apply ReplayGain volume adjustment",
+      "Ren\xc3\xa9 Stadler <mail@renestadler.de>");
+
+  GST_DEBUG_CATEGORY_INIT (gst_rg_volume_debug, "rgvolume", 0,
+      "ReplayGain volume element");
 }
 
 static void
-gst_rg_volume_init (GstRgVolume * self, GstRgVolumeClass * gclass)
+gst_rg_volume_init (GstRgVolume * self)
 {
   GObjectClass *volume_class;
   GstPad *volume_pad, *ghost_pad;
index 5c43cce..bfdc5d8 100644 (file)
@@ -4,7 +4,6 @@ libgstrtp_la_SOURCES = \
        fnv1hash.c \
        gstrtp.c \
        gstrtpchannels.c \
-       gstrtpdepay.c \
        gstrtpac3depay.c \
        gstrtpac3pay.c \
        gstrtpbvdepay.c \
@@ -84,6 +83,7 @@ endif
 libgstrtp_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
 libgstrtp_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
                -lgstaudio-@GST_MAJORMINOR@ \
+               -lgstvideo-@GST_MAJORMINOR@ \
                 -lgsttag-@GST_MAJORMINOR@ \
                 -lgstrtp-@GST_MAJORMINOR@ \
                 -lgstpbutils-@GST_MAJORMINOR@ \
@@ -149,7 +149,6 @@ noinst_HEADERS =                    \
                 gstrtpmp4gpay.h        \
                 gstrtpmp4adepay.h      \
                 gstrtpmp4apay.h        \
-                gstrtpdepay.h          \
                 gstasteriskh263.h      \
                 gstrtpqcelpdepay.h     \
                 gstrtpqdmdepay.h       \
index 79aa32b..2cd075c 100644 (file)
@@ -44,8 +44,8 @@ typedef struct _GstAsteriskH263Header
   guint16 length;               /* Length */
 } GstAsteriskH263Header;
 
-#define GST_ASTERISKH263_HEADER_TIMESTAMP(buf) (((GstAsteriskH263Header *)(GST_BUFFER_DATA (buf)))->timestamp)
-#define GST_ASTERISKH263_HEADER_LENGTH(buf) (((GstAsteriskH263Header *)(GST_BUFFER_DATA (buf)))->length)
+#define GST_ASTERISKH263_HEADER_TIMESTAMP(data) (((GstAsteriskH263Header *)(data))->timestamp)
+#define GST_ASTERISKH263_HEADER_LENGTH(data) (((GstAsteriskH263Header *)(data))->length)
 
 static GstStaticPadTemplate gst_asteriskh263_src_template =
 GST_STATIC_PAD_TEMPLATE ("src",
@@ -71,24 +71,8 @@ static GstFlowReturn gst_asteriskh263_chain (GstPad * pad, GstBuffer * buffer);
 static GstStateChangeReturn gst_asteriskh263_change_state (GstElement *
     element, GstStateChange transition);
 
-GST_BOILERPLATE (GstAsteriskh263, gst_asteriskh263, GstElement,
-    GST_TYPE_ELEMENT);
-
-static void
-gst_asteriskh263_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_asteriskh263_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_asteriskh263_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP Asterisk H263 depayloader", "Codec/Depayloader/Network/RTP",
-      "Extracts H263 video from RTP and encodes in Asterisk H263 format",
-      "Neil Stratford <neils@vipadia.com>");
-}
+#define gst_asteriskh263_parent_class parent_class
+G_DEFINE_TYPE (GstAsteriskh263, gst_asteriskh263, GST_TYPE_ELEMENT);
 
 static void
 gst_asteriskh263_class_init (GstAsteriskh263Class * klass)
@@ -102,11 +86,20 @@ gst_asteriskh263_class_init (GstAsteriskh263Class * klass)
   gobject_class->finalize = gst_asteriskh263_finalize;
 
   gstelement_class->change_state = gst_asteriskh263_change_state;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_asteriskh263_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_asteriskh263_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP Asterisk H263 depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts H263 video from RTP and encodes in Asterisk H263 format",
+      "Neil Stratford <neils@vipadia.com>");
 }
 
 static void
-gst_asteriskh263_init (GstAsteriskh263 * asteriskh263,
-    GstAsteriskh263Class * klass)
+gst_asteriskh263_init (GstAsteriskh263 * asteriskh263)
 {
   asteriskh263->srcpad =
       gst_pad_new_from_static_template (&gst_asteriskh263_src_template, "src");
@@ -153,12 +146,18 @@ gst_asteriskh263_chain (GstPad * pad, GstBuffer * buf)
     guint32 timestamp;
     guint32 samples;
     guint16 asterisk_len;
+    GstRTPBuffer rtp;
+    guint8 *data;
+
+    gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
 
-    payload_len = gst_rtp_buffer_get_payload_len (buf);
-    payload = gst_rtp_buffer_get_payload (buf);
+    payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+    payload = gst_rtp_buffer_get_payload (&rtp);
 
-    M = gst_rtp_buffer_get_marker (buf);
-    timestamp = gst_rtp_buffer_get_timestamp (buf);
+    M = gst_rtp_buffer_get_marker (&rtp);
+    timestamp = gst_rtp_buffer_get_timestamp (&rtp);
+
+    gst_rtp_buffer_unmap (&rtp);
 
     outbuf = gst_buffer_new_and_alloc (payload_len +
         GST_ASTERISKH263_HEADER_LEN);
@@ -172,16 +171,24 @@ gst_asteriskh263_chain (GstPad * pad, GstBuffer * buf)
     samples = timestamp - asteriskh263->lastts;
     asteriskh263->lastts = timestamp;
 
-    GST_ASTERISKH263_HEADER_TIMESTAMP (outbuf) = g_htonl (samples);
-    GST_ASTERISKH263_HEADER_LENGTH (outbuf) = g_htons (asterisk_len);
+    data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+    GST_ASTERISKH263_HEADER_TIMESTAMP (data) = g_htonl (samples);
+    GST_ASTERISKH263_HEADER_LENGTH (data) = g_htons (asterisk_len);
 
     /* copy the data into place */
-    memcpy (GST_BUFFER_DATA (outbuf) + GST_ASTERISKH263_HEADER_LEN, payload,
-        payload_len);
+    memcpy (data + GST_ASTERISKH263_HEADER_LEN, payload, payload_len);
+
+    gst_buffer_unmap (outbuf, data, -1);
 
     GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
-    gst_buffer_set_caps (outbuf,
-        (GstCaps *) gst_pad_get_pad_template_caps (asteriskh263->srcpad));
+    if (!gst_pad_has_current_caps (asteriskh263->srcpad)) {
+      GstCaps *caps;
+
+      caps = gst_caps_copy
+          (gst_pad_get_pad_template_caps (asteriskh263->srcpad));
+      gst_pad_set_caps (asteriskh263->srcpad, caps);
+      gst_caps_unref (caps);
+    }
 
     ret = gst_pad_push (asteriskh263->srcpad, outbuf);
 
index 721cee3..7de6da3 100644 (file)
@@ -21,7 +21,6 @@
 #include "config.h"
 #endif
 
-#include "gstrtpdepay.h"
 #include "gstrtpac3depay.h"
 #include "gstrtpac3pay.h"
 #include "gstrtpbvdepay.h"
@@ -94,9 +93,6 @@
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  if (!gst_rtp_depay_plugin_init (plugin))
-    return FALSE;
-
   if (!gst_rtp_ac3_depay_plugin_init (plugin))
     return FALSE;
 
index 7943f1b..1321a7e 100644 (file)
@@ -37,11 +37,8 @@ static GstStaticPadTemplate gst_rtp_L16_depay_src_template =
 GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "endianness = (int) BIG_ENDIAN, "
-        "signed = (boolean) true, "
-        "width = (int) 16, "
-        "depth = (int) 16, "
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) S16_BE, "
         "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
     );
 
@@ -67,8 +64,8 @@ static GstStaticPadTemplate gst_rtp_L16_depay_sink_template =
     )
     );
 
-GST_BOILERPLATE (GstRtpL16Depay, gst_rtp_L16_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_L16_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpL16Depay, gst_rtp_L16_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static gboolean gst_rtp_L16_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
@@ -76,38 +73,33 @@ static GstBuffer *gst_rtp_L16_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
 static void
-gst_rtp_L16_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_L16_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_L16_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP audio depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts raw audio from RTP packets",
-      "Zeeshan Ali <zak147@yahoo.com>," "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_L16_depay_class_init (GstRtpL16DepayClass * klass)
 {
+  GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
+  gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->set_caps = gst_rtp_L16_depay_setcaps;
   gstbasertpdepayload_class->process = gst_rtp_L16_depay_process;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_L16_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_L16_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP audio depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts raw audio from RTP packets",
+      "Zeeshan Ali <zak147@yahoo.com>," "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtpL16depay_debug, "rtpL16depay", 0,
       "Raw Audio RTP Depayloader");
 }
 
 static void
-gst_rtp_L16_depay_init (GstRtpL16Depay * rtpL16depay,
-    GstRtpL16DepayClass * klass)
+gst_rtp_L16_depay_init (GstRtpL16Depay * rtpL16depay)
 {
   /* needed because of GST_BOILERPLATE */
 }
@@ -182,11 +174,8 @@ gst_rtp_L16_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   rtpL16depay->rate = clock_rate;
   rtpL16depay->channels = channels;
 
-  srccaps = gst_caps_new_simple ("audio/x-raw-int",
-      "endianness", G_TYPE_INT, G_BIG_ENDIAN,
-      "signed", G_TYPE_BOOLEAN, TRUE,
-      "width", G_TYPE_INT, 16,
-      "depth", G_TYPE_INT, 16,
+  srccaps = gst_caps_new_simple ("audio/x-raw",
+      "format", G_TYPE_STRING, "S16_BE",
       "rate", G_TYPE_INT, clock_rate, "channels", G_TYPE_INT, channels, NULL);
 
   /* add channel positions */
@@ -228,24 +217,28 @@ gst_rtp_L16_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   GstBuffer *outbuf;
   gint payload_len;
   gboolean marker;
+  GstRTPBuffer rtp;
 
   rtpL16depay = GST_RTP_L16_DEPAY (depayload);
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   if (payload_len <= 0)
     goto empty_packet;
 
   GST_DEBUG_OBJECT (rtpL16depay, "got payload of %d bytes", payload_len);
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
-  marker = gst_rtp_buffer_get_marker (buf);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  marker = gst_rtp_buffer_get_marker (&rtp);
 
   if (marker) {
     /* mark talk spurt with DISCONT */
     GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
   }
 
+  gst_rtp_buffer_unmap (&rtp);
+
   return outbuf;
 
   /* ERRORS */
@@ -253,6 +246,7 @@ empty_packet:
   {
     GST_ELEMENT_WARNING (rtpL16depay, STREAM, DECODE,
         ("Empty Payload."), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index a6fbacc..e13e135 100644 (file)
@@ -37,11 +37,8 @@ static GstStaticPadTemplate gst_rtp_L16_pay_sink_template =
 GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "endianness = (int) BIG_ENDIAN, "
-        "signed = (boolean) true, "
-        "width = (int) 16, "
-        "depth = (int) 16, "
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) S16_BE, "
         "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
     );
 
@@ -70,43 +67,39 @@ static GstStaticPadTemplate gst_rtp_L16_pay_src_template =
 static gboolean gst_rtp_L16_pay_setcaps (GstBaseRTPPayload * basepayload,
     GstCaps * caps);
 static GstCaps *gst_rtp_L16_pay_getcaps (GstBaseRTPPayload * rtppayload,
-    GstPad * pad);
+    GstPad * pad, GstCaps * filter);
 
-GST_BOILERPLATE (GstRtpL16Pay, gst_rtp_L16_pay, GstBaseRTPAudioPayload,
-    GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
-
-static void
-gst_rtp_L16_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_L16_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_L16_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP audio payloader",
-      "Codec/Payloader/Network/RTP",
-      "Payload-encode Raw audio into RTP packets (RFC 3551)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_rtp_L16_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpL16Pay, gst_rtp_L16_pay, GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
 
 static void
 gst_rtp_L16_pay_class_init (GstRtpL16PayClass * klass)
 {
+  GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
+  gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gstbasertppayload_class->set_caps = gst_rtp_L16_pay_setcaps;
   gstbasertppayload_class->get_caps = gst_rtp_L16_pay_getcaps;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_L16_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_L16_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP audio payloader",
+      "Codec/Payloader/Network/RTP",
+      "Payload-encode Raw audio into RTP packets (RFC 3551)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtpL16pay_debug, "rtpL16pay", 0,
       "L16 RTP Payloader");
 }
 
 static void
-gst_rtp_L16_pay_init (GstRtpL16Pay * rtpL16pay, GstRtpL16PayClass * klass)
+gst_rtp_L16_pay_init (GstRtpL16Pay * rtpL16pay)
 {
   GstBaseRTPAudioPayload *basertpaudiopayload;
 
@@ -191,7 +184,8 @@ no_channels:
 }
 
 static GstCaps *
-gst_rtp_L16_pay_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad)
+gst_rtp_L16_pay_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad,
+    GstCaps * filter)
 {
   GstCaps *otherpadcaps;
   GstCaps *caps;
@@ -227,6 +221,14 @@ gst_rtp_L16_pay_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad)
     }
     gst_caps_unref (otherpadcaps);
   }
+
+  if (filter) {
+    GstCaps *tcaps = caps;
+
+    caps = gst_caps_intersect_full (filter, tcaps, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (tcaps);
+  }
+
   return caps;
 }
 
index cb6304e..17da501 100644 (file)
@@ -47,8 +47,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
         "encoding-name = (string) \"AC3\"")
     );
 
-GST_BOILERPLATE (GstRtpAC3Depay, gst_rtp_ac3_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+G_DEFINE_TYPE (GstRtpAC3Depay, gst_rtp_ac3_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static gboolean gst_rtp_ac3_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
@@ -56,27 +55,23 @@ static GstBuffer *gst_rtp_ac3_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
 static void
-gst_rtp_ac3_depay_base_init (gpointer klass)
+gst_rtp_ac3_depay_class_init (GstRtpAC3DepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_ac3_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_ac3_depay_sink_template));
 
-  gst_element_class_set_details_simple (element_class, "RTP AC3 depayloader",
+  gst_element_class_set_details_simple (gstelement_class, "RTP AC3 depayloader",
       "Codec/Depayloader/Network/RTP",
       "Extracts AC3 audio from RTP packets (RFC 4184)",
       "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_ac3_depay_class_init (GstRtpAC3DepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->set_caps = gst_rtp_ac3_depay_setcaps;
   gstbasertpdepayload_class->process = gst_rtp_ac3_depay_process;
@@ -86,10 +81,9 @@ gst_rtp_ac3_depay_class_init (GstRtpAC3DepayClass * klass)
 }
 
 static void
-gst_rtp_ac3_depay_init (GstRtpAC3Depay * rtpac3depay,
-    GstRtpAC3DepayClass * klass)
+gst_rtp_ac3_depay_init (GstRtpAC3Depay * rtpac3depay)
 {
-  /* needed because of GST_BOILERPLATE */
+  /* needed because of G_DEFINE_TYPE */
 }
 
 static gboolean
@@ -165,48 +159,49 @@ gst_rtp_ac3_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstRtpAC3Depay *rtpac3depay;
   GstBuffer *outbuf;
+  GstRTPBuffer rtp = { NULL, };
+  guint8 *payload;
+  guint16 FT, NF;
 
   rtpac3depay = GST_RTP_AC3_DEPAY (depayload);
 
-  {
-    guint8 *payload;
-    guint16 FT, NF;
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
 
-    if (gst_rtp_buffer_get_payload_len (buf) < 2)
-      goto empty_packet;
+  if (gst_rtp_buffer_get_payload_len (&rtp) < 2)
+    goto empty_packet;
 
-    payload = gst_rtp_buffer_get_payload (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
-    /* strip off header
-     *
-     *  0                   1
-     *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
-     * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     * |    MBZ    | FT|       NF      |
-     * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     */
-    FT = payload[0] & 0x3;
-    NF = payload[1];
+  /* strip off header
+   *
+   *  0                   1
+   *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   * |    MBZ    | FT|       NF      |
+   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   */
+  FT = payload[0] & 0x3;
+  NF = payload[1];
 
-    GST_DEBUG_OBJECT (rtpac3depay, "FT: %d, NF: %d", FT, NF);
+  GST_DEBUG_OBJECT (rtpac3depay, "FT: %d, NF: %d", FT, NF);
 
-    /* We don't bother with fragmented packets yet */
-    outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 2, -1);
+  /* We don't bother with fragmented packets yet */
+  outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, 2, -1);
 
-    if (outbuf)
-        GST_DEBUG_OBJECT (rtpac3depay, "pushing buffer of size %d",
-            GST_BUFFER_SIZE (outbuf));
+  gst_rtp_buffer_unmap (&rtp);
 
-    return outbuf;
-  }
+  if (outbuf)
+    GST_DEBUG_OBJECT (rtpac3depay, "pushing buffer of size %d",
+        gst_buffer_get_size (outbuf));
 
-  return NULL;
+  return outbuf;
 
   /* ERRORS */
 empty_packet:
   {
     GST_ELEMENT_WARNING (rtpac3depay, STREAM, DECODE,
         ("Empty Payload."), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index fddea38..851b92d 100644 (file)
@@ -55,28 +55,14 @@ static GstStateChangeReturn gst_rtp_ac3_pay_change_state (GstElement * element,
 
 static gboolean gst_rtp_ac3_pay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
-static gboolean gst_rtp_ac3_pay_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_ac3_pay_handle_event (GstBaseRTPPayload * payload,
+    GstEvent * event);
 static GstFlowReturn gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay);
 static GstFlowReturn gst_rtp_ac3_pay_handle_buffer (GstBaseRTPPayload * payload,
     GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRtpAC3Pay, gst_rtp_ac3_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD)
-
-     static void gst_rtp_ac3_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_ac3_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_ac3_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP AC3 audio payloader", "Codec/Payloader/Network/RTP",
-      "Payload AC3 audio as RTP packets (RFC 4184)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_rtp_ac3_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpAC3Pay, gst_rtp_ac3_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_ac3_pay_class_init (GstRtpAC3PayClass * klass)
@@ -85,6 +71,9 @@ gst_rtp_ac3_pay_class_init (GstRtpAC3PayClass * klass)
   GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
+  GST_DEBUG_CATEGORY_INIT (rtpac3pay_debug, "rtpac3pay", 0,
+      "AC3 Audio RTP Depayloader");
+
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
@@ -93,16 +82,23 @@ gst_rtp_ac3_pay_class_init (GstRtpAC3PayClass * klass)
 
   gstelement_class->change_state = gst_rtp_ac3_pay_change_state;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_ac3_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_ac3_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP AC3 audio payloader", "Codec/Payloader/Network/RTP",
+      "Payload AC3 audio as RTP packets (RFC 4184)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   gstbasertppayload_class->set_caps = gst_rtp_ac3_pay_setcaps;
   gstbasertppayload_class->handle_event = gst_rtp_ac3_pay_handle_event;
   gstbasertppayload_class->handle_buffer = gst_rtp_ac3_pay_handle_buffer;
-
-  GST_DEBUG_CATEGORY_INIT (rtpac3pay_debug, "rtpac3pay", 0,
-      "AC3 Audio RTP Depayloader");
 }
 
 static void
-gst_rtp_ac3_pay_init (GstRtpAC3Pay * rtpac3pay, GstRtpAC3PayClass * klass)
+gst_rtp_ac3_pay_init (GstRtpAC3Pay * rtpac3pay)
 {
   rtpac3pay->adapter = gst_adapter_new ();
 }
@@ -147,11 +143,12 @@ gst_rtp_ac3_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
 }
 
 static gboolean
-gst_rtp_ac3_pay_handle_event (GstPad * pad, GstEvent * event)
+gst_rtp_ac3_pay_handle_event (GstBaseRTPPayload * payload, GstEvent * event)
 {
+  gboolean res;
   GstRtpAC3Pay *rtpac3pay;
 
-  rtpac3pay = GST_RTP_AC3_PAY (gst_pad_get_parent (pad));
+  rtpac3pay = GST_RTP_AC3_PAY (payload);
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_EOS:
@@ -165,10 +162,10 @@ gst_rtp_ac3_pay_handle_event (GstPad * pad, GstEvent * event)
       break;
   }
 
-  gst_object_unref (rtpac3pay);
+  res =
+      GST_BASE_RTP_PAYLOAD_CLASS (parent_class)->handle_event (payload, event);
 
-  /* FALSE to let the parent handle the event as well */
-  return FALSE;
+  return res;
 }
 
 struct frmsize_s
@@ -247,6 +244,7 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay)
     guint8 *payload;
     guint payload_len;
     guint packet_len;
+    GstRTPBuffer rtp = { NULL, };
 
     /* this will be the total length of the packet */
     packet_len = gst_rtp_buffer_calc_packet_len (2 + avail, 0, 0);
@@ -294,8 +292,9 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay)
      *     3: other fragment
      * NF: amount of frames if FT = 0, else number of fragments.
      */
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
     GST_LOG_OBJECT (rtpac3pay, "FT %u, NF %u", FT, NF);
-    payload = gst_rtp_buffer_get_payload (outbuf);
+    payload = gst_rtp_buffer_get_payload (&rtp);
     payload[0] = (FT & 3);
     payload[1] = NF;
     payload_len -= 2;
@@ -305,7 +304,8 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay)
 
     avail -= payload_len;
     if (avail == 0)
-      gst_rtp_buffer_set_marker (outbuf, TRUE);
+      gst_rtp_buffer_set_marker (&rtp, TRUE);
+    gst_rtp_buffer_unmap (&rtp);
 
     GST_BUFFER_TIMESTAMP (outbuf) = rtpac3pay->first_ts;
     GST_BUFFER_DURATION (outbuf) = rtpac3pay->duration;
@@ -322,15 +322,14 @@ gst_rtp_ac3_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 {
   GstRtpAC3Pay *rtpac3pay;
   GstFlowReturn ret;
-  guint size, avail, left, NF;
+  gsize size, avail, left, NF;
   guint8 *data, *p;
   guint packet_len;
   GstClockTime duration, timestamp;
 
   rtpac3pay = GST_RTP_AC3_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   duration = GST_BUFFER_DURATION (buffer);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
 
@@ -374,6 +373,7 @@ gst_rtp_ac3_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     p += frame_size;
     left -= frame_size;
   }
+  gst_buffer_unmap (buffer, data, size);
   if (NF == 0)
     goto no_frames;
 
index 5a545bf..74dbef8 100644 (file)
@@ -111,31 +111,27 @@ static gboolean gst_rtp_amr_depay_setcaps (GstBaseRTPDepayload * depayload,
 static GstBuffer *gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
-GST_BOILERPLATE (GstRtpAMRDepay, gst_rtp_amr_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_amr_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpAMRDepay, gst_rtp_amr_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_amr_depay_base_init (gpointer klass)
+gst_rtp_amr_depay_class_init (GstRtpAMRDepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_amr_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_amr_depay_sink_template));
 
-  gst_element_class_set_details_simple (element_class, "RTP AMR depayloader",
+  gst_element_class_set_details_simple (gstelement_class, "RTP AMR depayloader",
       "Codec/Depayloader/Network/RTP",
       "Extracts AMR or AMR-WB audio from RTP packets (RFC 3267)",
       "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_amr_depay_class_init (GstRtpAMRDepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->process = gst_rtp_amr_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_amr_depay_setcaps;
@@ -145,8 +141,7 @@ gst_rtp_amr_depay_class_init (GstRtpAMRDepayClass * klass)
 }
 
 static void
-gst_rtp_amr_depay_init (GstRtpAMRDepay * rtpamrdepay,
-    GstRtpAMRDepayClass * klass)
+gst_rtp_amr_depay_init (GstRtpAMRDepay * rtpamrdepay)
 {
   GstBaseRTPDepayload *depayload;
 
@@ -277,6 +272,9 @@ gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   const gint *frame_size;
   GstBuffer *outbuf = NULL;
   gint payload_len;
+  GstRTPBuffer rtp = { NULL };
+  guint8 *odata;
+  gsize osize;
 
   rtpamrdepay = GST_RTP_AMR_DEPAY (depayload);
 
@@ -286,6 +284,8 @@ gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   else
     frame_size = wb_frame_size;
 
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
   /* when we get here, 1 channel, 8000/16000 Hz, octet aligned, no CRC,
    * no robust sorting, no interleaving data is to be depayloaded */
   {
@@ -294,13 +294,13 @@ gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     gint amr_len;
     gint ILL, ILP;
 
-    payload_len = gst_rtp_buffer_get_payload_len (buf);
+    payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
     /* need at least 2 bytes for the header */
     if (payload_len < 2)
       goto too_small;
 
-    payload = gst_rtp_buffer_get_payload (buf);
+    payload = gst_rtp_buffer_get_payload (&rtp);
 
     /* depay CMR. The CMR is used by the sender to request
      * a new encoding mode.
@@ -375,8 +375,10 @@ gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     outbuf = gst_buffer_new_and_alloc (payload_len);
 
     /* point to destination */
-    p = GST_BUFFER_DATA (outbuf);
+    odata = gst_buffer_map (outbuf, &osize, NULL, GST_MAP_WRITE);
+
     /* point to first data packet */
+    p = odata;
     dp = payload + num_packets;
     if (rtpamrdepay->crc) {
       /* skip CRC if present */
@@ -398,17 +400,19 @@ gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
         dp += fr_size;
       }
     }
+    gst_buffer_unmap (outbuf, odata, osize);
+
     /* we can set the duration because each packet is 20 milliseconds */
     GST_BUFFER_DURATION (outbuf) = num_packets * 20 * GST_MSECOND;
 
-    if (gst_rtp_buffer_get_marker (buf)) {
+    if (gst_rtp_buffer_get_marker (&rtp)) {
       /* marker bit marks a discont buffer after a talkspurt. */
       GST_DEBUG_OBJECT (depayload, "marker bit was set");
       GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
     }
 
     GST_DEBUG_OBJECT (depayload, "pushing buffer of size %d",
-        GST_BUFFER_SIZE (outbuf));
+        gst_buffer_get_size (outbuf));
   }
   return outbuf;
 
index 89a149f..5454b69 100644 (file)
@@ -93,35 +93,29 @@ static GstFlowReturn gst_rtp_amr_pay_handle_buffer (GstBaseRTPPayload * pad,
 static GstStateChangeReturn
 gst_rtp_amr_pay_change_state (GstElement * element, GstStateChange transition);
 
-GST_BOILERPLATE (GstRtpAMRPay, gst_rtp_amr_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
+#define gst_rtp_amr_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpAMRPay, gst_rtp_amr_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
-gst_rtp_amr_pay_base_init (gpointer klass)
+gst_rtp_amr_pay_class_init (GstRtpAMRPayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPPayloadClass *gstbasertppayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gstelement_class->change_state = gst_rtp_amr_pay_change_state;
+
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_amr_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_amr_pay_sink_template));
 
-  gst_element_class_set_details_simple (element_class, "RTP AMR payloader",
+  gst_element_class_set_details_simple (gstelement_class, "RTP AMR payloader",
       "Codec/Payloader/Network/RTP",
       "Payload-encode AMR or AMR-WB audio into RTP packets (RFC 3267)",
       "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_amr_pay_class_init (GstRtpAMRPayClass * klass)
-{
-  GstBaseRTPPayloadClass *gstbasertppayload_class;
-  GstElementClass *gstelement_class;
-
-  gstelement_class = (GstElementClass *) klass;
-  gstelement_class->change_state = gst_rtp_amr_pay_change_state;
-
-  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gstbasertppayload_class->set_caps = gst_rtp_amr_pay_setcaps;
   gstbasertppayload_class->handle_buffer = gst_rtp_amr_pay_handle_buffer;
@@ -131,9 +125,8 @@ gst_rtp_amr_pay_class_init (GstRtpAMRPayClass * klass)
 }
 
 static void
-gst_rtp_amr_pay_init (GstRtpAMRPay * rtpamrpay, GstRtpAMRPayClass * klass)
+gst_rtp_amr_pay_init (GstRtpAMRPay * rtpamrpay)
 {
-  /* needed because of GST_BOILERPLATE */
 }
 
 static void
@@ -234,20 +227,22 @@ gst_rtp_amr_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   GstRtpAMRPay *rtpamrpay;
   const gint *frame_size;
   GstFlowReturn ret;
-  guint size, payload_len;
+  guint payload_len;
+  gsize size;
   GstBuffer *outbuf;
-  guint8 *payload, *data, *payload_amr;
+  guint8 *payload, *data, *ptr, *payload_amr;
   GstClockTime timestamp, duration;
   guint packet_len, mtu;
   gint i, num_packets, num_nonempty_packets;
   gint amr_len;
   gboolean sid = FALSE;
+  GstRTPBuffer rtp = { NULL };
 
   rtpamrpay = GST_RTP_AMR_PAY (basepayload);
   mtu = GST_BASE_RTP_PAYLOAD_MTU (rtpamrpay);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
   duration = GST_BUFFER_DURATION (buffer);
 
@@ -301,6 +296,8 @@ gst_rtp_amr_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   /* now alloc output buffer */
   outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
 
+  gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+
   /* copy timestamp */
   GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
 
@@ -313,7 +310,7 @@ gst_rtp_amr_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   if (GST_BUFFER_IS_DISCONT (buffer)) {
     GST_DEBUG_OBJECT (basepayload, "discont, setting marker bit");
     GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
-    gst_rtp_buffer_set_marker (outbuf, TRUE);
+    gst_rtp_buffer_set_marker (&rtp, TRUE);
     gst_rtp_amr_pay_recalc_rtp_time (rtpamrpay, timestamp);
   }
 
@@ -331,7 +328,7 @@ gst_rtp_amr_pay_handle_buffer (GstBaseRTPPayload * basepayload,
       (num_packets * 160) << (rtpamrpay->mode == GST_RTP_AMR_P_MODE_WB);
 
   /* get payload, this is now writable */
-  payload = gst_rtp_buffer_get_payload (outbuf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
   /*   0 1 2 3 4 5 6 7
    *  +-+-+-+-+-+-+-+-+
@@ -346,6 +343,7 @@ gst_rtp_amr_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
   /* copy data in payload, first we copy all the FTs then all
    * the AMR data. The last FT has to have the F flag cleared. */
+  ptr = data;
   for (i = 1; i <= num_packets; i++) {
     guint8 FT;
     gint fr_size;
@@ -355,26 +353,29 @@ gst_rtp_amr_pay_handle_buffer (GstBaseRTPPayload * basepayload,
      *  |F|  FT   |Q|P|P| more FT...
      *  +-+-+-+-+-+-+-+-+
      */
-    FT = (*data & 0x78) >> 3;
+    FT = (*ptr & 0x78) >> 3;
 
     fr_size = frame_size[FT];
 
     if (i == num_packets)
       /* last packet, clear F flag */
-      payload[i] = *data & 0x7f;
+      payload[i] = *ptr & 0x7f;
     else
       /* set F flag */
-      payload[i] = *data | 0x80;
+      payload[i] = *ptr | 0x80;
 
-    memcpy (payload_amr, &data[1], fr_size);
+    memcpy (payload_amr, &ptr[1], fr_size);
 
     /* all sizes are > 0 since we checked for that above */
-    data += fr_size + 1;
+    ptr += fr_size + 1;
     payload_amr += fr_size;
   }
 
+  gst_buffer_unmap (buffer, data, size);
   gst_buffer_unref (buffer);
 
+  gst_rtp_buffer_unmap (&rtp);
+
   ret = gst_basertppayload_push (basepayload, outbuf);
 
   return ret;
@@ -384,6 +385,7 @@ wrong_size:
   {
     GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
         (NULL), ("received AMR frame with size <= 0"));
+    gst_buffer_unmap (buffer, data, size);
     gst_buffer_unref (buffer);
 
     return GST_FLOW_ERROR;
@@ -392,6 +394,7 @@ incomplete_frame:
   {
     GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
         (NULL), ("received incomplete AMR frames"));
+    gst_buffer_unmap (buffer, data, size);
     gst_buffer_unref (buffer);
 
     return GST_FLOW_ERROR;
@@ -400,6 +403,7 @@ too_big:
   {
     GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
         (NULL), ("received too many AMR frames for MTU"));
+    gst_buffer_unmap (buffer, data, size);
     gst_buffer_unref (buffer);
 
     return GST_FLOW_ERROR;
index 1957cee..7b8d67f 100644 (file)
@@ -54,37 +54,34 @@ static GstBuffer *gst_rtp_bv_depay_process (GstBaseRTPDepayload * depayload,
 static gboolean gst_rtp_bv_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRTPBVDepay, gst_rtp_bv_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_bv_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPBVDepay, gst_rtp_bv_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_bv_depay_base_init (gpointer klass)
+gst_rtp_bv_depay_class_init (GstRTPBVDepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_bv_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_bv_depay_sink_template));
-  gst_element_class_set_details_simple (element_class,
+
+  gst_element_class_set_details_simple (gstelement_class,
       "RTP BroadcomVoice depayloader", "Codec/Depayloader/Network/RTP",
       "Extracts BroadcomVoice audio from RTP packets (RFC 4298)",
       "Wim Taymans <wim.taymans@collabora.co.uk>");
-}
-
-static void
-gst_rtp_bv_depay_class_init (GstRTPBVDepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->process = gst_rtp_bv_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_bv_depay_setcaps;
 }
 
 static void
-gst_rtp_bv_depay_init (GstRTPBVDepay * rtpbvdepay, GstRTPBVDepayClass * klass)
+gst_rtp_bv_depay_init (GstRTPBVDepay * rtpbvdepay)
 {
   rtpbvdepay->mode = -1;
 }
@@ -156,14 +153,18 @@ gst_rtp_bv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstBuffer *outbuf;
   gboolean marker;
+  GstRTPBuffer rtp = { NULL, };
+
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
 
-  marker = gst_rtp_buffer_get_marker (buf);
+  marker = gst_rtp_buffer_get_marker (&rtp);
 
   GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
-      GST_BUFFER_SIZE (buf), marker,
-      gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+      gst_buffer_get_size (buf), marker,
+      gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker && outbuf) {
     /* mark start of talkspurt with DISCONT */
index 0c01001..2066d9c 100644 (file)
@@ -54,44 +54,41 @@ static GstStaticPadTemplate gst_rtp_bv_pay_src_template =
 
 
 static GstCaps *gst_rtp_bv_pay_sink_getcaps (GstBaseRTPPayload * payload,
-    GstPad * pad);
+    GstPad * pad, GstCaps * filter);
 static gboolean gst_rtp_bv_pay_sink_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRTPBVPay, gst_rtp_bv_pay, GstBaseRTPAudioPayload,
-    GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
+#define gst_rtp_bv_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPBVPay, gst_rtp_bv_pay, GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
 
 static void
-gst_rtp_bv_pay_base_init (gpointer klass)
+gst_rtp_bv_pay_class_init (GstRTPBVPayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPPayloadClass *gstbasertppayload_class;
+
+  GST_DEBUG_CATEGORY_INIT (rtpbvpay_debug, "rtpbvpay", 0,
+      "BroadcomVoice audio RTP payloader");
 
-  gst_element_class_add_pad_template (element_class,
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_bv_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_bv_pay_src_template));
-  gst_element_class_set_details_simple (element_class, "RTP BV Payloader",
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP BV Payloader",
       "Codec/Payloader/Network/RTP",
       "Packetize BroadcomVoice audio streams into RTP packets (RFC 4298)",
       "Wim Taymans <wim.taymans@collabora.co.uk>");
-}
-
-static void
-gst_rtp_bv_pay_class_init (GstRTPBVPayClass * klass)
-{
-  GstBaseRTPPayloadClass *gstbasertppayload_class;
-
-  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gstbasertppayload_class->set_caps = gst_rtp_bv_pay_sink_setcaps;
   gstbasertppayload_class->get_caps = gst_rtp_bv_pay_sink_getcaps;
-
-  GST_DEBUG_CATEGORY_INIT (rtpbvpay_debug, "rtpbvpay", 0,
-      "BroadcomVoice audio RTP payloader");
 }
 
 static void
-gst_rtp_bv_pay_init (GstRTPBVPay * rtpbvpay, GstRTPBVPayClass * klass)
+gst_rtp_bv_pay_init (GstRTPBVPay * rtpbvpay)
 {
   GstBaseRTPAudioPayload *basertpaudiopayload;
 
@@ -176,7 +173,8 @@ mode_changed:
 /* we return the padtemplate caps with the mode field fixated to a value if we
  * can */
 static GstCaps *
-gst_rtp_bv_pay_sink_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad)
+gst_rtp_bv_pay_sink_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad,
+    GstCaps * filter)
 {
   GstCaps *otherpadcaps;
   GstCaps *caps;
index c03a5b4..6472b30 100644 (file)
@@ -70,41 +70,38 @@ static GstBuffer *gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload,
 static gboolean gst_rtp_celt_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRtpCELTDepay, gst_rtp_celt_depay, GstBaseRTPDepayload,
+#define gst_rtp_celt_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpCELTDepay, gst_rtp_celt_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_celt_depay_base_init (gpointer klass)
+gst_rtp_celt_depay_class_init (GstRtpCELTDepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_celt_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_celt_depay_sink_template));
-  gst_element_class_set_details_simple (element_class, "RTP CELT depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts CELT audio from RTP packets",
-      "Wim Taymans <wim.taymans@gmail.com>");
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
   GST_DEBUG_CATEGORY_INIT (rtpceltdepay_debug, "rtpceltdepay", 0,
       "CELT RTP Depayloader");
-}
-
-static void
-gst_rtp_celt_depay_class_init (GstRtpCELTDepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
+  gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_celt_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_celt_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP CELT depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts CELT audio from RTP packets",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   gstbasertpdepayload_class->process = gst_rtp_celt_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_celt_depay_setcaps;
 }
 
 static void
-gst_rtp_celt_depay_init (GstRtpCELTDepay * rtpceltdepay,
-    GstRtpCELTDepayClass * klass)
+gst_rtp_celt_depay_init (GstRtpCELTDepay * rtpceltdepay)
 {
 }
 
@@ -122,7 +119,8 @@ gst_rtp_celt_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   GstRtpCELTDepay *rtpceltdepay;
   gint clock_rate, nb_channels = 0, frame_size = 0;
   GstBuffer *buf;
-  guint8 *data;
+  guint8 *data, *ptr;
+  gsize size;
   const gchar *params;
   GstCaps *srccaps;
   gboolean res;
@@ -151,39 +149,37 @@ gst_rtp_celt_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
 
   /* construct minimal header and comment packet for the decoder */
   buf = gst_buffer_new_and_alloc (60);
-  data = GST_BUFFER_DATA (buf);
-  memcpy (data, "CELT    ", 8);
-  data += 8;
-  memcpy (data, "1.1.12", 7);
-  data += 20;
-  GST_WRITE_UINT32_LE (data, 0x80000006);       /* version */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, 56);       /* header_size */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, clock_rate);       /* rate */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, nb_channels);      /* channels */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, frame_size);       /* frame-size */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, -1);       /* overlap */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, -1);       /* bytes_per_packet */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, 0);        /* extra headers */
+  ptr = data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
+  memcpy (ptr, "CELT    ", 8);
+  ptr += 8;
+  memcpy (ptr, "1.1.12", 7);
+  ptr += 20;
+  GST_WRITE_UINT32_LE (ptr, 0x80000006);        /* version */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, 56);        /* header_size */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, clock_rate);        /* rate */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, nb_channels);       /* channels */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, frame_size);        /* frame-size */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, -1);        /* overlap */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, -1);        /* bytes_per_packet */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, 0); /* extra headers */
+  gst_buffer_unmap (buf, data, size);
 
   srccaps = gst_caps_new_simple ("audio/x-celt", NULL);
   res = gst_pad_set_caps (depayload->srcpad, srccaps);
   gst_caps_unref (srccaps);
 
-  gst_buffer_set_caps (buf, GST_PAD_CAPS (depayload->srcpad));
   gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpceltdepay), buf);
 
   buf = gst_buffer_new_and_alloc (sizeof (gst_rtp_celt_comment));
-  memcpy (GST_BUFFER_DATA (buf), gst_rtp_celt_comment,
-      sizeof (gst_rtp_celt_comment));
+  gst_buffer_fill (buf, 0, gst_rtp_celt_comment, sizeof (gst_rtp_celt_comment));
 
-  gst_buffer_set_caps (buf, GST_PAD_CAPS (depayload->srcpad));
   gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpceltdepay), buf);
 
   return res;
@@ -207,6 +203,7 @@ gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   GstClockTime framesize_ns = 0, timestamp;
   guint n = 0;
   GstRtpCELTDepay *rtpceltdepay;
+  GstRTPBuffer rtp = { NULL, };
 
   rtpceltdepay = GST_RTP_CELT_DEPAY (depayload);
   clock_rate = depayload->clock_rate;
@@ -215,17 +212,19 @@ gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
   timestamp = GST_BUFFER_TIMESTAMP (buf);
 
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
   GST_LOG_OBJECT (depayload, "got %d bytes, mark %d ts %u seqn %d",
-      GST_BUFFER_SIZE (buf),
-      gst_rtp_buffer_get_marker (buf),
-      gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+      gst_buffer_get_size (buf),
+      gst_rtp_buffer_get_marker (&rtp),
+      gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
 
   GST_LOG_OBJECT (depayload, "got clock-rate=%d, frame_size=%d, "
       "_ns=%" GST_TIME_FORMAT ", timestamp=%" GST_TIME_FORMAT, clock_rate,
       frame_size, GST_TIME_ARGS (framesize_ns), GST_TIME_ARGS (timestamp));
 
-  payload = gst_rtp_buffer_get_payload (buf);
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   /* first count how many bytes are consumed by the size headers and make offset
    * point to the first data byte */
@@ -250,7 +249,7 @@ gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
       total_size += size + 1;
     } while (s == 0xff);
 
-    outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, offset, size);
+    outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, offset, size);
     offset += size;
 
     if (frame_size != -1 && clock_rate != -1) {
@@ -264,6 +263,8 @@ gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
     gst_base_rtp_depayload_push (depayload, outbuf);
   }
+  gst_rtp_buffer_unmap (&rtp);
+
   return NULL;
 }
 
index 05715c1..176de7e 100644 (file)
@@ -58,30 +58,12 @@ static GstStateChangeReturn gst_rtp_celt_pay_change_state (GstElement *
 static gboolean gst_rtp_celt_pay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 static GstCaps *gst_rtp_celt_pay_getcaps (GstBaseRTPPayload * payload,
-    GstPad * pad);
+    GstPad * pad, GstCaps * filter);
 static GstFlowReturn gst_rtp_celt_pay_handle_buffer (GstBaseRTPPayload *
     payload, GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRtpCELTPay, gst_rtp_celt_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
-
-static void
-gst_rtp_celt_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_celt_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_celt_pay_src_template));
-  gst_element_class_set_details_simple (element_class, "RTP CELT payloader",
-      "Codec/Payloader/Network/RTP",
-      "Payload-encodes CELT audio into a RTP packet",
-      "Wim Taymans <wim.taymans@gmail.com>");
-
-  GST_DEBUG_CATEGORY_INIT (rtpceltpay_debug, "rtpceltpay", 0,
-      "CELT RTP Payloader");
-}
+#define gst_rtp_celt_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpCELTPay, gst_rtp_celt_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_celt_pay_class_init (GstRtpCELTPayClass * klass)
@@ -90,6 +72,9 @@ gst_rtp_celt_pay_class_init (GstRtpCELTPayClass * klass)
   GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
+  GST_DEBUG_CATEGORY_INIT (rtpceltpay_debug, "rtpceltpay", 0,
+      "CELT RTP Payloader");
+
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
@@ -98,13 +83,23 @@ gst_rtp_celt_pay_class_init (GstRtpCELTPayClass * klass)
 
   gstelement_class->change_state = gst_rtp_celt_pay_change_state;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_celt_pay_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_celt_pay_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP CELT payloader",
+      "Codec/Payloader/Network/RTP",
+      "Payload-encodes CELT audio into a RTP packet",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   gstbasertppayload_class->set_caps = gst_rtp_celt_pay_setcaps;
   gstbasertppayload_class->get_caps = gst_rtp_celt_pay_getcaps;
   gstbasertppayload_class->handle_buffer = gst_rtp_celt_pay_handle_buffer;
 }
 
 static void
-gst_rtp_celt_pay_init (GstRtpCELTPay * rtpceltpay, GstRtpCELTPayClass * klass)
+gst_rtp_celt_pay_init (GstRtpCELTPay * rtpceltpay)
 {
   rtpceltpay->queue = g_queue_new ();
 }
@@ -162,7 +157,8 @@ gst_rtp_celt_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
 
 
 static GstCaps *
-gst_rtp_celt_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad)
+gst_rtp_celt_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad,
+    GstCaps * filter)
 {
   GstCaps *otherpadcaps;
   GstCaps *caps;
@@ -310,6 +306,7 @@ gst_rtp_celt_pay_flush_queued (GstRtpCELTPay * rtpceltpay)
   guint8 *payload, *spayload;
   guint payload_len;
   GstClockTime duration;
+  GstRTPBuffer rtp = { NULL, };
 
   payload_len = rtpceltpay->bytes + rtpceltpay->sbytes;
   duration = rtpceltpay->qduration;
@@ -322,8 +319,10 @@ gst_rtp_celt_pay_flush_queued (GstRtpCELTPay * rtpceltpay)
 
   GST_BUFFER_DURATION (outbuf) = duration;
 
+  gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+
   /* point to the payload for size headers and data */
-  spayload = gst_rtp_buffer_get_payload (outbuf);
+  spayload = gst_rtp_buffer_get_payload (&rtp);
   payload = spayload + rtpceltpay->sbytes;
 
   while ((buf = g_queue_pop_head (rtpceltpay->queue))) {
@@ -334,20 +333,21 @@ gst_rtp_celt_pay_flush_queued (GstRtpCELTPay * rtpceltpay)
       GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
 
     /* write the size to the header */
-    size = GST_BUFFER_SIZE (buf);
+    size = gst_buffer_get_size (buf);
     while (size > 0xff) {
       *spayload++ = 0xff;
       size -= 0xff;
     }
     *spayload++ = size;
 
-    size = GST_BUFFER_SIZE (buf);
     /* copy payload */
-    memcpy (payload, GST_BUFFER_DATA (buf), size);
+    size = gst_buffer_get_size (buf);
+    gst_buffer_extract (buf, 0, payload, size);
     payload += size;
 
     gst_buffer_unref (buf);
   }
+  gst_rtp_buffer_unmap (&rtp);
 
   /* we consumed it all */
   rtpceltpay->bytes = 0;
@@ -365,7 +365,7 @@ gst_rtp_celt_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 {
   GstFlowReturn ret;
   GstRtpCELTPay *rtpceltpay;
-  guint size, payload_len;
+  gsize size, payload_len;
   guint8 *data;
   GstClockTime duration, packet_dur;
   guint i, ssize, packet_len;
@@ -374,8 +374,7 @@ gst_rtp_celt_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
   ret = GST_FLOW_OK;
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   switch (rtpceltpay->packet) {
     case 0:
@@ -384,14 +383,15 @@ gst_rtp_celt_pay_handle_buffer (GstBaseRTPPayload * basepayload,
       if (!gst_rtp_celt_pay_parse_ident (rtpceltpay, data, size))
         goto parse_error;
 
-      goto done;
+      goto cleanup;
     case 1:
       /* comment packet, we ignore it */
-      goto done;
+      goto cleanup;
     default:
       /* other packets go in the payload */
       break;
   }
+  gst_buffer_unmap (buffer, data, size);
 
   duration = GST_BUFFER_DURATION (buffer);
 
@@ -429,10 +429,16 @@ done:
   return ret;
 
   /* ERRORS */
+cleanup:
+  {
+    gst_buffer_unmap (buffer, data, size);
+    goto done;
+  }
 parse_error:
   {
     GST_ELEMENT_ERROR (rtpceltpay, STREAM, DECODE, (NULL),
         ("Error parsing first identification packet."));
+    gst_buffer_unmap (buffer, data, size);
     return GST_FLOW_ERROR;
   }
 }
diff --git a/gst/rtp/gstrtpdepay.c b/gst/rtp/gstrtpdepay.c
deleted file mode 100644 (file)
index d94d9b1..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim.taymans@gmail.com>
- *
- * 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.
- */
-/* Element-Checklist-Version: 5 */
-
-#include "gstrtpdepay.h"
-
-GST_DEBUG_CATEGORY_STATIC (rtpdepay_debug);
-#define GST_CAT_DEFAULT (rtpdepay_debug)
-
-static GstStaticPadTemplate gst_rtp_depay_src_rtp_template =
-GST_STATIC_PAD_TEMPLATE ("srcrtp",
-    GST_PAD_SRC,
-    GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("application/x-rtp")
-    );
-
-static GstStaticPadTemplate gst_rtp_depay_src_rtcp_template =
-GST_STATIC_PAD_TEMPLATE ("srcrtcp",
-    GST_PAD_SRC,
-    GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("application/x-rtcp")
-    );
-
-static GstStaticPadTemplate gst_rtp_depay_sink_rtp_template =
-GST_STATIC_PAD_TEMPLATE ("sinkrtp",
-    GST_PAD_SINK,
-    GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("application/x-rtp")
-    );
-
-static GstStaticPadTemplate gst_rtp_depay_sink_rtcp_template =
-GST_STATIC_PAD_TEMPLATE ("sinkrtcp",
-    GST_PAD_SINK,
-    GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("application/x-rtcp")
-    );
-
-static GstCaps *gst_rtp_depay_getcaps (GstPad * pad);
-static GstFlowReturn gst_rtp_depay_chain_rtp (GstPad * pad, GstBuffer * buffer);
-static GstFlowReturn gst_rtp_depay_chain_rtcp (GstPad * pad,
-    GstBuffer * buffer);
-
-GST_BOILERPLATE (GstRTPDepay, gst_rtp_depay, GstElement, GST_TYPE_ELEMENT);
-
-static void
-gst_rtp_depay_base_init (gpointer klass)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&gst_rtp_depay_src_rtp_template));
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&gst_rtp_depay_src_rtcp_template));
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&gst_rtp_depay_sink_rtp_template));
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&gst_rtp_depay_sink_rtcp_template));
-  gst_element_class_set_details_simple (gstelement_class,
-      "Dummy RTP session manager", "Codec/Depayloader/Network/RTP",
-      "Accepts raw RTP and RTCP packets and sends them forward",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_depay_class_init (GstRTPDepayClass * klass)
-{
-  GST_DEBUG_CATEGORY_INIT (rtpdepay_debug, "rtpdepay", 0, "RTP decoder");
-}
-
-static void
-gst_rtp_depay_init (GstRTPDepay * rtpdepay, GstRTPDepayClass * klass)
-{
-  /* the input rtp pad */
-  rtpdepay->sink_rtp =
-      gst_pad_new_from_static_template (&gst_rtp_depay_sink_rtp_template,
-      "sinkrtp");
-  gst_element_add_pad (GST_ELEMENT (rtpdepay), rtpdepay->sink_rtp);
-  gst_pad_set_getcaps_function (rtpdepay->sink_rtp, gst_rtp_depay_getcaps);
-  gst_pad_set_chain_function (rtpdepay->sink_rtp, gst_rtp_depay_chain_rtp);
-
-  /* the input rtcp pad */
-  rtpdepay->sink_rtcp =
-      gst_pad_new_from_static_template (&gst_rtp_depay_sink_rtcp_template,
-      "sinkrtcp");
-  gst_element_add_pad (GST_ELEMENT (rtpdepay), rtpdepay->sink_rtcp);
-  gst_pad_set_chain_function (rtpdepay->sink_rtcp, gst_rtp_depay_chain_rtcp);
-
-  /* the output rtp pad */
-  rtpdepay->src_rtp =
-      gst_pad_new_from_static_template (&gst_rtp_depay_src_rtp_template,
-      "srcrtp");
-  gst_pad_set_getcaps_function (rtpdepay->src_rtp, gst_rtp_depay_getcaps);
-  gst_element_add_pad (GST_ELEMENT (rtpdepay), rtpdepay->src_rtp);
-
-  /* the output rtcp pad */
-  rtpdepay->src_rtcp =
-      gst_pad_new_from_static_template (&gst_rtp_depay_src_rtcp_template,
-      "srcrtcp");
-  gst_element_add_pad (GST_ELEMENT (rtpdepay), rtpdepay->src_rtcp);
-}
-
-static GstCaps *
-gst_rtp_depay_getcaps (GstPad * pad)
-{
-  GstRTPDepay *src;
-  GstPad *other;
-  GstCaps *caps;
-
-  src = GST_RTP_DEPAY (GST_PAD_PARENT (pad));
-
-  other = pad == src->src_rtp ? src->sink_rtp : src->src_rtp;
-
-  caps = gst_pad_peer_get_caps (other);
-
-  if (caps == NULL)
-    caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
-
-  return caps;
-}
-
-static GstFlowReturn
-gst_rtp_depay_chain_rtp (GstPad * pad, GstBuffer * buffer)
-{
-  GstRTPDepay *src;
-
-  src = GST_RTP_DEPAY (GST_PAD_PARENT (pad));
-
-  GST_DEBUG ("got rtp packet");
-  return gst_pad_push (src->src_rtp, buffer);
-}
-
-static GstFlowReturn
-gst_rtp_depay_chain_rtcp (GstPad * pad, GstBuffer * buffer)
-{
-  GST_DEBUG ("got rtcp packet");
-
-  gst_buffer_unref (buffer);
-  return GST_FLOW_OK;
-}
-
-gboolean
-gst_rtp_depay_plugin_init (GstPlugin * plugin)
-{
-  return gst_element_register (plugin, "rtpdepay",
-      GST_RANK_SECONDARY, GST_TYPE_RTP_DEPAY);
-}
diff --git a/gst/rtp/gstrtpdepay.h b/gst/rtp/gstrtpdepay.h
deleted file mode 100644 (file)
index b2b4683..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim.taymans@gmail.com>
- *
- * 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_RTP_DEPAY_H__
-#define __GST_RTP_DEPAY_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_RTP_DEPAY              (gst_rtp_depay_get_type())
-#define GST_IS_RTP_DEPAY(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_DEPAY))
-#define GST_IS_RTP_DEPAY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_DEPAY))
-#define GST_RTP_DEPAY(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_DEPAY, GstRTPDepay))
-#define GST_RTP_DEPAY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_DEPAY, GstRTPDepayClass))
-
-typedef struct _GstRTPDepay GstRTPDepay;
-typedef struct _GstRTPDepayClass GstRTPDepayClass;
-
-struct _GstRTPDepay {
-  GstElement element;
-
-  GstPad *sink_rtp;
-  GstPad *sink_rtcp;
-  GstPad *src_rtp;
-  GstPad *src_rtcp;
-};
-
-struct _GstRTPDepayClass {
-  GstElementClass parent_class;
-};
-
-gboolean gst_rtp_depay_plugin_init (GstPlugin * plugin);
-
-GType gst_rtp_depay_get_type(void);
-
-G_END_DECLS
-
-#endif /* __GST_RTP_DEPAY_H__ */
index 883d115..6134477 100644 (file)
@@ -80,25 +80,10 @@ static GstBuffer *gst_rtp_dv_depay_process (GstBaseRTPDepayload * base,
 static gboolean gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRTPDVDepay, gst_rtp_dv_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD)
+#define gst_rtp_dv_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPDVDepay, gst_rtp_dv_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
-     static void gst_rtp_dv_depay_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_factory));
-
-  gst_element_class_set_details_simple (element_class, "RTP DV Depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Depayloads DV from RTP packets (RFC 3189)",
-      "Marcel Moreaux <marcelm@spacelabs.nl>, Wim Taymans <wim.taymans@gmail.com>");
-}
 
-/* initialize the plugin's class */
 static void
 gst_rtp_dv_depay_class_init (GstRTPDVDepayClass * klass)
 {
@@ -106,16 +91,26 @@ gst_rtp_dv_depay_class_init (GstRTPDVDepayClass * klass)
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class =
       (GstBaseRTPDepayloadClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (rtpdvdepay_debug, "rtpdvdepay", 0,
+      "DV RTP Depayloader");
+
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_change_state);
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_factory));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP DV Depayloader",
+      "Codec/Depayloader/Network/RTP",
+      "Depayloads DV from RTP packets (RFC 3189)",
+      "Marcel Moreaux <marcelm@spacelabs.nl>, Wim Taymans <wim.taymans@gmail.com>");
+
   gstbasertpdepayload_class->process =
       GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_process);
   gstbasertpdepayload_class->set_caps =
       GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_setcaps);
-
-  GST_DEBUG_CATEGORY_INIT (rtpdvdepay_debug, "rtpdvdepay", 0,
-      "DV RTP Depayloader");
 }
 
 /* initialize the new element
@@ -124,7 +119,7 @@ gst_rtp_dv_depay_class_init (GstRTPDVDepayClass * klass)
  * initialize structure
  */
 static void
-gst_rtp_dv_depay_init (GstRTPDVDepay * filter, GstRTPDVDepayClass * klass)
+gst_rtp_dv_depay_init (GstRTPDVDepay * filter)
 {
 }
 
@@ -172,6 +167,8 @@ gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   gint clock_rate;
   gboolean systemstream, ret;
   const gchar *encode, *media;
+  guint8 *data;
+  gsize size;
 
   rtpdvdepay = GST_RTP_DV_DEPAY (depayload);
 
@@ -216,7 +213,9 @@ gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   /* Initialize the new accumulator frame.
    * If the previous frame exists, copy that into the accumulator frame.
    * This way, missing packets in the stream won't show up badly. */
-  memset (GST_BUFFER_DATA (rtpdvdepay->acc), 0, rtpdvdepay->frame_size);
+  data = gst_buffer_map (rtpdvdepay->acc, &size, NULL, GST_MAP_WRITE);
+  memset (data, 0, rtpdvdepay->frame_size);
+  gst_buffer_unmap (rtpdvdepay->acc, data, size);
 
   srccaps = gst_caps_new_simple ("video/x-dv",
       "systemstream", G_TYPE_BOOLEAN, systemstream,
@@ -300,12 +299,15 @@ gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in)
   guint payload_len, location;
   GstRTPDVDepay *dvdepay = GST_RTP_DV_DEPAY (base);
   gboolean marker;
+  GstRTPBuffer rtp = { NULL, };
+
+  gst_rtp_buffer_map (in, GST_MAP_READ, &rtp);
 
-  marker = gst_rtp_buffer_get_marker (in);
+  marker = gst_rtp_buffer_get_marker (&rtp);
 
   /* Check if the received packet contains (the start of) a new frame, we do
    * this by checking the RTP timestamp. */
-  rtp_ts = gst_rtp_buffer_get_timestamp (in);
+  rtp_ts = gst_rtp_buffer_get_timestamp (&rtp);
 
   /* we cannot copy the packet yet if the marker is set, we will do that below
    * after taking out the data */
@@ -319,8 +321,8 @@ gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in)
   }
 
   /* Extract the payload */
-  payload_len = gst_rtp_buffer_get_payload_len (in);
-  payload = gst_rtp_buffer_get_payload (in);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
   /* copy all DIF chunks in their place. */
   while (payload_len >= 80) {
@@ -343,11 +345,12 @@ gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in)
 
     /* And copy it in, provided the location is sane. */
     if (offset >= 0 && offset <= dvdepay->frame_size - 80)
-      memcpy (GST_BUFFER_DATA (dvdepay->acc) + offset, payload, 80);
+      gst_buffer_fill (dvdepay->acc, offset, payload, 80);
 
     payload += 80;
     payload_len -= 80;
   }
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker) {
     GST_DEBUG_OBJECT (dvdepay, "marker bit complete frame %u", rtp_ts);
index 1d6230c..10690ab 100644 (file)
@@ -94,49 +94,47 @@ static void gst_dv_pay_set_property (GObject * object,
 static void gst_dv_pay_get_property (GObject * object,
     guint prop_id, GValue * value, GParamSpec * pspec);
 
-GST_BOILERPLATE (GstRTPDVPay, gst_rtp_dv_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD)
-
-     static void gst_rtp_dv_pay_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_dv_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_dv_pay_src_template));
-  gst_element_class_set_details_simple (element_class, "RTP DV Payloader",
-      "Codec/Payloader/Network/RTP",
-      "Payloads DV into RTP packets (RFC 3189)",
-      "Marcel Moreaux <marcelm@spacelabs.nl>, Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_rtp_dv_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPDVPay, gst_rtp_dv_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_dv_pay_class_init (GstRTPDVPayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
+  GST_DEBUG_CATEGORY_INIT (rtpdvpay_debug, "rtpdvpay", 0, "DV RTP Payloader");
+
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gobject_class->set_property = gst_dv_pay_set_property;
   gobject_class->get_property = gst_dv_pay_get_property;
 
-  gstbasertppayload_class->set_caps = gst_rtp_dv_pay_setcaps;
-  gstbasertppayload_class->handle_buffer = gst_rtp_dv_pay_handle_buffer;
-
   g_object_class_install_property (gobject_class, PROP_MODE,
       g_param_spec_enum ("mode", "Mode",
           "The payload mode of payloading",
           GST_TYPE_DV_PAY_MODE, DEFAULT_MODE,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
-  GST_DEBUG_CATEGORY_INIT (rtpdvpay_debug, "rtpdvpay", 0, "DV RTP Payloader");
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_dv_pay_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_dv_pay_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP DV Payloader",
+      "Codec/Payloader/Network/RTP",
+      "Payloads DV into RTP packets (RFC 3189)",
+      "Marcel Moreaux <marcelm@spacelabs.nl>, Wim Taymans <wim.taymans@gmail.com>");
+
+  gstbasertppayload_class->set_caps = gst_rtp_dv_pay_setcaps;
+  gstbasertppayload_class->handle_buffer = gst_rtp_dv_pay_handle_buffer;
 }
 
 static void
-gst_rtp_dv_pay_init (GstRTPDVPay * rtpdvpay, GstRTPDVPayClass * klass)
+gst_rtp_dv_pay_init (GstRTPDVPay * rtpdvpay)
 {
 }
 
@@ -183,7 +181,7 @@ gst_rtp_dv_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
 }
 
 static gboolean
-gst_dv_pay_negotiate (GstRTPDVPay * rtpdvpay, guint8 * data, guint size)
+gst_dv_pay_negotiate (GstRTPDVPay * rtpdvpay, guint8 * data, gsize size)
 {
   const gchar *encode, *media;
   gboolean audio_bundled, res;
@@ -284,10 +282,11 @@ gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   GstBuffer *outbuf;
   GstFlowReturn ret = GST_FLOW_OK;
   gint hdrlen;
-  guint size;
-  guint8 *data;
+  gsize size, osize;
+  guint8 *data, *odata;
   guint8 *dest;
   guint filled;
+  GstRTPBuffer rtp = { NULL, };
 
   rtpdvpay = GST_RTP_DV_PAY (basepayload);
 
@@ -300,8 +299,10 @@ gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   max_payload_size = ((GST_BASE_RTP_PAYLOAD_MTU (rtpdvpay) - hdrlen) / 80) * 80;
 
   /* The length of the buffer to transmit. */
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
+  odata = data;
+  osize = size;
 
   GST_DEBUG_OBJECT (rtpdvpay,
       "DV RTP payloader got buffer of %u bytes, splitting in %u byte "
@@ -324,7 +325,9 @@ gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     if (outbuf == NULL) {
       outbuf = gst_rtp_buffer_new_allocate (max_payload_size, 0, 0);
       GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
-      dest = gst_rtp_buffer_get_payload (outbuf);
+
+      gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+      dest = gst_rtp_buffer_get_payload (&rtp);
       filled = 0;
     }
 
@@ -348,13 +351,15 @@ gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
         guint hlen;
 
         /* set marker */
-        gst_rtp_buffer_set_marker (outbuf, TRUE);
+        gst_rtp_buffer_set_marker (&rtp, TRUE);
 
         /* shrink buffer to last packet */
-        hlen = gst_rtp_buffer_get_header_len (outbuf);
-        gst_rtp_buffer_set_packet_len (outbuf, hlen + filled);
+        hlen = gst_rtp_buffer_get_header_len (&rtp);
+        gst_rtp_buffer_set_packet_len (&rtp, hlen + filled);
       }
+
       /* Push out the created piece, and check for errors. */
+      gst_rtp_buffer_unmap (&rtp);
       ret = gst_basertppayload_push (basepayload, outbuf);
       if (ret != GST_FLOW_OK)
         break;
@@ -362,6 +367,7 @@ gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
       outbuf = NULL;
     }
   }
+  gst_buffer_unmap (buffer, odata, osize);
   gst_buffer_unref (buffer);
 
   return ret;
index 0815b23..e792e60 100644 (file)
@@ -62,7 +62,8 @@ static GstStaticPadTemplate gst_rtp_g722_depay_sink_template =
     )
     );
 
-GST_BOILERPLATE (GstRtpG722Depay, gst_rtp_g722_depay, GstBaseRTPDepayload,
+#define gst_rtp_g722_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG722Depay, gst_rtp_g722_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static gboolean gst_rtp_g722_depay_setcaps (GstBaseRTPDepayload * depayload,
@@ -71,40 +72,34 @@ static GstBuffer *gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
 static void
-gst_rtp_g722_depay_base_init (gpointer klass)
+gst_rtp_g722_depay_class_init (GstRtpG722DepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+  GST_DEBUG_CATEGORY_INIT (rtpg722depay_debug, "rtpg722depay", 0,
+      "G722 RTP Depayloader");
 
-  gst_element_class_add_pad_template (element_class,
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_g722_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_g722_depay_sink_template));
 
-  gst_element_class_set_details_simple (element_class, "RTP audio depayloader",
-      "Codec/Depayloader/Network/RTP",
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP audio depayloader", "Codec/Depayloader/Network/RTP",
       "Extracts G722 audio from RTP packets",
       "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_g722_depay_class_init (GstRtpG722DepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->set_caps = gst_rtp_g722_depay_setcaps;
   gstbasertpdepayload_class->process = gst_rtp_g722_depay_process;
-
-  GST_DEBUG_CATEGORY_INIT (rtpg722depay_debug, "rtpg722depay", 0,
-      "G722 RTP Depayloader");
 }
 
 static void
-gst_rtp_g722_depay_init (GstRtpG722Depay * rtpg722depay,
-    GstRtpG722DepayClass * klass)
+gst_rtp_g722_depay_init (GstRtpG722Depay * rtpg722depay)
 {
-  /* needed because of GST_BOILERPLATE */
 }
 
 static gint
@@ -223,18 +218,22 @@ gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   GstBuffer *outbuf;
   gint payload_len;
   gboolean marker;
+  GstRTPBuffer rtp = { NULL };
 
   rtpg722depay = GST_RTP_G722_DEPAY (depayload);
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   if (payload_len <= 0)
     goto empty_packet;
 
   GST_DEBUG_OBJECT (rtpg722depay, "got payload of %d bytes", payload_len);
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
-  marker = gst_rtp_buffer_get_marker (buf);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  marker = gst_rtp_buffer_get_marker (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker && outbuf) {
     /* mark talk spurt with DISCONT */
@@ -248,6 +247,7 @@ empty_packet:
   {
     GST_ELEMENT_WARNING (rtpg722depay, STREAM, DECODE,
         ("Empty Payload."), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index 29cd22a..362e4bc 100644 (file)
@@ -54,43 +54,40 @@ GST_STATIC_PAD_TEMPLATE ("src",
 static gboolean gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload,
     GstCaps * caps);
 static GstCaps *gst_rtp_g722_pay_getcaps (GstBaseRTPPayload * rtppayload,
-    GstPad * pad);
+    GstPad * pad, GstCaps * filter);
 
-GST_BOILERPLATE (GstRtpG722Pay, gst_rtp_g722_pay, GstBaseRTPAudioPayload,
+#define gst_rtp_g722_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG722Pay, gst_rtp_g722_pay,
     GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
 
 static void
-gst_rtp_g722_pay_base_init (gpointer klass)
+gst_rtp_g722_pay_class_init (GstRtpG722PayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPPayloadClass *gstbasertppayload_class;
+
+  GST_DEBUG_CATEGORY_INIT (rtpg722pay_debug, "rtpg722pay", 0,
+      "G722 RTP Payloader");
 
-  gst_element_class_add_pad_template (element_class,
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_g722_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_g722_pay_sink_template));
 
-  gst_element_class_set_details_simple (element_class, "RTP audio payloader",
+  gst_element_class_set_details_simple (gstelement_class, "RTP audio payloader",
       "Codec/Payloader/Network/RTP",
       "Payload-encode Raw audio into RTP packets (RFC 3551)",
       "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_g722_pay_class_init (GstRtpG722PayClass * klass)
-{
-  GstBaseRTPPayloadClass *gstbasertppayload_class;
-
-  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gstbasertppayload_class->set_caps = gst_rtp_g722_pay_setcaps;
   gstbasertppayload_class->get_caps = gst_rtp_g722_pay_getcaps;
-
-  GST_DEBUG_CATEGORY_INIT (rtpg722pay_debug, "rtpg722pay", 0,
-      "G722 RTP Payloader");
 }
 
 static void
-gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay, GstRtpG722PayClass * klass)
+gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay)
 {
   GstBaseRTPAudioPayload *basertpaudiopayload;
 
@@ -180,7 +177,8 @@ no_channels:
 }
 
 static GstCaps *
-gst_rtp_g722_pay_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad)
+gst_rtp_g722_pay_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad,
+    GstCaps * filter)
 {
   GstCaps *otherpadcaps;
   GstCaps *caps;
index b4aa5fe..0823ae7 100644 (file)
@@ -78,42 +78,38 @@ static gboolean gst_rtp_g723_depay_setcaps (GstBaseRTPDepayload * depayload,
 static GstBuffer *gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
-GST_BOILERPLATE (GstRtpG723Depay, gst_rtp_g723_depay, GstBaseRTPDepayload,
+#define gst_rtp_g723_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG723Depay, gst_rtp_g723_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_g723_depay_base_init (gpointer klass)
+gst_rtp_g723_depay_class_init (GstRtpG723DepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+  GST_DEBUG_CATEGORY_INIT (rtpg723depay_debug, "rtpg723depay", 0,
+      "G.723 RTP Depayloader");
 
-  gst_element_class_add_pad_template (element_class,
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_g723_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_g723_depay_sink_template));
 
-  gst_element_class_set_details_simple (element_class, "RTP G.723 depayloader",
-      "Codec/Depayloader/Network/RTP",
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP G.723 depayloader", "Codec/Depayloader/Network/RTP",
       "Extracts G.723 audio from RTP packets (RFC 3551)",
       "Wim Taymans <wim.taymans@gmail.com>");
 
-  GST_DEBUG_CATEGORY_INIT (rtpg723depay_debug, "rtpg723depay", 0,
-      "G.723 RTP Depayloader");
-}
-
-static void
-gst_rtp_g723_depay_class_init (GstRtpG723DepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
-
   gstbasertpdepayload_class->process = gst_rtp_g723_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_g723_depay_setcaps;
 }
 
 static void
-gst_rtp_g723_depay_init (GstRtpG723Depay * rtpg723depay,
-    GstRtpG723DepayClass * klass)
+gst_rtp_g723_depay_init (GstRtpG723Depay * rtpg723depay)
 {
   GstBaseRTPDepayload *depayload;
 
@@ -182,10 +178,13 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   GstBuffer *outbuf = NULL;
   gint payload_len;
   gboolean marker;
+  GstRTPBuffer rtp = { NULL };
 
   rtpg723depay = GST_RTP_G723_DEPAY (depayload);
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   /* At least 4 bytes */
   if (payload_len < 4)
@@ -193,8 +192,9 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
   GST_LOG_OBJECT (rtpg723depay, "payload len %d", payload_len);
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
-  marker = gst_rtp_buffer_get_marker (buf);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  marker = gst_rtp_buffer_get_marker (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker) {
     /* marker bit starts talkspurt */
@@ -202,7 +202,7 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   }
 
   GST_LOG_OBJECT (depayload, "pushing buffer of size %d",
-      GST_BUFFER_SIZE (outbuf));
+      gst_buffer_get_size (outbuf));
 
   return outbuf;
 
@@ -216,6 +216,7 @@ too_small:
 bad_packet:
   {
     /* no fatal error */
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index 439ef02..2621c55 100644 (file)
@@ -67,23 +67,8 @@ static void gst_rtp_g723_pay_finalize (GObject * object);
 static GstStateChangeReturn gst_rtp_g723_pay_change_state (GstElement * element,
     GstStateChange transition);
 
-GST_BOILERPLATE (GstRTPG723Pay, gst_rtp_g723_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
-
-static void
-gst_rtp_g723_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_g723_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_g723_pay_src_template));
-  gst_element_class_set_details_simple (element_class, "RTP G.723 payloader",
-      "Codec/Payloader/Network/RTP",
-      "Packetize G.723 audio into RTP packets",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_rtp_g723_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPG723Pay, gst_rtp_g723_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_g723_pay_class_init (GstRTPG723PayClass * klass)
@@ -100,12 +85,22 @@ gst_rtp_g723_pay_class_init (GstRTPG723PayClass * klass)
 
   gstelement_class->change_state = gst_rtp_g723_pay_change_state;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_g723_pay_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_g723_pay_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP G.723 payloader",
+      "Codec/Payloader/Network/RTP",
+      "Packetize G.723 audio into RTP packets",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   payload_class->set_caps = gst_rtp_g723_pay_set_caps;
   payload_class->handle_buffer = gst_rtp_g723_pay_handle_buffer;
 }
 
 static void
-gst_rtp_g723_pay_init (GstRTPG723Pay * pay, GstRTPG723PayClass * klass)
+gst_rtp_g723_pay_init (GstRTPG723Pay * pay)
 {
   GstBaseRTPPayload *payload = GST_BASE_RTP_PAYLOAD (pay);
 
@@ -155,11 +150,14 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay)
   GstFlowReturn ret;
   guint8 *payload;
   guint avail;
+  GstRTPBuffer rtp = { NULL };
 
   avail = gst_adapter_available (pay->adapter);
 
   outbuf = gst_rtp_buffer_new_allocate (avail, 0, 0);
-  payload = gst_rtp_buffer_get_payload (outbuf);
+
+  gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
   GST_BUFFER_TIMESTAMP (outbuf) = pay->timestamp;
   GST_BUFFER_DURATION (outbuf) = pay->duration;
@@ -175,9 +173,10 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay)
   /* set discont and marker */
   if (pay->discont) {
     GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
-    gst_rtp_buffer_set_marker (outbuf, TRUE);
+    gst_rtp_buffer_set_marker (&rtp, TRUE);
     pay->discont = FALSE;
   }
+  gst_rtp_buffer_unmap (&rtp);
 
   ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (pay), outbuf);
 
@@ -197,7 +196,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
 {
   GstFlowReturn ret = GST_FLOW_OK;
   guint8 *data;
-  guint size;
+  gsize size;
   guint8 HDR;
   GstRTPG723Pay *pay;
   GstClockTime packet_dur, timestamp;
@@ -205,8 +204,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
 
   pay = GST_RTP_G723_PAY (payload);
 
-  size = GST_BUFFER_SIZE (buf);
-  data = GST_BUFFER_DATA (buf);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
   timestamp = GST_BUFFER_TIMESTAMP (buf);
 
   if (GST_BUFFER_IS_DISCONT (buf)) {
@@ -244,6 +242,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
     else
       pay->timestamp = 0;
   }
+  gst_buffer_unmap (buf, data, size);
 
   /* add packet to the queue */
   gst_adapter_push (pay->adapter, buf);
@@ -262,6 +261,7 @@ invalid_size:
     GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
         ("Invalid input buffer size"),
         ("Input size should be 4, 20 or 24, got %u", size));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return GST_FLOW_OK;
   }
@@ -270,6 +270,7 @@ wrong_size:
     GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
         ("Wrong input buffer size"),
         ("Expected input buffer size %u but got %u", size_tab[HDR], size));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return GST_FLOW_OK;
   }
index 33247d0..2f34a0d 100644 (file)
@@ -87,31 +87,22 @@ static GstBuffer *gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload,
 static gboolean gst_rtp_g726_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRtpG726Depay, gst_rtp_g726_depay, GstBaseRTPDepayload,
+#define gst_rtp_g726_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG726Depay, gst_rtp_g726_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_g726_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_g726_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_g726_depay_sink_template));
-  gst_element_class_set_details_simple (element_class, "RTP G.726 depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts G.726 audio from RTP packets",
-      "Axis Communications <dev-gstreamer@axis.com>");
-}
-
-static void
 gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
+  GST_DEBUG_CATEGORY_INIT (rtpg726depay_debug, "rtpg726depay", 0,
+      "G.726 RTP Depayloader");
+
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gobject_class->set_property = gst_rtp_g726_depay_set_property;
@@ -122,16 +113,22 @@ gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass)
           "Force AAL2 decoding for compatibility with bad payloaders",
           DEFAULT_FORCE_AAL2, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_g726_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_g726_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP G.726 depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts G.726 audio from RTP packets",
+      "Axis Communications <dev-gstreamer@axis.com>");
+
   gstbasertpdepayload_class->process = gst_rtp_g726_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_g726_depay_setcaps;
-
-  GST_DEBUG_CATEGORY_INIT (rtpg726depay_debug, "rtpg726depay", 0,
-      "G.726 RTP Depayloader");
 }
 
 static void
-gst_rtp_g726_depay_init (GstRtpG726Depay * rtpG726depay,
-    GstRtpG726DepayClass * klass)
+gst_rtp_g726_depay_init (GstRtpG726Depay * rtpG726depay)
 {
   GstBaseRTPDepayload *depayload;
 
@@ -210,42 +207,38 @@ gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   GstRtpG726Depay *depay;
   GstBuffer *outbuf = NULL;
   gboolean marker;
+  GstRTPBuffer rtp = { NULL };
 
   depay = GST_RTP_G726_DEPAY (depayload);
 
-  marker = gst_rtp_buffer_get_marker (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
+
+  marker = gst_rtp_buffer_get_marker (&rtp);
 
   GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
-      GST_BUFFER_SIZE (buf), marker,
-      gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+      gst_buffer_get_size (buf), marker,
+      gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
 
   if (depay->aal2 || depay->force_aal2) {
     /* AAL2, we can just copy the bytes */
-    outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+    outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
     if (!outbuf)
       goto bad_len;
   } else {
-    guint8 *in, *out, tmp;
+    guint8 *in, *out, tmp, *odata;
     guint len;
+    gsize osize;
 
-    in = gst_rtp_buffer_get_payload (buf);
-    len = gst_rtp_buffer_get_payload_len (buf);
-
-    if (gst_buffer_is_writable (buf)) {
-      outbuf = gst_rtp_buffer_get_payload_buffer (buf);
-    } else {
-      GstBuffer *copy;
-
-      /* copy buffer */
-      copy = gst_buffer_copy (buf);
-      outbuf = gst_rtp_buffer_get_payload_buffer (copy);
-      gst_buffer_unref (copy);
-    }
+    in = gst_rtp_buffer_get_payload (&rtp);
+    len = gst_rtp_buffer_get_payload_len (&rtp);
 
+    outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
     if (!outbuf)
       goto bad_len;
+    outbuf = gst_buffer_make_writable (outbuf);
 
-    out = GST_BUFFER_DATA (outbuf);
+    odata = gst_buffer_map (outbuf, &osize, NULL, GST_MAP_WRITE);
+    out = odata;
 
     /* we need to reshuffle the bytes, input is always of the form
      * A B C D ... with the number of bits depending on the bitrate. */
@@ -333,6 +326,7 @@ gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
         break;
       }
     }
+    gst_buffer_unmap (outbuf, odata, osize);
   }
 
   if (marker) {
index 16086bf..12b772f 100644 (file)
@@ -75,31 +75,19 @@ static gboolean gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload,
 static GstFlowReturn gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload *
     payload, GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRtpG726Pay, gst_rtp_g726_pay, GstBaseRTPAudioPayload,
+#define gst_rtp_g726_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG726Pay, gst_rtp_g726_pay,
     GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
 
 static void
-gst_rtp_g726_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_g726_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_g726_pay_src_template));
-  gst_element_class_set_details_simple (element_class, "RTP G.726 payloader",
-      "Codec/Payloader/Network/RTP",
-      "Payload-encodes G.726 audio into a RTP packet",
-      "Axis Communications <dev-gstreamer@axis.com>");
-}
-
-static void
 gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gobject_class->set_property = gst_rtp_g726_pay_set_property;
@@ -110,6 +98,16 @@ gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
           "Force AAL2 encoding for compatibility with bad depayloaders",
           DEFAULT_FORCE_AAL2, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_g726_pay_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_g726_pay_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP G.726 payloader",
+      "Codec/Payloader/Network/RTP",
+      "Payload-encodes G.726 audio into a RTP packet",
+      "Axis Communications <dev-gstreamer@axis.com>");
+
   gstbasertppayload_class->set_caps = gst_rtp_g726_pay_setcaps;
   gstbasertppayload_class->handle_buffer = gst_rtp_g726_pay_handle_buffer;
 
@@ -118,7 +116,7 @@ gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
 }
 
 static void
-gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay, GstRtpG726PayClass * klass)
+gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay)
 {
   GstBaseRTPAudioPayload *basertpaudiopayload;
 
@@ -183,7 +181,7 @@ gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
   GST_DEBUG_OBJECT (payload, "selected base encoding %s", encoding_name);
 
   /* now see if we need to produce AAL2 or not */
-  peercaps = gst_pad_peer_get_caps (payload->srcpad);
+  peercaps = gst_pad_peer_get_caps (payload->srcpad, NULL);
   if (peercaps) {
     GstCaps *filter, *intersect;
     gchar *capsstr;
@@ -269,14 +267,13 @@ gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
 
   if (!pay->aal2) {
     guint8 *data, tmp;
-    guint len;
+    gsize len;
 
     /* for non AAL2, we need to reshuffle the bytes, we can do this in-place
      * when the buffer is writable. */
     buffer = gst_buffer_make_writable (buffer);
 
-    data = GST_BUFFER_DATA (buffer);
-    len = GST_BUFFER_SIZE (buffer);
+    data = gst_buffer_map (buffer, &len, NULL, GST_MAP_READWRITE);
 
     GST_LOG_OBJECT (pay, "packing %u bytes of data", len);
 
@@ -366,6 +363,7 @@ gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
         break;
       }
     }
+    gst_buffer_unmap (buffer, data, len);
   }
 
   res =
index 3d22508..4a9b4af 100644 (file)
@@ -76,42 +76,38 @@ static gboolean gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload,
 static GstBuffer *gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
-GST_BOILERPLATE (GstRtpG729Depay, gst_rtp_g729_depay, GstBaseRTPDepayload,
+#define gst_rtp_g729_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG729Depay, gst_rtp_g729_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_g729_depay_base_init (gpointer klass)
+gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+  GST_DEBUG_CATEGORY_INIT (rtpg729depay_debug, "rtpg729depay", 0,
+      "G.729 RTP Depayloader");
 
-  gst_element_class_add_pad_template (element_class,
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_g729_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_g729_depay_sink_template));
 
-  gst_element_class_set_details_simple (element_class, "RTP G.729 depayloader",
-      "Codec/Depayloader/Network/RTP",
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP G.729 depayloader", "Codec/Depayloader/Network/RTP",
       "Extracts G.729 audio from RTP packets (RFC 3551)",
       "Laurent Glayal <spglegle@yahoo.fr>");
 
-  GST_DEBUG_CATEGORY_INIT (rtpg729depay_debug, "rtpg729depay", 0,
-      "G.729 RTP Depayloader");
-}
-
-static void
-gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
-
   gstbasertpdepayload_class->process = gst_rtp_g729_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_g729_depay_setcaps;
 }
 
 static void
-gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay,
-    GstRtpG729DepayClass * klass)
+gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay)
 {
   GstBaseRTPDepayload *depayload;
 
@@ -172,7 +168,6 @@ wrong_clock_rate:
   }
 }
 
-
 static GstBuffer *
 gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
@@ -180,10 +175,13 @@ gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   GstBuffer *outbuf = NULL;
   gint payload_len;
   gboolean marker;
+  GstRTPBuffer rtp = { NULL };
 
   rtpg729depay = GST_RTP_G729_DEPAY (depayload);
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   /* At least 2 bytes (CNG from G729 Annex B) */
   if (payload_len < 2) {
@@ -198,8 +196,10 @@ gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     GST_LOG_OBJECT (rtpg729depay, "G729 payload contains CNG frame");
   }
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
-  marker = gst_rtp_buffer_get_marker (buf);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  marker = gst_rtp_buffer_get_marker (&rtp);
+
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker) {
     /* marker bit starts talkspurt */
@@ -207,7 +207,7 @@ gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   }
 
   GST_LOG_OBJECT (depayload, "pushing buffer of size %d",
-      GST_BUFFER_SIZE (outbuf));
+      gst_buffer_get_size (outbuf));
 
   return outbuf;
 
index 37049d6..746b2f9 100644 (file)
@@ -74,26 +74,8 @@ static GstStaticPadTemplate gst_rtp_g729_pay_src_template =
         "clock-rate = (int) 8000, " "encoding-name = (string) \"G729\"")
     );
 
-GST_BOILERPLATE (GstRTPG729Pay, gst_rtp_g729_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
-
-static void
-gst_rtp_g729_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_g729_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_g729_pay_src_template));
-  gst_element_class_set_details_simple (element_class, "RTP G.729 payloader",
-      "Codec/Payloader/Network/RTP",
-      "Packetize G.729 audio into RTP packets",
-      "Olivier Crete <olivier.crete@collabora.co.uk>");
-
-  GST_DEBUG_CATEGORY_INIT (rtpg729pay_debug, "rtpg729pay", 0,
-      "G.729 RTP Payloader");
-}
+#define gst_rtp_g729_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPG729Pay, gst_rtp_g729_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_g729_pay_finalize (GObject * object)
@@ -112,16 +94,29 @@ gst_rtp_g729_pay_class_init (GstRTPG729PayClass * klass)
   GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseRTPPayloadClass *payload_class = GST_BASE_RTP_PAYLOAD_CLASS (klass);
 
+  GST_DEBUG_CATEGORY_INIT (rtpg729pay_debug, "rtpg729pay", 0,
+      "G.729 RTP Payloader");
+
   gobject_class->finalize = gst_rtp_g729_pay_finalize;
 
   gstelement_class->change_state = gst_rtp_g729_pay_change_state;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_g729_pay_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_g729_pay_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP G.729 payloader",
+      "Codec/Payloader/Network/RTP",
+      "Packetize G.729 audio into RTP packets",
+      "Olivier Crete <olivier.crete@collabora.co.uk>");
+
   payload_class->set_caps = gst_rtp_g729_pay_set_caps;
   payload_class->handle_buffer = gst_rtp_g729_pay_handle_buffer;
 }
 
 static void
-gst_rtp_g729_pay_init (GstRTPG729Pay * pay, GstRTPG729PayClass * klass)
+gst_rtp_g729_pay_init (GstRTPG729Pay * pay)
 {
   GstBaseRTPPayload *payload = GST_BASE_RTP_PAYLOAD (pay);
 
@@ -170,6 +165,7 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay,
   GstBuffer *outbuf;
   guint8 *payload;
   GstFlowReturn ret;
+  GstRTPBuffer rtp = { NULL };
 
   basepayload = GST_BASE_RTP_PAYLOAD (rtpg729pay);
 
@@ -179,8 +175,10 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay,
   /* create buffer to hold the payload */
   outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
 
+  gst_rtp_buffer_map (outbuf, GST_MAP_READWRITE, &rtp);
+
   /* copy payload */
-  payload = gst_rtp_buffer_get_payload (outbuf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
   memcpy (payload, data, payload_len);
 
   /* set metadata */
@@ -196,9 +194,10 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay,
   if (G_UNLIKELY (rtpg729pay->discont)) {
     GST_DEBUG_OBJECT (basepayload, "discont, setting marker bit");
     GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
-    gst_rtp_buffer_set_marker (outbuf, TRUE);
+    gst_rtp_buffer_set_marker (&rtp, TRUE);
     rtpg729pay->discont = FALSE;
   }
+  gst_rtp_buffer_unmap (&rtp);
 
   ret = gst_basertppayload_push (basepayload, outbuf);
 
@@ -235,11 +234,13 @@ gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
   guint minptime_octets = 0;
   guint min_payload_len;
   guint max_payload_len;
+  gsize size;
+  GstClockTime timestamp;
 
-  available = GST_BUFFER_SIZE (buf);
+  size = gst_buffer_get_size (buf);
 
-  if (available % G729_FRAME_SIZE != 0 &&
-      available % G729_FRAME_SIZE != G729B_CN_FRAME_SIZE)
+  if (size % G729_FRAME_SIZE != 0 &&
+      size % G729_FRAME_SIZE != G729B_CN_FRAME_SIZE)
     goto invalid_size;
 
   /* max number of bytes based on given ptime, has to be multiple of
@@ -302,6 +303,8 @@ gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
   adapter = rtpg729pay->adapter;
   available = gst_adapter_available (adapter);
 
+  timestamp = GST_BUFFER_TIMESTAMP (buf);
+
   /* resync rtp time on discont or a discontinuous cn packet */
   if (GST_BUFFER_IS_DISCONT (buf)) {
     /* flush remainder */
@@ -311,26 +314,27 @@ gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
       available = 0;
     }
     rtpg729pay->discont = TRUE;
-    gst_rtp_g729_pay_recalc_rtp_time (rtpg729pay, GST_BUFFER_TIMESTAMP (buf));
+    gst_rtp_g729_pay_recalc_rtp_time (rtpg729pay, timestamp);
   }
 
-  if (GST_BUFFER_SIZE (buf) < G729_FRAME_SIZE)
-    gst_rtp_g729_pay_recalc_rtp_time (rtpg729pay, GST_BUFFER_TIMESTAMP (buf));
+  if (size < G729_FRAME_SIZE)
+    gst_rtp_g729_pay_recalc_rtp_time (rtpg729pay, timestamp);
 
   if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (rtpg729pay->first_ts))) {
-    rtpg729pay->first_ts = GST_BUFFER_TIMESTAMP (buf);
+    rtpg729pay->first_ts = timestamp;
     rtpg729pay->first_rtp_time = rtpg729pay->next_rtp_time;
   }
 
   /* let's reset the base timestamp when the adapter is empty */
   if (available == 0)
-    rtpg729pay->next_ts = GST_BUFFER_TIMESTAMP (buf);
+    rtpg729pay->next_ts = timestamp;
 
-  if (available == 0 &&
-      GST_BUFFER_SIZE (buf) >= min_payload_len &&
-      GST_BUFFER_SIZE (buf) <= max_payload_len) {
-    ret = gst_rtp_g729_pay_push (rtpg729pay,
-        GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  if (available == 0 && size >= min_payload_len && size <= max_payload_len) {
+    guint8 *data;
+
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+    ret = gst_rtp_g729_pay_push (rtpg729pay, data, size);
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return ret;
   }
@@ -364,7 +368,7 @@ invalid_size:
         ("Invalid input buffer size"),
         ("Invalid buffer size, should be a multiple of"
             " G729_FRAME_SIZE(10) with an optional G729B_CN_FRAME_SIZE(2)"
-            " added to it, but it is %u", available));
+            " added to it, but it is %u", size));
     gst_buffer_unref (buf);
     return GST_FLOW_ERROR;
   }
index ca54ea8..298708a 100644 (file)
@@ -62,29 +62,26 @@ static GstBuffer *gst_rtp_gsm_depay_process (GstBaseRTPDepayload * _depayload,
 static gboolean gst_rtp_gsm_depay_setcaps (GstBaseRTPDepayload * _depayload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRTPGSMDepay, gst_rtp_gsm_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_gsm_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPGSMDepay, gst_rtp_gsm_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_gsm_depay_base_init (gpointer klass)
+gst_rtp_gsm_depay_class_init (GstRTPGSMDepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertp_depayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertp_depayload_class = (GstBaseRTPDepayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_gsm_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_gsm_depay_sink_template));
-  gst_element_class_set_details_simple (element_class, "RTP GSM depayloader",
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP GSM depayloader",
       "Codec/Depayloader/Network/RTP",
       "Extracts GSM audio from RTP packets", "Zeeshan Ali <zeenix@gmail.com>");
-}
-
-static void
-gst_rtp_gsm_depay_class_init (GstRTPGSMDepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertp_depayload_class;
-
-  gstbasertp_depayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertp_depayload_class->process = gst_rtp_gsm_depay_process;
   gstbasertp_depayload_class->set_caps = gst_rtp_gsm_depay_setcaps;
@@ -94,10 +91,8 @@ gst_rtp_gsm_depay_class_init (GstRTPGSMDepayClass * klass)
 }
 
 static void
-gst_rtp_gsm_depay_init (GstRTPGSMDepay * rtpgsmdepay,
-    GstRTPGSMDepayClass * klass)
+gst_rtp_gsm_depay_init (GstRTPGSMDepay * rtpgsmdepay)
 {
-  /* needed because of GST_BOILERPLATE */
 }
 
 static gboolean
@@ -127,14 +122,19 @@ gst_rtp_gsm_depay_process (GstBaseRTPDepayload * _depayload, GstBuffer * buf)
 {
   GstBuffer *outbuf = NULL;
   gboolean marker;
+  GstRTPBuffer rtp = { NULL };
+
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
 
-  marker = gst_rtp_buffer_get_marker (buf);
+  marker = gst_rtp_buffer_get_marker (&rtp);
 
   GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
-      GST_BUFFER_SIZE (buf), marker,
-      gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+      gst_buffer_get_size (buf), marker,
+      gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
+
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker && outbuf) {
     /* mark start of talkspurt with DISCONT */
index 479013e..5a8061f 100644 (file)
@@ -57,40 +57,37 @@ static gboolean gst_rtp_gsm_pay_setcaps (GstBaseRTPPayload * payload,
 static GstFlowReturn gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * payload,
     GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRTPGSMPay, gst_rtp_gsm_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
+#define gst_rtp_gsm_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPGSMPay, gst_rtp_gsm_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
-gst_rtp_gsm_pay_base_init (gpointer klass)
+gst_rtp_gsm_pay_class_init (GstRTPGSMPayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPPayloadClass *gstbasertppayload_class;
+
+  GST_DEBUG_CATEGORY_INIT (rtpgsmpay_debug, "rtpgsmpay", 0,
+      "GSM Audio RTP Payloader");
 
-  gst_element_class_add_pad_template (element_class,
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_gsm_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_gsm_pay_src_template));
-  gst_element_class_set_details_simple (element_class, "RTP GSM payloader",
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP GSM payloader",
       "Codec/Payloader/Network/RTP",
       "Payload-encodes GSM audio into a RTP packet",
       "Zeeshan Ali <zeenix@gmail.com>");
-}
-
-static void
-gst_rtp_gsm_pay_class_init (GstRTPGSMPayClass * klass)
-{
-  GstBaseRTPPayloadClass *gstbasertppayload_class;
-
-  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gstbasertppayload_class->set_caps = gst_rtp_gsm_pay_setcaps;
   gstbasertppayload_class->handle_buffer = gst_rtp_gsm_pay_handle_buffer;
-
-  GST_DEBUG_CATEGORY_INIT (rtpgsmpay_debug, "rtpgsmpay", 0,
-      "GSM Audio RTP Payloader");
 }
 
 static void
-gst_rtp_gsm_pay_init (GstRTPGSMPay * rtpgsmpay, GstRTPGSMPayClass * klass)
+gst_rtp_gsm_pay_init (GstRTPGSMPay * rtpgsmpay)
 {
   GST_BASE_RTP_PAYLOAD (rtpgsmpay)->clock_rate = 8000;
   GST_BASE_RTP_PAYLOAD_PT (rtpgsmpay) = GST_RTP_PAYLOAD_GSM;
@@ -128,15 +125,18 @@ gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     GstBuffer * buffer)
 {
   GstRTPGSMPay *rtpgsmpay;
-  guint size, payload_len;
+  guint payload_len;
   GstBuffer *outbuf;
   guint8 *payload, *data;
   GstClockTime timestamp, duration;
   GstFlowReturn ret;
+  gsize size;
+  GstRTPBuffer rtp = { NULL };
 
   rtpgsmpay = GST_RTP_GSM_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
   duration = GST_BUFFER_DURATION (buffer);
 
@@ -144,12 +144,8 @@ gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   payload_len = size;
 
   /* FIXME, just error out for now */
-  if (payload_len > GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay)) {
-    GST_ELEMENT_ERROR (rtpgsmpay, STREAM, ENCODE, (NULL),
-        ("payload_len %u > mtu %u", payload_len,
-            GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay)));
-    return GST_FLOW_ERROR;
-  }
+  if (payload_len > GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay))
+    goto too_big;
 
   outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
 
@@ -158,21 +154,33 @@ gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   GST_BUFFER_DURATION (outbuf) = duration;
 
   /* get payload */
-  payload = gst_rtp_buffer_get_payload (outbuf);
-
-  data = GST_BUFFER_DATA (buffer);
+  gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
 
   /* copy data in payload */
-  memcpy (&payload[0], data, size);
+  payload = gst_rtp_buffer_get_payload (&rtp);
+  memcpy (payload, data, size);
+
+  gst_rtp_buffer_unmap (&rtp);
 
+  gst_buffer_unmap (buffer, data, size);
   gst_buffer_unref (buffer);
 
   GST_DEBUG ("gst_rtp_gsm_pay_chain: pushing buffer of size %d",
-      GST_BUFFER_SIZE (outbuf));
+      gst_buffer_get_size (outbuf));
 
   ret = gst_basertppayload_push (basepayload, outbuf);
 
   return ret;
+
+  /* ERRORS */
+too_big:
+  {
+    GST_ELEMENT_ERROR (rtpgsmpay, STREAM, ENCODE, (NULL),
+        ("payload_len %u > mtu %u", payload_len,
+            GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay)));
+    gst_buffer_unmap (buffer, data, size);
+    return GST_FLOW_ERROR;
+  }
 }
 
 gboolean
index 6dc5e51..4db6362 100644 (file)
@@ -45,8 +45,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
         "clock-rate = (int) 90000, " "encoding-name = (string) \"X-GST\"")
     );
 
-GST_BOILERPLATE (GstRtpGSTDepay, gst_rtp_gst_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_gst_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpGSTDepay, gst_rtp_gst_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void gst_rtp_gst_depay_finalize (GObject * object);
 
@@ -60,28 +60,15 @@ static GstBuffer *gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
 static void
-gst_rtp_gst_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_gst_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_gst_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "GStreamer depayloader", "Codec/Depayloader/Network",
-      "Extracts GStreamer buffers from RTP packets",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_gst_depay_class_init (GstRtpGSTDepayClass * klass)
 {
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
+  GST_DEBUG_CATEGORY_INIT (rtpgstdepay_debug, "rtpgstdepay", 0,
+      "Gstreamer RTP Depayloader");
+
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
@@ -90,16 +77,22 @@ gst_rtp_gst_depay_class_init (GstRtpGSTDepayClass * klass)
 
   gstelement_class->change_state = gst_rtp_gst_depay_change_state;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_gst_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_gst_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "GStreamer depayloader", "Codec/Depayloader/Network",
+      "Extracts GStreamer buffers from RTP packets",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   gstbasertpdepayload_class->set_caps = gst_rtp_gst_depay_setcaps;
   gstbasertpdepayload_class->process = gst_rtp_gst_depay_process;
-
-  GST_DEBUG_CATEGORY_INIT (rtpgstdepay_debug, "rtpgstdepay", 0,
-      "Gstreamer RTP Depayloader");
 }
 
 static void
-gst_rtp_gst_depay_init (GstRtpGSTDepay * rtpgstdepay,
-    GstRtpGSTDepayClass * klass)
+gst_rtp_gst_depay_init (GstRtpGSTDepay * rtpgstdepay)
 {
   rtpgstdepay->adapter = gst_adapter_new ();
 }
@@ -184,10 +177,13 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   gint payload_len;
   guint8 *payload;
   guint CV;
+  GstRTPBuffer rtp = { NULL };
 
   rtpgstdepay = GST_RTP_GST_DEPAY (depayload);
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   if (payload_len <= 8)
     goto empty_packet;
@@ -197,14 +193,14 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     gst_adapter_clear (rtpgstdepay->adapter);
   }
 
-  payload = gst_rtp_buffer_get_payload (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
   /* strip off header
    *
    *  0                   1                   2                   3
    *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-   * |C| CV  |D|X|Y|Z|                  MBZ                          |
+   * |C| CV  |D|0|0|0|                  MBZ                          |
    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    * |                          Frag_offset                          |
    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -214,10 +210,10 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
    */
 
   /* subbuffer skipping the 8 header bytes */
-  subbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 8, -1);
+  subbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, 8, -1);
   gst_adapter_push (rtpgstdepay->adapter, subbuf);
 
-  if (gst_rtp_buffer_get_marker (buf)) {
+  if (gst_rtp_buffer_get_marker (&rtp)) {
     guint avail;
     GstCaps *outcaps;
 
@@ -228,25 +224,30 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     CV = (payload[0] >> 4) & 0x7;
 
     if (payload[0] & 0x80) {
-      guint b, csize, size, offset;
+      guint b, csize, left, offset;
+      gsize size;
       guint8 *data;
       GstBuffer *subbuf;
 
       /* C bit, we have inline caps */
-      data = GST_BUFFER_DATA (outbuf);
-      size = GST_BUFFER_SIZE (outbuf);
+      data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READ);
 
       /* start reading the length, we need this to skip to the data later */
       csize = offset = 0;
+      left = size;
       do {
-        if (offset >= size)
+        if (offset >= left) {
+          gst_buffer_unmap (outbuf, data, size);
           goto too_small;
+        }
         b = data[offset++];
         csize = (csize << 7) | (b & 0x7f);
       } while (b & 0x80);
 
-      if (size < csize)
+      if (left < csize) {
+        gst_buffer_unmap (outbuf, data, size);
         goto too_small;
+      }
 
       /* parse and store in cache */
       outcaps = gst_caps_from_string ((gchar *) & data[offset]);
@@ -254,17 +255,19 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
       /* skip caps */
       offset += csize;
-      size -= csize;
+      left -= csize;
 
       GST_DEBUG_OBJECT (rtpgstdepay,
           "inline caps %u, length %u, %" GST_PTR_FORMAT, CV, csize, outcaps);
 
       /* create real data buffer when needed */
       if (size)
-        subbuf = gst_buffer_create_sub (outbuf, offset, size);
+        subbuf =
+            gst_buffer_copy_region (outbuf, GST_BUFFER_COPY_ALL, offset, left);
       else
         subbuf = NULL;
 
+      gst_buffer_unmap (outbuf, data, size);
       gst_buffer_unref (outbuf);
       outbuf = subbuf;
     }
@@ -287,12 +290,6 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     if (outbuf) {
       if (payload[0] & 0x8)
         GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
-      if (payload[0] & 0x4)
-        GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_MEDIA1);
-      if (payload[0] & 0x2)
-        GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_MEDIA2);
-      if (payload[0] & 0x1)
-        GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_MEDIA3);
     }
   }
   return outbuf;
@@ -302,6 +299,7 @@ empty_packet:
   {
     GST_ELEMENT_WARNING (rtpgstdepay, STREAM, DECODE,
         ("Empty Payload."), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 too_small:
@@ -310,6 +308,7 @@ too_small:
         ("Buffer too small."), (NULL));
     if (outbuf)
       gst_buffer_unref (outbuf);
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 missing_caps:
@@ -318,6 +317,7 @@ missing_caps:
         ("Missing caps %u.", CV), (NULL));
     if (outbuf)
       gst_buffer_unref (outbuf);
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index e6e23de..571a7a8 100644 (file)
@@ -31,7 +31,7 @@
  *  0                   1                   2                   3
  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |C| CV  |D|X|Y|Z|                  MBZ                          |
+ * |C| CV  |D|0|0|0|                  MBZ                          |
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  * |                          Frag_offset                          |
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -45,9 +45,6 @@
  *
  * CV: caps version, 0 = caps from SDP, 1 - 7 inlined caps
  * D: delta unit buffer
- * X: media 1 flag
- * Y: media 2 flag
- * Z: media 3 flag
  *
  *
  */
@@ -73,37 +70,34 @@ static gboolean gst_rtp_gst_pay_setcaps (GstBaseRTPPayload * payload,
 static GstFlowReturn gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * payload,
     GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRtpGSTPay, gst_rtp_gst_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD)
+#define gst_rtp_gst_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpGSTPay, gst_rtp_gst_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
-     static void gst_rtp_gst_pay_base_init (gpointer klass)
+static void
+gst_rtp_gst_pay_class_init (GstRtpGSTPayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPPayloadClass *gstbasertppayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_gst_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_gst_pay_sink_template));
 
-  gst_element_class_set_details_simple (element_class,
+  gst_element_class_set_details_simple (gstelement_class,
       "RTP GStreamer payloader", "Codec/Payloader/Network/RTP",
       "Payload GStreamer buffers as RTP packets",
       "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_gst_pay_class_init (GstRtpGSTPayClass * klass)
-{
-  GstBaseRTPPayloadClass *gstbasertppayload_class;
-
-  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gstbasertppayload_class->set_caps = gst_rtp_gst_pay_setcaps;
   gstbasertppayload_class->handle_buffer = gst_rtp_gst_pay_handle_buffer;
 }
 
 static void
-gst_rtp_gst_pay_init (GstRtpGSTPay * rtpgstpay, GstRtpGSTPayClass * klass)
+gst_rtp_gst_pay_init (GstRtpGSTPay * rtpgstpay)
 {
 }
 
@@ -131,8 +125,8 @@ gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     GstBuffer * buffer)
 {
   GstRtpGSTPay *rtpgstpay;
-  guint8 *data;
-  guint size;
+  guint8 *data, *ptr;
+  gsize size, left;
   GstBuffer *outbuf;
   GstFlowReturn ret;
   GstClockTime timestamp;
@@ -141,8 +135,7 @@ gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
   rtpgstpay = GST_RTP_GST_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
 
   ret = GST_FLOW_OK;
@@ -151,12 +144,6 @@ gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   flags = 0;
   if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT))
     flags |= (1 << 3);
-  if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_MEDIA1))
-    flags |= (1 << 2);
-  if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_MEDIA2))
-    flags |= (1 << 1);
-  if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_MEDIA3))
-    flags |= (1 << 0);
 
   /*
    *  0                   1                   2                   3
@@ -168,15 +155,18 @@ gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload,
    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    */
   frag_offset = 0;
+  ptr = data;
+  left = size;
 
-  while (size > 0) {
+  while (left > 0) {
     guint towrite;
     guint8 *payload;
     guint payload_len;
     guint packet_len;
+    GstRTPBuffer rtp = { NULL };
 
     /* this will be the total lenght of the packet */
-    packet_len = gst_rtp_buffer_calc_packet_len (8 + size, 0, 0);
+    packet_len = gst_rtp_buffer_calc_packet_len (8 + left, 0, 0);
 
     /* fill one MTU or all available bytes */
     towrite = MIN (packet_len, GST_BASE_RTP_PAYLOAD_MTU (rtpgstpay));
@@ -186,7 +176,9 @@ gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
     /* create buffer to hold the payload */
     outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
-    payload = gst_rtp_buffer_get_payload (outbuf);
+
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+    payload = gst_rtp_buffer_get_payload (&rtp);
 
     payload[0] = flags;
     payload[1] = payload[2] = payload[3] = 0;
@@ -198,19 +190,22 @@ gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     payload += 8;
     payload_len -= 8;
 
-    memcpy (payload, data, payload_len);
+    memcpy (payload, ptr, payload_len);
 
-    data += payload_len;
-    size -= payload_len;
+    ptr += payload_len;
+    left -= payload_len;
     frag_offset += payload_len;
 
-    if (size == 0)
-      gst_rtp_buffer_set_marker (outbuf, TRUE);
+    if (left == 0)
+      gst_rtp_buffer_set_marker (&rtp, TRUE);
+
+    gst_rtp_buffer_unmap (&rtp);
 
     GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
 
     ret = gst_basertppayload_push (basepayload, outbuf);
   }
+  gst_buffer_unmap (buffer, data, size);
   gst_buffer_unref (buffer);
 
   return ret;
index 4bc8704..13a2cca 100644 (file)
@@ -61,7 +61,8 @@ static GstStaticPadTemplate gst_rtp_h263_depay_sink_template =
         "clock-rate = (int) 90000, " "encoding-name = (string) \"H263\"")
     );
 
-GST_BOILERPLATE (GstRtpH263Depay, gst_rtp_h263_depay, GstBaseRTPDepayload,
+#define gst_rtp_h263_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpH263Depay, gst_rtp_h263_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void gst_rtp_h263_depay_finalize (GObject * object);
@@ -75,47 +76,40 @@ gboolean gst_rtp_h263_depay_setcaps (GstBaseRTPDepayload * filter,
     GstCaps * caps);
 
 static void
-gst_rtp_h263_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h263_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h263_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP H263 depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts H263 video from RTP packets (RFC 2190)",
-      "Philippe Kalaf <philippe.kalaf@collabora.co.uk>, "
-      "Edward Hervey <bilboed@bilboed.com>");
-}
-
-static void
 gst_rtp_h263_depay_class_init (GstRtpH263DepayClass * klass)
 {
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
+  GST_DEBUG_CATEGORY_INIT (rtph263depay_debug, "rtph263depay", 0,
+      "H263 Video RTP Depayloader");
+
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
-  gstbasertpdepayload_class->process = gst_rtp_h263_depay_process;
-  gstbasertpdepayload_class->set_caps = gst_rtp_h263_depay_setcaps;
-
   gobject_class->finalize = gst_rtp_h263_depay_finalize;
 
   gstelement_class->change_state = gst_rtp_h263_depay_change_state;
 
-  GST_DEBUG_CATEGORY_INIT (rtph263depay_debug, "rtph263depay", 0,
-      "H263 Video RTP Depayloader");
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h263_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h263_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP H263 depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts H263 video from RTP packets (RFC 2190)",
+      "Philippe Kalaf <philippe.kalaf@collabora.co.uk>, "
+      "Edward Hervey <bilboed@bilboed.com>");
+
+  gstbasertpdepayload_class->process = gst_rtp_h263_depay_process;
+  gstbasertpdepayload_class->set_caps = gst_rtp_h263_depay_setcaps;
 }
 
 static void
-gst_rtp_h263_depay_init (GstRtpH263Depay * rtph263depay,
-    GstRtpH263DepayClass * klass)
+gst_rtp_h263_depay_init (GstRtpH263Depay * rtph263depay)
 {
   rtph263depay->adapter = gst_adapter_new ();
 
@@ -167,6 +161,7 @@ gst_rtp_h263_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   guint SBIT, EBIT;
   gboolean F, P, M;
   gboolean I;
+  GstRTPBuffer rtp = { NULL };
 
   rtph263depay = GST_RTP_H263_DEPAY (depayload);
 
@@ -179,10 +174,12 @@ gst_rtp_h263_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     rtph263depay->start = FALSE;
   }
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
-  payload = gst_rtp_buffer_get_payload (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
-  M = gst_rtp_buffer_get_marker (buf);
+  M = gst_rtp_buffer_get_marker (&rtp);
 
   /* Let's see what mode we are using */
   F = (payload[0] & 0x80) == 0x80;
@@ -287,13 +284,13 @@ gst_rtp_h263_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     GstBuffer *tmp;
 
     /* Take the entire buffer */
-    tmp = gst_rtp_buffer_get_payload_subbuffer (buf, header_len, payload_len);
+    tmp = gst_rtp_buffer_get_payload_subbuffer (&rtp, header_len, payload_len);
     gst_adapter_push (rtph263depay->adapter, tmp);
   } else {
     GstBuffer *tmp;
 
     /* Take the entire buffer except for the last byte */
-    tmp = gst_rtp_buffer_get_payload_subbuffer (buf, header_len,
+    tmp = gst_rtp_buffer_get_payload_subbuffer (&rtp, header_len,
         payload_len - 1);
     gst_adapter_push (rtph263depay->adapter, tmp);
 
@@ -317,7 +314,7 @@ skip:
         GstBuffer *buf = gst_buffer_new_and_alloc (1);
 
         GST_DEBUG ("Pushing leftover in adapter");
-        GST_BUFFER_DATA (buf)[0] = rtph263depay->leftover;
+        gst_buffer_fill (buf, 0, &rtph263depay->leftover, 1);
         gst_adapter_push (rtph263depay->adapter, buf);
       }
 
@@ -329,7 +326,7 @@ skip:
 
       GST_DEBUG ("Pushing out a buffer of %d bytes", avail);
 
-      timestamp = gst_rtp_buffer_get_timestamp (buf);
+      timestamp = gst_rtp_buffer_get_timestamp (&rtp);
       gst_base_rtp_depayload_push_ts (depayload, timestamp, outbuf);
       rtph263depay->offset = 0;
       rtph263depay->leftover = 0;
@@ -338,6 +335,7 @@ skip:
       rtph263depay->start = TRUE;
     }
   }
+  gst_rtp_buffer_unmap (&rtp);
 
   return NULL;
 }
index 8eb85bc..8bb5efe 100644 (file)
@@ -395,32 +395,18 @@ static void gst_rtp_h263_pay_context_destroy (GstRtpH263PayContext * context,
     guint ind);
 static void gst_rtp_h263_pay_package_destroy (GstRtpH263PayPackage * pack);
 
-GST_BOILERPLATE (GstRtpH263Pay, gst_rtp_h263_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD)
-
-     static void gst_rtp_h263_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h263_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h263_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP H263 packet payloader", "Codec/Payloader/Network/RTP",
-      "Payload-encodes H263 video in RTP packets (RFC 2190)",
-      "Neil Stratford <neils@vipadia.com>"
-      "Dejan Sakelsak <dejan.sakelsak@marand.si>");
-}
+#define gst_rtp_h263_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpH263Pay, gst_rtp_h263_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_h263_pay_class_init (GstRtpH263PayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gobject_class->finalize = gst_rtp_h263_pay_finalize;
@@ -436,12 +422,23 @@ gst_rtp_h263_pay_class_init (GstRtpH263PayClass * klass)
           "Disable packetization modes B and C", DEFAULT_MODE_A,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h263_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h263_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP H263 packet payloader", "Codec/Payloader/Network/RTP",
+      "Payload-encodes H263 video in RTP packets (RFC 2190)",
+      "Neil Stratford <neils@vipadia.com>"
+      "Dejan Sakelsak <dejan.sakelsak@marand.si>");
+
   GST_DEBUG_CATEGORY_INIT (rtph263pay_debug, "rtph263pay", 0,
       "H263 RTP Payloader");
 }
 
 static void
-gst_rtp_h263_pay_init (GstRtpH263Pay * rtph263pay, GstRtpH263PayClass * klass)
+gst_rtp_h263_pay_init (GstRtpH263Pay * rtph263pay)
 {
   rtph263pay->adapter = gst_adapter_new ();
 
@@ -1240,8 +1237,11 @@ gst_rtp_h263_pay_push (GstRtpH263Pay * rtph263pay,
   guint8 *header;
   guint8 *payload;
   GstFlowReturn ret;
+  GstRTPBuffer rtp = { NULL };
 
-  header = gst_rtp_buffer_get_payload (package->outbuf);
+  gst_rtp_buffer_map (package->outbuf, GST_MAP_WRITE, &rtp);
+
+  header = gst_rtp_buffer_get_payload (&rtp);
   payload = header + package->mode;
 
   switch (package->mode) {
@@ -1272,10 +1272,12 @@ gst_rtp_h263_pay_push (GstRtpH263Pay * rtph263pay,
    */
   GST_BUFFER_TIMESTAMP (package->outbuf) = rtph263pay->first_ts;
 
-  gst_rtp_buffer_set_marker (package->outbuf, package->marker);
+  gst_rtp_buffer_set_marker (&rtp, package->marker);
   if (package->marker)
     GST_DEBUG ("Marker set!");
 
+  gst_rtp_buffer_unmap (&rtp);
+
   ret =
       gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtph263pay),
       package->outbuf);
@@ -1611,7 +1613,7 @@ gst_rtp_h263_pay_flush (GstRtpH263Pay * rtph263pay)
 
   /* Get a pointer to all the data for the frame */
   rtph263pay->data =
-      (guint8 *) gst_adapter_peek (rtph263pay->adapter,
+      (guint8 *) gst_adapter_map (rtph263pay->adapter,
       rtph263pay->available_data);
 
   /* Picture header */
@@ -1767,7 +1769,7 @@ gst_rtp_h263_pay_flush (GstRtpH263Pay * rtph263pay)
 end:
   gst_rtp_h263_pay_context_destroy (context,
       context->piclayer->ptype_srcformat);
-  gst_adapter_flush (rtph263pay->adapter, rtph263pay->available_data);
+  gst_adapter_unmap (rtph263pay->adapter, rtph263pay->available_data);
 
   return ret;
 }
index 05fb733..3dbe534 100644 (file)
@@ -1,5 +1,5 @@
 /* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005> Wim Taymans <wim.taymans@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
index 5cad4bf..dea2ad0 100644 (file)
@@ -78,7 +78,8 @@ static GstStaticPadTemplate gst_rtp_h263p_depay_sink_template =
     )
     );
 
-GST_BOILERPLATE (GstRtpH263PDepay, gst_rtp_h263p_depay, GstBaseRTPDepayload,
+#define gst_rtp_h263p_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpH263PDepay, gst_rtp_h263p_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void gst_rtp_h263p_depay_finalize (GObject * object);
@@ -92,23 +93,6 @@ gboolean gst_rtp_h263p_depay_setcaps (GstBaseRTPDepayload * filter,
     GstCaps * caps);
 
 static void
-gst_rtp_h263p_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h263p_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h263p_depay_sink_template));
-
-
-  gst_element_class_set_details_simple (element_class, "RTP H263 depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts H263/+/++ video from RTP packets (RFC 4629)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_h263p_depay_class_init (GstRtpH263PDepayClass * klass)
 {
   GObjectClass *gobject_class;
@@ -119,17 +103,26 @@ gst_rtp_h263p_depay_class_init (GstRtpH263PDepayClass * klass)
   gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
-  gstbasertpdepayload_class->process = gst_rtp_h263p_depay_process;
-  gstbasertpdepayload_class->set_caps = gst_rtp_h263p_depay_setcaps;
-
   gobject_class->finalize = gst_rtp_h263p_depay_finalize;
 
   gstelement_class->change_state = gst_rtp_h263p_depay_change_state;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h263p_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h263p_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP H263 depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts H263/+/++ video from RTP packets (RFC 4629)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
+  gstbasertpdepayload_class->process = gst_rtp_h263p_depay_process;
+  gstbasertpdepayload_class->set_caps = gst_rtp_h263p_depay_setcaps;
 }
 
 static void
-gst_rtp_h263p_depay_init (GstRtpH263PDepay * rtph263pdepay,
-    GstRtpH263PDepayClass * klass)
+gst_rtp_h263p_depay_init (GstRtpH263PDepay * rtph263pdepay)
 {
   rtph263pdepay->adapter = gst_adapter_new ();
 }
@@ -237,6 +230,12 @@ gst_rtp_h263p_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstRtpH263PDepay *rtph263pdepay;
   GstBuffer *outbuf;
+  gint payload_len;
+  guint8 *payload;
+  gboolean P, V, M;
+  guint header_len;
+  guint8 PLEN, PEBIT;
+  GstRTPBuffer rtp = { NULL };
 
   rtph263pdepay = GST_RTP_H263P_DEPAY (depayload);
 
@@ -247,103 +246,100 @@ gst_rtp_h263p_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     rtph263pdepay->wait_start = TRUE;
   }
 
-  {
-    gint payload_len;
-    guint8 *payload;
-    gboolean P, V, M;
-    guint header_len;
-    guint8 PLEN, PEBIT;
-
-    payload_len = gst_rtp_buffer_get_payload_len (buf);
-    payload = gst_rtp_buffer_get_payload (buf);
-
-    header_len = 2;
-
-    if (payload_len < header_len)
-      goto too_small;
-
-    M = gst_rtp_buffer_get_marker (buf);
-
-    /*  0                   1
-     *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
-     * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     * |   RR    |P|V|   PLEN    |PEBIT|
-     * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     */
-    P = (payload[0] & 0x04) == 0x04;
-    V = (payload[0] & 0x02) == 0x02;
-    PLEN = ((payload[0] & 0x1) << 5) | (payload[1] >> 3);
-    PEBIT = payload[1] & 0x7;
-
-    GST_LOG_OBJECT (depayload, "P %d, V %d, PLEN %d, PEBIT %d", P, V, PLEN,
-        PEBIT);
-
-    if (V) {
-      header_len++;
-    }
-    if (PLEN) {
-      header_len += PLEN;
-    }
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
 
-    if ((!P && payload_len < header_len) || (P && payload_len < header_len - 2))
-      goto too_small;
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+  header_len = 2;
 
-    if (P) {
-      /* FIXME, have to make the packet writable hear. Better to reset these
-       * bytes when we copy the packet below */
-      rtph263pdepay->wait_start = FALSE;
-      header_len -= 2;
-      payload[header_len] = 0;
-      payload[header_len + 1] = 0;
-    }
+  if (payload_len < header_len)
+    goto too_small;
 
-    if (rtph263pdepay->wait_start)
-      goto waiting_start;
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
-    if (payload_len < header_len)
-      goto too_small;
+  M = gst_rtp_buffer_get_marker (&rtp);
 
-    /* FIXME do not ignore the VRC header (See RFC 2429 section 4.2) */
-    /* FIXME actually use the RTP picture header when it is lost in the network */
-    /* for now strip off header */
-    payload += header_len;
-    payload_len -= header_len;
+  /*  0                   1
+   *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   * |   RR    |P|V|   PLEN    |PEBIT|
+   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   */
+  P = (payload[0] & 0x04) == 0x04;
+  V = (payload[0] & 0x02) == 0x02;
+  PLEN = ((payload[0] & 0x1) << 5) | (payload[1] >> 3);
+  PEBIT = payload[1] & 0x7;
 
-    if (M) {
-      /* frame is completed: append to previous, push it out */
-      guint len, padlen;
-      guint avail;
+  GST_LOG_OBJECT (depayload, "P %d, V %d, PLEN %d, PEBIT %d", P, V, PLEN,
+      PEBIT);
 
-      GST_LOG_OBJECT (depayload, "Frame complete");
+  if (V) {
+    header_len++;
+  }
+  if (PLEN) {
+    header_len += PLEN;
+  }
 
-      avail = gst_adapter_available (rtph263pdepay->adapter);
+  if ((!P && payload_len < header_len) || (P && payload_len < header_len - 2))
+    goto too_small;
 
-      len = avail + payload_len;
-      padlen = (len % 4) + 4;
-      outbuf = gst_buffer_new_and_alloc (len + padlen);
-      memset (GST_BUFFER_DATA (outbuf) + len, 0, padlen);
-      GST_BUFFER_SIZE (outbuf) = len;
+  if (P) {
+    /* FIXME, have to make the packet writable hear. Better to reset these
+     * bytes when we copy the packet below */
+    rtph263pdepay->wait_start = FALSE;
+    header_len -= 2;
+    payload[header_len] = 0;
+    payload[header_len + 1] = 0;
+  }
 
-      /* prepend previous data */
-      if (avail > 0) {
-        gst_adapter_copy (rtph263pdepay->adapter, GST_BUFFER_DATA (outbuf), 0,
-            avail);
-        gst_adapter_flush (rtph263pdepay->adapter, avail);
-      }
-      memcpy (GST_BUFFER_DATA (outbuf) + avail, payload, payload_len);
+  if (rtph263pdepay->wait_start)
+    goto waiting_start;
 
-      return outbuf;
+  if (payload_len < header_len)
+    goto too_small;
 
-    } else {
-      /* frame not completed: store in adapter */
-      outbuf = gst_buffer_new_and_alloc (payload_len);
+  /* FIXME do not ignore the VRC header (See RFC 2429 section 4.2) */
+  /* FIXME actually use the RTP picture header when it is lost in the network */
+  /* for now strip off header */
+  payload += header_len;
+  payload_len -= header_len;
+
+  if (M) {
+    /* frame is completed: append to previous, push it out */
+    guint len, padlen;
+    guint avail;
+    guint8 *data;
+
+    GST_LOG_OBJECT (depayload, "Frame complete");
+
+    avail = gst_adapter_available (rtph263pdepay->adapter);
+    len = avail + payload_len;
+    padlen = (len % 4) + 4;
 
-      GST_LOG_OBJECT (depayload, "Frame incomplete, storing %d", payload_len);
+    outbuf = gst_buffer_new_and_alloc (len + padlen);
 
-      memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
+    data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+    memset (data + len, 0, padlen);
 
-      gst_adapter_push (rtph263pdepay->adapter, outbuf);
+    /* prepend previous data */
+    if (avail > 0) {
+      gst_adapter_copy (rtph263pdepay->adapter, data, 0, avail);
+      gst_adapter_flush (rtph263pdepay->adapter, avail);
     }
+    memcpy (data + avail, payload, payload_len);
+    gst_buffer_unmap (outbuf, data, len);
+    gst_rtp_buffer_unmap (&rtp);
+
+    return outbuf;
+
+  } else {
+    /* frame not completed: store in adapter */
+    outbuf = gst_buffer_new_and_alloc (payload_len);
+
+    GST_LOG_OBJECT (depayload, "Frame incomplete, storing %d", payload_len);
+    gst_buffer_fill (outbuf, 0, payload, payload_len);
+
+    gst_adapter_push (rtph263pdepay->adapter, outbuf);
+    gst_rtp_buffer_unmap (&rtp);
   }
   return NULL;
 
@@ -351,11 +347,13 @@ too_small:
   {
     GST_ELEMENT_WARNING (rtph263pdepay, STREAM, DECODE,
         ("Packet payload was too small"), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 waiting_start:
   {
     GST_DEBUG_OBJECT (rtph263pdepay, "waiting for picture start");
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index fff68ec..52a3fb3 100644 (file)
@@ -90,32 +90,18 @@ static gboolean gst_rtp_h263p_pay_setcaps (GstBaseRTPPayload * payload,
 static GstFlowReturn gst_rtp_h263p_pay_handle_buffer (GstBaseRTPPayload *
     payload, GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRtpH263PPay, gst_rtp_h263p_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
-
-static void
-gst_rtp_h263p_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h263p_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h263p_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP H263 payloader",
-      "Codec/Payloader/Network/RTP",
-      "Payload-encodes H263/+/++ video in RTP packets (RFC 4629)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_rtp_h263p_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpH263PPay, gst_rtp_h263p_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_h263p_pay_class_init (GstRtpH263PPayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gobject_class->finalize = gst_rtp_h263p_pay_finalize;
@@ -132,13 +118,22 @@ gst_rtp_h263p_pay_class_init (GstRtpH263PPayClass * klass)
           DEFAULT_FRAGMENTATION_MODE,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h263p_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h263p_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP H263 payloader",
+      "Codec/Payloader/Network/RTP",
+      "Payload-encodes H263/+/++ video in RTP packets (RFC 4629)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtph263ppay_debug, "rtph263ppay",
       0, "rtph263ppay (RFC 4629)");
 }
 
 static void
-gst_rtp_h263p_pay_init (GstRtpH263PPay * rtph263ppay,
-    GstRtpH263PPayClass * klass)
+gst_rtp_h263p_pay_init (GstRtpH263PPay * rtph263ppay)
 {
   rtph263ppay->adapter = gst_adapter_new ();
 
@@ -236,13 +231,14 @@ gst_rtp_h263p_pay_flush (GstRtpH263PPay * rtph263ppay)
     gint header_len;
     guint next_gop = 0;
     gboolean found_gob = FALSE;
+    GstRTPBuffer rtp = { NULL };
 
     if (rtph263ppay->fragmentation_mode == GST_FRAGMENTATION_MODE_SYNC) {
       /* start after 1st gop possible */
       guint parsed_len = 3;
       const guint8 *parse_data = NULL;
 
-      parse_data = gst_adapter_peek (rtph263ppay->adapter, avail);
+      parse_data = gst_adapter_map (rtph263ppay->adapter, avail);
 
       /* Check if we have a gob or eos , eossbs */
       /* FIXME EOS and EOSSBS packets should never contain any gobs and vice-versa */
@@ -264,6 +260,7 @@ gst_rtp_h263p_pay_flush (GstRtpH263PPay * rtph263ppay)
         }
         parsed_len++;
       }
+      gst_adapter_unmap (rtph263ppay->adapter, 0);
     }
 
     /* for picture start frames (non-fragmented), we need to remove the first
@@ -279,10 +276,12 @@ gst_rtp_h263p_pay_flush (GstRtpH263PPay * rtph263ppay)
     payload_len = header_len + towrite;
 
     outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
+
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
     /* last fragment gets the marker bit set */
-    gst_rtp_buffer_set_marker (outbuf, avail > towrite ? 0 : 1);
+    gst_rtp_buffer_set_marker (&rtp, avail > towrite ? 0 : 1);
 
-    payload = gst_rtp_buffer_get_payload (outbuf);
+    payload = gst_rtp_buffer_get_payload (&rtp);
 
     gst_adapter_copy (rtph263ppay->adapter, &payload[header_len], 0, towrite);
 
@@ -298,6 +297,7 @@ gst_rtp_h263p_pay_flush (GstRtpH263PPay * rtph263ppay)
 
     GST_BUFFER_TIMESTAMP (outbuf) = rtph263ppay->first_timestamp;
     GST_BUFFER_DURATION (outbuf) = rtph263ppay->first_duration;
+    gst_rtp_buffer_unmap (&rtp);
 
     gst_adapter_flush (rtph263ppay->adapter, towrite);
 
index fb06977..35078f9 100644 (file)
@@ -79,7 +79,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     /* "max-rcmd-nalu-size = (string) ANY " */
     );
 
-GST_BOILERPLATE (GstRtpH264Depay, gst_rtp_h264_depay, GstBaseRTPDepayload,
+#define gst_rtp_h264_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpH264Depay, gst_rtp_h264_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void gst_rtp_h264_depay_finalize (GObject * object);
@@ -99,22 +100,6 @@ static gboolean gst_rtp_h264_depay_handle_event (GstBaseRTPDepayload * depay,
     GstEvent * event);
 
 static void
-gst_rtp_h264_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h264_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h264_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP H264 depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts H264 video from RTP packets (RFC 3984)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_h264_depay_class_init (GstRtpH264DepayClass * klass)
 {
   GObjectClass *gobject_class;
@@ -139,6 +124,15 @@ gst_rtp_h264_depay_class_init (GstRtpH264DepayClass * klass)
           "Merge NALU into AU (picture) (deprecated; use caps)",
           DEFAULT_ACCESS_UNIT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h264_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h264_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP H264 depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts H264 video from RTP packets (RFC 3984)",
+      "Wim Taymans <wim.taymans@gmail.com>");
   gstelement_class->change_state = gst_rtp_h264_depay_change_state;
 
   gstbasertpdepayload_class->process = gst_rtp_h264_depay_process;
@@ -150,8 +144,7 @@ gst_rtp_h264_depay_class_init (GstRtpH264DepayClass * klass)
 }
 
 static void
-gst_rtp_h264_depay_init (GstRtpH264Depay * rtph264depay,
-    GstRtpH264DepayClass * klass)
+gst_rtp_h264_depay_init (GstRtpH264Depay * rtph264depay)
 {
   rtph264depay->adapter = gst_adapter_new ();
   rtph264depay->picture_adapter = gst_adapter_new ();
@@ -297,7 +290,7 @@ gst_rtp_h264_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   GstRtpH264Depay *rtph264depay;
   const gchar *ps, *profile;
   GstBuffer *codec_data;
-  guint8 *b64;
+  guint8 *ptr, *data;
   gboolean res;
 
   rtph264depay = GST_RTP_H264_DEPAY (depayload);
@@ -334,23 +327,25 @@ gst_rtp_h264_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
     }
     /* we seriously overshoot the length, but it's fine. */
     codec_data = gst_buffer_new_and_alloc (len);
-    b64 = GST_BUFFER_DATA (codec_data);
+
+    data = gst_buffer_map (codec_data, NULL, NULL, GST_MAP_WRITE);
+    ptr = data;
     total = 0;
     for (i = 0; params[i]; i++) {
       guint save = 0;
       gint state = 0;
 
       GST_DEBUG_OBJECT (depayload, "decoding param %d (%s)", i, params[i]);
-      memcpy (b64, sync_bytes, sizeof (sync_bytes));
-      b64 += sizeof (sync_bytes);
+      memcpy (ptr, sync_bytes, sizeof (sync_bytes));
+      ptr += sizeof (sync_bytes);
       len =
-          g_base64_decode_step (params[i], strlen (params[i]), b64, &state,
+          g_base64_decode_step (params[i], strlen (params[i]), ptr, &state,
           &save);
       GST_DEBUG_OBJECT (depayload, "decoded %d bytes", len);
       total += len + sizeof (sync_bytes);
-      b64 += len;
+      ptr += len;
     }
-    GST_BUFFER_SIZE (codec_data) = total;
+    gst_buffer_unmap (codec_data, data, total);
     g_strfreev (params);
 
     /* keep the codec_data, we need to send it as the first buffer. We cannot
@@ -364,7 +359,6 @@ gst_rtp_h264_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
     guint8 **sps, **pps;
     guint len, num_sps, num_pps;
     gint i;
-    guint8 *data;
 
     if (ps == NULL)
       goto incomplete_caps;
@@ -413,50 +407,51 @@ gst_rtp_h264_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
     }
 
     codec_data = gst_buffer_new_and_alloc (len);
-    data = GST_BUFFER_DATA (codec_data);
+
+    data = ptr = gst_buffer_map (codec_data, NULL, NULL, GST_MAP_WRITE);
 
     /* 8 bits version == 1 */
-    *data++ = 1;
+    *ptr++ = 1;
     if (profile) {
       guint32 profile_id;
 
       /* hex: AVCProfileIndication:8 | profile_compat:8 | AVCLevelIndication:8 */
       sscanf (profile, "%6x", &profile_id);
-      *data++ = (profile_id >> 16) & 0xff;
-      *data++ = (profile_id >> 8) & 0xff;
-      *data++ = profile_id & 0xff;
+      *ptr++ = (profile_id >> 16) & 0xff;
+      *ptr++ = (profile_id >> 8) & 0xff;
+      *ptr++ = profile_id & 0xff;
     } else {
       /* extract from SPS */
-      *data++ = sps[0][3];
-      *data++ = sps[0][4];
-      *data++ = sps[0][5];
+      *ptr++ = sps[0][3];
+      *ptr++ = sps[0][4];
+      *ptr++ = sps[0][5];
     }
     /* 6 bits reserved | 2 bits lengthSizeMinusOn */
-    *data++ = 0xff;
+    *ptr++ = 0xff;
     /* 3 bits reserved | 5 bits numOfSequenceParameterSets */
-    *data++ = 0xe0 | (num_sps & 0x1f);
+    *ptr++ = 0xe0 | (num_sps & 0x1f);
 
     /* copy all SPS */
     for (i = 0; sps[i]; i++) {
       len = ((sps[i][0] << 8) | sps[i][1]) + 2;
       GST_DEBUG_OBJECT (depayload, "copy SPS %d of length %d", i, len);
-      memcpy (data, sps[i], len);
+      memcpy (ptr, sps[i], len);
       g_free (sps[i]);
-      data += len;
+      ptr += len;
     }
     g_free (sps);
     /* 8 bits numOfPictureParameterSets */
-    *data++ = num_pps;
+    *ptr++ = num_pps;
     /* copy all PPS */
     for (i = 0; pps[i]; i++) {
       len = ((pps[i][0] << 8) | pps[i][1]) + 2;
       GST_DEBUG_OBJECT (depayload, "copy PPS %d of length %d", i, len);
-      memcpy (data, pps[i], len);
+      memcpy (ptr, pps[i], len);
       g_free (pps[i]);
-      data += len;
+      ptr += len;
     }
     g_free (pps);
-    GST_BUFFER_SIZE (codec_data) = data - GST_BUFFER_DATA (codec_data);
+    gst_buffer_unmap (codec_data, data, ptr - data);
 
     gst_caps_set_simple (srccaps,
         "codec_data", GST_TYPE_BUFFER, codec_data, NULL);
@@ -512,18 +507,16 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
 {
   GstBaseRTPDepayload *depayload = GST_BASE_RTP_DEPAYLOAD (rtph264depay);
   gint nal_type;
-  guint size;
+  gsize size;
   guint8 *data;
   GstBuffer *outbuf = NULL;
   GstClockTime out_timestamp;
   gboolean keyframe, out_keyframe;
 
-  size = GST_BUFFER_SIZE (nal);
+  data = gst_buffer_map (nal, &size, NULL, GST_MAP_READ);
   if (G_UNLIKELY (size < 5))
     goto short_nal;
 
-  data = GST_BUFFER_DATA (nal);
-
   nal_type = data[4] & 0x1f;
   GST_DEBUG_OBJECT (rtph264depay, "handle NAL type %d", nal_type);
 
@@ -573,6 +566,7 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
     GST_DEBUG_OBJECT (depayload, "using NAL as output");
     outbuf = nal;
   }
+  gst_buffer_unmap (nal, data, size);
 
   if (outbuf) {
     /* prepend codec_data */
@@ -582,7 +576,7 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
       rtph264depay->codec_data = NULL;
       out_keyframe = TRUE;
     }
-    outbuf = gst_buffer_make_metadata_writable (outbuf);
+    outbuf = gst_buffer_make_writable (outbuf);
 
     GST_BUFFER_TIMESTAMP (outbuf) = out_timestamp;
 
@@ -591,8 +585,6 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
     else
       GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
 
-    gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
-
     gst_base_rtp_depayload_push (depayload, outbuf);
   }
 
@@ -602,6 +594,7 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
 short_nal:
   {
     GST_WARNING_OBJECT (depayload, "dropping short NAL");
+    gst_buffer_unmap (nal, data, size);
     gst_buffer_unref (nal);
     return FALSE;
   }
@@ -616,7 +609,7 @@ gst_rtp_h264_push_fragmentation_unit (GstRtpH264Depay * rtph264depay)
 
   outsize = gst_adapter_available (rtph264depay->adapter);
   outbuf = gst_adapter_take_buffer (rtph264depay->adapter, outsize);
-  outdata = GST_BUFFER_DATA (outbuf);
+  outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
 
   GST_DEBUG_OBJECT (rtph264depay, "output %d bytes", outsize);
 
@@ -629,6 +622,7 @@ gst_rtp_h264_push_fragmentation_unit (GstRtpH264Depay * rtph264depay)
     outdata[2] = (outsize >> 8);
     outdata[3] = (outsize);
   }
+  gst_buffer_unmap (outbuf, outdata, -1);
 
   gst_rtp_h264_depay_handle_nal (rtph264depay, outbuf,
       rtph264depay->fu_timestamp, rtph264depay->fu_marker);
@@ -642,6 +636,7 @@ gst_rtp_h264_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   GstRtpH264Depay *rtph264depay;
   GstBuffer *outbuf;
   guint8 nal_unit_type;
+  GstRTPBuffer rtp = { NULL };
 
   rtph264depay = GST_RTP_H264_DEPAY (depayload);
 
@@ -664,9 +659,11 @@ gst_rtp_h264_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
     timestamp = GST_BUFFER_TIMESTAMP (buf);
 
-    payload_len = gst_rtp_buffer_get_payload_len (buf);
-    payload = gst_rtp_buffer_get_payload (buf);
-    marker = gst_rtp_buffer_get_marker (buf);
+    gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+    payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+    payload = gst_rtp_buffer_get_payload (&rtp);
+    marker = gst_rtp_buffer_get_marker (&rtp);
 
     GST_DEBUG_OBJECT (rtph264depay, "receiving %d bytes", payload_len);
 
@@ -732,7 +729,8 @@ gst_rtp_h264_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
           outsize = nalu_size + sizeof (sync_bytes);
           outbuf = gst_buffer_new_and_alloc (outsize);
-          outdata = GST_BUFFER_DATA (outbuf);
+
+          outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
           if (rtph264depay->byte_stream) {
             memcpy (outdata, sync_bytes, sizeof (sync_bytes));
           } else {
@@ -745,8 +743,8 @@ gst_rtp_h264_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
           payload += 2;
           payload_len -= 2;
 
-          outdata += sizeof (sync_bytes);
-          memcpy (outdata, payload, nalu_size);
+          memcpy (outdata + sizeof (sync_bytes), payload, nalu_size);
+          gst_buffer_unmap (outbuf, outdata, outsize);
 
           gst_adapter_push (rtph264depay->adapter, outbuf);
 
@@ -818,10 +816,11 @@ gst_rtp_h264_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
           nalu_size = payload_len;
           outsize = nalu_size + sizeof (sync_bytes);
           outbuf = gst_buffer_new_and_alloc (outsize);
-          outdata = GST_BUFFER_DATA (outbuf);
-          outdata += sizeof (sync_bytes);
-          memcpy (outdata, payload, nalu_size);
-          outdata[0] = nal_header;
+
+          outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+          memcpy (outdata + sizeof (sync_bytes), payload, nalu_size);
+          outdata[sizeof (sync_bytes)] = nal_header;
+          gst_buffer_unmap (outbuf, outdata, outsize);
 
           GST_DEBUG_OBJECT (rtph264depay, "queueing %d bytes", outsize);
 
@@ -834,8 +833,10 @@ gst_rtp_h264_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
           outsize = payload_len;
           outbuf = gst_buffer_new_and_alloc (outsize);
-          outdata = GST_BUFFER_DATA (outbuf);
+
+          outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
           memcpy (outdata, payload, outsize);
+          gst_buffer_unmap (outbuf, outdata, outsize);
 
           GST_DEBUG_OBJECT (rtph264depay, "queueing %d bytes", outsize);
 
@@ -859,7 +860,8 @@ gst_rtp_h264_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
         nalu_size = payload_len;
         outsize = nalu_size + sizeof (sync_bytes);
         outbuf = gst_buffer_new_and_alloc (outsize);
-        outdata = GST_BUFFER_DATA (outbuf);
+
+        outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
         if (rtph264depay->byte_stream) {
           memcpy (outdata, sync_bytes, sizeof (sync_bytes));
         } else {
@@ -867,13 +869,14 @@ gst_rtp_h264_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
           outdata[2] = nalu_size >> 8;
           outdata[3] = nalu_size & 0xff;
         }
-        outdata += sizeof (sync_bytes);
-        memcpy (outdata, payload, nalu_size);
+        memcpy (outdata + sizeof (sync_bytes), payload, nalu_size);
+        gst_buffer_unmap (outbuf, outdata, outsize);
 
         gst_rtp_h264_depay_handle_nal (rtph264depay, outbuf, timestamp, marker);
         break;
       }
     }
+    gst_rtp_buffer_unmap (&rtp);
   }
 
   return NULL;
@@ -883,17 +886,20 @@ undefined_type:
   {
     GST_ELEMENT_WARNING (rtph264depay, STREAM, DECODE,
         (NULL), ("Undefined packet type"));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 waiting_start:
   {
     GST_DEBUG_OBJECT (rtph264depay, "waiting for start");
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 not_implemented:
   {
     GST_ELEMENT_ERROR (rtph264depay, STREAM, FORMAT,
         (NULL), ("NAL unit type %d not supported yet", nal_unit_type));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index 738e938..7e08be3 100644 (file)
@@ -111,33 +111,18 @@ static void gst_rtp_h264_pay_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
 static GstCaps *gst_rtp_h264_pay_getcaps (GstBaseRTPPayload * payload,
-    GstPad * pad);
+    GstPad * pad, GstCaps * filter);
 static gboolean gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload,
     GstCaps * caps);
 static GstFlowReturn gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * pad,
     GstBuffer * buffer);
-static gboolean gst_rtp_h264_pay_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_h264_pay_handle_event (GstBaseRTPPayload * payload,
+    GstEvent * event);
 static GstStateChangeReturn gst_basertppayload_change_state (GstElement *
     element, GstStateChange transition);
 
-GST_BOILERPLATE (GstRtpH264Pay, gst_rtp_h264_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
-
-static void
-gst_rtp_h264_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h264_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_h264_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP H264 payloader",
-      "Codec/Payloader/Network/RTP",
-      "Payload-encode H264 video into RTP packets (RFC 3984)",
-      "Laurent Glayal <spglegle@yahoo.fr>");
-}
+#define gst_rtp_h264_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpH264Pay, gst_rtp_h264_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_h264_pay_class_init (GstRtpH264PayClass * klass)
@@ -192,6 +177,16 @@ gst_rtp_h264_pay_class_init (GstRtpH264PayClass * klass)
 
   gobject_class->finalize = gst_rtp_h264_pay_finalize;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h264_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_h264_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP H264 payloader",
+      "Codec/Payloader/Network/RTP",
+      "Payload-encode H264 video into RTP packets (RFC 3984)",
+      "Laurent Glayal <spglegle@yahoo.fr>");
+
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_basertppayload_change_state);
 
@@ -205,7 +200,7 @@ gst_rtp_h264_pay_class_init (GstRtpH264PayClass * klass)
 }
 
 static void
-gst_rtp_h264_pay_init (GstRtpH264Pay * rtph264pay, GstRtpH264PayClass * klass)
+gst_rtp_h264_pay_init (GstRtpH264Pay * rtph264pay)
 {
   rtph264pay->queue = g_array_new (FALSE, FALSE, sizeof (guint));
   rtph264pay->profile = 0;
@@ -269,12 +264,13 @@ static const gchar *all_levels[] = {
 };
 
 static GstCaps *
-gst_rtp_h264_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad)
+gst_rtp_h264_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad,
+    GstCaps * filter)
 {
   GstCaps *allowed_caps;
 
   allowed_caps =
-      gst_pad_peer_get_caps_reffed (GST_BASE_RTP_PAYLOAD_SRCPAD (payload));
+      gst_pad_peer_get_caps (GST_BASE_RTP_PAYLOAD_SRCPAD (payload), filter);
 
   if (allowed_caps) {
     GstCaps *caps = NULL;
@@ -377,6 +373,8 @@ gst_rtp_h264_pay_set_sps_pps (GstBaseRTPPayload * basepayload)
   GString *sprops;
   guint count;
   gboolean res;
+  guint8 *data;
+  gsize size;
 
   sprops = g_string_new ("");
   count = 0;
@@ -385,8 +383,10 @@ gst_rtp_h264_pay_set_sps_pps (GstBaseRTPPayload * basepayload)
   for (walk = payloader->sps; walk; walk = g_list_next (walk)) {
     GstBuffer *sps_buf = GST_BUFFER_CAST (walk->data);
 
-    set =
-        g_base64_encode (GST_BUFFER_DATA (sps_buf), GST_BUFFER_SIZE (sps_buf));
+    data = gst_buffer_map (sps_buf, &size, NULL, GST_MAP_READ);
+    set = g_base64_encode (data, size);
+    gst_buffer_unmap (sps_buf, data, size);
+
     g_string_append_printf (sprops, "%s%s", count ? "," : "", set);
     g_free (set);
     count++;
@@ -394,8 +394,10 @@ gst_rtp_h264_pay_set_sps_pps (GstBaseRTPPayload * basepayload)
   for (walk = payloader->pps; walk; walk = g_list_next (walk)) {
     GstBuffer *pps_buf = GST_BUFFER_CAST (walk->data);
 
-    set =
-        g_base64_encode (GST_BUFFER_DATA (pps_buf), GST_BUFFER_SIZE (pps_buf));
+    data = gst_buffer_map (pps_buf, &size, NULL, GST_MAP_READ);
+    set = g_base64_encode (data, size);
+    gst_buffer_unmap (pps_buf, data, size);
+
     g_string_append_printf (sprops, "%s%s", count ? "," : "", set);
     g_free (set);
     count++;
@@ -418,8 +420,9 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
   GstRtpH264Pay *rtph264pay;
   GstStructure *str;
   const GValue *value;
-  guint8 *data;
-  guint size;
+  guint8 *data, *bdata;
+  gsize size, bsize;
+  GstBuffer *buffer;
   const gchar *alignment;
 
   rtph264pay = GST_RTP_H264_PAY (basepayload);
@@ -438,7 +441,6 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
 
   /* packetized AVC video has a codec_data */
   if ((value = gst_structure_get_value (str, "codec_data"))) {
-    GstBuffer *buffer;
     guint num_sps, num_pps;
     gint i, nal_size;
 
@@ -446,8 +448,10 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
     rtph264pay->packetized = TRUE;
 
     buffer = gst_value_get_buffer (value);
-    data = GST_BUFFER_DATA (buffer);
-    size = GST_BUFFER_SIZE (buffer);
+
+    bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
+    data = bdata;
+    size = bsize;
 
     /* parse the avcC data */
     if (size < 7)
@@ -492,7 +496,7 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
 
       /* make a buffer out of it and add to SPS list */
       sps_buf = gst_buffer_new_and_alloc (nal_size);
-      memcpy (GST_BUFFER_DATA (sps_buf), data, nal_size);
+      gst_buffer_fill (sps_buf, 0, data, nal_size);
       rtph264pay->sps = g_list_append (rtph264pay->sps, sps_buf);
 
       data += nal_size;
@@ -524,7 +528,7 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
 
       /* make a buffer out of it and add to PPS list */
       pps_buf = gst_buffer_new_and_alloc (nal_size);
-      memcpy (GST_BUFFER_DATA (pps_buf), data, nal_size);
+      gst_buffer_fill (pps_buf, 0, data, nal_size);
       rtph264pay->pps = g_list_append (rtph264pay->pps, pps_buf);
 
       data += nal_size;
@@ -532,7 +536,7 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
     }
     /* and update the caps with the collected data */
     if (!gst_rtp_h264_pay_set_sps_pps (basepayload))
-      return FALSE;
+      goto set_sps_pps_failed;
   } else {
     GST_DEBUG_OBJECT (rtph264pay, "have bytestream h264");
     rtph264pay->packetized = FALSE;
@@ -543,16 +547,26 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
 avcc_too_small:
   {
     GST_ERROR_OBJECT (rtph264pay, "avcC size %u < 7", size);
-    return FALSE;
+    goto error;
   }
 wrong_version:
   {
     GST_ERROR_OBJECT (rtph264pay, "wrong avcC version");
-    return FALSE;
+    goto error;
   }
 avcc_error:
   {
     GST_ERROR_OBJECT (rtph264pay, "avcC too small ");
+    goto error;
+  }
+set_sps_pps_failed:
+  {
+    GST_ERROR_OBJECT (rtph264pay, "failed to set sps/pps");
+    goto error;
+  }
+error:
+  {
+    gst_buffer_unmap (buffer, bdata, bsize);
     return FALSE;
   }
 }
@@ -584,13 +598,15 @@ gst_rtp_h264_pay_parse_sprop_parameter_sets (GstRtpH264Pay * rtph264pay)
     guint8 *nalp;
     guint save = 0;
     gint state = 0;
+    guint8 nal_type;
 
     nal_len = strlen (params[i]);
     buf = gst_buffer_new_and_alloc (nal_len);
-    nalp = GST_BUFFER_DATA (buf);
 
+    nalp = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
     nal_len = g_base64_decode_step (params[i], nal_len, nalp, &state, &save);
-    GST_BUFFER_SIZE (buf) = nal_len;
+    nal_type = nalp[0];
+    gst_buffer_unmap (buf, nalp, nal_len);
 
     if (!nal_len) {
       gst_buffer_unref (buf);
@@ -598,7 +614,7 @@ gst_rtp_h264_pay_parse_sprop_parameter_sets (GstRtpH264Pay * rtph264pay)
     }
 
     /* append to the right list */
-    if ((nalp[0] & 0x1f) == 7) {
+    if ((nal_type & 0x1f) == 7) {
       GST_DEBUG_OBJECT (rtph264pay, "adding param %d as SPS %d", i, num_sps);
       rtph264pay->sps = g_list_append (rtph264pay->sps, buf);
       num_sps++;
@@ -707,8 +723,7 @@ gst_rtp_h264_pay_decode_nal (GstRtpH264Pay * payloader,
     if (payloader->sps != NULL) {
       sps_buf = GST_BUFFER_CAST (payloader->sps->data);
 
-      if ((GST_BUFFER_SIZE (sps_buf) != sps_len)
-          || memcmp (GST_BUFFER_DATA (sps_buf), sps, sps_len)) {
+      if (gst_buffer_memcmp (sps_buf, 0, sps, sps_len)) {
         /* something changed, update */
         payloader->profile = (sps[1] << 16) + (sps[2] << 8) + sps[3];
         GST_DEBUG ("Profile level IDC = %06x", payloader->profile);
@@ -721,7 +736,7 @@ gst_rtp_h264_pay_decode_nal (GstRtpH264Pay * payloader,
 
     if (updated) {
       sps_buf = gst_buffer_new_and_alloc (sps_len);
-      memcpy (GST_BUFFER_DATA (sps_buf), sps, sps_len);
+      gst_buffer_fill (sps_buf, 0, sps, sps_len);
 
       if (payloader->sps) {
         /* replace old buffer */
@@ -740,8 +755,7 @@ gst_rtp_h264_pay_decode_nal (GstRtpH264Pay * payloader,
     if (payloader->pps != NULL) {
       pps_buf = GST_BUFFER_CAST (payloader->pps->data);
 
-      if ((GST_BUFFER_SIZE (pps_buf) != pps_len)
-          || memcmp (GST_BUFFER_DATA (pps_buf), pps, pps_len)) {
+      if (gst_buffer_memcmp (pps_buf, 0, pps, pps_len)) {
         /* something changed, update */
         updated = TRUE;
       }
@@ -752,7 +766,7 @@ gst_rtp_h264_pay_decode_nal (GstRtpH264Pay * payloader,
 
     if (updated) {
       pps_buf = gst_buffer_new_and_alloc (pps_len);
-      memcpy (GST_BUFFER_DATA (pps_buf), pps, pps_len);
+      gst_buffer_fill (pps_buf, 0, pps, pps_len);
 
       if (payloader->pps) {
         /* replace old buffer */
@@ -778,15 +792,18 @@ gst_rtp_h264_pay_send_sps_pps (GstBaseRTPPayload * basepayload,
 {
   GstFlowReturn ret = GST_FLOW_OK;
   GList *walk;
+  guint8 *data;
+  gsize size;
 
   for (walk = rtph264pay->sps; walk; walk = g_list_next (walk)) {
     GstBuffer *sps_buf = GST_BUFFER_CAST (walk->data);
 
     GST_DEBUG_OBJECT (rtph264pay, "inserting SPS in the stream");
     /* resend SPS */
+    data = gst_buffer_map (sps_buf, &size, NULL, GST_MAP_READ);
     ret = gst_rtp_h264_pay_payload_nal (basepayload,
-        GST_BUFFER_DATA (sps_buf), GST_BUFFER_SIZE (sps_buf), timestamp,
-        sps_buf, FALSE);
+        data, size, timestamp, sps_buf, FALSE);
+    gst_buffer_unmap (sps_buf, data, size);
     /* Not critical here; but throw a warning */
     if (ret != GST_FLOW_OK)
       GST_WARNING ("Problem pushing SPS");
@@ -796,9 +813,10 @@ gst_rtp_h264_pay_send_sps_pps (GstBaseRTPPayload * basepayload,
 
     GST_DEBUG_OBJECT (rtph264pay, "inserting PPS in the stream");
     /* resend PPS */
+    data = gst_buffer_map (pps_buf, &size, NULL, GST_MAP_READ);
     ret = gst_rtp_h264_pay_payload_nal (basepayload,
-        GST_BUFFER_DATA (pps_buf), GST_BUFFER_SIZE (pps_buf), timestamp,
-        pps_buf, FALSE);
+        data, size, timestamp, pps_buf, FALSE);
+    gst_buffer_unmap (pps_buf, data, size);
     /* Not critical here; but throw a warning */
     if (ret != GST_FLOW_OK)
       GST_WARNING ("Problem pushing PPS");
@@ -821,9 +839,11 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
   guint packet_len, payload_len, mtu;
   GstBuffer *outbuf;
   guint8 *payload;
+#if 0
   GstBufferList *list = NULL;
-  GstBufferListIterator *it = NULL;
+#endif
   gboolean send_spspps;
+  GstRTPBuffer rtp = { NULL };
 
   rtph264pay = GST_RTP_H264_PAY (basepayload);
   mtu = GST_BASE_RTP_PAYLOAD_MTU (rtph264pay);
@@ -880,25 +900,31 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
         "NAL Unit fit in one packet datasize=%d mtu=%d", size, mtu);
     /* will fit in one packet */
 
+#if 0
     if (rtph264pay->buffer_list) {
       /* use buffer lists
        * first create buffer without payload containing only the RTP header
        * and then another buffer containing the payload. both buffers will
        * be then added to the list */
       outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
-    } else {
+    } else
+#endif
+    {
       /* use the old-fashioned way with a single buffer and memcpy */
       outbuf = gst_rtp_buffer_new_allocate (size, 0, 0);
     }
 
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+
     /* only set the marker bit on packets containing access units */
     if (IS_ACCESS_UNIT (nalType) && end_of_au) {
-      gst_rtp_buffer_set_marker (outbuf, 1);
+      gst_rtp_buffer_set_marker (&rtp, 1);
     }
 
     /* timestamp the outbuffer */
     GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
 
+#if 0
     if (rtph264pay->buffer_list) {
       GstBuffer *paybuf;
 
@@ -908,25 +934,24 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
             GST_BUFFER_DATA (buffer_orig), size);
       else {
         paybuf = gst_buffer_new_and_alloc (size);
-        memcpy (GST_BUFFER_DATA (paybuf), data, size);
+        gst_buffer_fill (paybuf, 0, data, size);
       }
 
       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, paybuf);
-
-      gst_buffer_list_iterator_free (it);
+      gst_buffer_list_add (list, outbuf);
+      gst_buffer_list_add (list, paybuf);
 
       /* push the list to the next element in the pipe */
       ret = gst_basertppayload_push_list (basepayload, list);
-    } else {
-      payload = gst_rtp_buffer_get_payload (outbuf);
+    } else
+#endif
+    {
+      payload = gst_rtp_buffer_get_payload (&rtp);
       GST_DEBUG_OBJECT (basepayload, "Copying %d bytes to outbuf", size);
       memcpy (payload, data, size);
+      gst_rtp_buffer_unmap (&rtp);
 
       ret = gst_basertppayload_push (basepayload, outbuf);
     }
@@ -951,10 +976,12 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
     /* We keep 2 bytes for FU indicator and FU Header */
     payload_len = gst_rtp_buffer_calc_payload_len (mtu - 2, 0, 0);
 
+#if 0
     if (rtph264pay->buffer_list) {
       list = gst_buffer_list_new ();
       it = gst_buffer_list_iterate (list);
     }
+#endif
 
     while (end == 0) {
       limitedSize = size < payload_len ? size : payload_len;
@@ -962,27 +989,32 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
           "Inside  FU-A fragmentation limitedSize=%d iteration=%d", limitedSize,
           ii);
 
+#if 0
       if (rtph264pay->buffer_list) {
         /* use buffer lists
          * first create buffer without payload containing only the RTP header
          * and then another buffer containing the payload. both buffers will
          * be then added to the list */
         outbuf = gst_rtp_buffer_new_allocate (2, 0, 0);
-      } else {
+      } else
+#endif
+      {
         /* use the old-fashioned way with a single buffer and memcpy
          * first create buffer to hold the payload */
         outbuf = gst_rtp_buffer_new_allocate (limitedSize + 2, 0, 0);
       }
 
+      gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+
       GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
-      payload = gst_rtp_buffer_get_payload (outbuf);
+      payload = gst_rtp_buffer_get_payload (&rtp);
 
       if (limitedSize == size) {
         GST_DEBUG_OBJECT (basepayload, "end size=%d iteration=%d", size, ii);
         end = 1;
       }
       if (IS_ACCESS_UNIT (nalType)) {
-        gst_rtp_buffer_set_marker (outbuf, end && end_of_au);
+        gst_rtp_buffer_set_marker (&rtp, end && end_of_au);
       }
 
       /* FU indicator */
@@ -991,6 +1023,7 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
       /* FU Header */
       payload[1] = (start << 7) | (end << 6) | (nalHeader & 0x1f);
 
+#if 0
       if (rtph264pay->buffer_list) {
         GstBuffer *paybuf;
 
@@ -1010,8 +1043,11 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
         gst_buffer_list_iterator_add (it, outbuf);
         gst_buffer_list_iterator_add (it, paybuf);
 
-      } else {
+      } else
+#endif
+      {
         memcpy (&payload[2], data + pos, limitedSize);
+        gst_rtp_buffer_unmap (&rtp);
         GST_DEBUG_OBJECT (basepayload,
             "recorded %d payload bytes into packet iteration=%d",
             limitedSize + 2, ii);
@@ -1027,11 +1063,13 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
       start = 0;
     }
 
+#if 0
     if (rtph264pay->buffer_list) {
       /* free iterator and push the whole buffer list at once */
       gst_buffer_list_iterator_free (it);
       ret = gst_basertppayload_push_list (basepayload, list);
     }
+#endif
   }
   return ret;
 }
@@ -1042,29 +1080,36 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 {
   GstRtpH264Pay *rtph264pay;
   GstFlowReturn ret;
-  guint size, nal_len, i;
+  gsize size;
+  guint nal_len, i;
+  guint8 *bdata = NULL;
+  gsize bsize;
   const guint8 *data, *nal_data;
   GstClockTime timestamp;
   GArray *nal_queue;
   guint pushed = 0;
+  gboolean bytestream;
 
   rtph264pay = GST_RTP_H264_PAY (basepayload);
 
   /* the input buffer contains one or more NAL units */
 
-  if (rtph264pay->scan_mode == GST_H264_SCAN_MODE_BYTESTREAM) {
+  bytestream = (rtph264pay->scan_mode == GST_H264_SCAN_MODE_BYTESTREAM);
+
+  if (bytestream) {
     timestamp = gst_adapter_prev_timestamp (rtph264pay->adapter, NULL);
     gst_adapter_push (rtph264pay->adapter, buffer);
     size = gst_adapter_available (rtph264pay->adapter);
-    data = gst_adapter_peek (rtph264pay->adapter, size);
+    data = gst_adapter_map (rtph264pay->adapter, size);
     GST_DEBUG_OBJECT (basepayload, "got %d bytes (%d)", size,
-        GST_BUFFER_SIZE (buffer));
+        gst_buffer_get_size (buffer));
 
     if (!GST_CLOCK_TIME_IS_VALID (timestamp))
       timestamp = GST_BUFFER_TIMESTAMP (buffer);
   } else {
-    size = GST_BUFFER_SIZE (buffer);
-    data = GST_BUFFER_DATA (buffer);
+    bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
+    data = bdata;
+    size = bsize;
     timestamp = GST_BUFFER_TIMESTAMP (buffer);
     GST_DEBUG_OBJECT (basepayload, "got %d bytes", size);
   }
@@ -1256,10 +1301,13 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     g_array_set_size (nal_queue, 0);
   }
 
-  if (rtph264pay->scan_mode == GST_H264_SCAN_MODE_BYTESTREAM)
-    gst_adapter_flush (rtph264pay->adapter, pushed);
-  else
+done:
+  if (bytestream) {
+    gst_adapter_unmap (rtph264pay->adapter, pushed);
+  } else {
+    gst_buffer_unmap (buffer, bdata, bsize);
     gst_buffer_unref (buffer);
+  }
 
   return ret;
 
@@ -1267,16 +1315,17 @@ caps_rejected:
   {
     GST_WARNING_OBJECT (basepayload, "Could not set outcaps");
     g_array_set_size (nal_queue, 0);
-    gst_buffer_unref (buffer);
-    return GST_FLOW_NOT_NEGOTIATED;
+    ret = GST_FLOW_NOT_NEGOTIATED;
+    goto done;
   }
 }
 
 static gboolean
-gst_rtp_h264_pay_handle_event (GstPad * pad, GstEvent * event)
+gst_rtp_h264_pay_handle_event (GstBaseRTPPayload * payload, GstEvent * event)
 {
+  gboolean res;
   const GstStructure *s;
-  GstRtpH264Pay *rtph264pay = GST_RTP_H264_PAY (GST_PAD_PARENT (pad));
+  GstRtpH264Pay *rtph264pay = GST_RTP_H264_PAY (payload);
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_FLUSH_STOP:
@@ -1296,7 +1345,10 @@ gst_rtp_h264_pay_handle_event (GstPad * pad, GstEvent * event)
       break;
   }
 
-  return FALSE;
+  res =
+      GST_BASE_RTP_PAYLOAD_CLASS (parent_class)->handle_event (payload, event);
+
+  return res;
 }
 
 static GstStateChangeReturn
index d5465c2..f8e8ab5 100644 (file)
@@ -71,7 +71,8 @@ static GstBuffer *gst_rtp_ilbc_depay_process (GstBaseRTPDepayload * depayload,
 static gboolean gst_rtp_ilbc_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRTPiLBCDepay, gst_rtp_ilbc_depay, GstBaseRTPDepayload,
+#define gst_rtp_ilbc_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPiLBCDepay, gst_rtp_ilbc_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 #define GST_TYPE_ILBC_MODE (gst_ilbc_mode_get_type())
@@ -92,27 +93,14 @@ gst_ilbc_mode_get_type (void)
 }
 
 static void
-gst_rtp_ilbc_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_ilbc_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_ilbc_depay_sink_template));
-  gst_element_class_set_details_simple (element_class, "RTP iLBC depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts iLBC audio from RTP packets (RFC 3952)",
-      "Philippe Kalaf <philippe.kalaf@collabora.co.uk>");
-}
-
-static void
 gst_rtp_ilbc_depay_class_init (GstRTPiLBCDepayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gobject_class->set_property = gst_ilbc_depay_set_property;
@@ -124,13 +112,22 @@ gst_rtp_ilbc_depay_class_init (GstRTPiLBCDepayClass * klass)
           GST_TYPE_ILBC_MODE, DEFAULT_MODE,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_ilbc_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_ilbc_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP iLBC depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts iLBC audio from RTP packets (RFC 3952)",
+      "Philippe Kalaf <philippe.kalaf@collabora.co.uk>");
+
   gstbasertpdepayload_class->process = gst_rtp_ilbc_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_ilbc_depay_setcaps;
 }
 
 static void
-gst_rtp_ilbc_depay_init (GstRTPiLBCDepay * rtpilbcdepay,
-    GstRTPiLBCDepayClass * klass)
+gst_rtp_ilbc_depay_init (GstRTPiLBCDepay * rtpilbcdepay)
 {
   /* Set default mode */
   rtpilbcdepay->mode = DEFAULT_MODE;
@@ -179,14 +176,19 @@ gst_rtp_ilbc_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstBuffer *outbuf;
   gboolean marker;
+  GstRTPBuffer rtp = { NULL };
 
-  marker = gst_rtp_buffer_get_marker (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  marker = gst_rtp_buffer_get_marker (&rtp);
 
   GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
-      GST_BUFFER_SIZE (buf), marker,
-      gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+      gst_buffer_get_size (buf), marker,
+      gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
+
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker && outbuf) {
     /* mark start of talkspurt with DISCONT */
index c070d6c..3460e7f 100644 (file)
@@ -49,44 +49,42 @@ GST_STATIC_PAD_TEMPLATE ("src",
 
 
 static GstCaps *gst_rtp_ilbc_pay_sink_getcaps (GstBaseRTPPayload * payload,
-    GstPad * pad);
+    GstPad * pad, GstCaps * filter);
 static gboolean gst_rtp_ilbc_pay_sink_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRTPILBCPay, gst_rtp_ilbc_pay, GstBaseRTPAudioPayload,
+#define gst_rtp_ilbc_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPILBCPay, gst_rtp_ilbc_pay,
     GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
 
 static void
-gst_rtp_ilbc_pay_base_init (gpointer klass)
+gst_rtp_ilbc_pay_class_init (GstRTPILBCPayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPPayloadClass *gstbasertppayload_class;
+
+  GST_DEBUG_CATEGORY_INIT (rtpilbcpay_debug, "rtpilbcpay", 0,
+      "iLBC audio RTP payloader");
 
-  gst_element_class_add_pad_template (element_class,
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_ilbc_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_ilbc_pay_src_template));
-  gst_element_class_set_details_simple (element_class, "RTP iLBC Payloader",
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP iLBC Payloader",
       "Codec/Payloader/Network/RTP",
       "Packetize iLBC audio streams into RTP packets",
       "Philippe Kalaf <philippe.kalaf@collabora.co.uk>");
-}
-
-static void
-gst_rtp_ilbc_pay_class_init (GstRTPILBCPayClass * klass)
-{
-  GstBaseRTPPayloadClass *gstbasertppayload_class;
-
-  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gstbasertppayload_class->set_caps = gst_rtp_ilbc_pay_sink_setcaps;
   gstbasertppayload_class->get_caps = gst_rtp_ilbc_pay_sink_getcaps;
-
-  GST_DEBUG_CATEGORY_INIT (rtpilbcpay_debug, "rtpilbcpay", 0,
-      "iLBC audio RTP payloader");
 }
 
 static void
-gst_rtp_ilbc_pay_init (GstRTPILBCPay * rtpilbcpay, GstRTPILBCPayClass * klass)
+gst_rtp_ilbc_pay_init (GstRTPILBCPay * rtpilbcpay)
 {
   GstBaseRTPPayload *basertppayload;
   GstBaseRTPAudioPayload *basertpaudiopayload;
@@ -177,7 +175,8 @@ mode_changed:
 /* we return the padtemplate caps with the mode field fixated to a value if we
  * can */
 static GstCaps *
-gst_rtp_ilbc_pay_sink_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad)
+gst_rtp_ilbc_pay_sink_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad,
+    GstCaps * filter)
 {
   GstCaps *otherpadcaps;
   GstCaps *caps;
index 4ac7c34..be6ba97 100644 (file)
@@ -65,8 +65,8 @@ enum
   PROP_LAST
 };
 
-GST_BOILERPLATE (GstRtpJ2KDepay, gst_rtp_j2k_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_j2k_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpJ2KDepay, gst_rtp_j2k_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void gst_rtp_j2k_depay_finalize (GObject * object);
 
@@ -85,22 +85,6 @@ static GstBuffer *gst_rtp_j2k_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
 static void
-gst_rtp_j2k_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_j2k_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_j2k_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP JPEG 2000 depayloader", "Codec/Depayloader/Network/RTP",
-      "Extracts JPEG 2000 video from RTP packets (RFC 5371)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_j2k_depay_class_init (GstRtpJ2KDepayClass * klass)
 {
   GObjectClass *gobject_class;
@@ -121,6 +105,16 @@ gst_rtp_j2k_depay_class_init (GstRtpJ2KDepayClass * klass)
           "Use Buffer Lists",
           DEFAULT_BUFFER_LIST, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_j2k_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_j2k_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP JPEG 2000 depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts JPEG 2000 video from RTP packets (RFC 5371)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   gstelement_class->change_state = gst_rtp_j2k_depay_change_state;
 
   gstbasertpdepayload_class->set_caps = gst_rtp_j2k_depay_setcaps;
@@ -131,8 +125,7 @@ gst_rtp_j2k_depay_class_init (GstRtpJ2KDepayClass * klass)
 }
 
 static void
-gst_rtp_j2k_depay_init (GstRtpJ2KDepay * rtpj2kdepay,
-    GstRtpJ2KDepayClass * klass)
+gst_rtp_j2k_depay_init (GstRtpJ2KDepay * rtpj2kdepay)
 {
   rtpj2kdepay->buffer_list = DEFAULT_BUFFER_LIST;
 
@@ -204,8 +197,7 @@ gst_rtp_j2k_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
 
   outcaps =
       gst_caps_new_simple ("image/x-jpc", "framerate", GST_TYPE_FRACTION, 0, 1,
-      "fields", G_TYPE_INT, 1, "fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('s',
-          'Y', 'U', 'V'), NULL);
+      "fields", G_TYPE_INT, 1, "colorspace", G_TYPE_STRING, "sYUV", NULL);
   res = gst_pad_set_caps (depayload->srcpad, outcaps);
   gst_caps_unref (outcaps);
 
@@ -246,7 +238,7 @@ gst_rtp_j2k_depay_flush_pu (GstBaseRTPDepayload * depayload)
     for (walk = packets; walk; walk = g_list_next (walk)) {
       GstBuffer *buf = GST_BUFFER_CAST (walk->data);
       GST_DEBUG_OBJECT (rtpj2kdepay, "append pu packet of size %u",
-          GST_BUFFER_SIZE (buf));
+          gst_buffer_get_size (buf));
       gst_adapter_push (rtpj2kdepay->t_adapter, buf);
     }
     g_list_free (packets);
@@ -274,6 +266,9 @@ gst_rtp_j2k_depay_flush_tile (GstBaseRTPDepayload * depayload)
   GList *packets, *walk;
   guint8 end[2];
   GstFlowReturn ret = GST_FLOW_OK;
+  guint8 *data;
+  gsize size;
+  GstBuffer *buf;
 
   rtpj2kdepay = GST_RTP_J2K_DEPAY (depayload);
 
@@ -307,15 +302,11 @@ gst_rtp_j2k_depay_flush_tile (GstBaseRTPDepayload * depayload)
   /* now append the tile packets to the frame */
   packets = gst_adapter_take_list (rtpj2kdepay->t_adapter, avail);
   for (walk = packets; walk; walk = g_list_next (walk)) {
-    GstBuffer *buf = GST_BUFFER_CAST (walk->data);
+    buf = GST_BUFFER_CAST (walk->data);
 
     if (walk == packets) {
-      guint8 *data;
-      guint size;
-
       /* first buffer should contain the SOT */
-      data = GST_BUFFER_DATA (buf);
-      size = GST_BUFFER_SIZE (buf);
+      data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
 
       if (size < 12)
         goto invalid_tile;
@@ -332,15 +323,19 @@ gst_rtp_j2k_depay_flush_tile (GstBaseRTPDepayload * depayload)
         if (Psot != nPsot && Psot != 0) {
           /* Psot must match the size of the tile */
           GST_DEBUG_OBJECT (rtpj2kdepay, "set Psot from %u to %u", Psot, nPsot);
+          gst_buffer_unmap (buf, data, size);
+
           buf = gst_buffer_make_writable (buf);
-          data = GST_BUFFER_DATA (buf);
+
+          data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
           GST_WRITE_UINT32_BE (&data[6], nPsot);
         }
       }
+      gst_buffer_unmap (buf, data, size);
     }
 
     GST_DEBUG_OBJECT (rtpj2kdepay, "append pu packet of size %u",
-        GST_BUFFER_SIZE (buf));
+        gst_buffer_get_size (buf));
     gst_adapter_push (rtpj2kdepay->f_adapter, buf);
   }
   g_list_free (packets);
@@ -361,6 +356,7 @@ waiting_header:
 invalid_tile:
   {
     GST_ELEMENT_WARNING (rtpj2kdepay, STREAM, DECODE, ("Invalid tile"), (NULL));
+    gst_buffer_unmap (buf, data, size);
     gst_adapter_clear (rtpj2kdepay->t_adapter);
     rtpj2kdepay->last_tile = -1;
     return ret;
@@ -372,7 +368,6 @@ gst_rtp_j2k_depay_flush_frame (GstBaseRTPDepayload * depayload)
 {
   GstRtpJ2KDepay *rtpj2kdepay;
   guint8 end[2];
-  guint8 *data;
   guint avail;
 
   GstFlowReturn ret = GST_FLOW_OK;
@@ -395,18 +390,19 @@ gst_rtp_j2k_depay_flush_frame (GstBaseRTPDepayload * depayload)
     gst_adapter_copy (rtpj2kdepay->f_adapter, end, avail - 2, 2);
 
     if (end[0] != 0xff && end[1] != 0xd9) {
+      end[0] = 0xff;
+      end[1] = 0xd9;
+
       GST_DEBUG_OBJECT (rtpj2kdepay, "no EOC marker, adding one");
 
       /* no EOI marker, add one */
       outbuf = gst_buffer_new_and_alloc (2);
-      data = GST_BUFFER_DATA (outbuf);
-      data[0] = 0xff;
-      data[1] = 0xd9;
+      gst_buffer_fill (outbuf, 0, end, 2);
 
       gst_adapter_push (rtpj2kdepay->f_adapter, outbuf);
       avail += 2;
     }
-
+#if 0
     if (rtpj2kdepay->buffer_list) {
       GList *list;
       GstBufferList *buflist;
@@ -422,7 +418,9 @@ gst_rtp_j2k_depay_flush_frame (GstBaseRTPDepayload * depayload)
       gst_buffer_list_iterator_free (it);
 
       ret = gst_base_rtp_depayload_push_list (depayload, buflist);
-    } else {
+    } else
+#endif
+    {
       GST_DEBUG_OBJECT (rtpj2kdepay, "pushing buffer of %u bytes", avail);
       outbuf = gst_adapter_take_buffer (rtpj2kdepay->f_adapter, avail);
       ret = gst_base_rtp_depayload_push (depayload, outbuf);
@@ -454,17 +452,20 @@ gst_rtp_j2k_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   guint MHF, mh_id, frag_offset, tile, payload_len, j2klen;
   gint gap;
   guint32 rtptime;
+  GstRTPBuffer rtp = { NULL };
 
   rtpj2kdepay = GST_RTP_J2K_DEPAY (depayload);
 
-  payload = gst_rtp_buffer_get_payload (buf);
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload = gst_rtp_buffer_get_payload (&rtp);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   /* we need at least a header */
   if (payload_len < 8)
     goto empty_packet;
 
-  rtptime = gst_rtp_buffer_get_timestamp (buf);
+  rtptime = gst_rtp_buffer_get_timestamp (&rtp);
 
   /* new timestamp marks new frame */
   if (rtpj2kdepay->last_rtptime != rtptime) {
@@ -561,7 +562,7 @@ gst_rtp_j2k_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     }
     /* and push in pu adapter */
     GST_DEBUG_OBJECT (rtpj2kdepay, "push pu of size %u in adapter", j2klen);
-    pu_frag = gst_rtp_buffer_get_payload_subbuffer (buf, 8, -1);
+    pu_frag = gst_rtp_buffer_get_payload_subbuffer (&rtp, 8, -1);
     gst_adapter_push (rtpj2kdepay->pu_adapter, pu_frag);
 
     if (MHF & 2) {
@@ -574,11 +575,13 @@ gst_rtp_j2k_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   }
 
   /* marker bit finishes the frame */
-  if (gst_rtp_buffer_get_marker (buf)) {
+  if (gst_rtp_buffer_get_marker (&rtp)) {
     GST_DEBUG_OBJECT (rtpj2kdepay, "marker set, last buffer");
     /* then flush frame */
     gst_rtp_j2k_depay_flush_frame (depayload);
   }
+  gst_rtp_buffer_unmap (&rtp);
+
   return NULL;
 
   /* ERRORS */
@@ -586,6 +589,7 @@ empty_packet:
   {
     GST_ELEMENT_WARNING (rtpj2kdepay, STREAM, DECODE,
         ("Empty Payload."), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 wrong_mh_id:
@@ -594,6 +598,7 @@ wrong_mh_id:
         ("Invalid mh_id %u, expected %u", mh_id, rtpj2kdepay->last_mh_id),
         (NULL));
     gst_rtp_j2k_depay_clear_pu (rtpj2kdepay);
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index 782cf22..d615ea9 100644 (file)
@@ -111,32 +111,18 @@ static gboolean gst_rtp_j2k_pay_setcaps (GstBaseRTPPayload * basepayload,
 static GstFlowReturn gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * pad,
     GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRtpJ2KPay, gst_rtp_j2k_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
-
-static void
-gst_rtp_j2k_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_j2k_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_j2k_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP JPEG 2000 payloader", "Codec/Payloader/Network/RTP",
-      "Payload-encodes JPEG 2000 pictures into RTP packets (RFC 5371)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_rtp_j2k_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpJ2KPay, gst_rtp_j2k_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gobject_class->set_property = gst_rtp_j2k_pay_set_property;
@@ -147,6 +133,16 @@ gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * klass)
           "Use Buffer Lists",
           DEFAULT_BUFFER_LIST, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_j2k_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_j2k_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP JPEG 2000 payloader", "Codec/Payloader/Network/RTP",
+      "Payload-encodes JPEG 2000 pictures into RTP packets (RFC 5371)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   gstbasertppayload_class->set_caps = gst_rtp_j2k_pay_setcaps;
   gstbasertppayload_class->handle_buffer = gst_rtp_j2k_pay_handle_buffer;
 
@@ -155,7 +151,7 @@ gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * klass)
 }
 
 static void
-gst_rtp_j2k_pay_init (GstRtpJ2KPay * pay, GstRtpJ2KPayClass * klass)
+gst_rtp_j2k_pay_init (GstRtpJ2KPay * pay)
 {
   pay->buffer_list = DEFAULT_BUFFER_LIST;
 }
@@ -336,10 +332,11 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   GstClockTime timestamp;
   GstFlowReturn ret = GST_FLOW_ERROR;
   RtpJ2KState state;
+#if 0
   GstBufferList *list = NULL;
-  GstBufferListIterator *it = NULL;
+#endif
   guint8 *data;
-  guint size;
+  gsize size;
   guint mtu, max_size;
   guint offset;
   guint end, pos;
@@ -347,8 +344,7 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   pay = GST_RTP_J2K_PAY (basepayload);
   mtu = GST_BASE_RTP_PAYLOAD_MTU (pay);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
   offset = pos = end = 0;
 
@@ -368,10 +364,12 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   state.next_sot = 0;
   state.force_packet = FALSE;
 
+#if 0
   if (pay->buffer_list) {
     list = gst_buffer_list_new ();
     it = gst_buffer_list_iterate (list);
   }
+#endif
 
   /* get max packet length */
   max_size = gst_rtp_buffer_calc_payload_len (mtu - HEADER_SIZE, 0, 0);
@@ -381,6 +379,7 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     guint8 *header;
     guint payload_size;
     guint pu_size;
+    GstRTPBuffer rtp = { NULL };
 
     /* try to pack as much as we can */
     do {
@@ -440,17 +439,22 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
       payload_size = gst_rtp_buffer_calc_payload_len (packet_size, 0, 0);
       data_size = payload_size - HEADER_SIZE;
 
+#if 0
       if (pay->buffer_list) {
         /* make buffer for header */
         outbuf = gst_rtp_buffer_new_allocate (HEADER_SIZE, 0, 0);
-      } else {
+      } else
+#endif
+      {
         /* make buffer for header and data */
         outbuf = gst_rtp_buffer_new_allocate (payload_size, 0, 0);
       }
       GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
 
+      gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+
       /* get pointer to header */
-      header = gst_rtp_buffer_get_payload (outbuf);
+      header = gst_rtp_buffer_get_payload (&rtp);
 
       pu_size -= data_size;
       if (pu_size == 0) {
@@ -464,7 +468,7 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
             state.header.MHF = 2;
         }
         if (end >= size)
-          gst_rtp_buffer_set_marker (outbuf, TRUE);
+          gst_rtp_buffer_set_marker (&rtp, TRUE);
       }
 
       /*
@@ -496,6 +500,7 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
       header[6] = (state.header.offset >> 8) & 0xff;
       header[7] = state.header.offset & 0xff;
 
+#if 0
       if (pay->buffer_list) {
         GstBuffer *paybuf;
 
@@ -508,9 +513,12 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
         /* add both buffers to the buffer list */
         gst_buffer_list_iterator_add (it, outbuf);
         gst_buffer_list_iterator_add (it, paybuf);
-      } else {
+      } else
+#endif
+      {
         /* copy payload */
         memcpy (header + HEADER_SIZE, &data[offset], data_size);
+        gst_rtp_buffer_unmap (&rtp);
 
         ret = gst_basertppayload_push (basepayload, outbuf);
         if (ret != GST_FLOW_OK)
@@ -530,11 +538,13 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 done:
   gst_buffer_unref (buffer);
 
+#if 0
   if (pay->buffer_list) {
     /* free iterator and push the whole buffer list at once */
     gst_buffer_list_iterator_free (it);
     ret = gst_basertppayload_push_list (basepayload, list);
   }
+#endif
 
   return ret;
 }
index 5ab88fb..3159925 100644 (file)
@@ -66,7 +66,8 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template =
     )
     );
 
-GST_BOILERPLATE (GstRtpJPEGDepay, gst_rtp_jpeg_depay, GstBaseRTPDepayload,
+#define gst_rtp_jpeg_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpJPEGDepay, gst_rtp_jpeg_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void gst_rtp_jpeg_depay_finalize (GObject * object);
@@ -80,22 +81,6 @@ static GstBuffer *gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
 static void
-gst_rtp_jpeg_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_jpeg_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_jpeg_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP JPEG depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts JPEG video from RTP packets (RFC 2435)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_jpeg_depay_class_init (GstRtpJPEGDepayClass * klass)
 {
   GObjectClass *gobject_class;
@@ -108,6 +93,16 @@ gst_rtp_jpeg_depay_class_init (GstRtpJPEGDepayClass * klass)
 
   gobject_class->finalize = gst_rtp_jpeg_depay_finalize;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_jpeg_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_jpeg_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP JPEG depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts JPEG video from RTP packets (RFC 2435)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   gstelement_class->change_state = gst_rtp_jpeg_depay_change_state;
 
   gstbasertpdepayload_class->set_caps = gst_rtp_jpeg_depay_setcaps;
@@ -118,8 +113,7 @@ gst_rtp_jpeg_depay_class_init (GstRtpJPEGDepayClass * klass)
 }
 
 static void
-gst_rtp_jpeg_depay_init (GstRtpJPEGDepay * rtpjpegdepay,
-    GstRtpJPEGDepayClass * klass)
+gst_rtp_jpeg_depay_init (GstRtpJPEGDepay * rtpjpegdepay)
 {
   rtpjpegdepay->adapter = gst_adapter_new ();
 }
@@ -494,6 +488,7 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   guint type, width, height;
   guint16 dri, precision, length;
   guint8 *qtable;
+  GstRTPBuffer rtp;
 
   rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload);
 
@@ -502,12 +497,13 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     rtpjpegdepay->discont = TRUE;
   }
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   if (payload_len < 8)
     goto empty_packet;
 
-  payload = gst_rtp_buffer_get_payload (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
   header_len = 0;
 
   /*  0                   1                   2                   3
@@ -607,6 +603,7 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
   if (frag_offset == 0) {
     guint size;
+    guint8 *data;
 
     if (rtpjpegdepay->width != width || rtpjpegdepay->height != height) {
       GstCaps *outcaps;
@@ -648,23 +645,23 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     }
     /* max header length, should be big enough */
     outbuf = gst_buffer_new_and_alloc (1000);
-    size = MakeHeaders (GST_BUFFER_DATA (outbuf), type,
-        width, height, qtable, precision, dri);
+    data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+    size = MakeHeaders (data, type, width, height, qtable, precision, dri);
+    gst_buffer_unmap (outbuf, data, size);
 
-    GST_DEBUG_OBJECT (rtpjpegdepay, "pushing %u bytes of header", size);
-
-    GST_BUFFER_SIZE (outbuf) = size;
+    GST_DEBUG_OBJECT (rtpjpegdepay,
+        "pushing %" G_GSIZE_FORMAT " bytes of header", size);
 
     gst_adapter_push (rtpjpegdepay->adapter, outbuf);
   }
 
   /* take JPEG data, push in the adapter */
   GST_DEBUG_OBJECT (rtpjpegdepay, "pushing data at offset %d", header_len);
-  outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, header_len, -1);
+  outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, header_len, -1);
   gst_adapter_push (rtpjpegdepay->adapter, outbuf);
   outbuf = NULL;
 
-  if (gst_rtp_buffer_get_marker (buf)) {
+  if (gst_rtp_buffer_get_marker (&rtp)) {
     guint avail;
     guint8 end[2];
     guint8 *data;
@@ -682,9 +679,10 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
       /* no EOI marker, add one */
       outbuf = gst_buffer_new_and_alloc (2);
-      data = GST_BUFFER_DATA (outbuf);
+      data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
       data[0] = 0xff;
       data[1] = 0xd9;
+      gst_buffer_unmap (outbuf, data, -1);
 
       gst_adapter_push (rtpjpegdepay->adapter, outbuf);
       avail += 2;
@@ -699,6 +697,8 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     GST_DEBUG_OBJECT (rtpjpegdepay, "returning %u bytes", avail);
   }
 
+  gst_rtp_buffer_unmap (&rtp);
+
   return outbuf;
 
   /* ERRORS */
@@ -706,17 +706,20 @@ empty_packet:
   {
     GST_ELEMENT_WARNING (rtpjpegdepay, STREAM, DECODE,
         ("Empty Payload."), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 invalid_dimension:
   {
     GST_ELEMENT_WARNING (rtpjpegdepay, STREAM, FORMAT,
         ("Invalid Dimension %dx%d.", width, height), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 no_qtable:
   {
     GST_WARNING_OBJECT (rtpjpegdepay, "no qtable");
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index 33e026b..3c8ca57 100644 (file)
@@ -236,37 +236,33 @@ static gboolean gst_rtp_jpeg_pay_setcaps (GstBaseRTPPayload * basepayload,
 static GstFlowReturn gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * pad,
     GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRtpJPEGPay, gst_rtp_jpeg_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
-
-static void
-gst_rtp_jpeg_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_jpeg_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_jpeg_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP JPEG payloader",
-      "Codec/Payloader/Network/RTP",
-      "Payload-encodes JPEG pictures into RTP packets (RFC 2435)",
-      "Axis Communications <dev-gstreamer@axis.com>");
-}
+#define gst_rtp_jpeg_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpJPEGPay, gst_rtp_jpeg_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_jpeg_pay_class_init (GstRtpJPEGPayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gobject_class->set_property = gst_rtp_jpeg_pay_set_property;
   gobject_class->get_property = gst_rtp_jpeg_pay_get_property;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_jpeg_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_jpeg_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP JPEG payloader",
+      "Codec/Payloader/Network/RTP",
+      "Payload-encodes JPEG pictures into RTP packets (RFC 2435)",
+      "Axis Communications <dev-gstreamer@axis.com>");
+
   gstbasertppayload_class->set_caps = gst_rtp_jpeg_pay_setcaps;
   gstbasertppayload_class->handle_buffer = gst_rtp_jpeg_pay_handle_buffer;
 
@@ -290,7 +286,7 @@ gst_rtp_jpeg_pay_class_init (GstRtpJPEGPayClass * klass)
 }
 
 static void
-gst_rtp_jpeg_pay_init (GstRtpJPEGPay * pay, GstRtpJPEGPayClass * klass)
+gst_rtp_jpeg_pay_init (GstRtpJPEGPay * pay)
 {
   pay->quality = DEFAULT_JPEG_QUALITY;
   pay->quant = DEFAULT_JPEG_QUANT;
@@ -611,8 +607,8 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   RtpQuantTable tables[15] = { {0, NULL}, };
   CompInfo info[3] = { {0,}, };
   guint quant_data_size;
-  guint8 *data;
-  guint size;
+  guint8 *data, *bdata;
+  gsize size;
   guint mtu;
   guint bytes_left;
   guint jpeg_header_size = 0;
@@ -621,18 +617,16 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   gboolean sos_found, sof_found, dqt_found, dri_found;
   gint i;
   GstBufferList *list = NULL;
-  GstBufferListIterator *it = NULL;
 
   pay = GST_RTP_JPEG_PAY (basepayload);
   mtu = GST_BASE_RTP_PAYLOAD_MTU (pay);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = bdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
   offset = 0;
 
-  GST_LOG_OBJECT (pay, "got buffer size %u, timestamp %" GST_TIME_FORMAT, size,
-      GST_TIME_ARGS (timestamp));
+  GST_LOG_OBJECT (pay, "got buffer size %" G_GSIZE_FORMAT
+      " , timestamp %" GST_TIME_FORMAT, size, GST_TIME_ARGS (timestamp));
 
   /* parse the jpeg header for 'start of scan' and read quant tables if needed */
   sos_found = FALSE;
@@ -737,7 +731,6 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
   if (pay->buffer_list) {
     list = gst_buffer_list_new ();
-    it = gst_buffer_list_iterate (list);
   }
 
   bytes_left = sizeof (jpeg_header) + quant_data_size + size;
@@ -750,27 +743,25 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     GstBuffer *outbuf;
     guint8 *payload;
     guint payload_size = (bytes_left < mtu ? bytes_left : mtu);
+    guint header_size;
+    GstBuffer *paybuf;
+    GstRTPBuffer rtp;
 
-    if (pay->buffer_list) {
-      guint header_size;
+    header_size = sizeof (jpeg_header) + quant_data_size;
+    if (dri_found)
+      header_size += sizeof (restart_marker_header);
 
-      header_size = sizeof (jpeg_header) + quant_data_size;
-      if (dri_found)
-        header_size += sizeof (restart_marker_header);
+    outbuf = gst_rtp_buffer_new_allocate (header_size, 0, 0);
 
-      outbuf = gst_rtp_buffer_new_allocate (header_size, 0, 0);
-    } else {
-      outbuf = gst_rtp_buffer_new_allocate (payload_size, 0, 0);
-    }
-    GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
 
     if (payload_size == bytes_left) {
       GST_LOG_OBJECT (pay, "last packet of frame");
       frame_done = TRUE;
-      gst_rtp_buffer_set_marker (outbuf, 1);
+      gst_rtp_buffer_set_marker (&rtp, 1);
     }
 
-    payload = gst_rtp_buffer_get_payload (outbuf);
+    payload = gst_rtp_buffer_get_payload (&rtp);
 
     /* update offset */
 #if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
@@ -813,20 +804,21 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
       quant_data_size = 0;
     }
     GST_LOG_OBJECT (pay, "sending payload size %d", payload_size);
+    gst_rtp_buffer_unmap (&rtp);
 
-    if (pay->buffer_list) {
-      GstBuffer *paybuf;
+    /* create a new buf to hold the payload */
+    paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY,
+        jpeg_header_size + offset, payload_size);
 
-      /* create a new buf to hold the payload */
-      paybuf = gst_buffer_create_sub (buffer, jpeg_header_size + offset,
-          payload_size);
+    /* join memory parts */
+    outbuf = gst_buffer_join (outbuf, paybuf);
 
-      /* create a new group to hold the rtp header and the payload */
-      gst_buffer_list_iterator_add_group (it);
-      gst_buffer_list_iterator_add (it, outbuf);
-      gst_buffer_list_iterator_add (it, paybuf);
+    GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
+
+    if (pay->buffer_list) {
+      /* and add to list */
+      gst_buffer_list_insert (list, -1, outbuf);
     } else {
-      memcpy (payload, data, payload_size);
       ret = gst_basertppayload_push (basepayload, outbuf);
       if (ret != GST_FLOW_OK)
         break;
@@ -839,11 +831,11 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   while (!frame_done);
 
   if (pay->buffer_list) {
-    gst_buffer_list_iterator_free (it);
     /* push the whole buffer list at once */
     ret = gst_basertppayload_push_list (basepayload, list);
   }
 
+  gst_buffer_unmap (buffer, bdata, -1);
   gst_buffer_unref (buffer);
 
   return ret;
@@ -852,24 +844,28 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 unsupported_jpeg:
   {
     GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Unsupported JPEG"), (NULL));
+    gst_buffer_unmap (buffer, bdata, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_NOT_SUPPORTED;
   }
 no_dimension:
   {
     GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("No size given"), (NULL));
+    gst_buffer_unmap (buffer, bdata, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_NOT_NEGOTIATED;
   }
 invalid_format:
   {
     /* error was posted */
+    gst_buffer_unmap (buffer, bdata, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_ERROR;
   }
 invalid_quant:
   {
     GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Invalid quant tables"), (NULL));
+    gst_buffer_unmap (buffer, bdata, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_ERROR;
   }
index b7063d6..5c4bace 100644 (file)
@@ -62,7 +62,7 @@ static GstStaticPadTemplate gst_rtp_mp1s_depay_sink_template =
         "clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"MP1S\"")
     );
 
-GST_BOILERPLATE (GstRtpMP1SDepay, gst_rtp_mp1s_depay, GstBaseRTPDepayload,
+G_DEFINE_TYPE (GstRtpMP1SDepay, gst_rtp_mp1s_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static gboolean gst_rtp_mp1s_depay_setcaps (GstBaseRTPDepayload * depayload,
@@ -71,35 +71,30 @@ static GstBuffer *gst_rtp_mp1s_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
 static void
-gst_rtp_mp1s_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp1s_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp1s_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP MPEG1 System Stream depayloader", "Codec/Depayloader/Network/RTP",
-      "Extracts MPEG1 System Streams from RTP packets (RFC 3555)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_mp1s_depay_class_init (GstRtpMP1SDepayClass * klass)
 {
+  GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
+  gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->process = gst_rtp_mp1s_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_mp1s_depay_setcaps;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp1s_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp1s_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG1 System Stream depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts MPEG1 System Streams from RTP packets (RFC 3555)",
+      "Wim Taymans <wim.taymans@gmail.com>");
 }
 
 static void
-gst_rtp_mp1s_depay_init (GstRtpMP1SDepay * rtpmp1sdepay,
-    GstRtpMP1SDepayClass * klass)
+gst_rtp_mp1s_depay_init (GstRtpMP1SDepay * rtpmp1sdepay)
 {
 }
 
@@ -128,12 +123,15 @@ static GstBuffer *
 gst_rtp_mp1s_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstBuffer *outbuf;
+  GstRTPBuffer rtp;
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   if (outbuf)
     GST_DEBUG ("gst_rtp_mp1s_depay_chain: pushing buffer of size %d",
-        GST_BUFFER_SIZE (outbuf));
+        gst_buffer_get_size (outbuf));
 
   return outbuf;
 }
index 4f5e720..e3a85be 100644 (file)
@@ -68,7 +68,7 @@ static GstStaticPadTemplate gst_rtp_mp2t_depay_sink_template =
         "clock-rate = (int) [1, MAX ]")
     );
 
-GST_BOILERPLATE (GstRtpMP2TDepay, gst_rtp_mp2t_depay, GstBaseRTPDepayload,
+G_DEFINE_TYPE (GstRtpMP2TDepay, gst_rtp_mp2t_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static gboolean gst_rtp_mp2t_depay_setcaps (GstBaseRTPDepayload * depayload,
@@ -82,30 +82,14 @@ static void gst_rtp_mp2t_depay_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
 static void
-gst_rtp_mp2t_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp2t_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp2t_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP MPEG Transport Stream depayloader", "Codec/Depayloader/Network/RTP",
-      "Extracts MPEG2 TS from RTP packets (RFC 2250)",
-      "Wim Taymans <wim.taymans@gmail.com>, "
-      "Thijs Vermeir <thijs.vermeir@barco.com>");
-}
-
-static void
 gst_rtp_mp2t_depay_class_init (GstRtpMP2TDepayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
   gobject_class = (GObjectClass *) klass;
-
+  gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->process = gst_rtp_mp2t_depay_process;
@@ -114,6 +98,17 @@ gst_rtp_mp2t_depay_class_init (GstRtpMP2TDepayClass * klass)
   gobject_class->set_property = gst_rtp_mp2t_depay_set_property;
   gobject_class->get_property = gst_rtp_mp2t_depay_get_property;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp2t_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp2t_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG Transport Stream depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts MPEG2 TS from RTP packets (RFC 2250)",
+      "Wim Taymans <wim.taymans@gmail.com>, "
+      "Thijs Vermeir <thijs.vermeir@barco.com>");
+
   g_object_class_install_property (gobject_class, PROP_SKIP_FIRST_BYTES,
       g_param_spec_uint ("skip-first-bytes",
           "Skip first bytes",
@@ -123,8 +118,7 @@ gst_rtp_mp2t_depay_class_init (GstRtpMP2TDepayClass * klass)
 }
 
 static void
-gst_rtp_mp2t_depay_init (GstRtpMP2TDepay * rtpmp2tdepay,
-    GstRtpMP2TDepayClass * klass)
+gst_rtp_mp2t_depay_init (GstRtpMP2TDepay * rtpmp2tdepay)
 {
   rtpmp2tdepay->skip_first_bytes = DEFAULT_SKIP_FIRST_BYTES;
 }
@@ -157,21 +151,24 @@ gst_rtp_mp2t_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   GstRtpMP2TDepay *rtpmp2tdepay;
   GstBuffer *outbuf;
   gint payload_len;
+  GstRTPBuffer rtp;
 
   rtpmp2tdepay = GST_RTP_MP2T_DEPAY (depayload);
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   if (G_UNLIKELY (payload_len <= rtpmp2tdepay->skip_first_bytes))
     goto empty_packet;
 
-  outbuf =
-      gst_rtp_buffer_get_payload_subbuffer (buf, rtpmp2tdepay->skip_first_bytes,
-      -1);
+  outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp,
+      rtpmp2tdepay->skip_first_bytes, -1);
+
+  gst_rtp_buffer_unmap (&rtp);
 
   if (outbuf)
     GST_DEBUG ("gst_rtp_mp2t_depay_chain: pushing buffer of size %d",
-        GST_BUFFER_SIZE (outbuf));
+        gst_buffer_get_size (outbuf));
 
   return outbuf;
 
@@ -180,6 +177,7 @@ empty_packet:
   {
     GST_ELEMENT_WARNING (rtpmp2tdepay, STREAM, DECODE,
         (NULL), ("Packet was empty"));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index 3ddb5cb..1e2589d 100644 (file)
@@ -52,41 +52,37 @@ static GstFlowReturn gst_rtp_mp2t_pay_handle_buffer (GstBaseRTPPayload *
 static GstFlowReturn gst_rtp_mp2t_pay_flush (GstRTPMP2TPay * rtpmp2tpay);
 static void gst_rtp_mp2t_pay_finalize (GObject * object);
 
-GST_BOILERPLATE (GstRTPMP2TPay, gst_rtp_mp2t_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
-
-static void
-gst_rtp_mp2t_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp2t_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp2t_pay_src_template));
-  gst_element_class_set_details_simple (element_class,
-      "RTP MPEG2 Transport Stream payloader", "Codec/Payloader/Network/RTP",
-      "Payload-encodes MPEG2 TS into RTP packets (RFC 2250)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_rtp_mp2t_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPMP2TPay, gst_rtp_mp2t_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_mp2t_pay_class_init (GstRTPMP2TPayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gobject_class->finalize = gst_rtp_mp2t_pay_finalize;
 
   gstbasertppayload_class->set_caps = gst_rtp_mp2t_pay_setcaps;
   gstbasertppayload_class->handle_buffer = gst_rtp_mp2t_pay_handle_buffer;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp2t_pay_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp2t_pay_src_template));
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG2 Transport Stream payloader", "Codec/Payloader/Network/RTP",
+      "Payload-encodes MPEG2 TS into RTP packets (RFC 2250)",
+      "Wim Taymans <wim.taymans@gmail.com>");
 }
 
 static void
-gst_rtp_mp2t_pay_init (GstRTPMP2TPay * rtpmp2tpay, GstRTPMP2TPayClass * klass)
+gst_rtp_mp2t_pay_init (GstRTPMP2TPay * rtpmp2tpay)
 {
   GST_BASE_RTP_PAYLOAD (rtpmp2tpay)->clock_rate = 90000;
   GST_BASE_RTP_PAYLOAD_PT (rtpmp2tpay) = GST_RTP_PAYLOAD_MP2T;
@@ -125,21 +121,24 @@ gst_rtp_mp2t_pay_flush (GstRTPMP2TPay * rtpmp2tpay)
   guint8 *payload;
   GstFlowReturn ret;
   GstBuffer *outbuf;
+  GstRTPBuffer rtp;
 
   avail = gst_adapter_available (rtpmp2tpay->adapter);
   outbuf = gst_rtp_buffer_new_allocate (avail, 0, 0);
 
   /* get payload */
-  payload = gst_rtp_buffer_get_payload (outbuf);
+  gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
   /* copy stuff from adapter to payload */
   gst_adapter_copy (rtpmp2tpay->adapter, payload, 0, avail);
+  gst_rtp_buffer_unmap (&rtp);
 
   GST_BUFFER_TIMESTAMP (outbuf) = rtpmp2tpay->first_ts;
   GST_BUFFER_DURATION (outbuf) = rtpmp2tpay->duration;
 
   GST_DEBUG_OBJECT (rtpmp2tpay, "pushing buffer of size %d",
-      GST_BUFFER_SIZE (outbuf));
+      gst_buffer_get_size (outbuf));
 
   ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpmp2tpay), outbuf);
 
@@ -160,7 +159,7 @@ gst_rtp_mp2t_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
   rtpmp2tpay = GST_RTP_MP2T_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
+  size = gst_buffer_get_size (buffer);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
   duration = GST_BUFFER_DURATION (buffer);
 
index 00899c4..24f8f59 100644 (file)
@@ -56,7 +56,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     )
     );
 
-GST_BOILERPLATE (GstRtpMP4ADepay, gst_rtp_mp4a_depay, GstBaseRTPDepayload,
+#define gst_rtp_mp4a_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMP4ADepay, gst_rtp_mp4a_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void gst_rtp_mp4a_depay_finalize (GObject * object);
@@ -71,23 +72,6 @@ static GstStateChangeReturn gst_rtp_mp4a_depay_change_state (GstElement *
 
 
 static void
-gst_rtp_mp4a_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4a_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4a_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP MPEG4 audio depayloader", "Codec/Depayloader/Network/RTP",
-      "Extracts MPEG4 audio from RTP packets (RFC 3016)",
-      "Nokia Corporation (contact <stefan.kost@nokia.com>), "
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_mp4a_depay_class_init (GstRtpMP4ADepayClass * klass)
 {
   GObjectClass *gobject_class;
@@ -105,13 +89,23 @@ gst_rtp_mp4a_depay_class_init (GstRtpMP4ADepayClass * klass)
   gstbasertpdepayload_class->process = gst_rtp_mp4a_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_mp4a_depay_setcaps;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4a_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4a_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG4 audio depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts MPEG4 audio from RTP packets (RFC 3016)",
+      "Nokia Corporation (contact <stefan.kost@nokia.com>), "
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtpmp4adepay_debug, "rtpmp4adepay", 0,
       "MPEG4 audio RTP Depayloader");
 }
 
 static void
-gst_rtp_mp4a_depay_init (GstRtpMP4ADepay * rtpmp4adepay,
-    GstRtpMP4ADepayClass * klass)
+gst_rtp_mp4a_depay_init (GstRtpMP4ADepay * rtpmp4adepay)
 {
   rtpmp4adepay->adapter = gst_adapter_new ();
 }
@@ -168,7 +162,7 @@ gst_rtp_mp4a_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
     if (gst_value_deserialize (&v, str)) {
       GstBuffer *buffer;
       guint8 *data;
-      guint size;
+      gsize size;
       gint i;
       guint32 rate = 0;
       guint8 obj_type = 0, sr_idx = 0, channels = 0;
@@ -178,11 +172,11 @@ gst_rtp_mp4a_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
       gst_buffer_ref (buffer);
       g_value_unset (&v);
 
-      data = GST_BUFFER_DATA (buffer);
-      size = GST_BUFFER_SIZE (buffer);
+      data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
       if (size < 2) {
-        GST_WARNING_OBJECT (depayload, "config too short (%d < 2)", size);
+        GST_WARNING_OBJECT (depayload, "config too short (%d < 2)",
+            (gint) size);
         goto bad_config;
       }
 
@@ -214,8 +208,6 @@ gst_rtp_mp4a_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
       for (i = 0; i < size; i++) {
         data[i] = ((data[i + 1] & 1) << 7) | ((data[i + 2] & 0xfe) >> 1);
       }
-      /* ignore remaining bit, we're only interested in full bytes */
-      GST_BUFFER_SIZE (buffer) = size;
 
       gst_bit_reader_init (&br, data, size);
 
@@ -273,16 +265,22 @@ gst_rtp_mp4a_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
           break;
       }
 
+      /* ignore remaining bit, we're only interested in full bytes */
+      gst_buffer_unmap (buffer, data, size);
+      data = NULL;
+
       gst_caps_set_simple (srccaps,
           "channels", G_TYPE_INT, (gint) channels,
           "rate", G_TYPE_INT, (gint) rate,
           "codec_data", GST_TYPE_BUFFER, buffer, NULL);
+    bad_config:
+      if (data)
+        gst_buffer_unmap (buffer, data, -1);
       gst_buffer_unref (buffer);
     } else {
       g_warning ("cannot convert config to buffer");
     }
   }
-bad_config:
   res = gst_pad_set_caps (depayload->srcpad, srccaps);
   gst_caps_unref (srccaps);
 
@@ -294,6 +292,8 @@ gst_rtp_mp4a_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstRtpMP4ADepay *rtpmp4adepay;
   GstBuffer *outbuf;
+  GstRTPBuffer rtp;
+  guint8 *bdata;
 
   rtpmp4adepay = GST_RTP_MP4A_DEPAY (depayload);
 
@@ -302,14 +302,16 @@ gst_rtp_mp4a_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     gst_adapter_clear (rtpmp4adepay->adapter);
   }
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
 
-  gst_buffer_copy_metadata (outbuf, buf, GST_BUFFER_COPY_TIMESTAMPS);
+  outbuf = gst_buffer_make_writable (outbuf);
+  GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
   gst_adapter_push (rtpmp4adepay->adapter, outbuf);
 
   /* RTP marker bit indicates the last packet of the AudioMuxElement => create
    * and push a buffer */
-  if (gst_rtp_buffer_get_marker (buf)) {
+  if (gst_rtp_buffer_get_marker (&rtp)) {
     guint avail;
     guint i;
     guint8 *data;
@@ -322,7 +324,7 @@ gst_rtp_mp4a_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     GST_LOG_OBJECT (rtpmp4adepay, "have marker and %u available", avail);
 
     outbuf = gst_adapter_take_buffer (rtpmp4adepay->adapter, avail);
-    data = GST_BUFFER_DATA (outbuf);
+    data = bdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_READ);
     /* position in data we are at */
     pos = 0;
 
@@ -353,7 +355,8 @@ gst_rtp_mp4a_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
       /* take data out, skip the header */
       pos += skip;
-      tmp = gst_buffer_create_sub (outbuf, pos, data_len);
+      tmp = gst_buffer_copy_region (outbuf, GST_BUFFER_COPY_MEMORY, pos,
+          data_len);
 
       /* skip data too */
       skip += data_len;
@@ -382,8 +385,10 @@ gst_rtp_mp4a_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
               "possible wrongly encoded packet."));
     }
 
+    gst_buffer_unmap (outbuf, bdata, -1);
     gst_buffer_unref (outbuf);
   }
+  gst_rtp_buffer_unmap (&rtp);
   return NULL;
 
   /* ERRORS */
@@ -391,7 +396,9 @@ wrong_size:
   {
     GST_ELEMENT_WARNING (rtpmp4adepay, STREAM, DECODE,
         ("Packet did not validate"), ("wrong packet size"));
+    gst_buffer_unmap (outbuf, bdata, -1);
     gst_buffer_unref (outbuf);
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index 70fdbed..59c7e60 100644 (file)
@@ -64,31 +64,17 @@ static gboolean gst_rtp_mp4a_pay_setcaps (GstBaseRTPPayload * payload,
 static GstFlowReturn gst_rtp_mp4a_pay_handle_buffer (GstBaseRTPPayload *
     payload, GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRtpMP4APay, gst_rtp_mp4a_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD)
+#define gst_rtp_mp4a_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMP4APay, gst_rtp_mp4a_pay, GST_TYPE_BASE_RTP_PAYLOAD)
 
-     static void gst_rtp_mp4a_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4a_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4a_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP MPEG4 audio payloader", "Codec/Payloader/Network/RTP",
-      "Payload MPEG4 audio as RTP packets (RFC 3016)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_mp4a_pay_class_init (GstRtpMP4APayClass * klass)
+     static void gst_rtp_mp4a_pay_class_init (GstRtpMP4APayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gobject_class->finalize = gst_rtp_mp4a_pay_finalize;
@@ -96,12 +82,22 @@ gst_rtp_mp4a_pay_class_init (GstRtpMP4APayClass * klass)
   gstbasertppayload_class->set_caps = gst_rtp_mp4a_pay_setcaps;
   gstbasertppayload_class->handle_buffer = gst_rtp_mp4a_pay_handle_buffer;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4a_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4a_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG4 audio payloader", "Codec/Payloader/Network/RTP",
+      "Payload MPEG4 audio as RTP packets (RFC 3016)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtpmp4apay_debug, "rtpmp4apay", 0,
       "MP4A-LATM RTP Payloader");
 }
 
 static void
-gst_rtp_mp4a_pay_init (GstRtpMP4APay * rtpmp4apay, GstRtpMP4APayClass * klass)
+gst_rtp_mp4a_pay_init (GstRtpMP4APay * rtpmp4apay)
 {
   rtpmp4apay->rate = 90000;
   rtpmp4apay->profile = g_strdup ("1");
@@ -137,13 +133,12 @@ gst_rtp_mp4a_pay_parse_audio_config (GstRtpMP4APay * rtpmp4apay,
     GstBuffer * buffer)
 {
   guint8 *data;
-  guint size;
+  gsize size;
   guint8 objectType;
   guint8 samplingIdx;
   guint8 channelCfg;
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   if (size < 2)
     goto too_short;
@@ -187,6 +182,8 @@ gst_rtp_mp4a_pay_parse_audio_config (GstRtpMP4APay * rtpmp4apay,
       "objectType: %d, samplingIdx: %d (%d), channelCfg: %d", objectType,
       samplingIdx, rtpmp4apay->rate, channelCfg);
 
+  gst_buffer_unmap (buffer, data, -1);
+
   return TRUE;
 
   /* ERROR */
@@ -194,24 +191,28 @@ too_short:
   {
     GST_ELEMENT_ERROR (rtpmp4apay, STREAM, FORMAT,
         (NULL), ("config string too short, expected 2 bytes, got %d", size));
+    gst_buffer_unmap (buffer, data, -1);
     return FALSE;
   }
 invalid_object:
   {
     GST_ELEMENT_ERROR (rtpmp4apay, STREAM, FORMAT,
         (NULL), ("invalid object type 0"));
+    gst_buffer_unmap (buffer, data, -1);
     return FALSE;
   }
 wrong_freq:
   {
     GST_ELEMENT_ERROR (rtpmp4apay, STREAM, NOT_IMPLEMENTED,
         (NULL), ("unsupported frequency index %d", samplingIdx));
+    gst_buffer_unmap (buffer, data, -1);
     return FALSE;
   }
 wrong_channels:
   {
     GST_ELEMENT_ERROR (rtpmp4apay, STREAM, NOT_IMPLEMENTED,
         (NULL), ("unsupported number of channels %d, must < 8", channelCfg));
+    gst_buffer_unmap (buffer, data, -1);
     return FALSE;
   }
 }
@@ -271,7 +272,8 @@ gst_rtp_mp4a_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
       GstBuffer *buffer, *cbuffer;
       guint8 *config;
       guint8 *data;
-      guint size, i;
+      guint i;
+      gsize size;
 
       buffer = gst_value_get_buffer (codec_data);
       GST_LOG_OBJECT (rtpmp4apay, "configuring codec_data");
@@ -282,11 +284,11 @@ gst_rtp_mp4a_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
       if (!res)
         goto config_failed;
 
-      size = GST_BUFFER_SIZE (buffer);
-      data = GST_BUFFER_DATA (buffer);
+      data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
       /* make the StreamMuxConfig, we need 15 bits for the header */
-      config = g_malloc0 (size + 2);
+      cbuffer = gst_buffer_new_and_alloc (size + 2);
+      config = gst_buffer_map (cbuffer, NULL, NULL, GST_MAP_WRITE);
 
       /* Create StreamMuxConfig according to ISO/IEC 14496-3:
        *
@@ -305,10 +307,8 @@ gst_rtp_mp4a_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
         config[i + 2] |= ((data[i] & 0x7f) << 1);
       }
 
-      cbuffer = gst_buffer_new ();
-      GST_BUFFER_DATA (cbuffer) = config;
-      GST_BUFFER_MALLOCDATA (cbuffer) = config;
-      GST_BUFFER_SIZE (cbuffer) = size + 2;
+      gst_buffer_unmap (cbuffer, config, -1);
+      gst_buffer_unmap (buffer, data, -1);
 
       /* now we can configure the buffer */
       if (rtpmp4apay->config)
@@ -345,8 +345,9 @@ gst_rtp_mp4a_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   GstRtpMP4APay *rtpmp4apay;
   GstFlowReturn ret;
   GstBuffer *outbuf;
-  guint count, mtu, size;
-  guint8 *data;
+  guint count, mtu;
+  gsize size;
+  guint8 *data, *bdata;
   gboolean fragmented;
   GstClockTime timestamp;
 
@@ -354,8 +355,7 @@ gst_rtp_mp4a_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
   rtpmp4apay = GST_RTP_MP4A_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = bdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
 
   fragmented = FALSE;
@@ -366,6 +366,7 @@ gst_rtp_mp4a_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     guint8 *payload;
     guint payload_len;
     guint packet_len;
+    GstRTPBuffer rtp;
 
     /* this will be the total lenght of the packet */
     packet_len = gst_rtp_buffer_calc_packet_len (size, 0, 0);
@@ -394,7 +395,8 @@ gst_rtp_mp4a_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     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);
 
     if (!fragmented) {
       /* first packet write the header */
@@ -414,7 +416,9 @@ gst_rtp_mp4a_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     size -= payload_len;
 
     /* marker only if the packet is complete */
-    gst_rtp_buffer_set_marker (outbuf, size == 0);
+    gst_rtp_buffer_set_marker (&rtp, size == 0);
+
+    gst_rtp_buffer_unmap (&rtp);
 
     /* copy incomming timestamp (if any) to outgoing buffers */
     GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
@@ -424,6 +428,7 @@ gst_rtp_mp4a_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     fragmented = TRUE;
   }
 
+  gst_buffer_unmap (buffer, bdata, -1);
   gst_buffer_unref (buffer);
 
   return ret;
index 02ac8d6..5a3d59c 100644 (file)
@@ -126,7 +126,8 @@ gst_bs_parse_read (GstBsParse * bs, guint n)
 }
 
 
-GST_BOILERPLATE (GstRtpMP4GDepay, gst_rtp_mp4g_depay, GstBaseRTPDepayload,
+#define gst_rtp_mp4g_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMP4GDepay, gst_rtp_mp4g_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void gst_rtp_mp4g_depay_finalize (GObject * object);
@@ -143,22 +144,6 @@ static GstStateChangeReturn gst_rtp_mp4g_depay_change_state (GstElement *
 
 
 static void
-gst_rtp_mp4g_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4g_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4g_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP MPEG4 ES depayloader", "Codec/Depayloader/Network/RTP",
-      "Extracts MPEG4 elementary streams from RTP packets (RFC 3640)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_mp4g_depay_class_init (GstRtpMP4GDepayClass * klass)
 {
   GObjectClass *gobject_class;
@@ -177,13 +162,22 @@ gst_rtp_mp4g_depay_class_init (GstRtpMP4GDepayClass * klass)
   gstbasertpdepayload_class->set_caps = gst_rtp_mp4g_depay_setcaps;
   gstbasertpdepayload_class->handle_event = gst_rtp_mp4g_depay_handle_event;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4g_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4g_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG4 ES depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts MPEG4 elementary streams from RTP packets (RFC 3640)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtpmp4gdepay_debug, "rtpmp4gdepay", 0,
       "MP4-generic RTP Depayloader");
 }
 
 static void
-gst_rtp_mp4g_depay_init (GstRtpMP4GDepay * rtpmp4gdepay,
-    GstRtpMP4GDepayClass * klass)
+gst_rtp_mp4g_depay_init (GstRtpMP4GDepay * rtpmp4gdepay)
 {
   rtpmp4gdepay->adapter = gst_adapter_new ();
   rtpmp4gdepay->packets = g_queue_new ();
@@ -428,8 +422,9 @@ static GstBuffer *
 gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstRtpMP4GDepay *rtpmp4gdepay;
-  GstBuffer *outbuf;
+  GstBuffer *outbuf = NULL;
   GstClockTime timestamp;
+  GstRTPBuffer rtp;
 
   rtpmp4gdepay = GST_RTP_MP4G_DEPAY (depayload);
 
@@ -449,13 +444,16 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     guint AU_size, AU_index, AU_index_delta, payload_AU_size;
     gboolean M;
 
-    payload_len = gst_rtp_buffer_get_payload_len (buf);
-    payload = gst_rtp_buffer_get_payload (buf);
+    gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+    payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+    payload = gst_rtp_buffer_get_payload (&rtp);
 
     GST_DEBUG_OBJECT (rtpmp4gdepay, "received payload of %d", payload_len);
 
-    rtptime = gst_rtp_buffer_get_timestamp (buf);
-    M = gst_rtp_buffer_get_marker (buf);
+    rtptime = gst_rtp_buffer_get_timestamp (&rtp);
+    M = gst_rtp_buffer_get_marker (&rtp);
+
+    gst_rtp_buffer_unmap (&rtp);
 
     if (rtpmp4gdepay->sizelength > 0) {
       gint num_AU_headers, AU_headers_bytes, i;
@@ -653,7 +651,7 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
         /* collect stuff in the adapter, strip header from payload and push in
          * the adapter */
         outbuf =
-            gst_rtp_buffer_get_payload_subbuffer (buf, payload_AU, AU_size);
+            gst_rtp_buffer_get_payload_subbuffer (&rtp, payload_AU, AU_size);
         gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
 
         if (M) {
@@ -663,7 +661,6 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
           avail = gst_adapter_available (rtpmp4gdepay->adapter);
 
           outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
-          gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
 
           /* copy some of the fields we calculated above on the buffer. We also
            * copy the AU_index so that we can sort the packets in our queue. */
@@ -675,7 +672,7 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
           timestamp = -1;
 
           GST_DEBUG_OBJECT (depayload, "pushing buffer of size %d",
-              GST_BUFFER_SIZE (outbuf));
+              gst_buffer_get_size (outbuf));
 
           gst_rtp_mp4g_depay_queue (rtpmp4gdepay, outbuf);
 
@@ -685,7 +682,7 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
       }
     } else {
       /* push complete buffer in adapter */
-      outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 0, payload_len);
+      outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, 0, payload_len);
       gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
 
       /* if this was the last packet of the VOP, create and push a buffer */
@@ -697,12 +694,15 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
         outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
 
         GST_DEBUG ("gst_rtp_mp4g_depay_chain: pushing buffer of size %d",
-            GST_BUFFER_SIZE (outbuf));
+            gst_buffer_get_size (outbuf));
 
+        gst_rtp_buffer_unmap (&rtp);
         return outbuf;
       }
     }
   }
+
+  gst_rtp_buffer_unmap (&rtp);
   return NULL;
 
   /* ERRORS */
@@ -710,6 +710,7 @@ short_payload:
   {
     GST_ELEMENT_WARNING (rtpmp4gdepay, STREAM, DECODE,
         ("Packet payload was too short."), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index b3a6966..1514911 100644 (file)
@@ -82,28 +82,13 @@ static gboolean gst_rtp_mp4g_pay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 static GstFlowReturn gst_rtp_mp4g_pay_handle_buffer (GstBaseRTPPayload *
     payload, GstBuffer * buffer);
-static gboolean gst_rtp_mp4g_pay_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_mp4g_pay_handle_event (GstBaseRTPPayload * payload,
+    GstEvent * event);
 
-GST_BOILERPLATE (GstRtpMP4GPay, gst_rtp_mp4g_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD)
+#define gst_rtp_mp4g_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMP4GPay, gst_rtp_mp4g_pay, GST_TYPE_BASE_RTP_PAYLOAD)
 
-     static void gst_rtp_mp4g_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4g_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4g_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP MPEG4 ES payloader",
-      "Codec/Payloader/Network/RTP",
-      "Payload MPEG4 elementary streams as RTP packets (RFC 3640)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_mp4g_pay_class_init (GstRtpMP4GPayClass * klass)
+     static void gst_rtp_mp4g_pay_class_init (GstRtpMP4GPayClass * klass)
 {
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
@@ -121,12 +106,23 @@ gst_rtp_mp4g_pay_class_init (GstRtpMP4GPayClass * klass)
   gstbasertppayload_class->handle_buffer = gst_rtp_mp4g_pay_handle_buffer;
   gstbasertppayload_class->handle_event = gst_rtp_mp4g_pay_handle_event;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4g_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4g_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG4 ES payloader",
+      "Codec/Payloader/Network/RTP",
+      "Payload MPEG4 elementary streams as RTP packets (RFC 3640)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtpmp4gpay_debug, "rtpmp4gpay", 0,
       "MP4-generic RTP Payloader");
 }
 
 static void
-gst_rtp_mp4g_pay_init (GstRtpMP4GPay * rtpmp4gpay, GstRtpMP4GPayClass * klass)
+gst_rtp_mp4g_pay_init (GstRtpMP4GPay * rtpmp4gpay)
 {
   rtpmp4gpay->adapter = gst_adapter_new ();
 }
@@ -186,14 +182,13 @@ gst_rtp_mp4g_pay_parse_audio_config (GstRtpMP4GPay * rtpmp4gpay,
     GstBuffer * buffer)
 {
   guint8 *data;
-  guint size;
+  gsize size;
   guint8 objectType = 0;
   guint8 samplingIdx = 0;
   guint8 channelCfg = 0;
   GstBitReader br;
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   gst_bit_reader_init (&br, data, size);
 
@@ -266,6 +261,7 @@ gst_rtp_mp4g_pay_parse_audio_config (GstRtpMP4GPay * rtpmp4gpay,
       objectType, samplingIdx, rtpmp4gpay->rate, channelCfg,
       rtpmp4gpay->frame_len);
 
+  gst_buffer_unmap (buffer, data, -1);
   return TRUE;
 
   /* ERROR */
@@ -273,24 +269,28 @@ too_short:
   {
     GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
         (NULL), ("config string too short"));
+    gst_buffer_unmap (buffer, data, -1);
     return FALSE;
   }
 invalid_object:
   {
     GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
         (NULL), ("invalid object type"));
+    gst_buffer_unmap (buffer, data, -1);
     return FALSE;
   }
 wrong_freq:
   {
     GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, NOT_IMPLEMENTED,
         (NULL), ("unsupported frequency index %d", samplingIdx));
+    gst_buffer_unmap (buffer, data, -1);
     return FALSE;
   }
 wrong_channels:
   {
     GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, NOT_IMPLEMENTED,
         (NULL), ("unsupported number of channels %d, must < 8", channelCfg));
+    gst_buffer_unmap (buffer, data, -1);
     return FALSE;
   }
 }
@@ -302,11 +302,10 @@ gst_rtp_mp4g_pay_parse_video_config (GstRtpMP4GPay * rtpmp4gpay,
     GstBuffer * buffer)
 {
   guint8 *data;
-  guint size;
+  gsize size;
   guint32 code;
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   if (size < 5)
     goto too_short;
@@ -334,6 +333,8 @@ gst_rtp_mp4g_pay_parse_video_config (GstRtpMP4GPay * rtpmp4gpay,
 
   GST_LOG_OBJECT (rtpmp4gpay, "profile %s", rtpmp4gpay->profile);
 
+  gst_buffer_unmap (buffer, data, -1);
+
   return TRUE;
 
   /* ERROR */
@@ -341,6 +342,7 @@ too_short:
   {
     GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
         (NULL), ("config string too short"));
+    gst_buffer_unmap (buffer, data, -1);
     return FALSE;
   }
 }
@@ -468,6 +470,7 @@ gst_rtp_mp4g_pay_flush (GstRtpMP4GPay * rtpmp4gpay)
     guint8 *payload;
     guint payload_len;
     guint packet_len;
+    GstRTPBuffer rtp;
 
     /* this will be the total lenght of the packet */
     packet_len = gst_rtp_buffer_calc_packet_len (avail, 0, 0);
@@ -486,8 +489,10 @@ gst_rtp_mp4g_pay_flush (GstRtpMP4GPay * rtpmp4gpay)
     /* create buffer to hold the payload, also make room for the 4 header bytes. */
     outbuf = gst_rtp_buffer_new_allocate (payload_len + 4, 0, 0);
 
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+
     /* copy payload */
-    payload = gst_rtp_buffer_get_payload (outbuf);
+    payload = gst_rtp_buffer_get_payload (&rtp);
 
     /* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- .. -+-+-+-+-+-+-+-+-+-+
      * |AU-headers-length|AU-header|AU-header|      |AU-header|padding|
@@ -528,7 +533,9 @@ gst_rtp_mp4g_pay_flush (GstRtpMP4GPay * rtpmp4gpay)
     gst_adapter_flush (rtpmp4gpay->adapter, payload_len);
 
     /* marker only if the packet is complete */
-    gst_rtp_buffer_set_marker (outbuf, avail <= payload_len);
+    gst_rtp_buffer_set_marker (&rtp, avail <= payload_len);
+
+    gst_rtp_buffer_unmap (&rtp);
 
     GST_BUFFER_TIMESTAMP (outbuf) = rtpmp4gpay->first_timestamp;
     GST_BUFFER_DURATION (outbuf) = rtpmp4gpay->first_duration;
@@ -566,16 +573,16 @@ gst_rtp_mp4g_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 }
 
 static gboolean
-gst_rtp_mp4g_pay_handle_event (GstPad * pad, GstEvent * event)
+gst_rtp_mp4g_pay_handle_event (GstBaseRTPPayload * payload, GstEvent * event)
 {
   GstRtpMP4GPay *rtpmp4gpay;
 
-  rtpmp4gpay = GST_RTP_MP4G_PAY (gst_pad_get_parent (pad));
+  rtpmp4gpay = GST_RTP_MP4G_PAY (payload);
 
   GST_DEBUG ("Got event: %s", GST_EVENT_TYPE_NAME (event));
 
   switch (GST_EVENT_TYPE (event)) {
-    case GST_EVENT_NEWSEGMENT:
+    case GST_EVENT_SEGMENT:
     case GST_EVENT_EOS:
       /* This flush call makes sure that the last buffer is always pushed
        * to the base payloader */
@@ -588,8 +595,6 @@ gst_rtp_mp4g_pay_handle_event (GstPad * pad, GstEvent * event)
       break;
   }
 
-  g_object_unref (rtpmp4gpay);
-
   /* let parent handle event too */
   return FALSE;
 }
index ce18cec..84acff0 100644 (file)
@@ -53,7 +53,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     )
     );
 
-GST_BOILERPLATE (GstRtpMP4VDepay, gst_rtp_mp4v_depay, GstBaseRTPDepayload,
+#define gst_rtp_mp4v_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMP4VDepay, gst_rtp_mp4v_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void gst_rtp_mp4v_depay_finalize (GObject * object);
@@ -66,23 +67,6 @@ static GstBuffer *gst_rtp_mp4v_depay_process (GstBaseRTPDepayload * depayload,
 static GstStateChangeReturn gst_rtp_mp4v_depay_change_state (GstElement *
     element, GstStateChange transition);
 
-
-static void
-gst_rtp_mp4v_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4v_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4v_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP MPEG4 video depayloader", "Codec/Depayloader/Network/RTP",
-      "Extracts MPEG4 video from RTP packets (RFC 3016)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
 static void
 gst_rtp_mp4v_depay_class_init (GstRtpMP4VDepayClass * klass)
 {
@@ -101,13 +85,22 @@ gst_rtp_mp4v_depay_class_init (GstRtpMP4VDepayClass * klass)
   gstbasertpdepayload_class->process = gst_rtp_mp4v_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_mp4v_depay_setcaps;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4v_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4v_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG4 video depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts MPEG4 video from RTP packets (RFC 3016)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtpmp4vdepay_debug, "rtpmp4vdepay", 0,
       "MPEG4 video RTP Depayloader");
 }
 
 static void
-gst_rtp_mp4v_depay_init (GstRtpMP4VDepay * rtpmp4vdepay,
-    GstRtpMP4VDepayClass * klass)
+gst_rtp_mp4v_depay_init (GstRtpMP4VDepay * rtpmp4vdepay)
 {
   rtpmp4vdepay->adapter = gst_adapter_new ();
 }
@@ -170,7 +163,8 @@ static GstBuffer *
 gst_rtp_mp4v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstRtpMP4VDepay *rtpmp4vdepay;
-  GstBuffer *outbuf;
+  GstBuffer *outbuf = NULL;
+  GstRTPBuffer rtp;
 
   rtpmp4vdepay = GST_RTP_MP4V_DEPAY (depayload);
 
@@ -178,11 +172,12 @@ gst_rtp_mp4v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   if (GST_BUFFER_IS_DISCONT (buf))
     gst_adapter_clear (rtpmp4vdepay->adapter);
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
   gst_adapter_push (rtpmp4vdepay->adapter, outbuf);
 
   /* if this was the last packet of the VOP, create and push a buffer */
-  if (gst_rtp_buffer_get_marker (buf)) {
+  if (gst_rtp_buffer_get_marker (&rtp)) {
     guint avail;
 
     avail = gst_adapter_available (rtpmp4vdepay->adapter);
@@ -190,11 +185,12 @@ gst_rtp_mp4v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     outbuf = gst_adapter_take_buffer (rtpmp4vdepay->adapter, avail);
 
     GST_DEBUG ("gst_rtp_mp4v_depay_chain: pushing buffer of size %d",
-        GST_BUFFER_SIZE (outbuf));
-
-    return outbuf;
+        gst_buffer_get_size (outbuf));
   }
-  return NULL;
+
+  gst_rtp_buffer_unmap (&rtp);
+
+  return outbuf;
 }
 
 static GstStateChangeReturn
index e11fbfc..21b8d0d 100644 (file)
@@ -78,38 +78,35 @@ static gboolean gst_rtp_mp4v_pay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 static GstFlowReturn gst_rtp_mp4v_pay_handle_buffer (GstBaseRTPPayload *
     payload, GstBuffer * buffer);
-static gboolean gst_rtp_mp4v_pay_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_mp4v_pay_handle_event (GstBaseRTPPayload * pay,
+    GstEvent * event);
 
-GST_BOILERPLATE (GstRtpMP4VPay, gst_rtp_mp4v_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD)
+#define gst_rtp_mp4v_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMP4VPay, gst_rtp_mp4v_pay, GST_TYPE_BASE_RTP_PAYLOAD)
 
-     static void gst_rtp_mp4v_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4v_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mp4v_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP MPEG4 Video payloader", "Codec/Payloader/Network/RTP",
-      "Payload MPEG-4 video as RTP packets (RFC 3016)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_mp4v_pay_class_init (GstRtpMP4VPayClass * klass)
+     static void gst_rtp_mp4v_pay_class_init (GstRtpMP4VPayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gobject_class->set_property = gst_rtp_mp4v_pay_set_property;
   gobject_class->get_property = gst_rtp_mp4v_pay_get_property;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4v_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mp4v_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG4 Video payloader", "Codec/Payloader/Network/RTP",
+      "Payload MPEG-4 video as RTP packets (RFC 3016)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SEND_CONFIG,
       g_param_spec_boolean ("send-config", "Send Config",
           "Send the config parameters in RTP packets as well(deprecated "
@@ -140,7 +137,7 @@ gst_rtp_mp4v_pay_class_init (GstRtpMP4VPayClass * klass)
 }
 
 static void
-gst_rtp_mp4v_pay_init (GstRtpMP4VPay * rtpmp4vpay, GstRtpMP4VPayClass * klass)
+gst_rtp_mp4v_pay_init (GstRtpMP4VPay * rtpmp4vpay)
 {
   rtpmp4vpay->adapter = gst_adapter_new ();
   rtpmp4vpay->rate = 90000;
@@ -216,20 +213,15 @@ gst_rtp_mp4v_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
     GST_LOG_OBJECT (rtpmp4vpay, "got codec_data");
     if (G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) {
       GstBuffer *buffer;
-      guint8 *data;
-      guint size;
 
       buffer = gst_value_get_buffer (codec_data);
 
-      data = GST_BUFFER_DATA (buffer);
-      size = GST_BUFFER_SIZE (buffer);
-
-      if (size < 5)
+      if (gst_buffer_get_size (buffer) < 5)
         goto done;
 
-      rtpmp4vpay->profile = data[4];
+      gst_buffer_extract (buffer, 4, &rtpmp4vpay->profile, 1);
       GST_LOG_OBJECT (rtpmp4vpay, "configuring codec_data, profile %d",
-          data[4]);
+          rtpmp4vpay->profile);
 
       if (rtpmp4vpay->config)
         gst_buffer_unref (rtpmp4vpay->config);
@@ -256,7 +248,6 @@ gst_rtp_mp4v_pay_flush (GstRtpMP4VPay * rtpmp4vpay)
   GstBuffer *outbuf_data = NULL;
   GstFlowReturn ret;
   GstBufferList *list = NULL;
-  GstBufferListIterator *it = NULL;
 
   /* the data available in the adapter is either smaller
    * than the MTU or bigger. In the case it is smaller, the complete
@@ -281,14 +272,13 @@ gst_rtp_mp4v_pay_flush (GstRtpMP4VPay * rtpmp4vpay)
      * of buffers and the whole list will be pushed downstream
      * at once */
     list = gst_buffer_list_new ();
-    it = gst_buffer_list_iterate (list);
   }
 
   while (avail > 0) {
     guint towrite;
-    guint8 *payload;
     guint payload_len;
     guint packet_len;
+    GstRTPBuffer rtp;
 
     /* this will be the total lenght of the packet */
     packet_len = gst_rtp_buffer_calc_packet_len (avail, 0, 0);
@@ -299,43 +289,32 @@ gst_rtp_mp4v_pay_flush (GstRtpMP4VPay * rtpmp4vpay)
     /* this is the payload length */
     payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0);
 
-    if (rtpmp4vpay->buffer_list) {
-      /* create buffer without payload. The payload will be put
-       * in next buffer instead. Both buffers will be then added
-       * to the list */
-      outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
-
-      /* Take buffer with the payload from the adapter */
-      outbuf_data = gst_adapter_take_buffer (rtpmp4vpay->adapter, payload_len);
-    } else {
-      /* 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);
+    /* create buffer without payload. The payload will be put
+     * in next buffer instead. Both buffers will be merged */
+    outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
 
-      gst_adapter_copy (rtpmp4vpay->adapter, payload, 0, payload_len);
-      gst_adapter_flush (rtpmp4vpay->adapter, payload_len);
-    }
+    /* Take buffer with the payload from the adapter */
+    outbuf_data = gst_adapter_take_buffer (rtpmp4vpay->adapter, payload_len);
 
     avail -= payload_len;
 
-    gst_rtp_buffer_set_marker (outbuf, avail == 0);
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+    gst_rtp_buffer_set_marker (&rtp, avail == 0);
+    gst_rtp_buffer_unmap (&rtp);
+
+    outbuf = gst_buffer_join (outbuf, outbuf_data);
 
     GST_BUFFER_TIMESTAMP (outbuf) = rtpmp4vpay->first_timestamp;
 
     if (rtpmp4vpay->buffer_list) {
-      /* create a new group to hold the rtp header and the payload */
-      gst_buffer_list_iterator_add_group (it);
-      gst_buffer_list_iterator_add (it, outbuf);
-      gst_buffer_list_iterator_add (it, outbuf_data);
+      /* add to list */
+      gst_buffer_list_insert (list, -1, outbuf);
     } else {
       ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpmp4vpay), outbuf);
     }
   }
 
   if (rtpmp4vpay->buffer_list) {
-    gst_buffer_list_iterator_free (it);
     /* push the whole buffer list at once */
     ret =
         gst_basertppayload_push_list (GST_BASE_RTP_PAYLOAD (rtpmp4vpay), list);
@@ -400,16 +379,20 @@ gst_rtp_mp4v_pay_depay_data (GstRtpMP4VPay * enc, guint8 * data, guint size,
       /* see if config changed */
       equal = FALSE;
       if (enc->config) {
-        if (GST_BUFFER_SIZE (enc->config) == i) {
-          equal = memcmp (GST_BUFFER_DATA (enc->config), data, i) == 0;
+        if (gst_buffer_get_size (enc->config) == i) {
+          equal = gst_buffer_memcmp (enc->config, 0, data, i) == 0;
         }
       }
       /* if config string changed or new profile, make new caps */
       if (!equal || newprofile) {
+        guint8 *bdata;
+
         if (enc->config)
           gst_buffer_unref (enc->config);
         enc->config = gst_buffer_new_and_alloc (i);
-        memcpy (GST_BUFFER_DATA (enc->config), data, i);
+        bdata = gst_buffer_map (enc->config, NULL, NULL, GST_MAP_WRITE);
+        memcpy (bdata, data, i);
+        gst_buffer_unmap (enc->config, bdata, -1);
         gst_rtp_mp4v_pay_new_caps (enc);
       }
       *strip = i;
@@ -458,7 +441,8 @@ gst_rtp_mp4v_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 {
   GstRtpMP4VPay *rtpmp4vpay;
   GstFlowReturn ret;
-  guint size, avail;
+  guint avail;
+  gsize size;
   guint packet_len;
   guint8 *data;
   gboolean flush;
@@ -472,8 +456,7 @@ gst_rtp_mp4v_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
   rtpmp4vpay = GST_RTP_MP4V_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
   duration = GST_BUFFER_DURATION (buffer);
   avail = gst_adapter_available (rtpmp4vpay->adapter);
@@ -490,21 +473,25 @@ gst_rtp_mp4v_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   /* depay incomming data and see if we need to start a new RTP
    * packet */
   flush = gst_rtp_mp4v_pay_depay_data (rtpmp4vpay, data, size, &strip, &vopi);
+  gst_buffer_unmap (buffer, data, -1);
+  data = NULL;
+
   if (strip) {
     /* strip off config if requested */
     if (!(rtpmp4vpay->config_interval > 0)) {
       GstBuffer *subbuf;
 
       GST_LOG_OBJECT (rtpmp4vpay, "stripping config at %d, size %d", strip,
-          size - strip);
+          (gint) size - strip);
 
       /* strip off header */
-      subbuf = gst_buffer_create_sub (buffer, strip, size - strip);
+      subbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY, strip,
+          size - strip);
       GST_BUFFER_TIMESTAMP (subbuf) = timestamp;
       gst_buffer_unref (buffer);
       buffer = subbuf;
 
-      size = GST_BUFFER_SIZE (buffer);
+      size = gst_buffer_get_size (buffer);
     } else {
       GST_LOG_OBJECT (rtpmp4vpay, "found config in stream");
       rtpmp4vpay->last_config = timestamp;
@@ -555,7 +542,7 @@ gst_rtp_mp4v_pay_handle_buffer (GstBaseRTPPayload * basepayload,
       gst_buffer_unref (buffer);
       buffer = superbuf;
 
-      size = GST_BUFFER_SIZE (buffer);
+      size = gst_buffer_get_size (buffer);
 
       if (timestamp != -1) {
         rtpmp4vpay->last_config = timestamp;
@@ -590,16 +577,16 @@ gst_rtp_mp4v_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 }
 
 static gboolean
-gst_rtp_mp4v_pay_handle_event (GstPad * pad, GstEvent * event)
+gst_rtp_mp4v_pay_handle_event (GstBaseRTPPayload * pay, GstEvent * event)
 {
   GstRtpMP4VPay *rtpmp4vpay;
 
-  rtpmp4vpay = GST_RTP_MP4V_PAY (gst_pad_get_parent (pad));
+  rtpmp4vpay = GST_RTP_MP4V_PAY (pay);
 
   GST_DEBUG ("Got event: %s", GST_EVENT_TYPE_NAME (event));
 
   switch (GST_EVENT_TYPE (event)) {
-    case GST_EVENT_NEWSEGMENT:
+    case GST_EVENT_SEGMENT:
     case GST_EVENT_EOS:
       /* This flush call makes sure that the last buffer is always pushed
        * to the base payloader */
@@ -612,8 +599,6 @@ gst_rtp_mp4v_pay_handle_event (GstPad * pad, GstEvent * event)
       break;
   }
 
-  g_object_unref (rtpmp4vpay);
-
   /* let parent handle event too */
   return FALSE;
 }
index 1fdc8d4..45240f9 100644 (file)
@@ -50,8 +50,8 @@ static GstStaticPadTemplate gst_rtp_mpa_depay_sink_template =
         "clock-rate = (int) 90000")
     );
 
-GST_BOILERPLATE (GstRtpMPADepay, gst_rtp_mpa_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_mpa_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMPADepay, gst_rtp_mpa_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static gboolean gst_rtp_mpa_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
@@ -59,38 +59,33 @@ static GstBuffer *gst_rtp_mpa_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
 static void
-gst_rtp_mpa_depay_base_init (gpointer klass)
+gst_rtp_mpa_depay_class_init (GstRtpMPADepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+  GST_DEBUG_CATEGORY_INIT (rtpmpadepay_debug, "rtpmpadepay", 0,
+      "MPEG Audio RTP Depayloader");
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_mpa_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_mpa_depay_sink_template));
 
-  gst_element_class_set_details_simple (element_class,
+  gst_element_class_set_details_simple (gstelement_class,
       "RTP MPEG audio depayloader", "Codec/Depayloader/Network/RTP",
       "Extracts MPEG audio from RTP packets (RFC 2038)",
       "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_mpa_depay_class_init (GstRtpMPADepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->set_caps = gst_rtp_mpa_depay_setcaps;
   gstbasertpdepayload_class->process = gst_rtp_mpa_depay_process;
-
-  GST_DEBUG_CATEGORY_INIT (rtpmpadepay_debug, "rtpmpadepay", 0,
-      "MPEG Audio RTP Depayloader");
 }
 
 static void
-gst_rtp_mpa_depay_init (GstRtpMPADepay * rtpmpadepay,
-    GstRtpMPADepayClass * klass)
+gst_rtp_mpa_depay_init (GstRtpMPADepay * rtpmpadepay)
 {
   /* needed because of GST_BOILERPLATE */
 }
@@ -122,52 +117,60 @@ gst_rtp_mpa_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstRtpMPADepay *rtpmpadepay;
   GstBuffer *outbuf;
+  GstRTPBuffer rtp = { NULL };
+  gint payload_len;
+#if 0
+  guint8 *payload;
+  guint16 frag_offset;
+#endif
+  gboolean marker;
 
   rtpmpadepay = GST_RTP_MPA_DEPAY (depayload);
 
-  {
-    gint payload_len;
-    gboolean marker;
-
-    payload_len = gst_rtp_buffer_get_payload_len (buf);
-
-    if (payload_len <= 4)
-      goto empty_packet;
-
-    /* strip off header
-     *
-     *  0                   1                   2                   3
-     *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-     * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     * |             MBZ               |          Frag_offset          |
-     * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     */
-    /* frag_offset = (payload[2] << 8) | payload[3]; */
-
-    /* subbuffer skipping the 4 header bytes */
-    outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 4, -1);
-    marker = gst_rtp_buffer_get_marker (buf);
-
-    if (marker) {
-      /* mark start of talkspurt with discont */
-      GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
-    }
-    GST_DEBUG_OBJECT (rtpmpadepay,
-        "gst_rtp_mpa_depay_chain: pushing buffer of size %d",
-        GST_BUFFER_SIZE (outbuf));
-
-    /* FIXME, we can push half mpeg frames when they are split over multiple
-     * RTP packets */
-    return outbuf;
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+
+  if (payload_len <= 4)
+    goto empty_packet;
+
+#if 0
+  payload = gst_rtp_buffer_get_payload (&rtp);
+  /* strip off header
+   *
+   *  0                   1                   2                   3
+   *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   * |             MBZ               |          Frag_offset          |
+   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   */
+  frag_offset = (payload[2] << 8) | payload[3];
+#endif
+
+  /* subbuffer skipping the 4 header bytes */
+  outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, 4, -1);
+  marker = gst_rtp_buffer_get_marker (&rtp);
+
+  if (marker) {
+    /* mark start of talkspurt with discont */
+    GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
   }
+  GST_DEBUG_OBJECT (rtpmpadepay,
+      "gst_rtp_mpa_depay_chain: pushing buffer of size %d",
+      gst_buffer_get_size (outbuf));
+
+  gst_rtp_buffer_unmap (&rtp);
 
-  return NULL;
+  /* FIXME, we can push half mpeg frames when they are split over multiple
+   * RTP packets */
+  return outbuf;
 
   /* ERRORS */
 empty_packet:
   {
     GST_ELEMENT_WARNING (rtpmpadepay, STREAM, DECODE,
         ("Empty Payload."), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index f685ef2..d4ab883 100644 (file)
@@ -58,28 +58,14 @@ static GstStateChangeReturn gst_rtp_mpa_pay_change_state (GstElement * element,
 
 static gboolean gst_rtp_mpa_pay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
-static gboolean gst_rtp_mpa_pay_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_mpa_pay_handle_event (GstBaseRTPPayload * payload,
+    GstEvent * event);
 static GstFlowReturn gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay);
 static GstFlowReturn gst_rtp_mpa_pay_handle_buffer (GstBaseRTPPayload * payload,
     GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRtpMPAPay, gst_rtp_mpa_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD)
-
-     static void gst_rtp_mpa_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mpa_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mpa_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP MPEG audio payloader", "Codec/Payloader/Network/RTP",
-      "Payload MPEG audio as RTP packets (RFC 2038)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_rtp_mpa_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMPAPay, gst_rtp_mpa_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_mpa_pay_class_init (GstRtpMPAPayClass * klass)
@@ -88,6 +74,9 @@ gst_rtp_mpa_pay_class_init (GstRtpMPAPayClass * klass)
   GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
+  GST_DEBUG_CATEGORY_INIT (rtpmpapay_debug, "rtpmpapay", 0,
+      "MPEG Audio RTP Depayloader");
+
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
@@ -96,16 +85,23 @@ gst_rtp_mpa_pay_class_init (GstRtpMPAPayClass * klass)
 
   gstelement_class->change_state = gst_rtp_mpa_pay_change_state;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mpa_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mpa_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG audio payloader", "Codec/Payloader/Network/RTP",
+      "Payload MPEG audio as RTP packets (RFC 2038)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   gstbasertppayload_class->set_caps = gst_rtp_mpa_pay_setcaps;
   gstbasertppayload_class->handle_event = gst_rtp_mpa_pay_handle_event;
   gstbasertppayload_class->handle_buffer = gst_rtp_mpa_pay_handle_buffer;
-
-  GST_DEBUG_CATEGORY_INIT (rtpmpapay_debug, "rtpmpapay", 0,
-      "MPEG Audio RTP Depayloader");
 }
 
 static void
-gst_rtp_mpa_pay_init (GstRtpMPAPay * rtpmpapay, GstRtpMPAPayClass * klass)
+gst_rtp_mpa_pay_init (GstRtpMPAPay * rtpmpapay)
 {
   rtpmpapay->adapter = gst_adapter_new ();
 }
@@ -144,11 +140,12 @@ gst_rtp_mpa_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
 }
 
 static gboolean
-gst_rtp_mpa_pay_handle_event (GstPad * pad, GstEvent * event)
+gst_rtp_mpa_pay_handle_event (GstBaseRTPPayload * payload, GstEvent * event)
 {
+  gboolean ret;
   GstRtpMPAPay *rtpmpapay;
 
-  rtpmpapay = GST_RTP_MPA_PAY (gst_pad_get_parent (pad));
+  rtpmpapay = GST_RTP_MPA_PAY (payload);
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_EOS:
@@ -162,10 +159,10 @@ gst_rtp_mpa_pay_handle_event (GstPad * pad, GstEvent * event)
       break;
   }
 
-  gst_object_unref (rtpmpapay);
+  ret =
+      GST_BASE_RTP_PAYLOAD_CLASS (parent_class)->handle_event (payload, event);
 
-  /* FALSE to let the parent handle the event as well */
-  return FALSE;
+  return ret;
 }
 
 static GstFlowReturn
@@ -192,6 +189,7 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay)
     guint8 *payload;
     guint payload_len;
     guint packet_len;
+    GstRTPBuffer rtp = { NULL };
 
     /* this will be the total length of the packet */
     packet_len = gst_rtp_buffer_calc_packet_len (4 + avail, 0, 0);
@@ -205,9 +203,11 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay)
     /* create buffer to hold the payload */
     outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
 
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+
     payload_len -= 4;
 
-    gst_rtp_buffer_set_payload_type (outbuf, GST_RTP_PAYLOAD_MPA);
+    gst_rtp_buffer_set_payload_type (&rtp, GST_RTP_PAYLOAD_MPA);
 
     /*
      *  0                   1                   2                   3
@@ -216,7 +216,7 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay)
      * |             MBZ               |          Frag_offset          |
      * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      */
-    payload = gst_rtp_buffer_get_payload (outbuf);
+    payload = gst_rtp_buffer_get_payload (&rtp);
     payload[0] = 0;
     payload[1] = 0;
     payload[2] = frag_offset >> 8;
@@ -229,7 +229,9 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay)
     frag_offset += payload_len;
 
     if (avail == 0)
-      gst_rtp_buffer_set_marker (outbuf, TRUE);
+      gst_rtp_buffer_set_marker (&rtp, TRUE);
+
+    gst_rtp_buffer_unmap (&rtp);
 
     GST_BUFFER_TIMESTAMP (outbuf) = rtpmpapay->first_ts;
     GST_BUFFER_DURATION (outbuf) = rtpmpapay->duration;
@@ -252,7 +254,7 @@ gst_rtp_mpa_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
   rtpmpapay = GST_RTP_MPA_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
+  size = gst_buffer_get_size (buffer);
   duration = GST_BUFFER_DURATION (buffer);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
 
index 0f3c049..62f6c9e 100644 (file)
@@ -69,8 +69,9 @@ typedef struct _GstADUFrame
   GstBuffer *buffer;
 } GstADUFrame;
 
-GST_BOILERPLATE (GstRtpMPARobustDepay, gst_rtp_mpa_robust_depay,
-    GstBaseRTPDepayload, GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_mpa_robust_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMPARobustDepay, gst_rtp_mpa_robust_depay,
+    GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static GstStateChangeReturn gst_rtp_mpa_robust_change_state (GstElement *
     element, GstStateChange transition);
@@ -81,22 +82,6 @@ static GstBuffer *gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload *
     depayload, GstBuffer * buf);
 
 static void
-gst_rtp_mpa_robust_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mpa_robust_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mpa_robust_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP MPEG audio depayloader", "Codec/Depayloader/Network/RTP",
-      "Extracts MPEG audio from RTP packets (RFC 5219)",
-      "Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>");
-}
-
-static void
 gst_rtp_mpa_robust_depay_finalize (GObject * object)
 {
   GstRtpMPARobustDepay *rtpmpadepay;
@@ -109,7 +94,6 @@ gst_rtp_mpa_robust_depay_finalize (GObject * object)
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
-
 static void
 gst_rtp_mpa_robust_depay_class_init (GstRtpMPARobustDepayClass * klass)
 {
@@ -117,6 +101,9 @@ gst_rtp_mpa_robust_depay_class_init (GstRtpMPARobustDepayClass * klass)
   GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
+  GST_DEBUG_CATEGORY_INIT (rtpmparobustdepay_debug, "rtpmparobustdepay", 0,
+      "Robust MPEG Audio RTP Depayloader");
+
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
@@ -126,16 +113,22 @@ gst_rtp_mpa_robust_depay_class_init (GstRtpMPARobustDepayClass * klass)
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_rtp_mpa_robust_change_state);
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mpa_robust_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mpa_robust_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG audio depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts MPEG audio from RTP packets (RFC 5219)",
+      "Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>");
+
   gstbasertpdepayload_class->set_caps = gst_rtp_mpa_robust_depay_setcaps;
   gstbasertpdepayload_class->process = gst_rtp_mpa_robust_depay_process;
-
-  GST_DEBUG_CATEGORY_INIT (rtpmparobustdepay_debug, "rtpmparobustdepay", 0,
-      "Robust MPEG Audio RTP Depayloader");
 }
 
 static void
-gst_rtp_mpa_robust_depay_init (GstRtpMPARobustDepay * rtpmpadepay,
-    GstRtpMPARobustDepayClass * klass)
+gst_rtp_mpa_robust_depay_init (GstRtpMPARobustDepay * rtpmpadepay)
 {
   rtpmpadepay->adapter = gst_adapter_new ();
   rtpmpadepay->adu_frames = g_queue_new ();
@@ -280,6 +273,8 @@ gst_rtp_mpa_robust_depay_generate_dummy_frame (GstRtpMPARobustDepay *
     rtpmpadepay, GstADUFrame * frame)
 {
   GstADUFrame *dummy;
+  guint8 *data;
+  gsize size;
 
   dummy = g_slice_dup (GstADUFrame, frame);
 
@@ -292,8 +287,12 @@ gst_rtp_mpa_robust_depay_generate_dummy_frame (GstRtpMPARobustDepay *
   dummy->backpointer = 0;
 
   dummy->buffer = gst_buffer_new_and_alloc (dummy->side_info + 4);
-  memset (GST_BUFFER_DATA (dummy->buffer), 0, dummy->side_info + 4);
-  GST_WRITE_UINT32_BE (GST_BUFFER_DATA (dummy->buffer), dummy->header);
+
+  data = gst_buffer_map (dummy->buffer, &size, NULL, GST_MAP_WRITE);
+  memset (data, 0, size);
+  GST_WRITE_UINT32_BE (data, dummy->header);
+  gst_buffer_unmap (dummy->buffer, data, size);
+
   GST_BUFFER_TIMESTAMP (dummy->buffer) = GST_BUFFER_TIMESTAMP (frame->buffer);
 
   return dummy;
@@ -309,15 +308,18 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
   GstADUFrame *frame = NULL;
   guint version, layer, channels, size;
   guint crc;
+  guint8 *bdata;
+  gsize bsize;
 
   g_return_val_if_fail (buf != NULL, FALSE);
 
-  if (GST_BUFFER_SIZE (buf) < 6) {
+  bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+
+  if (bsize < 6)
     goto corrupt_frame;
-  }
 
   frame = g_slice_new0 (GstADUFrame);
-  frame->header = GST_READ_UINT32_BE (GST_BUFFER_DATA (buf));
+  frame->header = GST_READ_UINT32_BE (bdata);
 
   size = mp3_type_frame_length_from_header (GST_ELEMENT_CAST (rtpmpadepay),
       frame->header, &version, &layer, &channels, NULL, NULL, NULL, &crc);
@@ -339,7 +341,7 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
 
   /* backpointer */
   if (layer == 3) {
-    frame->backpointer = GST_READ_UINT16_BE (GST_BUFFER_DATA (buf) + 4);
+    frame->backpointer = GST_READ_UINT16_BE (bdata + 4);
     frame->backpointer >>= 7;
     GST_LOG_OBJECT (rtpmpadepay, "backpointer: %d", frame->backpointer);
   }
@@ -351,14 +353,16 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
   frame->data_size = frame->size - 4 - frame->side_info;
 
   /* some size validation checks */
-  if (4 + frame->side_info > GST_BUFFER_SIZE (buf))
+  if (4 + frame->side_info > bsize)
     goto corrupt_frame;
 
   /* ADU data would then extend past MP3 frame,
    * even using past byte reservoir */
-  if (-frame->backpointer + (gint) (GST_BUFFER_SIZE (buf)) > frame->size)
+  if (-frame->backpointer + (gint) (bsize) > frame->size)
     goto corrupt_frame;
 
+  gst_buffer_unmap (buf, bdata, bsize);
+
   /* ok, take buffer and queue */
   frame->buffer = buf;
   g_queue_push_tail (rtpmpadepay->adu_frames, frame);
@@ -369,6 +373,7 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
 corrupt_frame:
   {
     GST_DEBUG_OBJECT (rtpmpadepay, "frame is corrupt");
+    gst_buffer_unmap (buf, bdata, bsize);
     gst_buffer_unref (buf);
     if (frame)
       g_slice_free (GstADUFrame, frame);
@@ -409,10 +414,13 @@ gst_rtp_mpa_robust_depay_deinterleave (GstRtpMPARobustDepay * rtpmpadepay,
 {
   gboolean ret = FALSE;
   guint8 *data;
+  gsize size;
   guint val, iindex, icc;
 
-  data = GST_BUFFER_DATA (buf);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
   val = GST_READ_UINT16_BE (data) >> 5;
+  gst_buffer_unmap (buf, data, size);
+
   iindex = val >> 3;
   icc = val & 0x7;
 
@@ -468,6 +476,8 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
   GstFlowReturn ret = GST_FLOW_OK;
 
   while (1) {
+    guint8 *data;
+    gsize size;
 
     if (G_UNLIKELY (!rtpmpadepay->cur_adu_frame)) {
       rtpmpadepay->cur_adu_frame = rtpmpadepay->adu_frames->head;
@@ -495,7 +505,7 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
       continue;
     }
 
-    if (rtpmpadepay->offset == GST_BUFFER_SIZE (frame->buffer)) {
+    if (rtpmpadepay->offset == gst_buffer_get_size (frame->buffer)) {
       if (g_list_next (rtpmpadepay->cur_adu_frame)) {
         GST_LOG_OBJECT (rtpmpadepay,
             "moving to next ADU frame, size %d, side_info %d",
@@ -523,8 +533,10 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
       gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, 0);
       /* bytewriter corresponds to head frame,
        * i.e. the header and the side info must match */
+      data = gst_buffer_map (head->buffer, &size, NULL, GST_MAP_READ);
       gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
-          GST_BUFFER_DATA (head->buffer), 4 + head->side_info);
+          data, 4 + head->side_info);
+      gst_buffer_unmap (head->buffer, data, size);
     }
 
     buf = frame->buffer;
@@ -534,15 +546,17 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
         rtpmpadepay->size);
 
     if (rtpmpadepay->offset) {
+      data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
       /* no need to position, simply append */
-      g_assert (GST_BUFFER_SIZE (buf) > rtpmpadepay->offset);
-      av = MIN (av, GST_BUFFER_SIZE (buf) - rtpmpadepay->offset);
+      g_assert (size > rtpmpadepay->offset);
+      av = MIN (av, size - rtpmpadepay->offset);
       GST_LOG_OBJECT (rtpmpadepay,
           "appending %d bytes from ADU frame at offset %d", av,
           rtpmpadepay->offset);
       gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
-          GST_BUFFER_DATA (buf) + rtpmpadepay->offset, av);
+          data + rtpmpadepay->offset, av);
       rtpmpadepay->offset += av;
+      gst_buffer_unmap (buf, data, size);
     } else {
       gint pos, tpos;
 
@@ -580,12 +594,14 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
         gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, pos + av);
       } else {
         /* position and append */
+        data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
         GST_LOG_OBJECT (rtpmpadepay, "adding to current MP3 frame");
         gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, tpos);
-        av = MIN (av, GST_BUFFER_SIZE (buf) - 4 - frame->side_info);
+        av = MIN (av, size - 4 - frame->side_info);
         gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
-            GST_BUFFER_DATA (buf) + 4 + frame->side_info, av);
+            data + 4 + frame->side_info, av);
         rtpmpadepay->offset += av + 4 + frame->side_info;
+        gst_buffer_unmap (buf, data, size);
       }
     }
 
@@ -634,16 +650,19 @@ gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * depayload,
   gboolean cont, dtype;
   guint av, size;
   GstClockTime timestamp;
+  GstRTPBuffer rtp = { NULL };
 
   rtpmpadepay = GST_RTP_MPA_ROBUST_DEPAY (depayload);
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
   timestamp = GST_BUFFER_TIMESTAMP (buf);
 
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
   if (payload_len <= 1)
     goto short_read;
 
-  payload = gst_rtp_buffer_get_payload (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
   offset = 0;
   GST_LOG_OBJECT (rtpmpadepay, "payload_len: %d", payload_len);
 
@@ -683,7 +702,7 @@ gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * depayload,
     GST_LOG_OBJECT (rtpmpadepay, "offset %d has cont: %d, dtype: %d, size: %d",
         offset, cont, dtype, size);
 
-    buf = gst_rtp_buffer_get_payload_subbuffer (buf, offset,
+    buf = gst_rtp_buffer_get_payload_subbuffer (&rtp, offset,
         MIN (size, payload_len));
 
     if (cont) {
@@ -693,7 +712,7 @@ gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * depayload,
             "discarding continuation fragment without prior fragment");
         gst_buffer_unref (buf);
       } else {
-        av += GST_BUFFER_SIZE (buf);
+        av += gst_buffer_get_size (buf);
         gst_adapter_push (rtpmpadepay->adapter, buf);
         if (av == size) {
           timestamp = gst_adapter_prev_timestamp (rtpmpadepay->adapter, NULL);
@@ -727,6 +746,7 @@ gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * depayload,
     /* timestamp applies to first payload, no idea for subsequent ones */
     timestamp = GST_CLOCK_TIME_NONE;
   }
+  gst_rtp_buffer_unmap (&rtp);
 
   return NULL;
 
@@ -735,6 +755,7 @@ short_read:
   {
     GST_ELEMENT_WARNING (rtpmpadepay, STREAM, DECODE,
         (NULL), ("Packet contains invalid data"));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index 1dea394..c94eb63 100644 (file)
@@ -53,8 +53,7 @@ static GstStaticPadTemplate gst_rtp_mpv_depay_sink_template =
         "clock-rate = (int) 90000")
     );
 
-GST_BOILERPLATE (GstRtpMPVDepay, gst_rtp_mpv_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+G_DEFINE_TYPE (GstRtpMPVDepay, gst_rtp_mpv_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static gboolean gst_rtp_mpv_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
@@ -62,27 +61,23 @@ static GstBuffer *gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
 static void
-gst_rtp_mpv_depay_base_init (gpointer klass)
+gst_rtp_mpv_depay_class_init (GstRtpMPVDepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_mpv_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_mpv_depay_sink_template));
 
-  gst_element_class_set_details_simple (element_class,
+  gst_element_class_set_details_simple (gstelement_class,
       "RTP MPEG video depayloader", "Codec/Depayloader/Network/RTP",
       "Extracts MPEG video from RTP packets (RFC 2250)",
       "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_mpv_depay_class_init (GstRtpMPVDepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->set_caps = gst_rtp_mpv_depay_setcaps;
   gstbasertpdepayload_class->process = gst_rtp_mpv_depay_process;
@@ -92,10 +87,8 @@ gst_rtp_mpv_depay_class_init (GstRtpMPVDepayClass * klass)
 }
 
 static void
-gst_rtp_mpv_depay_init (GstRtpMPVDepay * rtpmpvdepay,
-    GstRtpMPVDepayClass * klass)
+gst_rtp_mpv_depay_init (GstRtpMPVDepay * rtpmpvdepay)
 {
-  /* needed because of GST_BOILERPLATE */
 }
 
 static gboolean
@@ -126,16 +119,19 @@ gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstRtpMPVDepay *rtpmpvdepay;
   GstBuffer *outbuf;
+  GstRTPBuffer rtp = { NULL };
 
   rtpmpvdepay = GST_RTP_MPV_DEPAY (depayload);
 
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
   {
     gint payload_len, payload_header;
     guint8 *payload;
     guint8 T;
 
-    payload_len = gst_rtp_buffer_get_payload_len (buf);
-    payload = gst_rtp_buffer_get_payload (buf);
+    payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+    payload = gst_rtp_buffer_get_payload (&rtp);
     payload_header = 0;
 
     if (payload_len <= 4)
@@ -174,14 +170,13 @@ gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
       payload += 4;
     }
 
-    outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, payload_header, -1);
+    outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, payload_header, -1);
 
     if (outbuf) {
       GST_DEBUG_OBJECT (rtpmpvdepay,
           "gst_rtp_mpv_depay_chain: pushing buffer of size %d",
-          GST_BUFFER_SIZE (outbuf));
+          gst_buffer_get_size (outbuf));
     }
-
     return outbuf;
   }
 
index a96afbf..1d32e9a 100644 (file)
@@ -58,25 +58,11 @@ static gboolean gst_rtp_mpv_pay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 static GstFlowReturn gst_rtp_mpv_pay_handle_buffer (GstBaseRTPPayload *
     payload, GstBuffer * buffer);
-static gboolean gst_rtp_mpv_pay_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_mpv_pay_handle_event (GstBaseRTPPayload * payload,
+    GstEvent * event);
 
-GST_BOILERPLATE (GstRTPMPVPay, gst_rtp_mpv_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
-
-static void
-gst_rtp_mpv_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mpv_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_mpv_pay_src_template));
-  gst_element_class_set_details_simple (element_class,
-      "RTP MPEG2 ES video payloader", "Codec/Payloader/Network/RTP",
-      "Payload-encodes MPEG2 ES into RTP packets (RFC 2250)",
-      "Thijs Vermeir <thijsvermeir@gmail.com>");
-}
+#define gst_rtp_mpv_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPMPVPay, gst_rtp_mpv_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_mpv_pay_class_init (GstRTPMPVPayClass * klass)
@@ -93,6 +79,16 @@ gst_rtp_mpv_pay_class_init (GstRTPMPVPayClass * klass)
 
   gstelement_class->change_state = gst_rtp_mpv_pay_change_state;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mpv_pay_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_mpv_pay_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP MPEG2 ES video payloader", "Codec/Payloader/Network/RTP",
+      "Payload-encodes MPEG2 ES into RTP packets (RFC 2250)",
+      "Thijs Vermeir <thijsvermeir@gmail.com>");
+
   gstbasertppayload_class->set_caps = gst_rtp_mpv_pay_setcaps;
   gstbasertppayload_class->handle_buffer = gst_rtp_mpv_pay_handle_buffer;
   gstbasertppayload_class->handle_event = gst_rtp_mpv_pay_handle_event;
@@ -102,7 +98,7 @@ gst_rtp_mpv_pay_class_init (GstRTPMPVPayClass * klass)
 }
 
 static void
-gst_rtp_mpv_pay_init (GstRTPMPVPay * rtpmpvpay, GstRTPMPVPayClass * klass)
+gst_rtp_mpv_pay_init (GstRTPMPVPay * rtpmpvpay)
 {
   GST_BASE_RTP_PAYLOAD (rtpmpvpay)->clock_rate = 90000;
   GST_BASE_RTP_PAYLOAD_PT (rtpmpvpay) = GST_RTP_PAYLOAD_MPV;
@@ -140,11 +136,12 @@ gst_rtp_mpv_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
 }
 
 static gboolean
-gst_rtp_mpv_pay_handle_event (GstPad * pad, GstEvent * event)
+gst_rtp_mpv_pay_handle_event (GstBaseRTPPayload * payload, GstEvent * event)
 {
+  gboolean ret;
   GstRTPMPVPay *rtpmpvpay;
 
-  rtpmpvpay = GST_RTP_MPV_PAY (gst_pad_get_parent (pad));
+  rtpmpvpay = GST_RTP_MPV_PAY (payload);
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_EOS:
@@ -158,10 +155,10 @@ gst_rtp_mpv_pay_handle_event (GstPad * pad, GstEvent * event)
       break;
   }
 
-  gst_object_unref (rtpmpvpay);
+  ret =
+      GST_BASE_RTP_PAYLOAD_CLASS (parent_class)->handle_event (payload, event);
 
-  /* FALSE to let the parent handle the event as well */
-  return FALSE;
+  return ret;
 }
 
 static GstFlowReturn
@@ -181,6 +178,7 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
     guint towrite;
     guint packet_len;
     guint payload_len;
+    GstRTPBuffer rtp = { NULL };
 
     packet_len = gst_rtp_buffer_calc_packet_len (avail, 4, 0);
 
@@ -190,7 +188,9 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
 
     outbuf = gst_rtp_buffer_new_allocate (payload_len, 4, 0);
 
-    payload = gst_rtp_buffer_get_payload (outbuf);
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+
+    payload = gst_rtp_buffer_get_payload (&rtp);
     /* enable MPEG Video-specific header
      *
      *  0                   1                   2                   3
@@ -211,7 +211,8 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
 
     avail -= payload_len;
 
-    gst_rtp_buffer_set_marker (outbuf, avail == 0);
+    gst_rtp_buffer_set_marker (&rtp, avail == 0);
+    gst_rtp_buffer_unmap (&rtp);
 
     GST_BUFFER_TIMESTAMP (outbuf) = rtpmpvpay->first_ts;
 
index 91421a5..62fe4b9 100644 (file)
@@ -65,38 +65,35 @@ static GstBuffer *gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload,
 static gboolean gst_rtp_pcma_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRtpPcmaDepay, gst_rtp_pcma_depay, GstBaseRTPDepayload,
+#define gst_rtp_pcma_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpPcmaDepay, gst_rtp_pcma_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_pcma_depay_base_init (gpointer klass)
+gst_rtp_pcma_depay_class_init (GstRtpPcmaDepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_pcma_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_pcma_depay_sink_template));
-  gst_element_class_set_details_simple (element_class, "RTP PCMA depayloader",
-      "Codec/Depayloader/Network/RTP",
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP PCMA depayloader", "Codec/Depayloader/Network/RTP",
       "Extracts PCMA audio from RTP packets",
       "Edgard Lima <edgard.lima@indt.org.br>, Zeeshan Ali <zeenix@gmail.com>");
-}
-
-static void
-gst_rtp_pcma_depay_class_init (GstRtpPcmaDepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->process = gst_rtp_pcma_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_pcma_depay_setcaps;
 }
 
 static void
-gst_rtp_pcma_depay_init (GstRtpPcmaDepay * rtppcmadepay,
-    GstRtpPcmaDepayClass * klass)
+gst_rtp_pcma_depay_init (GstRtpPcmaDepay * rtppcmadepay)
 {
   GstBaseRTPDepayload *depayload;
 
@@ -133,15 +130,19 @@ gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   GstBuffer *outbuf = NULL;
   gboolean marker;
   guint len;
+  GstRTPBuffer rtp = { NULL };
+
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
 
-  marker = gst_rtp_buffer_get_marker (buf);
+  marker = gst_rtp_buffer_get_marker (&rtp);
 
   GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
-      GST_BUFFER_SIZE (buf), marker,
-      gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+      gst_buffer_get_size (buf), marker,
+      gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
 
-  len = gst_rtp_buffer_get_payload_len (buf);
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+  len = gst_rtp_buffer_get_payload_len (&rtp);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   if (outbuf) {
     GST_BUFFER_DURATION (outbuf) =
@@ -153,6 +154,7 @@ gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     }
   }
 
+
   return outbuf;
 }
 
index 8f3da0a..75d12e8 100644 (file)
@@ -53,36 +53,34 @@ static GstStaticPadTemplate gst_rtp_pcma_pay_src_template =
 static gboolean gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRtpPcmaPay, gst_rtp_pcma_pay, GstBaseRTPAudioPayload,
+#define gst_rtp_pcma_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpPcmaPay, gst_rtp_pcma_pay,
     GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
 
 static void
-gst_rtp_pcma_pay_base_init (gpointer klass)
+gst_rtp_pcma_pay_class_init (GstRtpPcmaPayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPPayloadClass *gstbasertppayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_pcma_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_pcma_pay_src_template));
-  gst_element_class_set_details_simple (element_class, "RTP PCMA payloader",
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP PCMA payloader",
       "Codec/Payloader/Network/RTP",
       "Payload-encodes PCMA audio into a RTP packet",
       "Edgard Lima <edgard.lima@indt.org.br>");
-}
-
-static void
-gst_rtp_pcma_pay_class_init (GstRtpPcmaPayClass * klass)
-{
-  GstBaseRTPPayloadClass *gstbasertppayload_class;
-
-  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gstbasertppayload_class->set_caps = gst_rtp_pcma_pay_setcaps;
 }
 
 static void
-gst_rtp_pcma_pay_init (GstRtpPcmaPay * rtppcmapay, GstRtpPcmaPayClass * klass)
+gst_rtp_pcma_pay_init (GstRtpPcmaPay * rtppcmapay)
 {
   GstBaseRTPAudioPayload *basertpaudiopayload;
 
index df9a7f6..9a44406 100644 (file)
@@ -66,38 +66,35 @@ static GstBuffer *gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload,
 static gboolean gst_rtp_pcmu_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRtpPcmuDepay, gst_rtp_pcmu_depay, GstBaseRTPDepayload,
+#define gst_rtp_pcmu_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpPcmuDepay, gst_rtp_pcmu_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_pcmu_depay_base_init (gpointer klass)
+gst_rtp_pcmu_depay_class_init (GstRtpPcmuDepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_pcmu_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_pcmu_depay_sink_template));
-  gst_element_class_set_details_simple (element_class, "RTP PCMU depayloader",
-      "Codec/Depayloader/Network/RTP",
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP PCMU depayloader", "Codec/Depayloader/Network/RTP",
       "Extracts PCMU audio from RTP packets",
       "Edgard Lima <edgard.lima@indt.org.br>, Zeeshan Ali <zeenix@gmail.com>");
-}
-
-static void
-gst_rtp_pcmu_depay_class_init (GstRtpPcmuDepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->process = gst_rtp_pcmu_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_pcmu_depay_setcaps;
 }
 
 static void
-gst_rtp_pcmu_depay_init (GstRtpPcmuDepay * rtppcmudepay,
-    GstRtpPcmuDepayClass * klass)
+gst_rtp_pcmu_depay_init (GstRtpPcmuDepay * rtppcmudepay)
 {
   GstBaseRTPDepayload *depayload;
 
@@ -134,15 +131,19 @@ gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   GstBuffer *outbuf = NULL;
   guint len;
   gboolean marker;
+  GstRTPBuffer rtp = { NULL };
+
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
 
-  marker = gst_rtp_buffer_get_marker (buf);
+  marker = gst_rtp_buffer_get_marker (&rtp);
 
   GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
-      GST_BUFFER_SIZE (buf), marker,
-      gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+      gst_buffer_get_size (buf), marker,
+      gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
 
-  len = gst_rtp_buffer_get_payload_len (buf);
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+  len = gst_rtp_buffer_get_payload_len (&rtp);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   if (outbuf) {
     GST_BUFFER_DURATION (outbuf) =
index 9a95406..665fba7 100644 (file)
@@ -53,36 +53,34 @@ static GstStaticPadTemplate gst_rtp_pcmu_pay_src_template =
 static gboolean gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRtpPcmuPay, gst_rtp_pcmu_pay, GstBaseRTPAudioPayload,
+#define gst_rtp_pcmu_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpPcmuPay, gst_rtp_pcmu_pay,
     GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
 
 static void
-gst_rtp_pcmu_pay_base_init (gpointer klass)
+gst_rtp_pcmu_pay_class_init (GstRtpPcmuPayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPPayloadClass *gstbasertppayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_pcmu_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_pcmu_pay_src_template));
-  gst_element_class_set_details_simple (element_class, "RTP PCMU payloader",
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP PCMU payloader",
       "Codec/Payloader/Network/RTP",
       "Payload-encodes PCMU audio into a RTP packet",
       "Edgard Lima <edgard.lima@indt.org.br>");
-}
-
-static void
-gst_rtp_pcmu_pay_class_init (GstRtpPcmuPayClass * klass)
-{
-  GstBaseRTPPayloadClass *gstbasertppayload_class;
-
-  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gstbasertppayload_class->set_caps = gst_rtp_pcmu_pay_setcaps;
 }
 
 static void
-gst_rtp_pcmu_pay_init (GstRtpPcmuPay * rtppcmupay, GstRtpPcmuPayClass * klass)
+gst_rtp_pcmu_pay_init (GstRtpPcmuPay * rtppcmupay)
 {
   GstBaseRTPAudioPayload *basertpaudiopayload;
 
index ce947d4..bfefcf9 100644 (file)
@@ -77,32 +77,19 @@ static gboolean gst_rtp_qcelp_depay_setcaps (GstBaseRTPDepayload * depayload,
 static GstBuffer *gst_rtp_qcelp_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
-GST_BOILERPLATE (GstRtpQCELPDepay, gst_rtp_qcelp_depay, GstBaseRTPDepayload,
+#define gst_rtp_qcelp_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpQCELPDepay, gst_rtp_qcelp_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_qcelp_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_qcelp_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_qcelp_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP QCELP depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts QCELP (PureVoice) audio from RTP packets (RFC 2658)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_qcelp_depay_class_init (GstRtpQCELPDepayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gobject_class->finalize = gst_rtp_qcelp_depay_finalize;
@@ -110,13 +97,22 @@ gst_rtp_qcelp_depay_class_init (GstRtpQCELPDepayClass * klass)
   gstbasertpdepayload_class->process = gst_rtp_qcelp_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_qcelp_depay_setcaps;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_qcelp_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_qcelp_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP QCELP depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts QCELP (PureVoice) audio from RTP packets (RFC 2658)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtpqcelpdepay_debug, "rtpqcelpdepay", 0,
       "QCELP RTP Depayloader");
 }
 
 static void
-gst_rtp_qcelp_depay_init (GstRtpQCELPDepay * rtpqcelpdepay,
-    GstRtpQCELPDepayClass * klass)
+gst_rtp_qcelp_depay_init (GstRtpQCELPDepay * rtpqcelpdepay)
 {
   GstBaseRTPDepayload G_GNUC_UNUSED *depayload;
 
@@ -245,9 +241,12 @@ static GstBuffer *
 create_erasure_buffer (GstRtpQCELPDepay * depay)
 {
   GstBuffer *outbuf;
+  guint8 *data;
 
   outbuf = gst_buffer_new_and_alloc (1);
-  GST_BUFFER_DATA (outbuf)[0] = 14;
+  data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+  data[0] = 14;
+  gst_buffer_unmap (outbuf, data, -1);
 
   return outbuf;
 }
@@ -261,17 +260,20 @@ gst_rtp_qcelp_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   guint payload_len, offset, index;
   guint8 *payload;
   guint LLL, NNN;
+  GstRTPBuffer rtp;
 
   depay = GST_RTP_QCELP_DEPAY (depayload);
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   if (payload_len < 2)
     goto too_small;
 
   timestamp = GST_BUFFER_TIMESTAMP (buf);
 
-  payload = gst_rtp_buffer_get_payload (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
   /*  0 1 2 3 4 5 6 7
    * +-+-+-+-+-+-+-+-+
@@ -353,7 +355,7 @@ gst_rtp_qcelp_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
       outbuf = create_erasure_buffer (depay);
     } else {
       /* each frame goes into its buffer */
-      outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, offset, frame_len);
+      outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, offset, frame_len);
     }
 
     GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
@@ -395,6 +397,7 @@ gst_rtp_qcelp_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     flush_packets (depay);
   }
 
+  gst_rtp_buffer_unmap (&rtp);
   return NULL;
 
   /* ERRORS */
@@ -402,24 +405,28 @@ too_small:
   {
     GST_ELEMENT_WARNING (depay, STREAM, DECODE,
         (NULL), ("QCELP RTP payload too small (%d)", payload_len));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 invalid_lll:
   {
     GST_ELEMENT_WARNING (depay, STREAM, DECODE,
         (NULL), ("QCELP RTP invalid LLL received (%d)", LLL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 invalid_nnn:
   {
     GST_ELEMENT_WARNING (depay, STREAM, DECODE,
         (NULL), ("QCELP RTP invalid NNN received (%d)", NNN));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 invalid_frame:
   {
     GST_ELEMENT_WARNING (depay, STREAM, DECODE,
         (NULL), ("QCELP RTP invalid frame received"));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index 7e2e50b..3b33367 100644 (file)
@@ -46,7 +46,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
         "encoding-name = (string)\"X-QDM\"")
     );
 
-GST_BOILERPLATE (GstRtpQDM2Depay, gst_rtp_qdm2_depay, GstBaseRTPDepayload,
+#define gst_rtp_qdm2_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpQDM2Depay, gst_rtp_qdm2_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static const guint8 headheader[20] = {
@@ -66,23 +67,6 @@ gboolean gst_rtp_qdm2_depay_setcaps (GstBaseRTPDepayload * filter,
     GstCaps * caps);
 
 static void
-gst_rtp_qdm2_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_qdm2_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_qdm2_depay_sink_template));
-
-
-  gst_element_class_set_details_simple (element_class, "RTP QDM2 depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts QDM2 audio from RTP packets (no RFC)",
-      "Edward Hervey <bilboed@bilboed.com>");
-}
-
-static void
 gst_rtp_qdm2_depay_class_init (GstRtpQDM2DepayClass * klass)
 {
   GObjectClass *gobject_class;
@@ -99,11 +83,21 @@ gst_rtp_qdm2_depay_class_init (GstRtpQDM2DepayClass * klass)
   gobject_class->finalize = gst_rtp_qdm2_depay_finalize;
 
   gstelement_class->change_state = gst_rtp_qdm2_depay_change_state;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_qdm2_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_qdm2_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP QDM2 depayloader",
+      "Codec/Depayloader/Network/RTP",
+      "Extracts QDM2 audio from RTP packets (no RFC)",
+      "Edward Hervey <bilboed@bilboed.com>");
 }
 
 static void
-gst_rtp_qdm2_depay_init (GstRtpQDM2Depay * rtpqdm2depay,
-    GstRtpQDM2DepayClass * klass)
+gst_rtp_qdm2_depay_init (GstRtpQDM2Depay * rtpqdm2depay)
 {
   rtpqdm2depay->adapter = gst_adapter_new ();
 }
@@ -187,9 +181,9 @@ flush_data (GstRtpQDM2Depay * depay)
     GST_MEMDUMP ("Extracted packet", data, depay->packetsize);
 
     buf = gst_buffer_new ();
-    GST_BUFFER_DATA (buf) = data;
-    GST_BUFFER_MALLOCDATA (buf) = data;
-    GST_BUFFER_SIZE (buf) = depay->packetsize;
+    gst_buffer_take_memory (buf, -1,
+        gst_memory_new_wrapped (0, data, g_free, depay->packetsize, 0,
+            depay->packetsize));
 
     gst_adapter_push (depay->adapter, buf);
 
@@ -236,8 +230,9 @@ static GstBuffer *
 gst_rtp_qdm2_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstRtpQDM2Depay *rtpqdm2depay;
-  GstBuffer *outbuf;
+  GstBuffer *outbuf = NULL;
   guint16 seq;
+  GstRTPBuffer rtp;
 
   rtpqdm2depay = GST_RTP_QDM2_DEPAY (depayload);
 
@@ -247,12 +242,13 @@ gst_rtp_qdm2_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     guint avail;
     guint pos = 0;
 
-    payload_len = gst_rtp_buffer_get_payload_len (buf);
+    gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+    payload_len = gst_rtp_buffer_get_payload_len (&rtp);
     if (payload_len < 3)
       goto bad_packet;
 
-    payload = gst_rtp_buffer_get_payload (buf);
-    seq = gst_rtp_buffer_get_seq (buf);
+    payload = gst_rtp_buffer_get_payload (&rtp);
+    seq = gst_rtp_buffer_get_seq (&rtp);
     if (G_UNLIKELY (seq != rtpqdm2depay->nextseq)) {
       GST_DEBUG ("GAP in sequence number, Resetting data !");
       /* Flush previous data */
@@ -287,6 +283,7 @@ gst_rtp_qdm2_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
           if (G_UNLIKELY (!rtpqdm2depay->configured)) {
             guint8 *ourdata;
             GstBuffer *codecdata;
+            guint8 *cdata;
             GstCaps *caps;
 
             /* First bytes are unknown */
@@ -309,8 +306,10 @@ gst_rtp_qdm2_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
             /* Caps */
             codecdata = gst_buffer_new_and_alloc (48);
-            memcpy (GST_BUFFER_DATA (codecdata), headheader, 20);
-            memcpy (GST_BUFFER_DATA (codecdata) + 20, ourdata, 28);
+            cdata = gst_buffer_map (codecdata, NULL, NULL, GST_MAP_WRITE);
+            memcpy (cdata, headheader, 20);
+            memcpy (cdata + 20, ourdata, 28);
+            gst_buffer_unmap (codecdata, cdata, -1);
 
             caps = gst_caps_new_simple ("audio/x-qdm2",
                 "samplesize", G_TYPE_INT, 16,
@@ -364,16 +363,18 @@ gst_rtp_qdm2_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
       GST_BUFFER_TIMESTAMP (outbuf) = rtpqdm2depay->ptimestamp;
       GST_DEBUG ("Outgoing buffer timestamp %" GST_TIME_FORMAT,
           GST_TIME_ARGS (rtpqdm2depay->ptimestamp));
-      return outbuf;
     }
   }
-  return NULL;
+
+  gst_rtp_buffer_unmap (&rtp);
+  return outbuf;
 
   /* ERRORS */
 bad_packet:
   {
     GST_ELEMENT_WARNING (rtpqdm2depay, STREAM, DECODE,
         (NULL), ("Packet was too short"));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index 2746e74..73aa17d 100644 (file)
@@ -51,38 +51,33 @@ static GstBuffer *gst_rtp_siren_depay_process (GstBaseRTPDepayload * depayload,
 static gboolean gst_rtp_siren_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRTPSirenDepay, gst_rtp_siren_depay, GstBaseRTPDepayload,
+G_DEFINE_TYPE (GstRTPSirenDepay, gst_rtp_siren_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_siren_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_siren_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_siren_depay_sink_template));
-  gst_element_class_set_details_simple (element_class,
-      "RTP Siren packet depayloader", "Codec/Depayloader/Network/RTP",
-      "Extracts Siren audio from RTP packets",
-      "Philippe Kalaf <philippe.kalaf@collabora.co.uk>");
-}
-
-static void
 gst_rtp_siren_depay_class_init (GstRTPSirenDepayClass * klass)
 {
+  GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
+  gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->process = gst_rtp_siren_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_siren_depay_setcaps;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_siren_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_siren_depay_sink_template));
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP Siren packet depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts Siren audio from RTP packets",
+      "Philippe Kalaf <philippe.kalaf@collabora.co.uk>");
 }
 
 static void
-gst_rtp_siren_depay_init (GstRTPSirenDepay * rtpsirendepay,
-    GstRTPSirenDepayClass * klass)
+gst_rtp_siren_depay_init (GstRTPSirenDepay * rtpsirendepay)
 {
 
 }
@@ -110,8 +105,11 @@ static GstBuffer *
 gst_rtp_siren_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstBuffer *outbuf;
+  GstRTPBuffer rtp;
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   return outbuf;
 }
index c7c9582..2aca54a 100644 (file)
@@ -51,40 +51,35 @@ GST_STATIC_PAD_TEMPLATE ("src",
 static gboolean gst_rtp_siren_pay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRTPSirenPay, gst_rtp_siren_pay, GstBaseRTPAudioPayload,
+G_DEFINE_TYPE (GstRTPSirenPay, gst_rtp_siren_pay,
     GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
 
 static void
-gst_rtp_siren_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_siren_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_siren_pay_src_template));
-  gst_element_class_set_details_simple (element_class,
-      "RTP Payloader for Siren Audio", "Codec/Payloader/Network/RTP",
-      "Packetize Siren audio streams into RTP packets",
-      "Youness Alaoui <kakaroto@kakaroto.homelinux.net>");
-}
-
-static void
 gst_rtp_siren_pay_class_init (GstRTPSirenPayClass * klass)
 {
+  GstElementClass *gstelement_class;
   GstBaseRTPPayloadClass *gstbasertppayload_class;
 
+  gstelement_class = (GstElementClass *) klass;
   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
 
   gstbasertppayload_class->set_caps = gst_rtp_siren_pay_setcaps;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_siren_pay_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_siren_pay_src_template));
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP Payloader for Siren Audio", "Codec/Payloader/Network/RTP",
+      "Packetize Siren audio streams into RTP packets",
+      "Youness Alaoui <kakaroto@kakaroto.homelinux.net>");
+
   GST_DEBUG_CATEGORY_INIT (rtpsirenpay_debug, "rtpsirenpay", 0,
       "siren audio RTP payloader");
 }
 
 static void
-gst_rtp_siren_pay_init (GstRTPSirenPay * rtpsirenpay,
-    GstRTPSirenPayClass * klass)
+gst_rtp_siren_pay_init (GstRTPSirenPay * rtpsirenpay)
 {
   GstBaseRTPPayload *basertppayload;
   GstBaseRTPAudioPayload *basertpaudiopayload;
index 87e8a77..c528e22 100644 (file)
@@ -63,38 +63,33 @@ static GstBuffer *gst_rtp_speex_depay_process (GstBaseRTPDepayload * depayload,
 static gboolean gst_rtp_speex_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
 
-GST_BOILERPLATE (GstRtpSPEEXDepay, gst_rtp_speex_depay, GstBaseRTPDepayload,
+G_DEFINE_TYPE (GstRtpSPEEXDepay, gst_rtp_speex_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void
-gst_rtp_speex_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_speex_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_speex_depay_sink_template));
-  gst_element_class_set_details_simple (element_class, "RTP Speex depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts Speex audio from RTP packets",
-      "Edgard Lima <edgard.lima@indt.org.br>");
-}
-
-static void
 gst_rtp_speex_depay_class_init (GstRtpSPEEXDepayClass * klass)
 {
+  GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
+  gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->process = gst_rtp_speex_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_speex_depay_setcaps;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_speex_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_speex_depay_sink_template));
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP Speex depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts Speex audio from RTP packets",
+      "Edgard Lima <edgard.lima@indt.org.br>");
 }
 
 static void
-gst_rtp_speex_depay_init (GstRtpSPEEXDepay * rtpspeexdepay,
-    GstRtpSPEEXDepayClass * klass)
+gst_rtp_speex_depay_init (GstRtpSPEEXDepay * rtpspeexdepay)
 {
 }
 
@@ -123,7 +118,7 @@ gst_rtp_speex_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   GstRtpSPEEXDepay *rtpspeexdepay;
   gint clock_rate, nb_channels;
   GstBuffer *buf;
-  guint8 *data;
+  guint8 *data, *bdata;
   const gchar *params;
   GstCaps *srccaps;
   gboolean res;
@@ -144,7 +139,7 @@ gst_rtp_speex_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
 
   /* construct minimal header and comment packet for the decoder */
   buf = gst_buffer_new_and_alloc (80);
-  data = GST_BUFFER_DATA (buf);
+  data = bdata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
   memcpy (data, "Speex   ", 8);
   data += 8;
   memcpy (data, "1.1.12", 7);
@@ -174,19 +169,19 @@ gst_rtp_speex_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   GST_WRITE_UINT32_LE (data, 0);        /* reserved1 */
   data += 4;
   GST_WRITE_UINT32_LE (data, 0);        /* reserved2 */
+  gst_buffer_unmap (buf, bdata, -1);
 
   srccaps = gst_caps_new_simple ("audio/x-speex", NULL);
   res = gst_pad_set_caps (depayload->srcpad, srccaps);
   gst_caps_unref (srccaps);
 
-  gst_buffer_set_caps (buf, GST_PAD_CAPS (depayload->srcpad));
   gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpspeexdepay), buf);
 
   buf = gst_buffer_new_and_alloc (sizeof (gst_rtp_speex_comment));
-  memcpy (GST_BUFFER_DATA (buf), gst_rtp_speex_comment,
-      sizeof (gst_rtp_speex_comment));
+  bdata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+  memcpy (bdata, gst_rtp_speex_comment, sizeof (gst_rtp_speex_comment));
+  gst_buffer_unmap (buf, bdata, -1);
 
-  gst_buffer_set_caps (buf, GST_PAD_CAPS (depayload->srcpad));
   gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpspeexdepay), buf);
 
   return res;
@@ -203,14 +198,18 @@ static GstBuffer *
 gst_rtp_speex_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstBuffer *outbuf = NULL;
+  GstRTPBuffer rtp;
+
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
 
   GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
-      GST_BUFFER_SIZE (buf),
-      gst_rtp_buffer_get_marker (buf),
-      gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+      gst_buffer_get_size (buf),
+      gst_rtp_buffer_get_marker (&rtp),
+      gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
 
   /* nothing special to be done */
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   if (outbuf)
     GST_BUFFER_DURATION (outbuf) = 20 * GST_MSECOND;
index 35273e2..d65f81e 100644 (file)
@@ -56,30 +56,12 @@ static GstStateChangeReturn gst_rtp_speex_pay_change_state (GstElement *
 static gboolean gst_rtp_speex_pay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 static GstCaps *gst_rtp_speex_pay_getcaps (GstBaseRTPPayload * payload,
-    GstPad * pad);
+    GstPad * pad, GstCaps * filter);
 static GstFlowReturn gst_rtp_speex_pay_handle_buffer (GstBaseRTPPayload *
     payload, GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRtpSPEEXPay, gst_rtp_speex_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
-
-static void
-gst_rtp_speex_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_speex_pay_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_speex_pay_src_template));
-  gst_element_class_set_details_simple (element_class, "RTP Speex payloader",
-      "Codec/Payloader/Network/RTP",
-      "Payload-encodes Speex audio into a RTP packet",
-      "Edgard Lima <edgard.lima@indt.org.br>");
-
-  GST_DEBUG_CATEGORY_INIT (rtpspeexpay_debug, "rtpspeexpay", 0,
-      "Speex RTP Payloader");
-}
+#define gst_rtp_speex_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpSPEEXPay, gst_rtp_speex_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static void
 gst_rtp_speex_pay_class_init (GstRtpSPEEXPayClass * klass)
@@ -95,11 +77,22 @@ gst_rtp_speex_pay_class_init (GstRtpSPEEXPayClass * klass)
   gstbasertppayload_class->set_caps = gst_rtp_speex_pay_setcaps;
   gstbasertppayload_class->get_caps = gst_rtp_speex_pay_getcaps;
   gstbasertppayload_class->handle_buffer = gst_rtp_speex_pay_handle_buffer;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_speex_pay_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_speex_pay_src_template));
+  gst_element_class_set_details_simple (gstelement_class, "RTP Speex payloader",
+      "Codec/Payloader/Network/RTP",
+      "Payload-encodes Speex audio into a RTP packet",
+      "Edgard Lima <edgard.lima@indt.org.br>");
+
+  GST_DEBUG_CATEGORY_INIT (rtpspeexpay_debug, "rtpspeexpay", 0,
+      "Speex RTP Payloader");
 }
 
 static void
-gst_rtp_speex_pay_init (GstRtpSPEEXPay * rtpspeexpay,
-    GstRtpSPEEXPayClass * klass)
+gst_rtp_speex_pay_init (GstRtpSPEEXPay * rtpspeexpay)
 {
   GST_BASE_RTP_PAYLOAD (rtpspeexpay)->clock_rate = 8000;
   GST_BASE_RTP_PAYLOAD_PT (rtpspeexpay) = 110;  /* Create String */
@@ -114,7 +107,8 @@ gst_rtp_speex_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
 
 
 static GstCaps *
-gst_rtp_speex_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad)
+gst_rtp_speex_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad,
+    GstCaps * filter)
 {
   GstCaps *otherpadcaps;
   GstCaps *caps;
@@ -135,6 +129,13 @@ gst_rtp_speex_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad)
     gst_caps_unref (otherpadcaps);
   }
 
+  if (filter) {
+    GstCaps *tcaps = caps;
+
+    caps = gst_caps_intersect_full (filter, tcaps, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (tcaps);
+  }
+
   return caps;
 }
 
@@ -231,16 +232,17 @@ gst_rtp_speex_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     GstBuffer * buffer)
 {
   GstRtpSPEEXPay *rtpspeexpay;
-  guint size, payload_len;
+  guint payload_len;
+  gsize size;
   GstBuffer *outbuf;
   guint8 *payload, *data;
   GstClockTime timestamp, duration;
   GstFlowReturn ret;
+  GstRTPBuffer rtp;
 
   rtpspeexpay = GST_RTP_SPEEX_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   switch (rtpspeexpay->packet) {
     case 0:
@@ -279,15 +281,19 @@ gst_rtp_speex_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
   GST_BUFFER_DURATION (outbuf) = duration;
 
+  gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
   /* get payload */
-  payload = gst_rtp_buffer_get_payload (outbuf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
   /* copy data in payload */
   memcpy (&payload[0], data, size);
 
+  gst_rtp_buffer_unmap (&rtp);
+
   ret = gst_basertppayload_push (basepayload, outbuf);
 
 done:
+  gst_buffer_unmap (buffer, data, -1);
   gst_buffer_unref (buffer);
 
   rtpspeexpay->packet++;
@@ -299,6 +305,7 @@ parse_error:
   {
     GST_ELEMENT_ERROR (rtpspeexpay, STREAM, DECODE, (NULL),
         ("Error parsing first identification packet."));
+    gst_buffer_unmap (buffer, data, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_ERROR;
   }
index a99559c..2e697ea 100644 (file)
@@ -47,7 +47,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
         "encoding-name = (string) { \"X-SV3V-ES\", \"X-SORENSON-VIDEO\" , \"X-SORENSONVIDEO\" , \"X-SorensonVideo\" }")
     );
 
-GST_BOILERPLATE (GstRtpSV3VDepay, gst_rtp_sv3v_depay, GstBaseRTPDepayload,
+#define gst_rtp_sv3v_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpSV3VDepay, gst_rtp_sv3v_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static void gst_rtp_sv3v_depay_finalize (GObject * object);
@@ -61,23 +62,6 @@ gboolean gst_rtp_sv3v_depay_setcaps (GstBaseRTPDepayload * filter,
     GstCaps * caps);
 
 static void
-gst_rtp_sv3v_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_sv3v_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_sv3v_depay_sink_template));
-
-
-  gst_element_class_set_details_simple (element_class, "RTP SVQ3 depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts SVQ3 video from RTP packets (no RFC)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_sv3v_depay_class_init (GstRtpSV3VDepayClass * klass)
 {
   GObjectClass *gobject_class;
@@ -94,11 +78,20 @@ gst_rtp_sv3v_depay_class_init (GstRtpSV3VDepayClass * klass)
   gobject_class->finalize = gst_rtp_sv3v_depay_finalize;
 
   gstelement_class->change_state = gst_rtp_sv3v_depay_change_state;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_sv3v_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_sv3v_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP SVQ3 depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts SVQ3 video from RTP packets (no RFC)",
+      "Wim Taymans <wim.taymans@gmail.com>");
 }
 
 static void
-gst_rtp_sv3v_depay_init (GstRtpSV3VDepay * rtpsv3vdepay,
-    GstRtpSV3VDepayClass * klass)
+gst_rtp_sv3v_depay_init (GstRtpSV3VDepay * rtpsv3vdepay)
 {
   rtpsv3vdepay->adapter = gst_adapter_new ();
 }
@@ -155,11 +148,14 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   gboolean C, S, E;
   GstBuffer *outbuf = NULL;
   guint16 seq;
+  GstRTPBuffer rtp;
 
   rtpsv3vdepay = GST_RTP_SV3V_DEPAY (depayload);
 
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
   /* flush on sequence number gaps */
-  seq = gst_rtp_buffer_get_seq (buf);
+  seq = gst_rtp_buffer_get_seq (&rtp);
 
   GST_DEBUG ("timestamp %" GST_TIME_FORMAT ", sequence number:%d",
       GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), seq);
@@ -170,13 +166,13 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   }
   rtpsv3vdepay->nextseq = seq + 1;
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
   if (payload_len < 3)
     goto bad_packet;
 
-  payload = gst_rtp_buffer_get_payload (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
-  M = gst_rtp_buffer_get_marker (buf);
+  M = gst_rtp_buffer_get_marker (&rtp);
 
   /* This is all a guess:
    *                      1 1 1 1 1 1
@@ -205,12 +201,14 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     GstCaps *caps;
     GstBuffer *codec_data;
     guint8 res;
+    guint8 *cdata;
 
     GST_DEBUG ("Configuration packet");
 
     /* if we already have caps, we don't need to do anything. FIXME, check if
      * something changed. */
-    if (G_UNLIKELY (GST_PAD_CAPS (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload)))) {
+    if (G_UNLIKELY (gst_pad_has_current_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD
+                (depayload)))) {
       GST_DEBUG ("Already configured, skipping config parsing");
       goto beach;
     }
@@ -231,12 +229,14 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     /* CodecData needs to be 'SEQH' + len (32bit) + data according to
      * ffmpeg's libavcodec/svq3.c:svq3_decode_init */
     codec_data = gst_buffer_new_and_alloc (payload_len + 6);
-    memcpy (GST_BUFFER_DATA (codec_data), "SEQH", 4);
-    GST_WRITE_UINT32_LE (GST_BUFFER_DATA (codec_data) + 4, payload_len - 2);
-    memcpy (GST_BUFFER_DATA (codec_data) + 8, payload + 2, payload_len - 2);
+    cdata = gst_buffer_map (codec_data, NULL, NULL, GST_MAP_WRITE);
+    memcpy (cdata, "SEQH", 4);
+    GST_WRITE_UINT32_LE (cdata + 4, payload_len - 2);
+    memcpy (cdata + 8, payload + 2, payload_len - 2);
+
+    GST_MEMDUMP ("codec_data", cdata, gst_buffer_get_size (codec_data));
 
-    GST_MEMDUMP ("codec_data", GST_BUFFER_DATA (codec_data),
-        GST_BUFFER_SIZE (codec_data));
+    gst_buffer_unmap (codec_data, cdata, -1);
 
     caps = gst_caps_new_simple ("video/x-svq",
         "svqversion", G_TYPE_INT, 3,
@@ -258,7 +258,7 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
     GST_DEBUG ("Storing incoming payload");
     /* store data in adapter, stip off 2 bytes header */
-    tmpbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 2, -1);
+    tmpbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, 2, -1);
     gst_adapter_push (rtpsv3vdepay->adapter, tmpbuf);
 
     if (G_UNLIKELY (M)) {
@@ -272,6 +272,7 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   }
 
 beach:
+  gst_rtp_buffer_unmap (&rtp);
   return outbuf;
 
   /* ERRORS */
@@ -279,6 +280,7 @@ bad_packet:
   {
     GST_ELEMENT_WARNING (rtpsv3vdepay, STREAM, DECODE,
         (NULL), ("Packet was too short"));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index c1a576b..59695e9 100644 (file)
@@ -60,7 +60,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
     GST_STATIC_CAPS ("video/x-theora")
     );
 
-GST_BOILERPLATE (GstRtpTheoraDepay, gst_rtp_theora_depay, GstBaseRTPDepayload,
+#define gst_rtp_theora_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpTheoraDepay, gst_rtp_theora_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static gboolean gst_rtp_theora_depay_setcaps (GstBaseRTPDepayload * depayload,
@@ -72,30 +73,15 @@ static gboolean gst_rtp_theora_depay_packet_lost (GstBaseRTPDepayload *
 
 static void gst_rtp_theora_depay_finalize (GObject * object);
 
-
-static void
-gst_rtp_theora_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_theora_depay_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_theora_depay_src_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP Theora depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts Theora video from RTP packets (draft-01 of RFC XXXX)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
 static void
 gst_rtp_theora_depay_class_init (GstRtpTheoraDepayClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gobject_class->finalize = gst_rtp_theora_depay_finalize;
@@ -104,13 +90,22 @@ gst_rtp_theora_depay_class_init (GstRtpTheoraDepayClass * klass)
   gstbasertpdepayload_class->set_caps = gst_rtp_theora_depay_setcaps;
   gstbasertpdepayload_class->packet_lost = gst_rtp_theora_depay_packet_lost;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_theora_depay_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_theora_depay_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP Theora depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts Theora video from RTP packets (draft-01 of RFC XXXX)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtptheoradepay_debug, "rtptheoradepay", 0,
       "Theora RTP Depayloader");
 }
 
 static void
-gst_rtp_theora_depay_init (GstRtpTheoraDepay * rtptheoradepay,
-    GstRtpTheoraDepayClass * klass)
+gst_rtp_theora_depay_init (GstRtpTheoraDepay * rtptheoradepay)
 {
   rtptheoradepay->adapter = gst_adapter_new ();
 }
@@ -131,14 +126,13 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
 {
   GstBuffer *buf;
   guint32 num_headers;
-  guint8 *data;
-  guint size;
+  guint8 *data, *bdata;
+  gsize size;
   gint i, j;
 
-  data = GST_BUFFER_DATA (confbuf);
-  size = GST_BUFFER_SIZE (confbuf);
+  data = bdata = gst_buffer_map (confbuf, &size, NULL, GST_MAP_READ);
 
-  GST_DEBUG_OBJECT (rtptheoradepay, "config size %u", size);
+  GST_DEBUG_OBJECT (rtptheoradepay, "config size %" G_GSIZE_FORMAT, size);
 
   /* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    * |                     Number of packed headers                  |
@@ -241,6 +235,7 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
 
     for (j = 0; j <= n_headers; j++) {
       guint h_size;
+      guint8 *odata;
 
       h_size = h_sizes[j];
       if (size < h_size) {
@@ -257,19 +252,24 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
           h_size);
 
       buf = gst_buffer_new_and_alloc (h_size);
-      memcpy (GST_BUFFER_DATA (buf), data, h_size);
+      odata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+      memcpy (odata, data, h_size);
+      gst_buffer_unmap (buf, odata, -1);
       conf->headers = g_list_append (conf->headers, buf);
       data += h_size;
       size -= h_size;
     }
     rtptheoradepay->configs = g_list_append (rtptheoradepay->configs, conf);
   }
+
+  gst_buffer_unmap (confbuf, bdata, -1);
   return TRUE;
 
   /* ERRORS */
 too_small:
   {
     GST_DEBUG_OBJECT (rtptheoradepay, "configuration too small");
+    gst_buffer_unmap (confbuf, bdata, -1);
     return FALSE;
   }
 }
@@ -287,7 +287,7 @@ gst_rtp_theora_depay_parse_inband_configuration (GstRtpTheoraDepay *
 
   /* transform inline to out-of-band and parse that one */
   confbuf = gst_buffer_new_and_alloc (size + 9);
-  conf = GST_BUFFER_DATA (confbuf);
+  conf = gst_buffer_map (confbuf, NULL, NULL, GST_MAP_WRITE);
   /* 1 header */
   GST_WRITE_UINT32_BE (conf, 1);
   /* write Ident */
@@ -296,6 +296,7 @@ gst_rtp_theora_depay_parse_inband_configuration (GstRtpTheoraDepay *
   GST_WRITE_UINT16_BE (conf + 7, length);
   /* copy remainder */
   memcpy (conf + 9, configuration, size);
+  gst_buffer_unmap (confbuf, conf, -1);
 
   return gst_rtp_theora_depay_parse_configuration (rtptheoradepay, confbuf);
 }
@@ -330,9 +331,8 @@ gst_rtp_theora_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
     data = g_base64_decode (configuration, &size);
 
     confbuf = gst_buffer_new ();
-    GST_BUFFER_DATA (confbuf) = data;
-    GST_BUFFER_MALLOCDATA (confbuf) = data;
-    GST_BUFFER_SIZE (confbuf) = size;
+    gst_buffer_take_memory (confbuf, -1,
+        gst_memory_new_wrapped (0, data, g_free, size, 0, size));
 
     if (!gst_rtp_theora_depay_parse_configuration (rtptheoradepay, confbuf))
       goto invalid_configuration;
@@ -407,10 +407,13 @@ gst_rtp_theora_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   guint32 timestamp;
   guint32 header, ident;
   guint8 F, TDT, packets;
+  GstRTPBuffer rtp;
 
   rtptheoradepay = GST_RTP_THEORA_DEPAY (depayload);
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   GST_DEBUG_OBJECT (depayload, "got RTP packet of size %d", payload_len);
 
@@ -418,7 +421,7 @@ gst_rtp_theora_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   if (G_UNLIKELY (payload_len < 4))
     goto packet_short;
 
-  payload = gst_rtp_buffer_get_payload (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
   header = GST_READ_UINT32_BE (payload);
   /*
@@ -483,7 +486,7 @@ gst_rtp_theora_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     /* first assembled packet, reuse 2 bytes to store the length */
     headerskip = (F == 1 ? 4 : 6);
     /* skip header and length. */
-    vdata = gst_rtp_buffer_get_payload_subbuffer (buf, headerskip, -1);
+    vdata = gst_rtp_buffer_get_payload_subbuffer (&rtp, headerskip, -1);
 
     GST_DEBUG_OBJECT (depayload, "assemble theora packet");
     gst_adapter_push (rtptheoradepay->adapter, vdata);
@@ -522,7 +525,7 @@ gst_rtp_theora_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
    * ..                        theora data                           |
    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+*
    */
-  timestamp = gst_rtp_buffer_get_timestamp (buf);
+  timestamp = gst_rtp_buffer_get_timestamp (&rtp);
 
   while (payload_len >= 2) {
     guint16 length;
@@ -550,13 +553,17 @@ gst_rtp_theora_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     /* create buffer for packet */
     if (G_UNLIKELY (to_free)) {
       outbuf = gst_buffer_new ();
-      GST_BUFFER_DATA (outbuf) = payload;
-      GST_BUFFER_MALLOCDATA (outbuf) = to_free;
-      GST_BUFFER_SIZE (outbuf) = length;
+      gst_buffer_take_memory (buf, -1,
+          gst_memory_new_wrapped (0, to_free, g_free,
+              (payload - to_free) + length, payload - to_free, length));
       to_free = NULL;
     } else {
+      guint8 *odata;
+
       outbuf = gst_buffer_new_and_alloc (length);
-      memcpy (GST_BUFFER_DATA (outbuf), payload, length);
+      odata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+      memcpy (odata, payload, length);
+      gst_buffer_unmap (outbuf, odata, -1);
     }
 
     if (payload_len > 0 && (payload[0] & 0xC0) == 0x0)
@@ -584,10 +591,12 @@ gst_rtp_theora_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   if (rtptheoradepay->needs_keyframe)
     goto request_keyframe;
 
+  gst_rtp_buffer_unmap (&rtp);
   return NULL;
 
 no_output:
   {
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
   /* ERORRS */
@@ -606,6 +615,7 @@ packet_short:
 ignore_reserved:
   {
     GST_WARNING_OBJECT (rtptheoradepay, "reserved TDT ignored");
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 length_short:
@@ -627,6 +637,7 @@ request_config:
         gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM,
             gst_structure_new ("GstForceKeyUnit",
                 "all-headers", G_TYPE_BOOLEAN, TRUE, NULL)));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 request_keyframe:
@@ -635,6 +646,7 @@ request_keyframe:
     gst_pad_push_event (GST_BASE_RTP_DEPAYLOAD_SINKPAD (depayload),
         gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM,
             gst_structure_new ("GstForceKeyUnit", NULL)));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
@@ -653,7 +665,7 @@ gst_rtp_theora_depay_packet_lost (GstBaseRTPDepayload * depayload,
   GstRtpTheoraDepay *rtptheoradepay = GST_RTP_THEORA_DEPAY (depayload);
   guint seqnum = 0;
 
-  gst_structure_get_uint (event->structure, "seqnum", &seqnum);
+  gst_structure_get_uint (gst_event_get_structure (event), "seqnum", &seqnum);
   GST_LOG_OBJECT (depayload, "Requested keyframe because frame with seqnum %u"
       " is missing", seqnum);
   rtptheoradepay->needs_keyframe = TRUE;
index 0092fbc..496f57c 100644 (file)
@@ -75,8 +75,8 @@ enum
   PROP_CONFIG_INTERVAL
 };
 
-GST_BOILERPLATE (GstRtpTheoraPay, gst_rtp_theora_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
+#define gst_rtp_theora_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpTheoraPay, gst_rtp_theora_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static gboolean gst_rtp_theora_pay_setcaps (GstBaseRTPPayload * basepayload,
     GstCaps * caps);
@@ -84,7 +84,7 @@ static GstStateChangeReturn gst_rtp_theora_pay_change_state (GstElement *
     element, GstStateChange transition);
 static GstFlowReturn gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * pad,
     GstBuffer * buffer);
-static gboolean gst_rtp_theora_pay_handle_event (GstPad * pad,
+static gboolean gst_rtp_theora_pay_handle_event (GstBaseRTPPayload * payload,
     GstEvent * event);
 
 
@@ -94,22 +94,6 @@ static void gst_rtp_theora_pay_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
 static void
-gst_rtp_theora_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_theora_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_theora_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP Theora payloader",
-      "Codec/Payloader/Network/RTP",
-      "Payload-encode Theora video into RTP packets (draft-01 RFC XXXX)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_theora_pay_class_init (GstRtpTheoraPayClass * klass)
 {
   GObjectClass *gobject_class;
@@ -129,6 +113,16 @@ gst_rtp_theora_pay_class_init (GstRtpTheoraPayClass * klass)
   gobject_class->set_property = gst_rtp_theora_pay_set_property;
   gobject_class->get_property = gst_rtp_theora_pay_get_property;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_theora_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_theora_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP Theora payloader", "Codec/Payloader/Network/RTP",
+      "Payload-encode Theora video into RTP packets (draft-01 RFC XXXX)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtptheorapay_debug, "rtptheorapay", 0,
       "Theora RTP Payloader");
 
@@ -142,8 +136,7 @@ gst_rtp_theora_pay_class_init (GstRtpTheoraPayClass * klass)
 }
 
 static void
-gst_rtp_theora_pay_init (GstRtpTheoraPay * rtptheorapay,
-    GstRtpTheoraPayClass * klass)
+gst_rtp_theora_pay_init (GstRtpTheoraPay * rtptheorapay)
 {
   rtptheorapay->last_config = GST_CLOCK_TIME_NONE;
 }
@@ -187,11 +180,14 @@ static void
 gst_rtp_theora_pay_reset_packet (GstRtpTheoraPay * rtptheorapay, guint8 TDT)
 {
   guint payload_len;
+  GstRTPBuffer rtp;
 
   GST_DEBUG_OBJECT (rtptheorapay, "reset packet");
 
   rtptheorapay->payload_pos = 4;
-  payload_len = gst_rtp_buffer_get_payload_len (rtptheorapay->packet);
+  gst_rtp_buffer_map (rtptheorapay->packet, GST_MAP_READ, &rtp);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
   rtptheorapay->payload_left = payload_len - 4;
   rtptheorapay->payload_duration = 0;
   rtptheorapay->payload_F = 0;
@@ -223,6 +219,7 @@ gst_rtp_theora_pay_flush_packet (GstRtpTheoraPay * rtptheorapay)
   GstFlowReturn ret;
   guint8 *payload;
   guint hlen;
+  GstRTPBuffer rtp;
 
   /* check for empty packet */
   if (!rtptheorapay->packet || rtptheorapay->payload_pos <= 4)
@@ -230,8 +227,10 @@ gst_rtp_theora_pay_flush_packet (GstRtpTheoraPay * rtptheorapay)
 
   GST_DEBUG_OBJECT (rtptheorapay, "flushing packet");
 
+  gst_rtp_buffer_map (rtptheorapay->packet, GST_MAP_WRITE, &rtp);
+
   /* fix header */
-  payload = gst_rtp_buffer_get_payload (rtptheorapay->packet);
+  payload = gst_rtp_buffer_get_payload (&rtp);
   /*
    *  0                   1                   2                   3
    *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -250,9 +249,11 @@ gst_rtp_theora_pay_flush_packet (GstRtpTheoraPay * rtptheorapay)
       (rtptheorapay->payload_TDT & 0x3) << 4 |
       (rtptheorapay->payload_pkts & 0xf);
 
+  gst_rtp_buffer_unmap (&rtp);
+
   /* shrink the buffer size to the last written byte */
   hlen = gst_rtp_buffer_calc_header_len (0);
-  GST_BUFFER_SIZE (rtptheorapay->packet) = hlen + rtptheorapay->payload_pos;
+  gst_buffer_resize (rtptheorapay->packet, 0, hlen + rtptheorapay->payload_pos);
 
   GST_BUFFER_DURATION (rtptheorapay->packet) = rtptheorapay->payload_duration;
 
@@ -334,10 +335,11 @@ gst_rtp_theora_pay_finish_headers (GstBaseRTPPayload * basepayload)
   extralen = 1;
   for (walk = rtptheorapay->headers; walk; walk = g_list_next (walk)) {
     GstBuffer *buf = GST_BUFFER_CAST (walk->data);
-
     guint bsize;
+    guint8 *data;
+    gsize size;
 
-    bsize = GST_BUFFER_SIZE (buf);
+    bsize = gst_buffer_get_size (buf);
     length += bsize;
     n_headers++;
 
@@ -351,8 +353,9 @@ gst_rtp_theora_pay_finish_headers (GstBaseRTPPayload * basepayload)
       } while (bsize);
     }
     /* update hash */
-    ident = fnv1_hash_32_update (ident, GST_BUFFER_DATA (buf),
-        GST_BUFFER_SIZE (buf));
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+    ident = fnv1_hash_32_update (ident, data, size);
+    gst_buffer_unmap (buf, data, -1);
   }
 
   /* packet length is header size + packet length */
@@ -393,7 +396,7 @@ gst_rtp_theora_pay_finish_headers (GstBaseRTPPayload * basepayload)
     if (!g_list_next (walk))
       break;
 
-    bsize = GST_BUFFER_SIZE (buf);
+    bsize = gst_buffer_get_size (buf);
 
     /* calc size */
     size = 0;
@@ -403,7 +406,7 @@ gst_rtp_theora_pay_finish_headers (GstBaseRTPPayload * basepayload)
     } while (bsize);
     temp = size;
 
-    bsize = GST_BUFFER_SIZE (buf);
+    bsize = gst_buffer_get_size (buf);
     /* write the size backwards */
     flag = 0;
     while (size) {
@@ -418,9 +421,13 @@ gst_rtp_theora_pay_finish_headers (GstBaseRTPPayload * basepayload)
   /* copy header data */
   for (walk = rtptheorapay->headers; walk; walk = g_list_next (walk)) {
     GstBuffer *buf = GST_BUFFER_CAST (walk->data);
+    guint8 *bdata;
+    gsize bsize;
 
-    memcpy (data, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
-    data += GST_BUFFER_SIZE (buf);
+    bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+    memcpy (data, bdata, bsize);
+    gst_buffer_unmap (buf, bdata, -1);
+    data += bsize;
   }
 
   /* serialize to base64 */
@@ -532,6 +539,7 @@ gst_rtp_theora_pay_payload_buffer (GstRtpTheoraPay * rtptheorapay, guint8 TDT,
   guint plen;
   guint8 *ppos, *payload;
   gboolean fragmented;
+  GstRTPBuffer rtp;
 
   /* size increases with packet length and 2 bytes size eader. */
   newduration = rtptheorapay->payload_duration;
@@ -557,7 +565,8 @@ gst_rtp_theora_pay_payload_buffer (GstRtpTheoraPay * rtptheorapay, guint8 TDT,
     gst_rtp_theora_pay_init_packet (rtptheorapay, TDT, timestamp);
   }
 
-  payload = gst_rtp_buffer_get_payload (rtptheorapay->packet);
+  gst_rtp_buffer_map (rtptheorapay->packet, GST_MAP_WRITE, &rtp);
+  payload = gst_rtp_buffer_get_payload (&rtp);
   ppos = payload + rtptheorapay->payload_pos;
   fragmented = FALSE;
 
@@ -602,13 +611,15 @@ gst_rtp_theora_pay_payload_buffer (GstRtpTheoraPay * rtptheorapay, guint8 TDT,
     if (fragmented) {
       /* fragmented packets are always flushed and have ptks of 0 */
       rtptheorapay->payload_pkts = 0;
+      gst_rtp_buffer_unmap (&rtp);
       ret = gst_rtp_theora_pay_flush_packet (rtptheorapay);
 
       if (size > 0) {
         /* start new packet and get pointers. TDT stays the same. */
         gst_rtp_theora_pay_init_packet (rtptheorapay,
             rtptheorapay->payload_TDT, timestamp);
-        payload = gst_rtp_buffer_get_payload (rtptheorapay->packet);
+        gst_rtp_buffer_map (rtptheorapay->packet, GST_MAP_WRITE, &rtp);
+        payload = gst_rtp_buffer_get_payload (&rtp);
         ppos = payload + rtptheorapay->payload_pos;
       }
     } else {
@@ -620,6 +631,9 @@ gst_rtp_theora_pay_payload_buffer (GstRtpTheoraPay * rtptheorapay, guint8 TDT,
     }
   } while (size);
 
+  if (rtp.buffer)
+    gst_rtp_buffer_unmap (&rtp);
+
   return ret;
 }
 
@@ -629,7 +643,7 @@ gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 {
   GstRtpTheoraPay *rtptheorapay;
   GstFlowReturn ret;
-  guint size;
+  gsize size;
   guint8 *data;
   GstClockTime duration, timestamp;
   guint8 TDT;
@@ -637,13 +651,12 @@ gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
   rtptheorapay = GST_RTP_THEORA_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   duration = GST_BUFFER_DURATION (buffer);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
 
-  GST_DEBUG_OBJECT (rtptheorapay, "size %u, duration %" GST_TIME_FORMAT,
-      size, GST_TIME_ARGS (duration));
+  GST_DEBUG_OBJECT (rtptheorapay, "size %" G_GSIZE_FORMAT
+      ", duration %" GST_TIME_FORMAT, size, GST_TIME_ARGS (duration));
 
   if (G_UNLIKELY (size > 0xffff))
     goto wrong_size;
@@ -679,6 +692,7 @@ gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     if (TDT != 0) {
       GST_DEBUG_OBJECT (rtptheorapay, "collecting header, buffer %p", buffer);
       /* append header to the list of headers */
+      gst_buffer_unmap (buffer, data, -1);
       rtptheorapay->headers = g_list_append (rtptheorapay->headers, buffer);
       ret = GST_FLOW_OK;
       goto done;
@@ -738,6 +752,8 @@ gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
   ret = gst_rtp_theora_pay_payload_buffer (rtptheorapay, TDT, data, size,
       timestamp, duration, 0);
+
+  gst_buffer_unmap (buffer, data, -1);
   gst_buffer_unref (buffer);
 
 done:
@@ -748,11 +764,13 @@ wrong_size:
   {
     GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
         ("Invalid packet size (%d <= 0xffff)", size), (NULL));
+    gst_buffer_unmap (buffer, data, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_OK;
   }
 parse_id_failed:
   {
+    gst_buffer_unmap (buffer, data, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_ERROR;
   }
@@ -760,6 +778,7 @@ unknown_header:
   {
     GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
         (NULL), ("Ignoring unknown header received"));
+    gst_buffer_unmap (buffer, data, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_OK;
   }
@@ -767,15 +786,16 @@ header_error:
   {
     GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
         (NULL), ("Error initializing header config"));
+    gst_buffer_unmap (buffer, data, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_OK;
   }
 }
 
 static gboolean
-gst_rtp_theora_pay_handle_event (GstPad * pad, GstEvent * event)
+gst_rtp_theora_pay_handle_event (GstBaseRTPPayload * payload, GstEvent * event)
 {
-  GstRtpTheoraPay *rtptheorapay = GST_RTP_THEORA_PAY (GST_PAD_PARENT (pad));
+  GstRtpTheoraPay *rtptheorapay = GST_RTP_THEORA_PAY (payload);
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_FLUSH_STOP:
index 506558d..08ef282 100644 (file)
@@ -57,7 +57,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
     GST_STATIC_CAPS ("audio/x-vorbis")
     );
 
-GST_BOILERPLATE (GstRtpVorbisDepay, gst_rtp_vorbis_depay, GstBaseRTPDepayload,
+#define gst_rtp_vorbis_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpVorbisDepay, gst_rtp_vorbis_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static gboolean gst_rtp_vorbis_depay_setcaps (GstBaseRTPDepayload * depayload,
@@ -70,23 +71,6 @@ static void gst_rtp_vorbis_depay_finalize (GObject * object);
 static GstStateChangeReturn gst_rtp_vorbis_depay_change_state (GstElement *
     element, GstStateChange transition);
 
-
-static void
-gst_rtp_vorbis_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_vorbis_depay_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_vorbis_depay_src_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP Vorbis depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts Vorbis Audio from RTP packets (RFC 5215)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
 static void
 gst_rtp_vorbis_depay_class_init (GstRtpVorbisDepayClass * klass)
 {
@@ -105,13 +89,22 @@ gst_rtp_vorbis_depay_class_init (GstRtpVorbisDepayClass * klass)
   gstbasertpdepayload_class->process = gst_rtp_vorbis_depay_process;
   gstbasertpdepayload_class->set_caps = gst_rtp_vorbis_depay_setcaps;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_vorbis_depay_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_vorbis_depay_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP Vorbis depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts Vorbis Audio from RTP packets (RFC 5215)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtpvorbisdepay_debug, "rtpvorbisdepay", 0,
       "Vorbis RTP Depayloader");
 }
 
 static void
-gst_rtp_vorbis_depay_init (GstRtpVorbisDepay * rtpvorbisdepay,
-    GstRtpVorbisDepayClass * klass)
+gst_rtp_vorbis_depay_init (GstRtpVorbisDepay * rtpvorbisdepay)
 {
   rtpvorbisdepay->adapter = gst_adapter_new ();
 }
@@ -159,15 +152,14 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
 {
   GstBuffer *buf;
   guint32 num_headers;
-  guint8 *data;
-  guint size;
+  guint8 *data, *bdata;
+  gsize size;
   guint offset;
   gint i, j;
 
-  data = GST_BUFFER_DATA (confbuf);
-  size = GST_BUFFER_SIZE (confbuf);
+  bdata = data = gst_buffer_map (confbuf, &size, NULL, GST_MAP_READ);
 
-  GST_DEBUG_OBJECT (rtpvorbisdepay, "config size %u", size);
+  GST_DEBUG_OBJECT (rtpvorbisdepay, "config size %" G_GSIZE_FORMAT, size);
 
   /* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    * |                     Number of packed headers                  |
@@ -293,13 +285,16 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
       GST_DEBUG_OBJECT (rtpvorbisdepay, "reading header %d, size %u", j,
           h_size);
 
-      buf = gst_buffer_create_sub (confbuf, offset, h_size);
+      buf = gst_buffer_copy_region (confbuf, GST_BUFFER_COPY_MEMORY, offset,
+          h_size);
       conf->headers = g_list_append (conf->headers, buf);
       offset += h_size;
       size -= h_size;
     }
     rtpvorbisdepay->configs = g_list_append (rtpvorbisdepay->configs, conf);
   }
+
+  gst_buffer_unmap (confbuf, bdata, -1);
   gst_buffer_unref (confbuf);
 
   return TRUE;
@@ -308,6 +303,7 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
 too_small:
   {
     GST_DEBUG_OBJECT (rtpvorbisdepay, "configuration too small");
+    gst_buffer_unmap (confbuf, bdata, -1);
     gst_buffer_unref (confbuf);
     return FALSE;
   }
@@ -326,7 +322,7 @@ gst_rtp_vorbis_depay_parse_inband_configuration (GstRtpVorbisDepay *
 
   /* transform inline to out-of-band and parse that one */
   confbuf = gst_buffer_new_and_alloc (size + 9);
-  conf = GST_BUFFER_DATA (confbuf);
+  conf = gst_buffer_map (confbuf, NULL, NULL, -1);
   /* 1 header */
   GST_WRITE_UINT32_BE (conf, 1);
   /* write Ident */
@@ -335,6 +331,7 @@ gst_rtp_vorbis_depay_parse_inband_configuration (GstRtpVorbisDepay *
   GST_WRITE_UINT16_BE (conf + 7, length);
   /* copy remainder */
   memcpy (conf + 9, configuration, size);
+  gst_buffer_unmap (confbuf, conf, -1);
 
   return gst_rtp_vorbis_depay_parse_configuration (rtpvorbisdepay, confbuf);
 }
@@ -368,9 +365,8 @@ gst_rtp_vorbis_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
     data = g_base64_decode (configuration, &size);
 
     confbuf = gst_buffer_new ();
-    GST_BUFFER_DATA (confbuf) = data;
-    GST_BUFFER_MALLOCDATA (confbuf) = data;
-    GST_BUFFER_SIZE (confbuf) = size;
+    gst_buffer_take_memory (confbuf, -1,
+        gst_memory_new_wrapped (0, data, g_free, size, 0, size));
     if (!gst_rtp_vorbis_depay_parse_configuration (rtpvorbisdepay, confbuf))
       goto invalid_configuration;
   } else {
@@ -447,10 +443,13 @@ gst_rtp_vorbis_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   guint32 timestamp;
   guint32 header, ident;
   guint8 F, VDT, packets;
+  GstRTPBuffer rtp;
 
   rtpvorbisdepay = GST_RTP_VORBIS_DEPAY (depayload);
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   GST_DEBUG_OBJECT (depayload, "got RTP packet of size %d", payload_len);
 
@@ -458,7 +457,7 @@ gst_rtp_vorbis_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   if (G_UNLIKELY (payload_len < 4))
     goto packet_short;
 
-  payload = gst_rtp_buffer_get_payload (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
   header = GST_READ_UINT32_BE (payload);
   /*
@@ -526,7 +525,7 @@ gst_rtp_vorbis_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     /* first assembled packet, reuse 2 bytes to store the length */
     headerskip = (F == 1 ? 4 : 6);
     /* skip header and length. */
-    vdata = gst_rtp_buffer_get_payload_subbuffer (buf, headerskip, -1);
+    vdata = gst_rtp_buffer_get_payload_subbuffer (&rtp, headerskip, -1);
 
     GST_DEBUG_OBJECT (depayload, "assemble vorbis packet");
     gst_adapter_push (rtpvorbisdepay->adapter, vdata);
@@ -565,7 +564,7 @@ gst_rtp_vorbis_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
    * ..                        vorbis data                           |
    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+*
    */
-  timestamp = gst_rtp_buffer_get_timestamp (buf);
+  timestamp = gst_rtp_buffer_get_timestamp (&rtp);
 
   while (payload_len > 2) {
     guint16 length;
@@ -593,13 +592,17 @@ gst_rtp_vorbis_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     /* create buffer for packet */
     if (G_UNLIKELY (to_free)) {
       outbuf = gst_buffer_new ();
-      GST_BUFFER_DATA (outbuf) = payload;
-      GST_BUFFER_MALLOCDATA (outbuf) = to_free;
-      GST_BUFFER_SIZE (outbuf) = length;
+      gst_buffer_take_memory (outbuf, -1,
+          gst_memory_new_wrapped (0, to_free, g_free,
+              (payload - to_free) + length, payload - to_free, length));
       to_free = NULL;
     } else {
+      guint8 *data;
+
       outbuf = gst_buffer_new_and_alloc (length);
-      memcpy (GST_BUFFER_DATA (outbuf), payload, length);
+      data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+      memcpy (data, payload, length);
+      gst_buffer_unmap (outbuf, data, -1);
     }
 
     payload += length;
@@ -621,10 +624,13 @@ gst_rtp_vorbis_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
   g_free (to_free);
 
+  gst_rtp_buffer_unmap (&rtp);
+
   return NULL;
 
 no_output:
   {
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
   /* ERORRS */
@@ -632,23 +638,27 @@ switch_failed:
   {
     GST_ELEMENT_WARNING (rtpvorbisdepay, STREAM, DECODE,
         (NULL), ("Could not switch codebooks"));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 packet_short:
   {
     GST_ELEMENT_WARNING (rtpvorbisdepay, STREAM, DECODE,
         (NULL), ("Packet was too short (%d < 4)", payload_len));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 ignore_reserved:
   {
     GST_WARNING_OBJECT (rtpvorbisdepay, "reserved VDT ignored");
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 length_short:
   {
     GST_ELEMENT_WARNING (rtpvorbisdepay, STREAM, DECODE,
         (NULL), ("Packet contains invalid data"));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 invalid_configuration:
@@ -656,6 +666,7 @@ invalid_configuration:
     /* fatal, as we otherwise risk carrying on without output */
     GST_ELEMENT_ERROR (rtpvorbisdepay, STREAM, DECODE,
         (NULL), ("Packet contains invalid configuration"));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index a7841c3..09f71e6 100644 (file)
@@ -58,8 +58,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     GST_STATIC_CAPS ("audio/x-vorbis")
     );
 
-GST_BOILERPLATE (GstRtpVorbisPay, gst_rtp_vorbis_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD);
+#define gst_rtp_vorbis_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpVorbisPay, gst_rtp_vorbis_pay, GST_TYPE_BASE_RTP_PAYLOAD);
 
 static gboolean gst_rtp_vorbis_pay_setcaps (GstBaseRTPPayload * basepayload,
     GstCaps * caps);
@@ -67,26 +67,10 @@ static GstStateChangeReturn gst_rtp_vorbis_pay_change_state (GstElement *
     element, GstStateChange transition);
 static GstFlowReturn gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * pad,
     GstBuffer * buffer);
-static gboolean gst_rtp_vorbis_pay_handle_event (GstPad * pad,
+static gboolean gst_rtp_vorbis_pay_handle_event (GstBaseRTPPayload * payload,
     GstEvent * event);
 
 static void
-gst_rtp_vorbis_pay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_vorbis_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_vorbis_pay_sink_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP Vorbis depayloader",
-      "Codec/Payloader/Network/RTP",
-      "Payload-encode Vorbis audio into RTP packets (RFC 5215)",
-      "Wim Taymans <wimi.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_vorbis_pay_class_init (GstRtpVorbisPayClass * klass)
 {
   GstElementClass *gstelement_class;
@@ -101,13 +85,23 @@ gst_rtp_vorbis_pay_class_init (GstRtpVorbisPayClass * klass)
   gstbasertppayload_class->handle_buffer = gst_rtp_vorbis_pay_handle_buffer;
   gstbasertppayload_class->handle_event = gst_rtp_vorbis_pay_handle_event;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_vorbis_pay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_vorbis_pay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP Vorbis depayloader",
+      "Codec/Payloader/Network/RTP",
+      "Payload-encode Vorbis audio into RTP packets (RFC 5215)",
+      "Wim Taymans <wimi.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtpvorbispay_debug, "rtpvorbispay", 0,
       "Vorbis RTP Payloader");
 }
 
 static void
-gst_rtp_vorbis_pay_init (GstRtpVorbisPay * rtpvorbispay,
-    GstRtpVorbisPayClass * klass)
+gst_rtp_vorbis_pay_init (GstRtpVorbisPay * rtpvorbispay)
 {
   /* needed because of GST_BOILERPLATE */
 }
@@ -146,11 +140,14 @@ static void
 gst_rtp_vorbis_pay_reset_packet (GstRtpVorbisPay * rtpvorbispay, guint8 VDT)
 {
   guint payload_len;
+  GstRTPBuffer rtp;
 
   GST_LOG_OBJECT (rtpvorbispay, "reset packet");
 
   rtpvorbispay->payload_pos = 4;
-  payload_len = gst_rtp_buffer_get_payload_len (rtpvorbispay->packet);
+  gst_rtp_buffer_map (rtpvorbispay->packet, GST_MAP_READ, &rtp);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
   rtpvorbispay->payload_left = payload_len - 4;
   rtpvorbispay->payload_duration = 0;
   rtpvorbispay->payload_F = 0;
@@ -181,6 +178,7 @@ gst_rtp_vorbis_pay_flush_packet (GstRtpVorbisPay * rtpvorbispay)
   GstFlowReturn ret;
   guint8 *payload;
   guint hlen;
+  GstRTPBuffer rtp;
 
   /* check for empty packet */
   if (!rtpvorbispay->packet || rtpvorbispay->payload_pos <= 4)
@@ -188,8 +186,10 @@ gst_rtp_vorbis_pay_flush_packet (GstRtpVorbisPay * rtpvorbispay)
 
   GST_LOG_OBJECT (rtpvorbispay, "flushing packet");
 
+  gst_rtp_buffer_map (rtpvorbispay->packet, GST_MAP_WRITE, &rtp);
+
   /* fix header */
-  payload = gst_rtp_buffer_get_payload (rtpvorbispay->packet);
+  payload = gst_rtp_buffer_get_payload (&rtp);
   /*
    *  0                   1                   2                   3
    *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -208,9 +208,11 @@ gst_rtp_vorbis_pay_flush_packet (GstRtpVorbisPay * rtpvorbispay)
       (rtpvorbispay->payload_VDT & 0x3) << 4 |
       (rtpvorbispay->payload_pkts & 0xf);
 
+  gst_rtp_buffer_unmap (&rtp);
+
   /* shrink the buffer size to the last written byte */
   hlen = gst_rtp_buffer_calc_header_len (0);
-  GST_BUFFER_SIZE (rtpvorbispay->packet) = hlen + rtpvorbispay->payload_pos;
+  gst_buffer_resize (rtpvorbispay->packet, 0, hlen + rtpvorbispay->payload_pos);
 
   GST_BUFFER_DURATION (rtpvorbispay->packet) = rtpvorbispay->payload_duration;
 
@@ -289,9 +291,10 @@ gst_rtp_vorbis_pay_finish_headers (GstBaseRTPPayload * basepayload)
   ident = fnv1_hash_32_new ();
   for (walk = rtpvorbispay->headers; walk; walk = g_list_next (walk)) {
     GstBuffer *buf = GST_BUFFER_CAST (walk->data);
-    guint bsize;
+    guint bsize, osize;
+    guint8 *data;
 
-    bsize = GST_BUFFER_SIZE (buf);
+    bsize = osize = gst_buffer_get_size (buf);
     length += bsize;
     n_headers++;
 
@@ -304,8 +307,9 @@ gst_rtp_vorbis_pay_finish_headers (GstBaseRTPPayload * basepayload)
       } while (bsize);
     }
     /* update hash */
-    ident = fnv1_hash_32_update (ident, GST_BUFFER_DATA (buf),
-        GST_BUFFER_SIZE (buf));
+    data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
+    ident = fnv1_hash_32_update (ident, data, osize);
+    gst_buffer_unmap (buf, data, -1);
   }
 
   /* packet length is header size + packet length */
@@ -345,7 +349,7 @@ gst_rtp_vorbis_pay_finish_headers (GstBaseRTPPayload * basepayload)
     if (!g_list_next (walk))
       break;
 
-    bsize = GST_BUFFER_SIZE (buf);
+    bsize = gst_buffer_get_size (buf);
 
     /* calc size */
     size = 0;
@@ -355,7 +359,7 @@ gst_rtp_vorbis_pay_finish_headers (GstBaseRTPPayload * basepayload)
     } while (bsize);
     temp = size;
 
-    bsize = GST_BUFFER_SIZE (buf);
+    bsize = gst_buffer_get_size (buf);
     /* write the size backwards */
     flag = 0;
     while (size) {
@@ -371,8 +375,8 @@ gst_rtp_vorbis_pay_finish_headers (GstBaseRTPPayload * basepayload)
   for (walk = rtpvorbispay->headers; walk; walk = g_list_next (walk)) {
     GstBuffer *buf = GST_BUFFER_CAST (walk->data);
 
-    memcpy (data, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
-    data += GST_BUFFER_SIZE (buf);
+    gst_buffer_extract (buf, 0, data, gst_buffer_get_size (buf));
+    data += gst_buffer_get_size (buf);
   }
 
   /* serialize to base64 */
@@ -470,7 +474,8 @@ gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 {
   GstRtpVorbisPay *rtpvorbispay;
   GstFlowReturn ret;
-  guint size, newsize;
+  guint newsize;
+  gsize size;
   guint8 *data;
   guint packet_len;
   GstClockTime duration, newduration, timestamp;
@@ -479,16 +484,16 @@ gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   guint plen;
   guint8 *ppos, *payload;
   gboolean fragmented;
+  GstRTPBuffer rtp;
 
   rtpvorbispay = GST_RTP_VORBIS_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   duration = GST_BUFFER_DURATION (buffer);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
 
-  GST_LOG_OBJECT (rtpvorbispay, "size %u, duration %" GST_TIME_FORMAT,
-      size, GST_TIME_ARGS (duration));
+  GST_LOG_OBJECT (rtpvorbispay, "size %" G_GSIZE_FORMAT
+      ", duration %" GST_TIME_FORMAT, size, GST_TIME_ARGS (duration));
 
   if (G_UNLIKELY (size < 1 || size > 0xffff))
     goto wrong_size;
@@ -518,6 +523,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     if (VDT != 0) {
       GST_DEBUG_OBJECT (rtpvorbispay, "collecting header");
       /* append header to the list of headers */
+      gst_buffer_unmap (buffer, data, -1);
       rtpvorbispay->headers = g_list_append (rtpvorbispay->headers, buffer);
       ret = GST_FLOW_OK;
       goto done;
@@ -551,7 +557,8 @@ gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     gst_rtp_vorbis_pay_init_packet (rtpvorbispay, VDT, timestamp);
   }
 
-  payload = gst_rtp_buffer_get_payload (rtpvorbispay->packet);
+  gst_rtp_buffer_map (rtpvorbispay->packet, GST_MAP_WRITE, &rtp);
+  payload = gst_rtp_buffer_get_payload (&rtp);
   ppos = payload + rtpvorbispay->payload_pos;
   fragmented = FALSE;
 
@@ -591,6 +598,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload,
       }
     }
     if (fragmented) {
+      gst_rtp_buffer_unmap (&rtp);
       /* fragmented packets are always flushed and have ptks of 0 */
       rtpvorbispay->payload_pkts = 0;
       ret = gst_rtp_vorbis_pay_flush_packet (rtpvorbispay);
@@ -599,7 +607,8 @@ gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload,
         /* start new packet and get pointers. VDT stays the same. */
         gst_rtp_vorbis_pay_init_packet (rtpvorbispay,
             rtpvorbispay->payload_VDT, timestamp);
-        payload = gst_rtp_buffer_get_payload (rtpvorbispay->packet);
+        gst_rtp_buffer_map (rtpvorbispay->packet, GST_MAP_WRITE, &rtp);
+        payload = gst_rtp_buffer_get_payload (&rtp);
         ppos = payload + rtpvorbispay->payload_pos;
       }
     } else {
@@ -610,6 +619,11 @@ gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload,
         rtpvorbispay->payload_duration += duration;
     }
   }
+
+  if (rtp.buffer)
+    gst_rtp_buffer_unmap (&rtp);
+
+  gst_buffer_unmap (buffer, data, -1);
   gst_buffer_unref (buffer);
 
 done:
@@ -620,11 +634,13 @@ wrong_size:
   {
     GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
         ("Invalid packet size (1 < %d <= 0xffff)", size), (NULL));
+    gst_buffer_unmap (buffer, data, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_OK;
   }
 parse_id_failed:
   {
+    gst_buffer_unmap (buffer, data, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_ERROR;
   }
@@ -632,6 +648,7 @@ unknown_header:
   {
     GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
         (NULL), ("Ignoring unknown header received"));
+    gst_buffer_unmap (buffer, data, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_OK;
   }
@@ -639,15 +656,16 @@ header_error:
   {
     GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
         (NULL), ("Error initializing header config"));
+    gst_buffer_unmap (buffer, data, -1);
     gst_buffer_unref (buffer);
     return GST_FLOW_OK;
   }
 }
 
 static gboolean
-gst_rtp_vorbis_pay_handle_event (GstPad * pad, GstEvent * event)
+gst_rtp_vorbis_pay_handle_event (GstBaseRTPPayload * payload, GstEvent * event)
 {
-  GstRtpVorbisPay *rtpvorbispay = GST_RTP_VORBIS_PAY (GST_PAD_PARENT (pad));
+  GstRtpVorbisPay *rtpvorbispay = GST_RTP_VORBIS_PAY (payload);
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_FLUSH_STOP:
index 5919a5b..e32f450 100644 (file)
@@ -31,10 +31,10 @@ GST_DEBUG_CATEGORY_STATIC (rtpvrawdepay_debug);
 #define GST_CAT_DEFAULT (rtpvrawdepay_debug)
 
 static GstStaticPadTemplate gst_rtp_vraw_depay_src_template =
-    GST_STATIC_PAD_TEMPLATE ("src",
+GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("video/x-raw-rgb; video/x-raw-yuv")
+    GST_STATIC_CAPS ("video/x-raw")
     );
 
 static GstStaticPadTemplate gst_rtp_vraw_depay_sink_template =
@@ -47,7 +47,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
         "clock-rate = (int) 90000, " "encoding-name = (string) \"RAW\"")
     );
 
-GST_BOILERPLATE (GstRtpVRawDepay, gst_rtp_vraw_depay, GstBaseRTPDepayload,
+#define gst_rtp_vraw_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpVRawDepay, gst_rtp_vraw_depay,
     GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static gboolean gst_rtp_vraw_depay_setcaps (GstBaseRTPDepayload * depayload,
@@ -62,22 +63,6 @@ static gboolean gst_rtp_vraw_depay_handle_event (GstBaseRTPDepayload * filter,
     GstEvent * event);
 
 static void
-gst_rtp_vraw_depay_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_vraw_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_vraw_depay_sink_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP Raw Video depayloader", "Codec/Depayloader/Network/RTP",
-      "Extracts raw video from RTP packets (RFC 4175)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_vraw_depay_class_init (GstRtpVRawDepayClass * klass)
 {
   GstElementClass *gstelement_class;
@@ -92,13 +77,22 @@ gst_rtp_vraw_depay_class_init (GstRtpVRawDepayClass * klass)
   gstbasertpdepayload_class->process = gst_rtp_vraw_depay_process;
   gstbasertpdepayload_class->handle_event = gst_rtp_vraw_depay_handle_event;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_vraw_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_vraw_depay_sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP Raw Video depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts raw video from RTP packets (RFC 4175)",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (rtpvrawdepay_debug, "rtpvrawdepay", 0,
       "raw video RTP Depayloader");
 }
 
 static void
-gst_rtp_vraw_depay_init (GstRtpVRawDepay * rtpvrawdepay,
-    GstRtpVRawDepayClass * klass)
+gst_rtp_vraw_depay_init (GstRtpVRawDepay * rtpvrawdepay)
 {
   /* needed because of GST_BOILERPLATE */
 }
@@ -111,6 +105,61 @@ gst_rtp_vraw_depay_reset (GstRtpVRawDepay * rtpvrawdepay)
     rtpvrawdepay->outbuf = NULL;
   }
   rtpvrawdepay->timestamp = -1;
+  if (rtpvrawdepay->pool) {
+    gst_buffer_pool_set_active (rtpvrawdepay->pool, FALSE);
+    gst_object_unref (rtpvrawdepay->pool);
+    rtpvrawdepay->pool = NULL;
+  }
+}
+
+static GstFlowReturn
+gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps,
+    GstVideoInfo * info)
+{
+  GstQuery *query;
+  GstBufferPool *pool = NULL;
+  guint size, min, max, prefix, alignment;
+  GstStructure *config;
+
+  /* find a pool for the negotiated caps now */
+  query = gst_query_new_allocation (caps, TRUE);
+
+  if (gst_pad_peer_query (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depay), query)) {
+    GST_DEBUG_OBJECT (depay, "got downstream ALLOCATION hints");
+    /* we got configuration from our peer, parse them */
+    gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
+        &alignment, &pool);
+  } else {
+    GST_DEBUG_OBJECT (depay, "didn't get downstream ALLOCATION hints");
+    size = info->size;
+    min = max = 0;
+    prefix = 0;
+    alignment = 0;
+  }
+
+  if (pool == NULL) {
+    /* we did not get a pool, make one ourselves then */
+    pool = gst_buffer_pool_new ();
+  }
+
+  if (depay->pool)
+    gst_object_unref (depay->pool);
+  depay->pool = pool;
+
+  config = gst_buffer_pool_get_config (pool);
+  gst_buffer_pool_config_set (config, caps, size, min, max, prefix, alignment);
+  /* just set the metadata, if the pool can support it we will transparently use
+   * it through the video info API. We could also see if the pool support this
+   * metadata and only activate it then. */
+  gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_META_VIDEO);
+
+  gst_buffer_pool_set_config (pool, config);
+  /* and activate */
+  gst_buffer_pool_set_active (pool, TRUE);
+
+  gst_query_unref (query);
+
+  return GST_FLOW_OK;
 }
 
 static gboolean
@@ -119,18 +168,16 @@ gst_rtp_vraw_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   GstStructure *structure;
   GstRtpVRawDepay *rtpvrawdepay;
   gint clock_rate;
-  const gchar *str, *type;
+  const gchar *str;
   gint format, width, height, pgroup, xinc, yinc;
-  guint ystride, uvstride, yp, up, vp, outsize;
   GstCaps *srccaps;
-  guint32 fourcc = 0;
   gboolean res;
+  GstFlowReturn ret;
 
   rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload);
 
   structure = gst_caps_get_structure (caps, 0);
 
-  yp = up = vp = uvstride = 0;
   xinc = yinc = 1;
 
   if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
@@ -156,96 +203,55 @@ gst_rtp_vraw_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   if (!strcmp (str, "RGB")) {
     format = GST_VIDEO_FORMAT_RGB;
     pgroup = 3;
-    ystride = GST_ROUND_UP_4 (width * 3);
-    outsize = ystride * height;
-    type = "video/x-raw-rgb";
   } else if (!strcmp (str, "RGBA")) {
     format = GST_VIDEO_FORMAT_RGBA;
     pgroup = 4;
-    ystride = width * 4;
-    outsize = ystride * height;
-    type = "video/x-raw-rgb";
   } else if (!strcmp (str, "BGR")) {
     format = GST_VIDEO_FORMAT_BGR;
     pgroup = 3;
-    ystride = GST_ROUND_UP_4 (width * 3);
-    outsize = ystride * height;
-    type = "video/x-raw-rgb";
   } else if (!strcmp (str, "BGRA")) {
     format = GST_VIDEO_FORMAT_BGRA;
     pgroup = 4;
-    ystride = width * 4;
-    outsize = ystride * height;
-    type = "video/x-raw-rgb";
   } else if (!strcmp (str, "YCbCr-4:4:4")) {
     format = GST_VIDEO_FORMAT_AYUV;
     pgroup = 3;
-    ystride = width * 4;
-    outsize = ystride * height;
-    type = "video/x-raw-yuv";
-    fourcc = GST_MAKE_FOURCC ('A', 'Y', 'U', 'V');
   } else if (!strcmp (str, "YCbCr-4:2:2")) {
     format = GST_VIDEO_FORMAT_UYVY;
     pgroup = 4;
-    ystride = GST_ROUND_UP_2 (width) * 2;
-    outsize = ystride * height;
-    type = "video/x-raw-yuv";
-    fourcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
     xinc = 2;
   } else if (!strcmp (str, "YCbCr-4:2:0")) {
     format = GST_VIDEO_FORMAT_I420;
     pgroup = 6;
-    ystride = GST_ROUND_UP_4 (width);
-    uvstride = GST_ROUND_UP_8 (width) / 2;
-    up = ystride * GST_ROUND_UP_2 (height);
-    vp = up + uvstride * GST_ROUND_UP_2 (height) / 2;
-    outsize = vp + uvstride * GST_ROUND_UP_2 (height) / 2;
-    type = "video/x-raw-yuv";
-    fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
     xinc = yinc = 2;
   } else if (!strcmp (str, "YCbCr-4:1:1")) {
     format = GST_VIDEO_FORMAT_Y41B;
     pgroup = 6;
-    ystride = GST_ROUND_UP_4 (width);
-    uvstride = GST_ROUND_UP_8 (width) / 4;
-    up = ystride * height;
-    vp = up + uvstride * height;
-    outsize = vp + uvstride * height;
-    type = "video/x-raw-yuv";
-    fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
     xinc = 4;
   } else
     goto unknown_format;
 
-  rtpvrawdepay->width = width;
-  rtpvrawdepay->height = height;
-  rtpvrawdepay->format = format;
-  rtpvrawdepay->yp = yp;
-  rtpvrawdepay->up = up;
-  rtpvrawdepay->vp = vp;
+  gst_video_info_init (&rtpvrawdepay->vinfo);
+  gst_video_info_set_format (&rtpvrawdepay->vinfo, format, width, height);
+  GST_VIDEO_INFO_FPS_N (&rtpvrawdepay->vinfo) = 0;
+  GST_VIDEO_INFO_FPS_D (&rtpvrawdepay->vinfo) = 1;
+
   rtpvrawdepay->pgroup = pgroup;
   rtpvrawdepay->xinc = xinc;
   rtpvrawdepay->yinc = yinc;
-  rtpvrawdepay->ystride = ystride;
-  rtpvrawdepay->uvstride = uvstride;
-  rtpvrawdepay->outsize = outsize;
-
-  srccaps = gst_caps_new_simple (type,
-      "width", G_TYPE_INT, width,
-      "height", G_TYPE_INT, height,
-      "format", GST_TYPE_FOURCC, fourcc,
-      "framerate", GST_TYPE_FRACTION, 0, 1, NULL);
 
+  srccaps = gst_video_info_to_caps (&rtpvrawdepay->vinfo);
   res = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
   gst_caps_unref (srccaps);
 
   GST_DEBUG_OBJECT (depayload, "width %d, height %d, format %d", width, height,
       format);
-  GST_DEBUG_OBJECT (depayload, "yp %d, up %d, vp %d", yp, up, vp);
-  GST_DEBUG_OBJECT (depayload, "xinc %d, yinc %d", xinc, yinc);
-  GST_DEBUG_OBJECT (depayload, "pgroup %d, ystride %d, uvstride %d", pgroup,
-      ystride, uvstride);
-  GST_DEBUG_OBJECT (depayload, "outsize %u", outsize);
+  GST_DEBUG_OBJECT (depayload, "xinc %d, yinc %d, pgroup %d",
+      xinc, yinc, pgroup);
+
+  /* negotiate a bufferpool */
+  if ((ret = gst_rtp_vraw_depay_negotiate_pool (rtpvrawdepay, caps,
+              &rtpvrawdepay->vinfo)) != GST_FLOW_OK)
+    goto no_bufferpool;
 
   return res;
 
@@ -275,20 +281,29 @@ unknown_format:
     GST_ERROR_OBJECT (depayload, "unknown sampling format '%s'", str);
     return FALSE;
   }
+no_bufferpool:
+  {
+    GST_DEBUG_OBJECT (depayload, "no bufferpool");
+    return FALSE;
+  }
 }
 
 static GstBuffer *
 gst_rtp_vraw_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstRtpVRawDepay *rtpvrawdepay;
-  guint8 *payload, *data, *yp, *up, *vp, *headers;
+  guint8 *payload, *yp, *up, *vp, *headers;
   guint32 timestamp;
   guint cont, ystride, uvstride, pgroup, payload_len;
   gint width, height, xinc, yinc;
+  GstRTPBuffer rtp;
+  GstVideoFrame frame;
 
   rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload);
 
-  timestamp = gst_rtp_buffer_get_timestamp (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  timestamp = gst_rtp_buffer_get_timestamp (&rtp);
 
   if (timestamp != rtpvrawdepay->timestamp || rtpvrawdepay->outbuf == NULL) {
     GstBuffer *outbuf;
@@ -302,9 +317,18 @@ gst_rtp_vraw_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
       rtpvrawdepay->outbuf = NULL;
     }
 
-    ret = gst_pad_alloc_buffer (depayload->srcpad, -1, rtpvrawdepay->outsize,
-        GST_PAD_CAPS (depayload->srcpad), &outbuf);
-    if (ret != GST_FLOW_OK)
+    if (gst_pad_check_reconfigure (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload))) {
+      GstCaps *caps;
+
+      caps =
+          gst_pad_get_current_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
+      gst_rtp_vraw_depay_negotiate_pool (rtpvrawdepay, caps,
+          &rtpvrawdepay->vinfo);
+      gst_caps_unref (caps);
+    }
+
+    ret = gst_buffer_pool_acquire_buffer (rtpvrawdepay->pool, &outbuf, NULL);
+    if (G_UNLIKELY (ret != GST_FLOW_OK))
       goto alloc_failed;
 
     /* clear timestamp from alloc... */
@@ -314,23 +338,26 @@ gst_rtp_vraw_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     rtpvrawdepay->timestamp = timestamp;
   }
 
-  data = GST_BUFFER_DATA (rtpvrawdepay->outbuf);
+  if (!gst_video_frame_map (&frame, &rtpvrawdepay->vinfo, rtpvrawdepay->outbuf,
+          GST_MAP_WRITE))
+    goto invalid_frame;
 
   /* get pointer and strides of the planes */
-  yp = data + rtpvrawdepay->yp;
-  up = data + rtpvrawdepay->up;
-  vp = data + rtpvrawdepay->vp;
+  yp = GST_VIDEO_FRAME_COMP_DATA (&frame, 0);
+  up = GST_VIDEO_FRAME_COMP_DATA (&frame, 1);
+  vp = GST_VIDEO_FRAME_COMP_DATA (&frame, 2);
+
+  ystride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, 0);
+  uvstride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, 1);
 
-  ystride = rtpvrawdepay->ystride;
-  uvstride = rtpvrawdepay->uvstride;
   pgroup = rtpvrawdepay->pgroup;
-  width = rtpvrawdepay->width;
-  height = rtpvrawdepay->height;
+  width = GST_VIDEO_INFO_WIDTH (&rtpvrawdepay->vinfo);
+  height = GST_VIDEO_INFO_HEIGHT (&rtpvrawdepay->vinfo);
   xinc = rtpvrawdepay->xinc;
   yinc = rtpvrawdepay->yinc;
 
-  payload = gst_rtp_buffer_get_payload (buf);
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   if (payload_len < 3)
     goto short_packet;
@@ -398,7 +425,7 @@ gst_rtp_vraw_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
         "writing length %u/%u, line %u, offset %u, remaining %u", plen, length,
         line, offs, payload_len);
 
-    switch (rtpvrawdepay->format) {
+    switch (GST_VIDEO_INFO_FORMAT (&rtpvrawdepay->vinfo)) {
       case GST_VIDEO_FORMAT_RGB:
       case GST_VIDEO_FORMAT_RGBA:
       case GST_VIDEO_FORMAT_BGR:
@@ -493,7 +520,10 @@ gst_rtp_vraw_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     payload_len -= length;
   }
 
-  if (gst_rtp_buffer_get_marker (buf)) {
+  gst_video_frame_unmap (&frame);
+  gst_rtp_buffer_unmap (&rtp);
+
+  if (gst_rtp_buffer_get_marker (&rtp)) {
     GST_LOG_OBJECT (depayload, "marker, flushing frame");
     if (rtpvrawdepay->outbuf) {
       gst_base_rtp_depayload_push_ts (depayload, timestamp,
@@ -509,21 +539,34 @@ unknown_sampling:
   {
     GST_ELEMENT_ERROR (depayload, STREAM, FORMAT,
         (NULL), ("unimplemented sampling"));
+    gst_video_frame_unmap (&frame);
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 alloc_failed:
   {
     GST_WARNING_OBJECT (depayload, "failed to alloc output buffer");
+    gst_rtp_buffer_unmap (&rtp);
+    return NULL;
+  }
+invalid_frame:
+  {
+    GST_ERROR_OBJECT (depayload, "could not map video frame");
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 wrong_length:
   {
     GST_WARNING_OBJECT (depayload, "length not multiple of pgroup");
+    gst_video_frame_unmap (&frame);
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 short_packet:
   {
     GST_WARNING_OBJECT (depayload, "short packet");
+    gst_video_frame_unmap (&frame);
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
index 77cb6bf..46d3695 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <gst/gst.h>
 #include <gst/video/video.h>
+#include <gst/video/gstmetavideo.h>
+#include <gst/video/gstvideopool.h>
 #include <gst/rtp/gstbasertpdepayload.h>
 
 G_BEGIN_DECLS
@@ -44,8 +46,8 @@ struct _GstRtpVRawDepay
 {
   GstBaseRTPDepayload payload;
 
-  gint width, height;
-  GstVideoFormat format;
+  GstBufferPool *pool;
+  GstVideoInfo vinfo;
 
   GstBuffer *outbuf;
   guint32 timestamp;
@@ -53,9 +55,6 @@ struct _GstRtpVRawDepay
 
   gint pgroup;
   gint xinc, yinc;
-  guint yp, up, vp;
-  gint ystride;
-  gint uvstride;
 };
 
 struct _GstRtpVRawDepayClass
index c354639..ae6dc83 100644 (file)
@@ -34,46 +34,8 @@ static GstStaticPadTemplate gst_rtp_vraw_pay_sink_template =
     GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("video/x-raw-rgb, "
-        "bpp = (int) 24, "
-        "depth = (int) 24, "
-        "endianness = (int) BIG_ENDIAN, "
-        "red_mask = (int) 0xFF000000, "
-        "green_mask = (int) 0x00FF0000, "
-        "blue_mask = (int) 0x0000FF00, "
-        "width = (int) [ 1, 32767 ], "
-        "height = (int) [ 1, 32767 ]; "
-        "video/x-raw-rgb, "
-        "bpp = (int) 32, "
-        "depth = (int) 32, "
-        "endianness = (int) BIG_ENDIAN, "
-        "red_mask = (int) 0xFF000000, "
-        "green_mask = (int) 0x00FF0000, "
-        "blue_mask = (int) 0x0000FF00, "
-        "alpha_mask = (int) 0x000000FF, "
-        "width = (int) [ 1, 32767 ], "
-        "height = (int) [ 1, 32767 ]; "
-        "video/x-raw-rgb, "
-        "bpp = (int) 24, "
-        "depth = (int) 24, "
-        "endianness = (int) BIG_ENDIAN, "
-        "red_mask = (int) 0x0000FF00, "
-        "green_mask = (int) 0x00FF0000, "
-        "blue_mask = (int) 0xFF000000, "
-        "width = (int) [ 1, 32767 ], "
-        "height = (int) [ 1, 32767 ]; "
-        "video/x-raw-rgb, "
-        "bpp = (int) 32, "
-        "depth = (int) 32, "
-        "endianness = (int) BIG_ENDIAN, "
-        "red_mask = (int) 0x0000FF00, "
-        "green_mask = (int) 0x00FF0000, "
-        "blue_mask = (int) 0xFF000000, "
-        "alpha_mask = (int) 0x000000FF, "
-        "width = (int) [ 1, 32767 ], "
-        "height = (int) [ 1, 32767 ]; "
-        "video/x-raw-yuv, "
-        "format = (fourcc) { AYUV, UYVY, I420, Y41B, UYVP }, "
+    GST_STATIC_CAPS ("video/x-raw, "
+        "format = (string) { RGB, RGBA, BGR, BGRA, AYUYV, UYVY, I420, Y41B, UYVP, I420, Y42B, Y444 }, "
         "width = (int) [ 1, 32767 ], " "height = (int) [ 1, 32767 ]; ")
     );
 
@@ -109,40 +71,35 @@ static gboolean gst_rtp_vraw_pay_setcaps (GstBaseRTPPayload * payload,
 static GstFlowReturn gst_rtp_vraw_pay_handle_buffer (GstBaseRTPPayload *
     payload, GstBuffer * buffer);
 
-GST_BOILERPLATE (GstRtpVRawPay, gst_rtp_vraw_pay, GstBaseRTPPayload,
-    GST_TYPE_BASE_RTP_PAYLOAD)
+G_DEFINE_TYPE (GstRtpVRawPay, gst_rtp_vraw_pay, GST_TYPE_BASE_RTP_PAYLOAD)
 
-     static void gst_rtp_vraw_pay_base_init (gpointer klass)
+     static void gst_rtp_vraw_pay_class_init (GstRtpVRawPayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstBaseRTPPayloadClass *gstbasertppayload_class;
+  GstElementClass *gstelement_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+
+  gstbasertppayload_class->set_caps = gst_rtp_vraw_pay_setcaps;
+  gstbasertppayload_class->handle_buffer = gst_rtp_vraw_pay_handle_buffer;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_vraw_pay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_vraw_pay_sink_template));
 
-  gst_element_class_set_details_simple (element_class,
+  gst_element_class_set_details_simple (gstelement_class,
       "RTP Raw Video payloader", "Codec/Payloader/Network/RTP",
       "Payload raw video as RTP packets (RFC 4175)",
       "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_vraw_pay_class_init (GstRtpVRawPayClass * klass)
-{
-  GstBaseRTPPayloadClass *gstbasertppayload_class;
-
-  gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
-
-  gstbasertppayload_class->set_caps = gst_rtp_vraw_pay_setcaps;
-  gstbasertppayload_class->handle_buffer = gst_rtp_vraw_pay_handle_buffer;
 
   GST_DEBUG_CATEGORY_INIT (rtpvrawpay_debug, "rtpvrawpay", 0,
       "Raw video RTP Payloader");
 }
 
 static void
-gst_rtp_vraw_pay_init (GstRtpVRawPay * rtpvrawpay, GstRtpVRawPayClass * klass)
+gst_rtp_vraw_pay_init (GstRtpVRawPay * rtpvrawpay)
 {
 }
 
@@ -150,177 +107,104 @@ static gboolean
 gst_rtp_vraw_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
 {
   GstRtpVRawPay *rtpvrawpay;
-  GstStructure *s;
   gboolean res;
-  const gchar *name;
-  gint width, height;
-  gint yp, up, vp;
-  gint pgroup, ystride, uvstride = 0, xinc, yinc;
-  GstVideoFormat sampling;
+  gint pgroup, xinc, yinc;
   const gchar *depthstr, *samplingstr, *colorimetrystr;
   gchar *wstr, *hstr;
-  gboolean interlaced;
-  const gchar *color_matrix;
   gint depth;
+  GstVideoInfo info;
 
   rtpvrawpay = GST_RTP_VRAW_PAY (payload);
 
-  s = gst_caps_get_structure (caps, 0);
-
-  /* start parsing the format */
-  name = gst_structure_get_name (s);
+  if (!gst_video_info_from_caps (&info, caps))
+    goto invalid_caps;
 
-  /* these values are the only thing we can do */
-  depthstr = "8";
+  rtpvrawpay->vinfo = info;
 
-  /* parse common width/height */
-  res = gst_structure_get_int (s, "width", &width);
-  res &= gst_structure_get_int (s, "height", &height);
-  if (!res)
-    goto missing_dimension;
-
-  if (!gst_structure_get_boolean (s, "interlaced", &interlaced))
-    interlaced = FALSE;
-
-  color_matrix = gst_structure_get_string (s, "color-matrix");
-  colorimetrystr = "SMPTE240M";
-  if (color_matrix) {
-    if (g_str_equal (color_matrix, "sdtv")) {
-      /* BT.601 implies a bit more than just color-matrix */
-      colorimetrystr = "BT601-5";
-    } else if (g_str_equal (color_matrix, "hdtv")) {
-      colorimetrystr = "BT709-2";
-    }
+  if (gst_video_colorimetry_matches (&info.colorimetry,
+          GST_VIDEO_COLORIMETRY_BT601)) {
+    colorimetrystr = "BT601-5";
+  } else if (gst_video_colorimetry_matches (&info.colorimetry,
+          GST_VIDEO_COLORIMETRY_BT709)) {
+    colorimetrystr = "BT709-2";
+  } else if (gst_video_colorimetry_matches (&info.colorimetry,
+          GST_VIDEO_COLORIMETRY_SMPTE240M)) {
+    colorimetrystr = "SMPTE240M";
+  } else {
+    colorimetrystr = "SMPTE240M";
   }
 
-  yp = up = vp = 0;
   xinc = yinc = 1;
 
-  if (!strcmp (name, "video/x-raw-rgb")) {
-    gint amask, rmask;
-    gboolean has_alpha;
-
-    has_alpha = gst_structure_get_int (s, "alpha_mask", &amask);
-    depth = 8;
-
-    if (!gst_structure_get_int (s, "red_mask", &rmask))
-      goto unknown_mask;
+  /* these values are the only thing we can do */
+  depthstr = "8";
+  depth = 8;
 
-    if (has_alpha) {
+  switch (GST_VIDEO_INFO_FORMAT (&info)) {
+    case GST_VIDEO_FORMAT_RGBA:
+      samplingstr = "RGBA";
       pgroup = 4;
-      ystride = width * 4;
-      if (rmask == 0xFF000000) {
-        sampling = GST_VIDEO_FORMAT_RGBA;
-        samplingstr = "RGBA";
-      } else {
-        sampling = GST_VIDEO_FORMAT_BGRA;
-        samplingstr = "BGRA";
-      }
-    } else {
+      break;
+    case GST_VIDEO_FORMAT_BGRA:
+      samplingstr = "BGRA";
+      pgroup = 4;
+      break;
+    case GST_VIDEO_FORMAT_RGB:
+      samplingstr = "RGB";
       pgroup = 3;
-      ystride = GST_ROUND_UP_4 (width * 3);
-      if (rmask == 0xFF000000) {
-        sampling = GST_VIDEO_FORMAT_RGB;
-        samplingstr = "RGB";
-      } else {
-        sampling = GST_VIDEO_FORMAT_BGR;
-        samplingstr = "BGR";
-      }
-    }
-  } else if (!strcmp (name, "video/x-raw-yuv")) {
-    guint32 fourcc;
-
-    if (!gst_structure_get_fourcc (s, "format", &fourcc))
-      goto unknown_fourcc;
-
-    GST_LOG_OBJECT (payload, "have fourcc %" GST_FOURCC_FORMAT,
-        GST_FOURCC_ARGS (fourcc));
-
-    switch (fourcc) {
-      case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
-        sampling = GST_VIDEO_FORMAT_AYUV;
-        samplingstr = "YCbCr-4:4:4";
-        pgroup = 3;
-        ystride = width * 4;
-        depth = 8;
-        break;
-      case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
-        sampling = GST_VIDEO_FORMAT_UYVY;
-        samplingstr = "YCbCr-4:2:2";
-        pgroup = 4;
-        xinc = 2;
-        ystride = GST_ROUND_UP_2 (width) * 2;
-        depth = 8;
-        break;
-      case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
-        sampling = GST_VIDEO_FORMAT_Y41B;
-        samplingstr = "YCbCr-4:1:1";
-        pgroup = 6;
-        xinc = 4;
-        ystride = GST_ROUND_UP_4 (width);
-        uvstride = GST_ROUND_UP_8 (width) / 4;
-        up = ystride * height;
-        vp = up + uvstride * height;
-        depth = 8;
-        break;
-      case GST_MAKE_FOURCC ('I', '4', '2', '0'):
-        sampling = GST_VIDEO_FORMAT_I420;
-        samplingstr = "YCbCr-4:2:0";
-        pgroup = 6;
-        xinc = yinc = 2;
-        ystride = GST_ROUND_UP_4 (width);
-        uvstride = GST_ROUND_UP_8 (width) / 2;
-        up = ystride * GST_ROUND_UP_2 (height);
-        vp = up + uvstride * GST_ROUND_UP_2 (height) / 2;
-        depth = 8;
-        break;
-      case GST_MAKE_FOURCC ('U', 'Y', 'V', 'P'):
-#define GST_VIDEO_FORMAT_UYVP GST_VIDEO_FORMAT_UYVY     /* FIXME */
-        sampling = GST_VIDEO_FORMAT_UYVP;
-        samplingstr = "YCbCr-4:2:2";
-        pgroup = 4;
-        xinc = 2;
-        ystride = GST_ROUND_UP_2 (width) * 2;
-        depth = 10;
-        break;
-      default:
-        goto unknown_fourcc;
-    }
-  } else
-    goto unknown_format;
+    case GST_VIDEO_FORMAT_BGR:
+      samplingstr = "BGR";
+      pgroup = 3;
+      break;
+    case GST_VIDEO_FORMAT_AYUV:
+      samplingstr = "YCbCr-4:4:4";
+      pgroup = 3;
+      break;
+    case GST_VIDEO_FORMAT_UYVY:
+      samplingstr = "YCbCr-4:2:2";
+      pgroup = 4;
+      xinc = 2;
+      break;
+    case GST_VIDEO_FORMAT_Y41B:
+      samplingstr = "YCbCr-4:1:1";
+      pgroup = 6;
+      xinc = 4;
+      break;
+    case GST_VIDEO_FORMAT_I420:
+      samplingstr = "YCbCr-4:2:0";
+      pgroup = 6;
+      xinc = yinc = 2;
+      break;
+    case GST_VIDEO_FORMAT_UYVP:
+      samplingstr = "YCbCr-4:2:2";
+      pgroup = 4;
+      xinc = 2;
+      depth = 10;
+      depthstr = "10";
+      break;
+    default:
+      goto unknown_format;
+      break;
+  }
 
-  if (interlaced) {
+  if (info.flags & GST_VIDEO_FLAG_INTERLACED) {
     yinc *= 2;
   }
-  if (depth == 10) {
-    depthstr = "10";
-  }
 
-  rtpvrawpay->width = width;
-  rtpvrawpay->height = height;
-  rtpvrawpay->sampling = sampling;
   rtpvrawpay->pgroup = pgroup;
   rtpvrawpay->xinc = xinc;
   rtpvrawpay->yinc = yinc;
-  rtpvrawpay->yp = yp;
-  rtpvrawpay->up = up;
-  rtpvrawpay->vp = vp;
-  rtpvrawpay->ystride = ystride;
-  rtpvrawpay->uvstride = uvstride;
-  rtpvrawpay->interlaced = interlaced;
   rtpvrawpay->depth = depth;
 
-  GST_DEBUG_OBJECT (payload, "width %d, height %d, sampling %d", width, height,
-      sampling);
-  GST_DEBUG_OBJECT (payload, "yp %d, up %d, vp %d", yp, up, vp);
-  GST_DEBUG_OBJECT (payload, "pgroup %d, ystride %d, uvstride %d", pgroup,
-      ystride, uvstride);
+  GST_DEBUG_OBJECT (payload, "width %d, height %d, sampling %s",
+      GST_VIDEO_INFO_WIDTH (&info), GST_VIDEO_INFO_HEIGHT (&info), samplingstr);
+  GST_DEBUG_OBJECT (payload, "xinc %d, yinc %d, pgroup %d", xinc, yinc, pgroup);
 
-  wstr = g_strdup_printf ("%d", rtpvrawpay->width);
-  hstr = g_strdup_printf ("%d", rtpvrawpay->height);
+  wstr = g_strdup_printf ("%d", GST_VIDEO_INFO_WIDTH (&info));
+  hstr = g_strdup_printf ("%d", GST_VIDEO_INFO_HEIGHT (&info));
 
   gst_basertppayload_set_options (payload, "video", TRUE, "RAW", 90000);
-  if (interlaced) {
+  if (info.flags & GST_VIDEO_FLAG_INTERLACED) {
     res = gst_basertppayload_set_outcaps (payload, "sampling", G_TYPE_STRING,
         samplingstr, "depth", G_TYPE_STRING, depthstr, "width", G_TYPE_STRING,
         wstr, "height", G_TYPE_STRING, hstr, "colorimetry", G_TYPE_STRING,
@@ -337,9 +221,9 @@ gst_rtp_vraw_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
   return res;
 
   /* ERRORS */
-unknown_mask:
+invalid_caps:
   {
-    GST_ERROR_OBJECT (payload, "unknown red mask specified");
+    GST_ERROR_OBJECT (payload, "could not parse caps");
     return FALSE;
   }
 unknown_format:
@@ -347,16 +231,6 @@ unknown_format:
     GST_ERROR_OBJECT (payload, "unknown caps format");
     return FALSE;
   }
-unknown_fourcc:
-  {
-    GST_ERROR_OBJECT (payload, "invalid or missing fourcc");
-    return FALSE;
-  }
-missing_dimension:
-  {
-    GST_ERROR_OBJECT (payload, "missing width or height property");
-    return FALSE;
-  }
 }
 
 static GstFlowReturn
@@ -365,38 +239,42 @@ gst_rtp_vraw_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
   GstRtpVRawPay *rtpvrawpay;
   GstFlowReturn ret = GST_FLOW_OK;
   guint line, offset;
-  guint8 *data, *yp, *up, *vp;
+  guint8 *yp, *up, *vp;
   guint ystride, uvstride;
-  guint size, pgroup;
+  guint pgroup;
   guint mtu;
   guint width, height;
   gint field;
+  GstVideoFrame frame;
+  gint interlaced;
+  GstRTPBuffer rtp;
 
   rtpvrawpay = GST_RTP_VRAW_PAY (payload);
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
+  gst_video_frame_map (&frame, &rtpvrawpay->vinfo, buffer, GST_MAP_READ);
 
-  GST_LOG_OBJECT (rtpvrawpay, "new frame of %u bytes", size);
+  GST_LOG_OBJECT (rtpvrawpay, "new frame of %u bytes",
+      gst_buffer_get_size (buffer));
 
   /* get pointer and strides of the planes */
-  yp = data + rtpvrawpay->yp;
-  up = data + rtpvrawpay->up;
-  vp = data + rtpvrawpay->vp;
+  yp = GST_VIDEO_FRAME_COMP_DATA (&frame, 0);
+  up = GST_VIDEO_FRAME_COMP_DATA (&frame, 1);
+  vp = GST_VIDEO_FRAME_COMP_DATA (&frame, 2);
 
-  ystride = rtpvrawpay->ystride;
-  uvstride = rtpvrawpay->uvstride;
+  ystride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, 0);
+  uvstride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, 1);
 
   mtu = GST_BASE_RTP_PAYLOAD_MTU (payload);
 
   /* amount of bytes for one pixel */
   pgroup = rtpvrawpay->pgroup;
-  width = rtpvrawpay->width;
-  height = rtpvrawpay->height;
+  width = GST_VIDEO_INFO_WIDTH (&rtpvrawpay->vinfo);
+  height = GST_VIDEO_INFO_HEIGHT (&rtpvrawpay->vinfo);
 
-  /* start with line 0, offset 0 */
+  interlaced = ! !(rtpvrawpay->vinfo.flags & GST_VIDEO_FLAG_INTERLACED);
 
-  for (field = 0; field < 1 + rtpvrawpay->interlaced; field++) {
+  /* start with line 0, offset 0 */
+  for (field = 0; field < 1 + interlaced; field++) {
     line = field;
     offset = 0;
 
@@ -419,7 +297,8 @@ gst_rtp_vraw_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
             GST_BUFFER_DURATION (buffer) / 2;
       }
 
-      outdata = gst_rtp_buffer_get_payload (out);
+      gst_rtp_buffer_map (out, GST_MAP_WRITE, &rtp);
+      outdata = gst_rtp_buffer_get_payload (&rtp);
 
       GST_LOG_OBJECT (rtpvrawpay, "created buffer of size %u for MTU %u", left,
           mtu);
@@ -524,7 +403,7 @@ gst_rtp_vraw_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
             "writing length %u, line %u, offset %u, cont %d", length, lin, offs,
             cont);
 
-        switch (rtpvrawpay->sampling) {
+        switch (GST_VIDEO_INFO_FORMAT (&rtpvrawpay->vinfo)) {
           case GST_VIDEO_FORMAT_RGB:
           case GST_VIDEO_FORMAT_RGBA:
           case GST_VIDEO_FORMAT_BGR:
@@ -595,6 +474,7 @@ gst_rtp_vraw_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
             break;
           }
           default:
+            gst_rtp_buffer_unmap (&rtp);
             gst_buffer_unref (out);
             goto unknown_sampling;
         }
@@ -605,11 +485,12 @@ gst_rtp_vraw_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
 
       if (line >= height) {
         GST_LOG_OBJECT (rtpvrawpay, "field/frame complete, set marker");
-        gst_rtp_buffer_set_marker (out, TRUE);
+        gst_rtp_buffer_set_marker (&rtp, TRUE);
       }
+      gst_rtp_buffer_unmap (&rtp);
       if (left > 0) {
         GST_LOG_OBJECT (rtpvrawpay, "we have %u bytes left", left);
-        GST_BUFFER_SIZE (out) -= left;
+        gst_buffer_resize (out, 0, gst_buffer_get_size (out) - left);
       }
 
       /* push buffer */
@@ -617,6 +498,8 @@ gst_rtp_vraw_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
     }
 
   }
+
+  gst_video_frame_unmap (&frame);
   gst_buffer_unref (buffer);
 
   return ret;
@@ -626,6 +509,7 @@ unknown_sampling:
   {
     GST_ELEMENT_ERROR (payload, STREAM, FORMAT,
         (NULL), ("unimplemented sampling"));
+    gst_video_frame_unmap (&frame);
     gst_buffer_unref (buffer);
     return GST_FLOW_NOT_SUPPORTED;
   }
index 0e6adf4..a519e70 100644 (file)
@@ -44,15 +44,14 @@ struct _GstRtpVRawPay
 {
   GstBaseRTPPayload payload;
 
-  gint width, height;
-  GstVideoFormat sampling;
+  GstVideoInfo vinfo;
 
   gint pgroup;
   gint xinc, yinc;
-  guint yp, up, vp;
-  gint ystride;
-  gint uvstride;
-  gboolean interlaced;
+//   guint yp, up, vp;
+//   gint ystride;
+//   gint uvstride;
+//   gboolean interlaced;
   gint depth;
 };
 
index e8d659f..88e6f6b 100644 (file)
@@ -1151,6 +1151,7 @@ gst_rtp_bin_handle_sync (GstElement * jitterbuffer, GstStructure * s,
   guint clock_rate;
   guint64 extrtptime;
   GstBuffer *buffer;
+  GstRTCPBuffer rtcp = { NULL };
 
   bin = stream->bin;
 
@@ -1170,7 +1171,10 @@ gst_rtp_bin_handle_sync (GstElement * jitterbuffer, GstStructure * s,
 
   have_sr = FALSE;
   have_sdes = FALSE;
-  GST_RTCP_BUFFER_FOR_PACKETS (more, buffer, &packet) {
+
+  gst_rtcp_buffer_map (buffer, GST_MAP_READ, &rtcp);
+
+  GST_RTCP_BUFFER_FOR_PACKETS (more, &rtcp, &packet) {
     /* first packet must be SR or RR or else the validate would have failed */
     switch (gst_rtcp_packet_get_type (&packet)) {
       case GST_RTCP_TYPE_SR:
@@ -1229,6 +1233,7 @@ gst_rtp_bin_handle_sync (GstElement * jitterbuffer, GstStructure * s,
         break;
     }
   }
+  gst_rtcp_buffer_unmap (&rtcp);
 }
 
 /* create a new stream with @ssrc in @session. Must be called with
@@ -1368,38 +1373,12 @@ static void gst_rtp_bin_get_property (GObject * object, guint prop_id,
 static GstStateChangeReturn gst_rtp_bin_change_state (GstElement * element,
     GstStateChange transition);
 static GstPad *gst_rtp_bin_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name);
+    GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
 static void gst_rtp_bin_release_pad (GstElement * element, GstPad * pad);
 static void gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message);
 
-GST_BOILERPLATE (GstRtpBin, gst_rtp_bin, GstBin, GST_TYPE_BIN);
-
-static void
-gst_rtp_bin_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  /* sink pads */
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpbin_recv_rtp_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpbin_recv_rtcp_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpbin_send_rtp_sink_template));
-
-  /* src pads */
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpbin_recv_rtp_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpbin_send_rtcp_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpbin_send_rtp_src_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP Bin",
-      "Filter/Network/RTP",
-      "Real-Time Transport Protocol bin",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_rtp_bin_parent_class parent_class
+G_DEFINE_TYPE (GstRtpBin, gst_rtp_bin, GST_TYPE_BIN);
 
 static void
 gst_rtp_bin_class_init (GstRtpBinClass * klass)
@@ -1682,6 +1661,27 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
       GST_DEBUG_FUNCPTR (gst_rtp_bin_request_new_pad);
   gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_rtp_bin_release_pad);
 
+  /* sink pads */
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpbin_recv_rtp_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpbin_recv_rtcp_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpbin_send_rtp_sink_template));
+
+  /* src pads */
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpbin_recv_rtp_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpbin_send_rtcp_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpbin_send_rtp_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP Bin",
+      "Filter/Network/RTP",
+      "Real-Time Transport Protocol bin",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   gstbin_class->handle_message = GST_DEBUG_FUNCPTR (gst_rtp_bin_handle_message);
 
   klass->clear_pt_map = GST_DEBUG_FUNCPTR (gst_rtp_bin_clear_pt_map);
@@ -1693,7 +1693,7 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
 }
 
 static void
-gst_rtp_bin_init (GstRtpBin * rtpbin, GstRtpBinClass * klass)
+gst_rtp_bin_init (GstRtpBin * rtpbin)
 {
   gchar *str;
 
@@ -2166,7 +2166,6 @@ new_payload_found (GstElement * element, guint pt, GstPad * pad,
   g_free (padname);
   g_object_set_data (G_OBJECT (pad), "GstRTPBin.ghostpad", gpad);
 
-  gst_pad_set_caps (gpad, GST_PAD_CAPS (pad));
   gst_pad_set_active (gpad, TRUE);
   GST_RTP_BIN_SHUTDOWN_UNLOCK (rtpbin);
 
@@ -2349,7 +2348,6 @@ new_ssrc_pad_found (GstElement * element, guint ssrc, GstPad * pad,
     gpad = gst_ghost_pad_new_from_template (padname, pad, templ);
     g_free (padname);
 
-    gst_pad_set_caps (gpad, GST_PAD_CAPS (pad));
     gst_pad_set_active (gpad, TRUE);
     gst_element_add_pad (GST_ELEMENT_CAST (rtpbin), gpad);
 
@@ -2788,24 +2786,24 @@ gst_rtp_bin_get_free_pad_name (GstElement * element, GstPadTemplate * templ)
   gint session = 0;
   GstIterator *pad_it = NULL;
   gchar *pad_name = NULL;
+  GValue data = { 0, };
 
   GST_DEBUG_OBJECT (element, "find a free pad name for template");
   while (!name_found) {
     gboolean done = FALSE;
+
     g_free (pad_name);
     pad_name = g_strdup_printf (templ->name_template, session++);
     pad_it = gst_element_iterate_pads (GST_ELEMENT (element));
     name_found = TRUE;
     while (!done) {
-      gpointer data;
-
       switch (gst_iterator_next (pad_it, &data)) {
         case GST_ITERATOR_OK:
         {
           GstPad *pad;
           gchar *name;
 
-          pad = GST_PAD_CAST (data);
+          pad = g_value_get_object (&data);
           name = gst_pad_get_name (pad);
 
           if (strcmp (name, pad_name) == 0) {
@@ -2813,7 +2811,7 @@ gst_rtp_bin_get_free_pad_name (GstElement * element, GstPadTemplate * templ)
             name_found = FALSE;
           }
           g_free (name);
-          gst_object_unref (pad);
+          g_value_reset (&data);
           break;
         }
         case GST_ITERATOR_ERROR:
@@ -2828,6 +2826,7 @@ gst_rtp_bin_get_free_pad_name (GstElement * element, GstPadTemplate * templ)
           break;
       }
     }
+    g_value_unset (&data);
     gst_iterator_free (pad_it);
   }
 
@@ -2839,7 +2838,7 @@ gst_rtp_bin_get_free_pad_name (GstElement * element, GstPadTemplate * templ)
  */
 static GstPad *
 gst_rtp_bin_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name)
+    GstPadTemplate * templ, const gchar * name, const GstCaps * caps)
 {
   GstRtpBin *rtpbin;
   GstElementClass *klass;
index e118699..3584d14 100644 (file)
@@ -218,8 +218,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
 
 static guint gst_rtp_jitter_buffer_signals[LAST_SIGNAL] = { 0 };
 
-GST_BOILERPLATE (GstRtpJitterBuffer, gst_rtp_jitter_buffer, GstElement,
-    GST_TYPE_ELEMENT);
+#define gst_rtp_jitter_buffer_parent_class parent_class
+G_DEFINE_TYPE (GstRtpJitterBuffer, gst_rtp_jitter_buffer, GST_TYPE_ELEMENT);
 
 /* object overrides */
 static void gst_rtp_jitter_buffer_set_property (GObject * object,
@@ -232,17 +232,16 @@ static void gst_rtp_jitter_buffer_finalize (GObject * object);
 static GstStateChangeReturn gst_rtp_jitter_buffer_change_state (GstElement
     * element, GstStateChange transition);
 static GstPad *gst_rtp_jitter_buffer_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name);
+    GstPadTemplate * templ, const gchar * name, const GstCaps * filter);
 static void gst_rtp_jitter_buffer_release_pad (GstElement * element,
     GstPad * pad);
 static GstClock *gst_rtp_jitter_buffer_provide_clock (GstElement * element);
 
 /* pad overrides */
-static GstCaps *gst_rtp_jitter_buffer_getcaps (GstPad * pad);
+static GstCaps *gst_rtp_jitter_buffer_getcaps (GstPad * pad, GstCaps * filter);
 static GstIterator *gst_rtp_jitter_buffer_iterate_internal_links (GstPad * pad);
 
 /* sinkpad overrides */
-static gboolean gst_jitter_buffer_sink_setcaps (GstPad * pad, GstCaps * caps);
 static gboolean gst_rtp_jitter_buffer_sink_event (GstPad * pad,
     GstEvent * event);
 static GstFlowReturn gst_rtp_jitter_buffer_chain (GstPad * pad,
@@ -268,25 +267,6 @@ gst_rtp_jitter_buffer_set_active (GstRtpJitterBuffer * jitterbuffer,
     gboolean active, guint64 base_time);
 
 static void
-gst_rtp_jitter_buffer_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_jitter_buffer_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_jitter_buffer_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_jitter_buffer_sink_rtcp_template));
-
-  gst_element_class_set_details_simple (element_class,
-      "RTP packet jitter-buffer", "Filter/Network/RTP",
-      "A buffer that deals with network jitter and other transmission faults",
-      "Philippe Kalaf <philippe.kalaf@collabora.co.uk>, "
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_jitter_buffer_class_init (GstRtpJitterBufferClass * klass)
 {
   GObjectClass *gobject_class;
@@ -443,6 +423,19 @@ gst_rtp_jitter_buffer_class_init (GstRtpJitterBufferClass * klass)
   gstelement_class->provide_clock =
       GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_provide_clock);
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_jitter_buffer_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_jitter_buffer_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_jitter_buffer_sink_rtcp_template));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP packet jitter-buffer", "Filter/Network/RTP",
+      "A buffer that deals with network jitter and other transmission faults",
+      "Philippe Kalaf <philippe.kalaf@collabora.co.uk>, "
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   klass->clear_pt_map = GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_clear_pt_map);
   klass->set_active = GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_set_active);
 
@@ -451,8 +444,7 @@ gst_rtp_jitter_buffer_class_init (GstRtpJitterBufferClass * klass)
 }
 
 static void
-gst_rtp_jitter_buffer_init (GstRtpJitterBuffer * jitterbuffer,
-    GstRtpJitterBufferClass * klass)
+gst_rtp_jitter_buffer_init (GstRtpJitterBuffer * jitterbuffer)
 {
   GstRtpJitterBufferPrivate *priv;
 
@@ -495,8 +487,6 @@ gst_rtp_jitter_buffer_init (GstRtpJitterBuffer * jitterbuffer,
       GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_chain));
   gst_pad_set_event_function (priv->sinkpad,
       GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_sink_event));
-  gst_pad_set_setcaps_function (priv->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_jitter_buffer_sink_setcaps));
   gst_pad_set_getcaps_function (priv->sinkpad,
       GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_getcaps));
 
@@ -525,6 +515,7 @@ gst_rtp_jitter_buffer_iterate_internal_links (GstPad * pad)
   GstRtpJitterBuffer *jitterbuffer;
   GstPad *otherpad = NULL;
   GstIterator *it;
+  GValue val = { 0, };
 
   jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));
 
@@ -536,8 +527,10 @@ gst_rtp_jitter_buffer_iterate_internal_links (GstPad * pad)
     otherpad = NULL;
   }
 
-  it = gst_iterator_new_single (GST_TYPE_PAD, otherpad,
-      (GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref);
+  g_value_init (&val, GST_TYPE_PAD);
+  g_value_set_object (&val, otherpad);
+  it = gst_iterator_new_single (GST_TYPE_PAD, &val);
+  g_value_unset (&val);
 
   gst_object_unref (jitterbuffer);
 
@@ -585,7 +578,7 @@ remove_rtcp_sink (GstRtpJitterBuffer * jitterbuffer)
 
 static GstPad *
 gst_rtp_jitter_buffer_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name)
+    GstPadTemplate * templ, const gchar * name, const GstCaps * filter)
 {
   GstRtpJitterBuffer *jitterbuffer;
   GstElementClass *klass;
@@ -714,7 +707,7 @@ gst_rtp_jitter_buffer_set_active (GstRtpJitterBuffer * jbuf, gboolean active,
 }
 
 static GstCaps *
-gst_rtp_jitter_buffer_getcaps (GstPad * pad)
+gst_rtp_jitter_buffer_getcaps (GstPad * pad, GstCaps * filter)
 {
   GstRtpJitterBuffer *jitterbuffer;
   GstRtpJitterBufferPrivate *priv;
@@ -727,7 +720,7 @@ gst_rtp_jitter_buffer_getcaps (GstPad * pad)
 
   other = (pad == priv->srcpad ? priv->sinkpad : priv->srcpad);
 
-  caps = gst_pad_peer_get_caps (other);
+  caps = gst_pad_peer_get_caps (other, filter);
 
   templ = gst_pad_get_pad_template_caps (pad);
   if (caps == NULL) {
@@ -832,29 +825,6 @@ wrong_rate:
   }
 }
 
-static gboolean
-gst_jitter_buffer_sink_setcaps (GstPad * pad, GstCaps * caps)
-{
-  GstRtpJitterBuffer *jitterbuffer;
-  GstRtpJitterBufferPrivate *priv;
-  gboolean res;
-
-  jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));
-  priv = jitterbuffer->priv;
-
-  JBUF_LOCK (priv);
-  res = gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps);
-  JBUF_UNLOCK (priv);
-
-  /* set same caps on srcpad on success */
-  if (res)
-    gst_pad_set_caps (priv->srcpad, caps);
-
-  gst_object_unref (jitterbuffer);
-
-  return res;
-}
-
 static void
 gst_rtp_jitter_buffer_flush_start (GstRtpJitterBuffer * jitterbuffer)
 {
@@ -1062,30 +1032,33 @@ gst_rtp_jitter_buffer_sink_event (GstPad * pad, GstEvent * event)
   GST_DEBUG_OBJECT (jitterbuffer, "received %s", GST_EVENT_TYPE_NAME (event));
 
   switch (GST_EVENT_TYPE (event)) {
-    case GST_EVENT_NEWSEGMENT:
+    case GST_EVENT_CAPS:
     {
-      GstFormat format;
-      gdouble rate, arate;
-      gint64 start, stop, time;
-      gboolean update;
+      GstCaps *caps;
+
+      gst_event_parse_caps (event, &caps);
+
+      JBUF_LOCK (priv);
+      ret = gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps);
+      JBUF_UNLOCK (priv);
+
+      /* set same caps on srcpad on success */
+      if (ret)
+        gst_pad_set_caps (priv->srcpad, caps);
 
-      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
-          &start, &stop, &time);
+      gst_event_unref (event);
+      break;
+    }
+    case GST_EVENT_SEGMENT:
+    {
+      gst_event_copy_segment (event, &priv->segment);
 
       /* we need time for now */
-      if (format != GST_FORMAT_TIME)
+      if (priv->segment.format != GST_FORMAT_TIME)
         goto newseg_wrong_format;
 
       GST_DEBUG_OBJECT (jitterbuffer,
-          "newsegment: update %d, rate %g, arate %g, start %" GST_TIME_FORMAT
-          ", stop %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
-          update, rate, arate, GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
-          GST_TIME_ARGS (time));
-
-      /* now configure the values, we need these to time the release of the
-       * buffers on the srcpad. */
-      gst_segment_set_newsegment_full (&priv->segment, update,
-          rate, arate, format, start, stop, time);
+          "newsegment:  %" GST_SEGMENT_FORMAT, &priv->segment);
 
       /* FIXME, push SEGMENT in the queue. Sorting order might be difficult. */
       ret = gst_pad_push_event (priv->srcpad, event);
@@ -1264,6 +1237,7 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstBuffer * buffer)
   gboolean tail;
   gint percent = -1;
   guint8 pt;
+  GstRTPBuffer rtp = { NULL };
 
   jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));
 
@@ -1272,7 +1246,10 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstBuffer * buffer)
 
   priv = jitterbuffer->priv;
 
-  pt = gst_rtp_buffer_get_payload_type (buffer);
+  gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp);
+  pt = gst_rtp_buffer_get_payload_type (&rtp);
+  seqnum = gst_rtp_buffer_get_seq (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   /* take the timestamp of the buffer. This is the time when the packet was
    * received and is used to calculate jitter and clock skew. We will adjust
@@ -1283,8 +1260,6 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstBuffer * buffer)
   timestamp = gst_segment_to_running_time (&priv->segment, GST_FORMAT_TIME,
       timestamp);
 
-  seqnum = gst_rtp_buffer_get_seq (buffer);
-
   GST_DEBUG_OBJECT (jitterbuffer,
       "Received packet #%d at time %" GST_TIME_FORMAT, seqnum,
       GST_TIME_ARGS (timestamp));
@@ -1292,19 +1267,20 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstBuffer * buffer)
   JBUF_LOCK_CHECK (priv, out_flushing);
 
   if (G_UNLIKELY (priv->last_pt != pt)) {
-    GstCaps *caps;
-
     GST_DEBUG_OBJECT (jitterbuffer, "pt changed from %u to %u", priv->last_pt,
         pt);
 
     priv->last_pt = pt;
     /* reset clock-rate so that we get a new one */
     priv->clock_rate = -1;
+#if 0
+    GstCaps *caps;
     /* Try to get the clock-rate from the caps first if we can. If there are no
      * caps we must fire the signal to get the clock-rate. */
     if ((caps = GST_BUFFER_CAPS (buffer))) {
       gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps);
     }
+#endif
   }
 
   if (G_UNLIKELY (priv->clock_rate == -1)) {
@@ -1380,8 +1356,8 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstBuffer * buffer)
 
       old_buf = rtp_jitter_buffer_pop (priv->jbuf, &percent);
 
-      GST_DEBUG_OBJECT (jitterbuffer, "Queue full, dropping old packet #%d",
-          gst_rtp_buffer_get_seq (old_buf));
+      GST_DEBUG_OBJECT (jitterbuffer, "Queue full, dropping old packet %p",
+          old_buf);
 
       gst_buffer_unref (old_buf);
     }
@@ -1389,7 +1365,7 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstBuffer * buffer)
 
   /* we need to make the metadata writable before pushing it in the jitterbuffer
    * because the jitterbuffer will update the timestamp */
-  buffer = gst_buffer_make_metadata_writable (buffer);
+  buffer = gst_buffer_make_writable (buffer);
 
   /* now insert the packet into the queue in sorted order. This function returns
    * FALSE if a packet with the same seqnum was already in the queue, meaning we
@@ -1541,9 +1517,12 @@ compute_elapsed (GstRtpJitterBuffer * jitterbuffer, GstBuffer * outbuf)
   guint64 ext_time, elapsed;
   guint32 rtp_time;
   GstRtpJitterBufferPrivate *priv;
+  GstRTPBuffer rtp = { NULL };
 
   priv = jitterbuffer->priv;
-  rtp_time = gst_rtp_buffer_get_timestamp (outbuf);
+  gst_rtp_buffer_map (outbuf, GST_MAP_READ, &rtp);
+  rtp_time = gst_rtp_buffer_get_timestamp (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   GST_LOG_OBJECT (jitterbuffer, "rtp %" G_GUINT32_FORMAT ", ext %"
       G_GUINT64_FORMAT, rtp_time, priv->ext_timestamp);
@@ -1585,6 +1564,7 @@ gst_rtp_jitter_buffer_loop (GstRtpJitterBuffer * jitterbuffer)
   GstClockID id;
   GstClockTime sync_time;
   gint percent = -1;
+  GstRTPBuffer rtp = { NULL };
 
   priv = jitterbuffer->priv;
 
@@ -1679,7 +1659,9 @@ again:
   outbuf = rtp_jitter_buffer_peek (priv->jbuf);
 
   /* get the seqnum and the next expected seqnum */
-  seqnum = gst_rtp_buffer_get_seq (outbuf);
+  gst_rtp_buffer_map (outbuf, GST_MAP_READ, &rtp);
+  seqnum = gst_rtp_buffer_get_seq (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
   next_seqnum = priv->next_seqnum;
 
   /* get the timestamp, this is already corrected for clock skew by the
@@ -1970,6 +1952,7 @@ gst_rtp_jitter_buffer_chain_rtcp (GstPad * pad, GstBuffer * buffer)
   guint64 ext_rtptime, diff;
   guint32 rtptime;
   gboolean drop = FALSE;
+  GstRTCPBuffer rtcp = { NULL };
 
   jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));
 
@@ -1978,8 +1961,10 @@ gst_rtp_jitter_buffer_chain_rtcp (GstPad * pad, GstBuffer * buffer)
 
   priv = jitterbuffer->priv;
 
-  if (!gst_rtcp_buffer_get_first_packet (buffer, &packet))
-    goto invalid_buffer;
+  gst_rtcp_buffer_map (buffer, GST_MAP_READ, &rtcp);
+
+  if (!gst_rtcp_buffer_get_first_packet (&rtcp, &packet))
+    goto empty_buffer;
 
   /* first packet must be SR or RR or else the validate would have failed */
   switch (gst_rtcp_packet_get_type (&packet)) {
@@ -1990,6 +1975,7 @@ gst_rtp_jitter_buffer_chain_rtcp (GstPad * pad, GstBuffer * buffer)
     default:
       goto ignore_buffer;
   }
+  gst_rtcp_buffer_unmap (&rtcp);
 
   GST_DEBUG_OBJECT (jitterbuffer, "received RTCP of SSRC %08x", ssrc);
 
@@ -2066,9 +2052,19 @@ invalid_buffer:
     ret = GST_FLOW_OK;
     goto done;
   }
+empty_buffer:
+  {
+    /* this is not fatal but should be filtered earlier */
+    GST_ELEMENT_WARNING (jitterbuffer, STREAM, DECODE, (NULL),
+        ("Received empty RTCP payload, dropping"));
+    gst_rtcp_buffer_unmap (&rtcp);
+    ret = GST_FLOW_OK;
+    goto done;
+  }
 ignore_buffer:
   {
     GST_DEBUG_OBJECT (jitterbuffer, "ignoring RTCP packet");
+    gst_rtcp_buffer_unmap (&rtcp);
     ret = GST_FLOW_OK;
     goto done;
   }
index 3c0004d..ce77773 100644 (file)
@@ -117,7 +117,8 @@ enum
   LAST_SIGNAL
 };
 
-GST_BOILERPLATE (GstRtpPtDemux, gst_rtp_pt_demux, GstElement, GST_TYPE_ELEMENT);
+#define gst_rtp_pt_demux_parent_class parent_class
+G_DEFINE_TYPE (GstRtpPtDemux, gst_rtp_pt_demux, GST_TYPE_ELEMENT);
 
 static void gst_rtp_pt_demux_finalize (GObject * object);
 
@@ -138,22 +139,6 @@ static gboolean gst_rtp_pt_demux_src_event (GstPad * pad, GstEvent * event);
 static guint gst_rtp_pt_demux_signals[LAST_SIGNAL] = { 0 };
 
 static void
-gst_rtp_pt_demux_base_init (gpointer g_class)
-{
-  GstElementClass *gstelement_klass = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (gstelement_klass,
-      gst_static_pad_template_get (&rtp_pt_demux_sink_template));
-  gst_element_class_add_pad_template (gstelement_klass,
-      gst_static_pad_template_get (&rtp_pt_demux_src_template));
-
-  gst_element_class_set_details_simple (gstelement_klass, "RTP Demux",
-      "Demux/Network/RTP",
-      "Parses codec streams transmitted in the same RTP session",
-      "Kai Vehmanen <kai.vehmanen@nokia.com>");
-}
-
-static void
 gst_rtp_pt_demux_class_init (GstRtpPtDemuxClass * klass)
 {
   GObjectClass *gobject_klass;
@@ -222,12 +207,22 @@ gst_rtp_pt_demux_class_init (GstRtpPtDemuxClass * klass)
 
   klass->clear_pt_map = GST_DEBUG_FUNCPTR (gst_rtp_pt_demux_clear_pt_map);
 
+  gst_element_class_add_pad_template (gstelement_klass,
+      gst_static_pad_template_get (&rtp_pt_demux_sink_template));
+  gst_element_class_add_pad_template (gstelement_klass,
+      gst_static_pad_template_get (&rtp_pt_demux_src_template));
+
+  gst_element_class_set_details_simple (gstelement_klass, "RTP Demux",
+      "Demux/Network/RTP",
+      "Parses codec streams transmitted in the same RTP session",
+      "Kai Vehmanen <kai.vehmanen@nokia.com>");
+
   GST_DEBUG_CATEGORY_INIT (gst_rtp_pt_demux_debug,
       "rtpptdemux", 0, "RTP codec demuxer");
 }
 
 static void
-gst_rtp_pt_demux_init (GstRtpPtDemux * ptdemux, GstRtpPtDemuxClass * g_class)
+gst_rtp_pt_demux_init (GstRtpPtDemux * ptdemux)
 {
   GstElementClass *klass = GST_ELEMENT_GET_CLASS (ptdemux);
 
@@ -274,9 +269,7 @@ gst_rtp_pt_demux_get_caps (GstRtpPtDemux * rtpdemux, guint pt)
   caps = g_value_dup_boxed (&ret);
   g_value_unset (&ret);
   if (caps == NULL) {
-    caps = GST_PAD_CAPS (rtpdemux->sink);
-    if (caps)
-      gst_caps_ref (caps);
+    caps = gst_pad_get_current_caps (rtpdemux->sink);
   }
 
   GST_DEBUG ("pt %d, got caps %" GST_PTR_FORMAT, pt, caps);
@@ -309,13 +302,16 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf)
   GstPad *srcpad;
   GstRtpPtDemuxPad *rtpdemuxpad;
   GstCaps *caps;
+  GstRTPBuffer rtp;
 
   rtpdemux = GST_RTP_PT_DEMUX (GST_OBJECT_PARENT (pad));
 
   if (!gst_rtp_buffer_validate (buf))
     goto invalid_buffer;
 
-  pt = gst_rtp_buffer_get_payload_type (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+  pt = gst_rtp_buffer_get_payload_type (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   GST_DEBUG_OBJECT (rtpdemux, "received buffer for pt %d", pt);
 
@@ -385,8 +381,6 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf)
     rtpdemuxpad->newcaps = FALSE;
   }
 
-  gst_buffer_set_caps (buf, GST_PAD_CAPS (srcpad));
-
   /* push to srcpad */
   ret = gst_pad_push (srcpad, buf);
 
@@ -490,11 +484,13 @@ gst_rtp_pt_demux_src_event (GstPad * pad, GstEvent * event)
           GstRtpPtDemuxPad *dpad = (GstRtpPtDemuxPad *) walk->data;
 
           if (dpad->pad == pad) {
+            GstStructure *ws;
+
             event =
                 GST_EVENT_CAST (gst_mini_object_make_writable
                 (GST_MINI_OBJECT_CAST (event)));
-            gst_structure_set (event->structure,
-                "payload", G_TYPE_UINT, dpad->pt, NULL);
+            ws = gst_event_writable_structure (event);
+            gst_structure_set (ws, "payload", G_TYPE_UINT, dpad->pt, NULL);
             break;
           }
         }
index ebeb3fd..4b112fa 100644 (file)
@@ -284,9 +284,12 @@ static void gst_rtp_session_get_property (GObject * object, guint prop_id,
 static GstStateChangeReturn gst_rtp_session_change_state (GstElement * element,
     GstStateChange transition);
 static GstPad *gst_rtp_session_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name);
+    GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
 static void gst_rtp_session_release_pad (GstElement * element, GstPad * pad);
 
+static gboolean gst_rtp_session_sink_setcaps (GstPad * pad, GstCaps * caps);
+static gboolean gst_rtp_session_setcaps_send_rtp (GstPad * pad, GstCaps * caps);
+
 static void gst_rtp_session_clear_pt_map (GstRtpSession * rtpsession);
 
 static guint gst_rtp_session_signals[LAST_SIGNAL] = { 0 };
@@ -365,35 +368,8 @@ on_sender_timeout (RTPSession * session, RTPSource * src, GstRtpSession * sess)
       src->ssrc);
 }
 
-GST_BOILERPLATE (GstRtpSession, gst_rtp_session, GstElement, GST_TYPE_ELEMENT);
-
-static void
-gst_rtp_session_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  /* sink pads */
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpsession_recv_rtp_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpsession_recv_rtcp_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpsession_send_rtp_sink_template));
-
-  /* src pads */
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpsession_recv_rtp_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpsession_sync_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpsession_send_rtp_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtpsession_send_rtcp_src_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP Session",
-      "Filter/Network/RTP",
-      "Implement an RTP session", "Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_rtp_session_parent_class parent_class
+G_DEFINE_TYPE (GstRtpSession, gst_rtp_session, GST_TYPE_ELEMENT);
 
 static void
 gst_rtp_session_class_init (GstRtpSessionClass * klass)
@@ -611,12 +587,34 @@ gst_rtp_session_class_init (GstRtpSessionClass * klass)
 
   klass->clear_pt_map = GST_DEBUG_FUNCPTR (gst_rtp_session_clear_pt_map);
 
+  /* sink pads */
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpsession_recv_rtp_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpsession_recv_rtcp_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpsession_send_rtp_sink_template));
+
+  /* src pads */
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpsession_recv_rtp_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpsession_sync_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpsession_send_rtp_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtpsession_send_rtcp_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP Session",
+      "Filter/Network/RTP",
+      "Implement an RTP session", "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (gst_rtp_session_debug,
       "rtpsession", 0, "RTP Session");
 }
 
 static void
-gst_rtp_session_init (GstRtpSession * rtpsession, GstRtpSessionClass * klass)
+gst_rtp_session_init (GstRtpSession * rtpsession)
 {
   rtpsession->priv = GST_RTP_SESSION_GET_PRIVATE (rtpsession);
   rtpsession->priv->lock = g_mutex_new ();
@@ -977,7 +975,7 @@ gst_rtp_session_change_state (GstElement * element, GstStateChange transition)
       break;
   }
 
-  res = parent_class->change_state (element, transition);
+  res = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
 
   switch (transition) {
     case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
@@ -1099,12 +1097,10 @@ gst_rtp_session_send_rtcp (RTPSession * sess, RTPSource * src,
     GstCaps *caps;
 
     /* set rtcp caps on output pad */
-    if (!(caps = GST_PAD_CAPS (rtcp_src))) {
+    if (!(caps = gst_pad_get_current_caps (rtcp_src))) {
       caps = gst_caps_new_simple ("application/x-rtcp", NULL);
       gst_pad_set_caps (rtcp_src, caps);
-    } else
-      gst_caps_ref (caps);
-    gst_buffer_set_caps (buffer, caps);
+    }
     gst_caps_unref (caps);
 
     gst_object_ref (rtcp_src);
@@ -1158,12 +1154,10 @@ gst_rtp_session_sync_rtcp (RTPSession * sess, RTPSource * src,
     GstCaps *caps;
 
     /* set rtcp caps on output pad */
-    if (!(caps = GST_PAD_CAPS (sync_src))) {
+    if (!(caps = gst_pad_get_current_caps (sync_src))) {
       caps = gst_caps_new_simple ("application/x-rtcp", NULL);
       gst_pad_set_caps (sync_src, caps);
-    } else
-      gst_caps_ref (caps);
-    gst_buffer_set_caps (buffer, caps);
+    }
     gst_caps_unref (caps);
 
     gst_object_ref (sync_src);
@@ -1334,37 +1328,36 @@ gst_rtp_session_event_recv_rtp_sink (GstPad * pad, GstEvent * event)
       GST_EVENT_TYPE_NAME (event));
 
   switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+
+      /* process */
+      gst_event_parse_caps (event, &caps);
+      gst_rtp_session_sink_setcaps (pad, caps);
+      /* and eat */
+      gst_event_unref (event);
+      break;
+    }
     case GST_EVENT_FLUSH_STOP:
       gst_segment_init (&rtpsession->recv_rtp_seg, GST_FORMAT_UNDEFINED);
       ret = gst_pad_push_event (rtpsession->recv_rtp_src, event);
       break;
-    case GST_EVENT_NEWSEGMENT:
+    case GST_EVENT_SEGMENT:
     {
-      gboolean update;
-      gdouble rate, arate;
-      GstFormat format;
-      gint64 start, stop, time;
-      GstSegment *segment;
+      GstSegment *segment, in_segment;
 
       segment = &rtpsession->recv_rtp_seg;
 
       /* the newsegment event is needed to convert the RTP timestamp to
        * running_time, which is needed to generate a mapping from RTP to NTP
        * timestamps in SR reports */
-      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
-          &start, &stop, &time);
-
-      GST_DEBUG_OBJECT (rtpsession,
-          "configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
-          "format GST_FORMAT_TIME, "
-          "%" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT
-          ", time %" GST_TIME_FORMAT ", accum %" GST_TIME_FORMAT,
-          update, rate, arate, GST_TIME_ARGS (segment->start),
-          GST_TIME_ARGS (segment->stop), GST_TIME_ARGS (segment->time),
-          GST_TIME_ARGS (segment->accum));
+      gst_event_copy_segment (event, &in_segment);
+      GST_DEBUG_OBJECT (rtpsession, "received segment %" GST_SEGMENT_FORMAT,
+          in_segment);
 
-      gst_segment_set_newsegment_full (segment, update, rate,
-          arate, format, start, stop, time);
+      /* accept upstream */
+      gst_segment_copy_into (&in_segment, segment);
 
       /* push event forward */
       ret = gst_pad_push_event (rtpsession->recv_rtp_src, event);
@@ -1475,8 +1468,12 @@ gst_rtp_session_iterate_internal_links (GstPad * pad)
   GST_RTP_SESSION_UNLOCK (rtpsession);
 
   if (otherpad) {
-    it = gst_iterator_new_single (GST_TYPE_PAD, otherpad,
-        (GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref);
+    GValue val = { 0, };
+
+    g_value_init (&val, GST_TYPE_PAD);
+    g_value_set_object (&val, otherpad);
+    it = gst_iterator_new_single (GST_TYPE_PAD, &val);
+    g_value_unset (&val);
     gst_object_unref (otherpad);
   }
 
@@ -1664,36 +1661,35 @@ gst_rtp_session_event_send_rtp_sink (GstPad * pad, GstEvent * event)
   GST_DEBUG_OBJECT (rtpsession, "received event");
 
   switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+
+      /* process */
+      gst_event_parse_caps (event, &caps);
+      gst_rtp_session_setcaps_send_rtp (pad, caps);
+      /* and eat */
+      gst_event_unref (event);
+      break;
+    }
     case GST_EVENT_FLUSH_STOP:
       gst_segment_init (&rtpsession->send_rtp_seg, GST_FORMAT_UNDEFINED);
       ret = gst_pad_push_event (rtpsession->send_rtp_src, event);
       break;
-    case GST_EVENT_NEWSEGMENT:{
-      gboolean update;
-      gdouble rate, arate;
-      GstFormat format;
-      gint64 start, stop, time;
-      GstSegment *segment;
+    case GST_EVENT_SEGMENT:{
+      GstSegment *segment, in_segment;
 
       segment = &rtpsession->send_rtp_seg;
 
       /* the newsegment event is needed to convert the RTP timestamp to
        * running_time, which is needed to generate a mapping from RTP to NTP
        * timestamps in SR reports */
-      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
-          &start, &stop, &time);
-
-      GST_DEBUG_OBJECT (rtpsession,
-          "configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
-          "format GST_FORMAT_TIME, "
-          "%" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT
-          ", time %" GST_TIME_FORMAT ", accum %" GST_TIME_FORMAT,
-          update, rate, arate, GST_TIME_ARGS (segment->start),
-          GST_TIME_ARGS (segment->stop), GST_TIME_ARGS (segment->time),
-          GST_TIME_ARGS (segment->accum));
+      gst_event_copy_segment (event, &in_segment);
+      GST_DEBUG_OBJECT (rtpsession, "received segment %" GST_SEGMENT_FORMAT,
+          in_segment);
 
-      gst_segment_set_newsegment_full (segment, update, rate,
-          arate, format, start, stop, time);
+      /* accept upstream */
+      gst_segment_copy_into (&in_segment, segment);
 
       /* push event forward */
       ret = gst_pad_push_event (rtpsession->send_rtp_src, event);
@@ -1733,7 +1729,7 @@ gst_rtp_session_event_send_rtp_sink (GstPad * pad, GstEvent * event)
 }
 
 static GstCaps *
-gst_rtp_session_getcaps_send_rtp (GstPad * pad)
+gst_rtp_session_getcaps_send_rtp (GstPad * pad, GstCaps * filter)
 {
   GstRtpSession *rtpsession;
   GstRtpSessionPrivate *priv;
@@ -1754,6 +1750,13 @@ gst_rtp_session_getcaps_send_rtp (GstPad * pad)
 
   result = gst_caps_new_full (s1, s2, NULL);
 
+  if (filter) {
+    GstCaps *caps = result;
+
+    result = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (caps);
+  }
+
   GST_DEBUG_OBJECT (rtpsession, "getting caps %" GST_PTR_FORMAT, result);
 
   gst_object_unref (rtpsession);
@@ -1806,7 +1809,7 @@ gst_rtp_session_chain_send_rtp_common (GstPad * pad, gpointer data,
 
     /* All groups in an list have the same timestamp.
      * So, just take it from the first group. */
-    buffer = gst_buffer_list_get (GST_BUFFER_LIST_CAST (data), 0, 0);
+    buffer = gst_buffer_list_get (GST_BUFFER_LIST_CAST (data), 0);
     if (buffer)
       timestamp = GST_BUFFER_TIMESTAMP (buffer);
     else
@@ -1872,8 +1875,6 @@ create_recv_rtp_sink (GstRtpSession * rtpsession)
       gst_rtp_session_chain_recv_rtp);
   gst_pad_set_event_function (rtpsession->recv_rtp_sink,
       (GstPadEventFunction) gst_rtp_session_event_recv_rtp_sink);
-  gst_pad_set_setcaps_function (rtpsession->recv_rtp_sink,
-      gst_rtp_session_sink_setcaps);
   gst_pad_set_iterate_internal_links_function (rtpsession->recv_rtp_sink,
       gst_rtp_session_iterate_internal_links);
   gst_pad_set_active (rtpsession->recv_rtp_sink, TRUE);
@@ -1986,8 +1987,6 @@ create_send_rtp_sink (GstRtpSession * rtpsession)
       gst_rtp_session_chain_send_rtp_list);
   gst_pad_set_getcaps_function (rtpsession->send_rtp_sink,
       gst_rtp_session_getcaps_send_rtp);
-  gst_pad_set_setcaps_function (rtpsession->send_rtp_sink,
-      gst_rtp_session_setcaps_send_rtp);
   gst_pad_set_event_function (rtpsession->send_rtp_sink,
       (GstPadEventFunction) gst_rtp_session_event_send_rtp_sink);
   gst_pad_set_iterate_internal_links_function (rtpsession->send_rtp_sink,
@@ -2064,7 +2063,7 @@ remove_send_rtcp_src (GstRtpSession * rtpsession)
 
 static GstPad *
 gst_rtp_session_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name)
+    GstPadTemplate * templ, const gchar * name, const GstCaps * caps)
 {
   GstRtpSession *rtpsession;
   GstElementClass *klass;
index a6a6bdc..13573c8 100644 (file)
@@ -95,9 +95,8 @@ enum
   LAST_SIGNAL
 };
 
-GST_BOILERPLATE (GstRtpSsrcDemux, gst_rtp_ssrc_demux, GstElement,
-    GST_TYPE_ELEMENT);
-
+#define gst_rtp_ssrc_demux_parent_class parent_class
+G_DEFINE_TYPE (GstRtpSsrcDemux, gst_rtp_ssrc_demux, GST_TYPE_ELEMENT);
 
 /* GObject vmethods */
 static void gst_rtp_ssrc_demux_dispose (GObject * object);
@@ -165,6 +164,7 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
   GstPadTemplate *templ;
   gchar *padname;
   GstRtpSsrcDemuxPad *demuxpad;
+  GstCaps *caps;
 
   GST_DEBUG_OBJECT (demux, "creating pad for SSRC %08x", ssrc);
 
@@ -196,9 +196,13 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
   demux->srcpads = g_slist_prepend (demux->srcpads, demuxpad);
 
   /* copy caps from input */
-  gst_pad_set_caps (rtp_pad, GST_PAD_CAPS (demux->rtp_sink));
+  caps = gst_pad_get_current_caps (demux->rtp_sink);
+  gst_pad_set_caps (rtp_pad, caps);
+  gst_caps_unref (caps);
   gst_pad_use_fixed_caps (rtp_pad);
-  gst_pad_set_caps (rtcp_pad, GST_PAD_CAPS (demux->rtcp_sink));
+  caps = gst_pad_get_current_caps (demux->rtcp_sink);
+  gst_pad_set_caps (rtcp_pad, caps);
+  gst_caps_unref (caps);
   gst_pad_use_fixed_caps (rtcp_pad);
 
   gst_pad_set_event_function (rtp_pad, gst_rtp_ssrc_demux_src_event);
@@ -222,26 +226,6 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
 }
 
 static void
-gst_rtp_ssrc_demux_base_init (gpointer g_class)
-{
-  GstElementClass *gstelement_klass = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (gstelement_klass,
-      gst_static_pad_template_get (&rtp_ssrc_demux_sink_template));
-  gst_element_class_add_pad_template (gstelement_klass,
-      gst_static_pad_template_get (&rtp_ssrc_demux_rtcp_sink_template));
-  gst_element_class_add_pad_template (gstelement_klass,
-      gst_static_pad_template_get (&rtp_ssrc_demux_src_template));
-  gst_element_class_add_pad_template (gstelement_klass,
-      gst_static_pad_template_get (&rtp_ssrc_demux_rtcp_src_template));
-
-  gst_element_class_set_details_simple (gstelement_klass, "RTP SSRC Demux",
-      "Demux/Network/RTP",
-      "Splits RTP streams based on the SSRC",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
 gst_rtp_ssrc_demux_class_init (GstRtpSsrcDemuxClass * klass)
 {
   GObjectClass *gobject_klass;
@@ -303,13 +287,26 @@ gst_rtp_ssrc_demux_class_init (GstRtpSsrcDemuxClass * klass)
   gstrtpssrcdemux_klass->clear_ssrc =
       GST_DEBUG_FUNCPTR (gst_rtp_ssrc_demux_clear_ssrc);
 
+  gst_element_class_add_pad_template (gstelement_klass,
+      gst_static_pad_template_get (&rtp_ssrc_demux_sink_template));
+  gst_element_class_add_pad_template (gstelement_klass,
+      gst_static_pad_template_get (&rtp_ssrc_demux_rtcp_sink_template));
+  gst_element_class_add_pad_template (gstelement_klass,
+      gst_static_pad_template_get (&rtp_ssrc_demux_src_template));
+  gst_element_class_add_pad_template (gstelement_klass,
+      gst_static_pad_template_get (&rtp_ssrc_demux_rtcp_src_template));
+
+  gst_element_class_set_details_simple (gstelement_klass, "RTP SSRC Demux",
+      "Demux/Network/RTP",
+      "Splits RTP streams based on the SSRC",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   GST_DEBUG_CATEGORY_INIT (gst_rtp_ssrc_demux_debug,
       "rtpssrcdemux", 0, "RTP SSRC demuxer");
 }
 
 static void
-gst_rtp_ssrc_demux_init (GstRtpSsrcDemux * demux,
-    GstRtpSsrcDemuxClass * g_class)
+gst_rtp_ssrc_demux_init (GstRtpSsrcDemux * demux)
 {
   GstElementClass *klass = GST_ELEMENT_GET_CLASS (demux);
 
@@ -433,7 +430,6 @@ gst_rtp_ssrc_demux_sink_event (GstPad * pad, GstEvent * event)
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_FLUSH_STOP:
       gst_segment_init (&demux->segment, GST_FORMAT_UNDEFINED);
-    case GST_EVENT_NEWSEGMENT:
     default:
     {
       GSList *walk;
@@ -477,7 +473,6 @@ gst_rtp_ssrc_demux_rtcp_sink_event (GstPad * pad, GstEvent * event)
   demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
 
   switch (GST_EVENT_TYPE (event)) {
-    case GST_EVENT_NEWSEGMENT:
     default:
     {
       GSList *walk;
@@ -514,6 +509,7 @@ gst_rtp_ssrc_demux_chain (GstPad * pad, GstBuffer * buf)
   GstRtpSsrcDemux *demux;
   guint32 ssrc;
   GstRtpSsrcDemuxPad *dpad;
+  GstRTPBuffer rtp;
   GstPad *srcpad;
 
   demux = GST_RTP_SSRC_DEMUX (GST_OBJECT_PARENT (pad));
@@ -521,7 +517,9 @@ gst_rtp_ssrc_demux_chain (GstPad * pad, GstBuffer * buf)
   if (!gst_rtp_buffer_validate (buf))
     goto invalid_payload;
 
-  ssrc = gst_rtp_buffer_get_ssrc (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+  ssrc = gst_rtp_buffer_get_ssrc (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   GST_DEBUG_OBJECT (demux, "received buffer of SSRC %08x", ssrc);
 
@@ -567,6 +565,7 @@ gst_rtp_ssrc_demux_rtcp_chain (GstPad * pad, GstBuffer * buf)
   guint32 ssrc;
   GstRtpSsrcDemuxPad *dpad;
   GstRTCPPacket packet;
+  GstRTCPBuffer rtcp;
   GstPad *srcpad;
 
   demux = GST_RTP_SSRC_DEMUX (GST_OBJECT_PARENT (pad));
@@ -574,8 +573,11 @@ gst_rtp_ssrc_demux_rtcp_chain (GstPad * pad, GstBuffer * buf)
   if (!gst_rtcp_buffer_validate (buf))
     goto invalid_rtcp;
 
-  if (!gst_rtcp_buffer_get_first_packet (buf, &packet))
+  gst_rtcp_buffer_map (buf, GST_MAP_READ, &rtcp);
+  if (!gst_rtcp_buffer_get_first_packet (&rtcp, &packet)) {
+    gst_rtcp_buffer_unmap (&rtcp);
     goto invalid_rtcp;
+  }
 
   /* first packet must be SR or RR or else the validate would have failed */
   switch (gst_rtcp_packet_get_type (&packet)) {
@@ -587,6 +589,7 @@ gst_rtp_ssrc_demux_rtcp_chain (GstPad * pad, GstBuffer * buf)
     default:
       goto unexpected_rtcp;
   }
+  gst_rtcp_buffer_unmap (&rtcp);
 
   GST_DEBUG_OBJECT (demux, "received RTCP of SSRC %08x", ssrc);
 
@@ -650,11 +653,13 @@ gst_rtp_ssrc_demux_src_event (GstPad * pad, GstEvent * event)
           GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) walk->data;
 
           if (dpad->rtp_pad == pad || dpad->rtcp_pad == pad) {
+            GstStructure *ws;
+
             event =
                 GST_EVENT_CAST (gst_mini_object_make_writable
                 (GST_MINI_OBJECT_CAST (event)));
-            gst_structure_set (event->structure, "ssrc", G_TYPE_UINT,
-                dpad->ssrc, NULL);
+            ws = gst_event_writable_structure (event);
+            gst_structure_set (ws, "ssrc", G_TYPE_UINT, dpad->ssrc, NULL);
             break;
           }
         }
@@ -694,8 +699,15 @@ gst_rtp_ssrc_demux_iterate_internal_links_src (GstPad * pad)
       break;
     }
   }
-  it = gst_iterator_new_single (GST_TYPE_PAD, otherpad,
-      (GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref);
+  if (otherpad) {
+    GValue val = { 0, };
+
+    g_value_init (&val, GST_TYPE_PAD);
+    g_value_set_object (&val, otherpad);
+    it = gst_iterator_new_single (GST_TYPE_PAD, &val);
+    g_value_unset (&val);
+    gst_object_unref (otherpad);
+  }
   GST_PAD_UNLOCK (demux);
 
   gst_object_unref (demux);
index f6382fc..73b09d4 100644 (file)
@@ -608,18 +608,24 @@ rtp_jitter_buffer_insert (RTPJitterBuffer * jbuf, GstBuffer * buf,
   GList *list;
   guint32 rtptime;
   guint16 seqnum;
+  GstRTPBuffer rtp;
 
   g_return_val_if_fail (jbuf != NULL, FALSE);
   g_return_val_if_fail (buf != NULL, FALSE);
 
-  seqnum = gst_rtp_buffer_get_seq (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  seqnum = gst_rtp_buffer_get_seq (&rtp);
 
   /* loop the list to skip strictly smaller seqnum buffers */
   for (list = jbuf->packets->head; list; list = g_list_next (list)) {
     guint16 qseq;
     gint gap;
+    GstRTPBuffer rtpb;
 
-    qseq = gst_rtp_buffer_get_seq (GST_BUFFER_CAST (list->data));
+    gst_rtp_buffer_map (GST_BUFFER_CAST (list->data), GST_MAP_READ, &rtpb);
+    qseq = gst_rtp_buffer_get_seq (&rtpb);
+    gst_rtp_buffer_unmap (&rtpb);
 
     /* compare the new seqnum to the one in the buffer */
     gap = gst_rtp_buffer_compare_seqnum (seqnum, qseq);
@@ -633,7 +639,7 @@ rtp_jitter_buffer_insert (RTPJitterBuffer * jbuf, GstBuffer * buf,
       break;
   }
 
-  rtptime = gst_rtp_buffer_get_timestamp (buf);
+  rtptime = gst_rtp_buffer_get_timestamp (&rtp);
   switch (jbuf->mode) {
     case RTP_JITTER_BUFFER_MODE_NONE:
     case RTP_JITTER_BUFFER_MODE_BUFFER:
@@ -673,11 +679,14 @@ rtp_jitter_buffer_insert (RTPJitterBuffer * jbuf, GstBuffer * buf,
   if (G_LIKELY (tail))
     *tail = (list == NULL);
 
+  gst_rtp_buffer_unmap (&rtp);
+
   return TRUE;
 
   /* ERRORS */
 duplicate:
   {
+    gst_rtp_buffer_unmap (&rtp);
     GST_WARNING ("duplicate packet %d found", (gint) seqnum);
     return FALSE;
   }
@@ -834,6 +843,7 @@ rtp_jitter_buffer_get_ts_diff (RTPJitterBuffer * jbuf)
   guint64 high_ts, low_ts;
   GstBuffer *high_buf, *low_buf;
   guint32 result;
+  GstRTPBuffer rtp;
 
   g_return_val_if_fail (jbuf != NULL, 0);
 
@@ -843,8 +853,12 @@ rtp_jitter_buffer_get_ts_diff (RTPJitterBuffer * jbuf)
   if (!high_buf || !low_buf || high_buf == low_buf)
     return 0;
 
-  high_ts = gst_rtp_buffer_get_timestamp (high_buf);
-  low_ts = gst_rtp_buffer_get_timestamp (low_buf);
+  gst_rtp_buffer_map (high_buf, GST_MAP_READ, &rtp);
+  high_ts = gst_rtp_buffer_get_timestamp (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
+  gst_rtp_buffer_map (low_buf, GST_MAP_READ, &rtp);
+  low_ts = gst_rtp_buffer_get_timestamp (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   /* it needs to work if ts wraps */
   if (high_ts >= low_ts) {
index 33c7375..4178412 100644 (file)
@@ -160,7 +160,7 @@ gst_rtp_bin_marshal_BOOLEAN__MINIOBJECT_BOOLEAN (GClosure * closure,
       cc->callback);
 
   v_return = callback (data1,
-      gst_value_get_mini_object (param_values + 1),
+      g_value_get_boxed (param_values + 1),
       g_value_get_boolean (param_values + 2), data2);
 
   g_value_set_boolean (return_value, v_return);
@@ -197,7 +197,7 @@ gst_rtp_bin_marshal_VOID__UINT_UINT_UINT_UINT_MINIOBJECT (GClosure * closure,
       g_value_get_uint (param_values + 2),
       g_value_get_uint (param_values + 3),
       g_value_get_uint (param_values + 4),
-      gst_value_get_mini_object (param_values + 5), data2);
+      g_value_get_boxed (param_values + 5), data2);
 }
 
 
@@ -1690,26 +1690,32 @@ update_arrival_stats (RTPSession * sess, RTPArrivalStats * arrival,
     gboolean rtp, GstBuffer * buffer, GstClockTime current_time,
     GstClockTime running_time, guint64 ntpnstime)
 {
+  GstMetaNetAddress *meta;
+  GstRTPBuffer rtpb;
+
   /* get time of arrival */
   arrival->current_time = current_time;
   arrival->running_time = running_time;
   arrival->ntpnstime = ntpnstime;
 
   /* get packet size including header overhead */
-  arrival->bytes = GST_BUFFER_SIZE (buffer) + sess->header_len;
+  arrival->bytes = gst_buffer_get_size (buffer) + sess->header_len;
 
   if (rtp) {
-    arrival->payload_len = gst_rtp_buffer_get_payload_len (buffer);
+    gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtpb);
+    arrival->payload_len = gst_rtp_buffer_get_payload_len (&rtpb);
+    gst_rtp_buffer_unmap (&rtpb);
   } else {
     arrival->payload_len = 0;
   }
 
   /* for netbuffer we can store the IP address to check for collisions */
-  arrival->have_address = GST_IS_NETBUFFER (buffer);
-  if (arrival->have_address) {
-    GstNetBuffer *netbuf = (GstNetBuffer *) buffer;
-
-    memcpy (&arrival->address, &netbuf->from, sizeof (GstNetAddress));
+  meta = gst_buffer_get_meta_net_address (buffer);
+  if (meta) {
+    arrival->have_address = TRUE;
+    memcpy (&arrival->address, &meta->naddr, sizeof (GstNetAddress));
+  } else {
+    arrival->have_address = FALSE;
   }
 }
 
@@ -1738,6 +1744,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
   guint32 csrcs[16];
   guint8 i, count;
   guint64 oldrate;
+  GstRTPBuffer rtp;
 
   g_return_val_if_fail (RTP_IS_SESSION (sess), GST_FLOW_ERROR);
   g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
@@ -1755,23 +1762,28 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
     goto ignore;
 
   /* get SSRC and look up in session database */
-  ssrc = gst_rtp_buffer_get_ssrc (buffer);
+  gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp);
+  ssrc = gst_rtp_buffer_get_ssrc (&rtp);
   source = obtain_source (sess, ssrc, &created, &arrival, TRUE);
-  if (!source)
+  if (!source) {
+    gst_rtp_buffer_unmap (&rtp);
     goto collision;
-
-  prevsender = RTP_SOURCE_IS_SENDER (source);
-  prevactive = RTP_SOURCE_IS_ACTIVE (source);
-  oldrate = source->bitrate;
+  }
 
   /* copy available csrc for later */
-  count = gst_rtp_buffer_get_csrc_count (buffer);
+  count = gst_rtp_buffer_get_csrc_count (&rtp);
   /* make sure to not overflow our array. An RTP buffer can maximally contain
    * 16 CSRCs */
   count = MIN (count, 16);
 
   for (i = 0; i < count; i++)
-    csrcs[i] = gst_rtp_buffer_get_csrc (buffer, i);
+    csrcs[i] = gst_rtp_buffer_get_csrc (&rtp, i);
+
+  gst_rtp_buffer_unmap (&rtp);
+
+  prevsender = RTP_SOURCE_IS_SENDER (source);
+  prevactive = RTP_SOURCE_IS_ACTIVE (source);
+  oldrate = source->bitrate;
 
   /* let source process the packet */
   result = rtp_source_process_rtp (source, buffer, &arrival);
@@ -2209,8 +2221,8 @@ rtp_session_process_feedback (RTPSession * sess, GstRTCPPacket * packet,
     GstBuffer *fci_buffer = NULL;
 
     if (fci_length > 0) {
-      fci_buffer = gst_buffer_create_sub (packet->buffer,
-          fci_data - GST_BUFFER_DATA (packet->buffer), fci_length);
+      fci_buffer = gst_buffer_copy_region (packet->rtcp->buffer,
+          GST_BUFFER_COPY_MEMORY, fci_data - packet->rtcp->data, fci_length);
       GST_BUFFER_TIMESTAMP (fci_buffer) = arrival->running_time;
     }
 
@@ -2270,6 +2282,7 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
   gboolean more, is_bye = FALSE, do_sync = FALSE;
   RTPArrivalStats arrival;
   GstFlowReturn result = GST_FLOW_OK;
+  GstRTCPBuffer rtcp;
 
   g_return_val_if_fail (RTP_IS_SESSION (sess), GST_FLOW_ERROR);
   g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
@@ -2288,7 +2301,8 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
     goto ignore;
 
   /* start processing the compound packet */
-  more = gst_rtcp_buffer_get_first_packet (buffer, &packet);
+  gst_rtcp_buffer_map (buffer, GST_MAP_READ, &rtcp);
+  more = gst_rtcp_buffer_get_first_packet (&rtcp, &packet);
   while (more) {
     GstRTCPType type;
 
@@ -2331,6 +2345,8 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
     more = gst_rtcp_packet_move_to_next (&packet);
   }
 
+  gst_rtcp_buffer_unmap (&rtcp);
+
   /* if we are scheduling a BYE, we only want to count bye packets, else we
    * count everything */
   if (sess->source->received_bye) {
@@ -2349,7 +2365,7 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
   /* notify caller of sr packets in the callback */
   if (do_sync && sess->callbacks.sync_rtcp) {
     /* make writable, we might want to change the buffer */
-    buffer = gst_buffer_make_metadata_writable (buffer);
+    buffer = gst_buffer_make_writable (buffer);
 
     result = sess->callbacks.sync_rtcp (sess, sess->source, buffer,
         sess->sync_rtcp_user_data);
@@ -2401,7 +2417,12 @@ rtp_session_send_rtp (RTPSession * sess, gpointer data, gboolean is_list,
   g_return_val_if_fail (is_list || GST_IS_BUFFER (data), GST_FLOW_ERROR);
 
   if (is_list) {
-    valid_packet = gst_rtp_buffer_list_validate (GST_BUFFER_LIST_CAST (data));
+    GstBufferList *blist = GST_BUFFER_LIST_CAST (data);
+    gint i, len = gst_buffer_list_len (blist);
+
+    valid_packet = TRUE;
+    for (i = 0; i < len; i++)
+      valid_packet &= gst_rtp_buffer_validate (gst_buffer_list_get (blist, i));
   } else {
     valid_packet = gst_rtp_buffer_validate (GST_BUFFER_CAST (data));
   }
@@ -2659,9 +2680,12 @@ session_start_rtcp (RTPSession * sess, ReportData * data)
 {
   GstRTCPPacket *packet = &data->packet;
   RTPSource *own = sess->source;
+  GstRTCPBuffer rtcp;
 
   data->rtcp = gst_rtcp_buffer_new (sess->mtu);
 
+  gst_rtcp_buffer_map (data->rtcp, GST_MAP_WRITE, &rtcp);
+
   if (RTP_SOURCE_IS_SENDER (own)) {
     guint64 ntptime;
     guint32 rtptime;
@@ -2669,7 +2693,7 @@ session_start_rtcp (RTPSession * sess, ReportData * data)
 
     /* we are a sender, create SR */
     GST_DEBUG ("create SR for SSRC %08x", own->ssrc);
-    gst_rtcp_buffer_add_packet (data->rtcp, GST_RTCP_TYPE_SR, packet);
+    gst_rtcp_buffer_add_packet (&rtcp, GST_RTCP_TYPE_SR, packet);
 
     /* get latest stats */
     rtp_source_get_new_sr (own, data->ntpnstime, data->running_time,
@@ -2684,9 +2708,11 @@ session_start_rtcp (RTPSession * sess, ReportData * data)
   } else {
     /* we are only receiver, create RR */
     GST_DEBUG ("create RR for SSRC %08x", own->ssrc);
-    gst_rtcp_buffer_add_packet (data->rtcp, GST_RTCP_TYPE_RR, packet);
+    gst_rtcp_buffer_add_packet (&rtcp, GST_RTCP_TYPE_RR, packet);
     gst_rtcp_packet_rr_set_ssrc (packet, own->ssrc);
   }
+
+  gst_rtcp_buffer_unmap (&rtcp);
 }
 
 /* construct a Sender or Receiver Report */
@@ -2810,9 +2836,12 @@ session_sdes (RTPSession * sess, ReportData * data)
   GstRTCPPacket *packet = &data->packet;
   const GstStructure *sdes;
   gint i, n_fields;
+  GstRTCPBuffer rtcp;
+
+  gst_rtcp_buffer_map (data->rtcp, GST_MAP_WRITE, &rtcp);
 
   /* add SDES packet */
-  gst_rtcp_buffer_add_packet (data->rtcp, GST_RTCP_TYPE_SDES, packet);
+  gst_rtcp_buffer_add_packet (&rtcp, GST_RTCP_TYPE_SDES, packet);
 
   gst_rtcp_packet_sdes_add_item (packet, sess->source->ssrc);
 
@@ -2866,6 +2895,8 @@ session_sdes (RTPSession * sess, ReportData * data)
   }
 
   data->has_sdes = TRUE;
+
+  gst_rtcp_buffer_unmap (&rtcp);
 }
 
 /* schedule a BYE packet */
@@ -2873,6 +2904,7 @@ static void
 session_bye (RTPSession * sess, ReportData * data)
 {
   GstRTCPPacket *packet = &data->packet;
+  GstRTCPBuffer rtcp;
 
   /* open packet */
   session_start_rtcp (sess, data);
@@ -2880,14 +2912,18 @@ session_bye (RTPSession * sess, ReportData * data)
   /* add SDES */
   session_sdes (sess, data);
 
+  gst_rtcp_buffer_map (data->rtcp, GST_MAP_WRITE, &rtcp);
+
   /* add a BYE packet */
-  gst_rtcp_buffer_add_packet (data->rtcp, GST_RTCP_TYPE_BYE, packet);
+  gst_rtcp_buffer_add_packet (&rtcp, GST_RTCP_TYPE_BYE, packet);
   gst_rtcp_packet_bye_add_ssrc (packet, sess->source->ssrc);
   if (sess->bye_reason)
     gst_rtcp_packet_bye_set_reason (packet, sess->bye_reason);
 
   /* we have a BYE packet now */
   data->is_bye = TRUE;
+
+  gst_rtcp_buffer_unmap (&rtcp);
 }
 
 static gboolean
@@ -3109,10 +3145,7 @@ rtp_session_on_timeout (RTPSession * sess, GstClockTime current_time,
     if (sess->callbacks.send_rtcp && (do_not_suppress || !data.may_suppress)) {
       guint packet_size;
 
-      /* close the RTCP packet */
-      gst_rtcp_buffer_end (data.rtcp);
-
-      packet_size = GST_BUFFER_SIZE (data.rtcp) + sess->header_len;
+      packet_size = gst_buffer_get_size (data.rtcp) + sess->header_len;
 
       UPDATE_AVG (sess->stats.avg_rtcp_packet_size, packet_size);
       GST_DEBUG ("%p, sending RTCP packet, avg size %u, %u", &sess->stats,
@@ -3213,15 +3246,20 @@ static gboolean
 has_pli_compare_func (gconstpointer a, gconstpointer ignored)
 {
   GstRTCPPacket packet;
+  GstRTCPBuffer rtcp;
+  gboolean ret = FALSE;
 
-  packet.buffer = (GstBuffer *) a;
-  packet.offset = 0;
+  gst_rtcp_buffer_map ((GstBuffer *) a, GST_MAP_READ, &rtcp);
 
-  if (gst_rtcp_packet_get_type (&packet) == GST_RTCP_TYPE_PSFB &&
-      gst_rtcp_packet_fb_get_type (&packet) == GST_RTCP_PSFB_TYPE_PLI)
-    return TRUE;
-  else
-    return FALSE;
+  if (gst_rtcp_buffer_get_first_packet (&rtcp, &packet)) {
+    if (gst_rtcp_packet_get_type (&packet) == GST_RTCP_TYPE_PSFB &&
+        gst_rtcp_packet_fb_get_type (&packet) == GST_RTCP_PSFB_TYPE_PLI)
+      ret = TRUE;
+  }
+
+  gst_rtcp_buffer_unmap (&rtcp);
+
+  return ret;
 }
 
 static gboolean
@@ -3240,16 +3278,21 @@ rtp_session_on_sending_rtcp (RTPSession * sess, GstBuffer * buffer,
 
     if (media_src && !rtp_source_has_retained (media_src,
             has_pli_compare_func, NULL)) {
-      if (gst_rtcp_buffer_add_packet (buffer, GST_RTCP_TYPE_PSFB, &rtcppacket)) {
+      GstRTCPBuffer rtcp;
+
+      gst_rtcp_buffer_map (buffer, GST_MAP_WRITE, &rtcp);
+      if (gst_rtcp_buffer_add_packet (&rtcp, GST_RTCP_TYPE_PSFB, &rtcppacket)) {
         gst_rtcp_packet_fb_set_type (&rtcppacket, GST_RTCP_PSFB_TYPE_PLI);
         gst_rtcp_packet_fb_set_sender_ssrc (&rtcppacket,
             rtp_source_get_ssrc (sess->source));
         gst_rtcp_packet_fb_set_media_ssrc (&rtcppacket, media_ssrc);
         ret = TRUE;
+        gst_rtcp_buffer_unmap (&rtcp);
       } else {
         /* Break because the packet is full, will put next request in a
          * further packet
          */
+        gst_rtcp_buffer_unmap (&rtcp);
         break;
       }
     }
index fb9e039..2912708 100644 (file)
@@ -897,20 +897,24 @@ calculate_jitter (RTPSource * src, GstBuffer * buffer,
   gint32 diff;
   gint clock_rate;
   guint8 pt;
+  GstRTPBuffer rtp;
 
   /* get arrival time */
   if ((running_time = arrival->running_time) == GST_CLOCK_TIME_NONE)
     goto no_time;
 
-  pt = gst_rtp_buffer_get_payload_type (buffer);
+  gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp);
+  pt = gst_rtp_buffer_get_payload_type (&rtp);
 
   GST_LOG ("SSRC %08x got payload %d", src->ssrc, pt);
 
   /* get clockrate */
-  if ((clock_rate = get_clock_rate (src, pt)) == -1)
+  if ((clock_rate = get_clock_rate (src, pt)) == -1) {
+    gst_rtp_buffer_unmap (&rtp);
     goto no_clock_rate;
+  }
 
-  rtptime = gst_rtp_buffer_get_timestamp (buffer);
+  rtptime = gst_rtp_buffer_get_timestamp (&rtp);
 
   /* convert arrival time to RTP timestamp units, truncate to 32 bits, we don't
    * care about the absolute value, just the difference. */
@@ -939,6 +943,7 @@ calculate_jitter (RTPSource * src, GstBuffer * buffer,
   GST_LOG ("rtparrival %u, rtptime %u, clock-rate %d, diff %d, jitter: %f",
       rtparrival, rtptime, clock_rate, diff, (src->stats.jitter) / 16.0);
 
+  gst_rtp_buffer_unmap (&rtp);
   return;
 
   /* ERRORS */
@@ -1021,15 +1026,21 @@ rtp_source_process_rtp (RTPSource * src, GstBuffer * buffer,
   guint16 seqnr, udelta;
   RTPSourceStats *stats;
   guint16 expected;
+  GstRTPBuffer rtp;
 
   g_return_val_if_fail (RTP_IS_SOURCE (src), GST_FLOW_ERROR);
   g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
 
   stats = &src->stats;
 
-  seqnr = gst_rtp_buffer_get_seq (buffer);
+  gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp);
+  seqnr = gst_rtp_buffer_get_seq (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
-  rtp_source_update_caps (src, GST_BUFFER_CAPS (buffer));
+  /* FIXME-0.11
+   * would be nice to be able to pass along with buffer */
+  g_assert_not_reached ();
+  /* rtp_source_update_caps (src, GST_BUFFER_CAPS (buffer)); */
 
   if (stats->cycles == -1) {
     GST_DEBUG ("received first buffer");
@@ -1157,12 +1168,16 @@ rtp_source_process_bye (RTPSource * src, const gchar * reason)
   src->received_bye = TRUE;
 }
 
-static GstBufferListItem
-set_ssrc (GstBuffer ** buffer, guint group, guint idx, RTPSource * src)
+static gboolean
+set_ssrc (GstBuffer ** buffer, guint idx, RTPSource * src)
 {
+  GstRTPBuffer rtp;
+
   *buffer = gst_buffer_make_writable (*buffer);
-  gst_rtp_buffer_set_ssrc (*buffer, src->ssrc);
-  return GST_BUFFER_LIST_SKIP_GROUP;
+  gst_rtp_buffer_map (*buffer, GST_MAP_WRITE, &rtp);
+  gst_rtp_buffer_set_ssrc (&rtp, src->ssrc);
+  gst_rtp_buffer_unmap (&rtp);
+  return TRUE;
 }
 
 /**
@@ -1191,6 +1206,7 @@ rtp_source_send_rtp (RTPSource * src, gpointer data, gboolean is_list,
   GstBuffer *buffer = NULL;
   guint packets;
   guint32 ssrc;
+  GstRTPBuffer rtp;
 
   g_return_val_if_fail (RTP_IS_SOURCE (src), GST_FLOW_ERROR);
   g_return_val_if_fail (is_list || GST_IS_BUFFER (data), GST_FLOW_ERROR);
@@ -1200,24 +1216,36 @@ rtp_source_send_rtp (RTPSource * src, gpointer data, gboolean is_list,
 
     /* We can grab the caps from the first group, since all
      * groups of a buffer list have same caps. */
-    buffer = gst_buffer_list_get (list, 0, 0);
+    buffer = gst_buffer_list_get (list, 0);
     if (!buffer)
       goto no_buffer;
   } else {
     buffer = GST_BUFFER_CAST (data);
   }
-  rtp_source_update_caps (src, GST_BUFFER_CAPS (buffer));
+
+  /* FIXME-0.11 */
+  g_assert_not_reached ();
+  /* rtp_source_update_caps (src, GST_BUFFER_CAPS (buffer)); */
 
   /* we are a sender now */
   src->is_sender = TRUE;
 
   if (is_list) {
+    gint i;
+
     /* Each group makes up a network packet. */
-    packets = gst_buffer_list_n_groups (list);
-    len = gst_rtp_buffer_list_get_payload_len (list);
+    packets = gst_buffer_list_len (list);
+    for (i = 0, len = 0; i < packets; i++) {
+      gst_rtp_buffer_map (gst_buffer_list_get (list, i), GST_MAP_READ, &rtp);
+      len += gst_rtp_buffer_get_payload_len (&rtp);
+      gst_rtp_buffer_unmap (&rtp);
+    }
+    /* subsequent info taken from first list member */
+    gst_rtp_buffer_map (gst_buffer_list_get (list, 0), GST_MAP_READ, &rtp);
   } else {
     packets = 1;
-    len = gst_rtp_buffer_get_payload_len (buffer);
+    gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp);
+    len = gst_rtp_buffer_get_payload_len (&rtp);
   }
 
   /* update stats for the SR */
@@ -1227,11 +1255,7 @@ rtp_source_send_rtp (RTPSource * src, gpointer data, gboolean is_list,
 
   do_bitrate_estimation (src, running_time, &src->bytes_sent);
 
-  if (is_list) {
-    rtptime = gst_rtp_buffer_list_get_timestamp (list);
-  } else {
-    rtptime = gst_rtp_buffer_get_timestamp (buffer);
-  }
+  rtptime = gst_rtp_buffer_get_timestamp (&rtp);
   ext_rtptime = src->last_rtptime;
   ext_rtptime = gst_rtp_buffer_ext_timestamp (&ext_rtptime, rtptime);
 
@@ -1255,15 +1279,14 @@ rtp_source_send_rtp (RTPSource * src, gpointer data, gboolean is_list,
   src->last_rtptime = ext_rtptime;
 
   /* push packet */
-  if (!src->callbacks.push_rtp)
+  if (!src->callbacks.push_rtp) {
+    gst_rtp_buffer_unmap (&rtp);
     goto no_callback;
-
-  if (is_list) {
-    ssrc = gst_rtp_buffer_list_get_ssrc (list);
-  } else {
-    ssrc = gst_rtp_buffer_get_ssrc (buffer);
   }
 
+  ssrc = gst_rtp_buffer_get_ssrc (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
+
   if (ssrc != src->ssrc) {
     /* the SSRC of the packet is not correct, make a writable buffer and
      * update the SSRC. This could involve a complete copy of the packet when
@@ -1279,7 +1302,7 @@ rtp_source_send_rtp (RTPSource * src, gpointer data, gboolean is_list,
       list = gst_buffer_list_make_writable (list);
       gst_buffer_list_foreach (list, (GstBufferListFunc) set_ssrc, src);
     } else {
-      set_ssrc (&buffer, 0, 0, src);
+      set_ssrc (&buffer, 0, src);
     }
   }
   GST_LOG ("pushing RTP %s %" G_GUINT64_FORMAT, is_list ? "list" : "packet",
@@ -1780,8 +1803,8 @@ rtp_source_retain_rtcp_packet (RTPSource * src, GstRTCPPacket * packet,
 {
   GstBuffer *buffer;
 
-  buffer = gst_buffer_create_sub (packet->buffer, packet->offset,
-      (gst_rtcp_packet_get_length (packet) + 1) * 4);
+  buffer = gst_buffer_copy_region (packet->rtcp->buffer, GST_BUFFER_COPY_MEMORY,
+      packet->offset, (gst_rtcp_packet_get_length (packet) + 1) * 4);
 
   GST_BUFFER_TIMESTAMP (buffer) = running_time;
 
index cbd5836..bc4e1f6 100644 (file)
@@ -1,5 +1,5 @@
 /* GStreamer
- * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005,2006> Wim Taymans <wim.taymans@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -124,7 +124,7 @@ static GstClock *gst_rtp_dec_provide_clock (GstElement * element);
 static GstStateChangeReturn gst_rtp_dec_change_state (GstElement * element,
     GstStateChange transition);
 static GstPad *gst_rtp_dec_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name);
+    GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
 static void gst_rtp_dec_release_pad (GstElement * element, GstPad * pad);
 
 static GstFlowReturn gst_rtp_dec_chain_rtp (GstPad * pad, GstBuffer * buffer);
@@ -193,29 +193,9 @@ free_session (GstRTPDecSession * session)
 
 static guint gst_rtp_dec_signals[LAST_SIGNAL] = { 0 };
 
-GST_BOILERPLATE (GstRTPDec, gst_rtp_dec, GstElement, GST_TYPE_ELEMENT);
+#define gst_rtp_dec_parent_class parent_class
+G_DEFINE_TYPE (GstRTPDec, gst_rtp_dec, GST_TYPE_ELEMENT);
 
-static void
-gst_rtp_dec_base_init (gpointer klass)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  /* sink pads */
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_dec_recv_rtp_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_dec_recv_rtcp_sink_template));
-  /* src pads */
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_dec_recv_rtp_src_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_rtp_dec_rtcp_src_template));
-
-  gst_element_class_set_details_simple (element_class, "RTP Decoder",
-      "Codec/Parser/Network",
-      "Accepts raw RTP and RTCP packets and sends them forward",
-      "Wim Taymans <wim@fluendo.com>");
-}
 
 /* BOXED:UINT,UINT */
 #define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
@@ -297,6 +277,8 @@ gst_rtp_dec_class_init (GstRTPDecClass * g_class)
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (rtpdec_debug, "rtpdec", 0, "RTP decoder");
+
   gobject_class->finalize = gst_rtp_dec_finalize;
   gobject_class->set_property = gst_rtp_dec_set_property;
   gobject_class->get_property = gst_rtp_dec_get_property;
@@ -413,11 +395,25 @@ gst_rtp_dec_class_init (GstRTPDecClass * g_class)
       GST_DEBUG_FUNCPTR (gst_rtp_dec_request_new_pad);
   gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_rtp_dec_release_pad);
 
-  GST_DEBUG_CATEGORY_INIT (rtpdec_debug, "rtpdec", 0, "RTP decoder");
+  /* sink pads */
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_dec_recv_rtp_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_dec_recv_rtcp_sink_template));
+  /* src pads */
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_dec_recv_rtp_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_dec_rtcp_src_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "RTP Decoder",
+      "Codec/Parser/Network",
+      "Accepts raw RTP and RTCP packets and sends them forward",
+      "Wim Taymans <wim.taymans@gmail.com>");
 }
 
 static void
-gst_rtp_dec_init (GstRTPDec * rtpdec, GstRTPDecClass * klass)
+gst_rtp_dec_init (GstRTPDec * rtpdec)
 {
   rtpdec->provided_clock = gst_system_clock_obtain ();
   rtpdec->latency = DEFAULT_LATENCY_MS;
@@ -464,6 +460,7 @@ gst_rtp_dec_chain_rtp (GstPad * pad, GstBuffer * buffer)
   GstRTPDecSession *session;
   guint32 ssrc;
   guint8 pt;
+  GstRTPBuffer rtp = { NULL, };
 
   rtpdec = GST_RTP_DEC (GST_PAD_PARENT (pad));
 
@@ -472,8 +469,11 @@ gst_rtp_dec_chain_rtp (GstPad * pad, GstBuffer * buffer)
   if (!gst_rtp_buffer_validate (buffer))
     goto bad_packet;
 
-  ssrc = gst_rtp_buffer_get_ssrc (buffer);
-  pt = gst_rtp_buffer_get_payload_type (buffer);
+
+  gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp);
+  ssrc = gst_rtp_buffer_get_ssrc (&rtp);
+  pt = gst_rtp_buffer_get_payload_type (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   GST_DEBUG_OBJECT (rtpdec, "SSRC %08x, PT %d", ssrc, pt);
 
@@ -518,7 +518,7 @@ gst_rtp_dec_chain_rtp (GstPad * pad, GstBuffer * buffer)
     session->recv_rtp_src = gst_pad_new_from_template (templ, name);
     g_free (name);
 
-    gst_pad_set_caps (session->recv_rtp_src, caps);
+    gst_pad_push_event (session->recv_rtp_src, gst_event_new_caps (caps));
 
     gst_pad_set_element_private (session->recv_rtp_src, session);
     gst_pad_set_query_function (session->recv_rtp_src, gst_rtp_dec_query_src);
@@ -528,8 +528,6 @@ gst_rtp_dec_chain_rtp (GstPad * pad, GstBuffer * buffer)
     session->active = TRUE;
   }
 
-  gst_buffer_set_caps (buffer, GST_PAD_CAPS (session->recv_rtp_src));
-
   res = gst_pad_push (session->recv_rtp_src, buffer);
 
   return res;
@@ -930,7 +928,7 @@ existed:
  */
 static GstPad *
 gst_rtp_dec_request_new_pad (GstElement * element,
-    GstPadTemplate * templ, const gchar * name)
+    GstPadTemplate * templ, const gchar * name, const GstCaps * caps)
 {
   GstRTPDec *rtpdec;
   GstElementClass *klass;
index c0b3753..37600f2 100644 (file)
@@ -283,39 +283,9 @@ G_STMT_START {                                          \
 } G_STMT_END
 
 /*static guint gst_rtspsrc_signals[LAST_SIGNAL] = { 0 }; */
-
-static void
-_do_init (GType rtspsrc_type)
-{
-  static const GInterfaceInfo urihandler_info = {
-    gst_rtspsrc_uri_handler_init,
-    NULL,
-    NULL
-  };
-
-  GST_DEBUG_CATEGORY_INIT (rtspsrc_debug, "rtspsrc", 0, "RTSP src");
-
-  g_type_add_interface_static (rtspsrc_type, GST_TYPE_URI_HANDLER,
-      &urihandler_info);
-}
-
-GST_BOILERPLATE_FULL (GstRTSPSrc, gst_rtspsrc, GstBin, GST_TYPE_BIN, _do_init);
-
-static void
-gst_rtspsrc_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&rtptemplate));
-
-  gst_element_class_set_details_simple (element_class, "RTSP packet receiver",
-      "Source/Network",
-      "Receive data over the network via RTSP (RFC 2326)",
-      "Wim Taymans <wim@fluendo.com>, "
-      "Thijs Vermeir <thijs.vermeir@barco.com>, "
-      "Lutz Mueller <lutz@topfrose.de>");
-}
+#define gst_rtspsrc_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstRTSPSrc, gst_rtspsrc, GST_TYPE_BIN,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_rtspsrc_uri_handler_init));
 
 static void
 gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
@@ -328,6 +298,8 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
   gstelement_class = (GstElementClass *) klass;
   gstbin_class = (GstBinClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (rtspsrc_debug, "rtspsrc", 0, "RTSP src");
+
   gobject_class->set_property = gst_rtspsrc_set_property;
   gobject_class->get_property = gst_rtspsrc_get_property;
 
@@ -475,6 +447,16 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
   gstelement_class->send_event = gst_rtspsrc_send_event;
   gstelement_class->change_state = gst_rtspsrc_change_state;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&rtptemplate));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTSP packet receiver", "Source/Network",
+      "Receive data over the network via RTSP (RFC 2326)",
+      "Wim Taymans <wim@fluendo.com>, "
+      "Thijs Vermeir <thijs.vermeir@barco.com>, "
+      "Lutz Mueller <lutz@topfrose.de>");
+
   gstbin_class->handle_message = gst_rtspsrc_handle_message;
 
   gst_rtsp_ext_list_init ();
@@ -482,7 +464,7 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
 
 
 static void
-gst_rtspsrc_init (GstRTSPSrc * src, GstRTSPSrcClass * g_class)
+gst_rtspsrc_init (GstRTSPSrc * src)
 {
 #ifdef G_OS_WIN32
   WSADATA wsa_data;
@@ -1600,18 +1582,14 @@ again:
 
   /* we keep these elements, we configure all in configure_transport when the
    * server told us to really use the UDP ports. */
-  stream->udpsrc[0] = gst_object_ref (udpsrc0);
-  stream->udpsrc[1] = gst_object_ref (udpsrc1);
+  stream->udpsrc[0] = gst_object_ref_sink (udpsrc0);
+  stream->udpsrc[1] = gst_object_ref_sink (udpsrc1);
 
   /* keep track of next available port number when we have a range
    * configured */
   if (src->next_port_num != 0)
     src->next_port_num = tmp_rtcp + 1;
 
-  /* they are ours now */
-  gst_object_sink (udpsrc0);
-  gst_object_sink (udpsrc1);
-
   return TRUE;
 
   /* ERRORS */
@@ -1667,7 +1645,7 @@ gst_rtspsrc_flush (GstRTSPSrc * src, gboolean flush)
     cmd = CMD_WAIT;
     state = GST_STATE_PAUSED;
   } else {
-    event = gst_event_new_flush_stop ();
+    event = gst_event_new_flush_stop (TRUE);
     GST_DEBUG_OBJECT (src, "stop flush");
     cmd = CMD_LOOP;
     state = GST_STATE_PLAYING;
@@ -1840,7 +1818,7 @@ gst_rtspsrc_perform_seek (GstRTSPSrc * src, GstEvent * event)
    * right values in the segment to perform the seek */
   if (event) {
     GST_DEBUG_OBJECT (src, "configuring seek");
-    gst_segment_set_seek (&seeksegment, rate, format, flags,
+    gst_segment_do_seek (&seeksegment, rate, format, flags,
         cur_type, cur, stop_type, stop, &update);
   }
 
@@ -1869,24 +1847,6 @@ gst_rtspsrc_perform_seek (GstRTSPSrc * src, GstEvent * event)
     /* if we started flush, we stop now */
     GST_DEBUG_OBJECT (src, "stopping flush");
     gst_rtspsrc_flush (src, FALSE);
-  } else if (src->running) {
-    /* re-engage loop */
-    gst_rtspsrc_loop_send_cmd (src, CMD_LOOP, FALSE);
-
-    /* we are running the current segment and doing a non-flushing seek,
-     * close the segment first based on the previous last_stop. */
-    GST_DEBUG_OBJECT (src, "closing running segment %" G_GINT64_FORMAT
-        " to %" G_GINT64_FORMAT, src->segment.accum, src->segment.last_stop);
-
-    /* queue the segment for sending in the stream thread */
-    if (src->close_segment)
-      gst_event_unref (src->close_segment);
-    src->close_segment = gst_event_new_new_segment (TRUE,
-        src->segment.rate, src->segment.format,
-        src->segment.accum, src->segment.last_stop, src->segment.accum);
-
-    /* keep track of our last_stop */
-    seeksegment.accum = src->segment.last_stop;
   }
 
   /* now we did the seek and can activate the new segment values */
@@ -1896,20 +1856,17 @@ gst_rtspsrc_perform_seek (GstRTSPSrc * src, GstEvent * event)
   if (src->segment.flags & GST_SEEK_FLAG_SEGMENT) {
     gst_element_post_message (GST_ELEMENT_CAST (src),
         gst_message_new_segment_start (GST_OBJECT_CAST (src),
-            src->segment.format, src->segment.last_stop));
+            src->segment.format, src->segment.position));
   }
 
   /* now create the newsegment */
   GST_DEBUG_OBJECT (src, "Creating newsegment from %" G_GINT64_FORMAT
-      " to %" G_GINT64_FORMAT, src->segment.last_stop, stop);
+      " to %" G_GINT64_FORMAT, src->segment.position, stop);
 
   /* store the newsegment event so it can be sent from the streaming thread. */
   if (src->start_segment)
     gst_event_unref (src->start_segment);
-  src->start_segment =
-      gst_event_new_new_segment (FALSE, src->segment.rate,
-      src->segment.format, src->segment.last_stop, stop,
-      src->segment.last_stop);
+  src->start_segment = gst_event_new_segment (&src->segment);
 
   /* mark discont */
   GST_DEBUG_OBJECT (src, "mark DISCONT, we did a seek to another position");
@@ -2128,6 +2085,7 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstBuffer * buffer)
   GstFlowReturn res = GST_FLOW_OK;
   guint8 *data;
   guint size;
+  gsize bsize;
   GstRTSPResult ret;
   GstRTSPMessage message = { 0 };
   GstRTSPConnection *conn;
@@ -2135,8 +2093,8 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstBuffer * buffer)
   stream = (GstRTSPStream *) gst_pad_get_element_private (pad);
   src = stream->parent;
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
+  data = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
+  size = bsize;
 
   gst_rtsp_message_init_data (&message, stream->channel[1]);
 
@@ -2157,20 +2115,18 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstBuffer * buffer)
   gst_rtsp_message_steal_body (&message, &data, &size);
   gst_rtsp_message_unset (&message);
 
+  gst_buffer_unmap (buffer, data, size);
   gst_buffer_unref (buffer);
 
   return res;
 }
 
-static void
-pad_unblocked (GstPad * pad, gboolean blocked, GstRTSPSrc * src)
+static GstProbeReturn
+pad_blocked (GstPad * pad, GstProbeType type, gpointer type_data,
+    gpointer user_data)
 {
-  GST_DEBUG_OBJECT (src, "pad %s:%s unblocked", GST_DEBUG_PAD_NAME (pad));
-}
+  GstRTSPSrc *src = user_data;
 
-static void
-pad_blocked (GstPad * pad, gboolean blocked, GstRTSPSrc * src)
-{
   GST_DEBUG_OBJECT (src, "pad %s:%s blocked, activating streams",
       GST_DEBUG_PAD_NAME (pad));
 
@@ -2184,12 +2140,12 @@ pad_blocked (GstPad * pad, gboolean blocked, GstRTSPSrc * src)
 
   gst_rtspsrc_activate_streams (src);
 
-  return;
+  return GST_PROBE_OK;
 
 was_ok:
   {
     GST_OBJECT_UNLOCK (src);
-    return;
+    return GST_PROBE_OK;
   }
 }
 
@@ -2714,8 +2670,7 @@ gst_rtspsrc_stream_configure_mcast (GstRTSPSrc * src, GstRTSPStream * stream,
       goto no_element;
 
     /* take ownership */
-    gst_object_ref (stream->udpsrc[0]);
-    gst_object_sink (stream->udpsrc[0]);
+    gst_object_ref_sink (stream->udpsrc[0]);
 
     /* change state */
     gst_element_set_state (stream->udpsrc[0], GST_STATE_PAUSED);
@@ -2730,8 +2685,7 @@ gst_rtspsrc_stream_configure_mcast (GstRTSPSrc * src, GstRTSPStream * stream,
       goto no_element;
 
     /* take ownership */
-    gst_object_ref (stream->udpsrc[1]);
-    gst_object_sink (stream->udpsrc[1]);
+    gst_object_ref_sink (stream->udpsrc[1]);
 
     gst_element_set_state (stream->udpsrc[1], GST_STATE_PAUSED);
   }
@@ -2782,8 +2736,9 @@ gst_rtspsrc_stream_configure_udp (GstRTSPSrc * src, GstRTSPStream * stream,
     /* configure pad block on the pad. As soon as there is dataflow on the
      * UDP source, we know that UDP is not blocked by a firewall and we can
      * configure all the streams to let the application autoplug decoders. */
-    gst_pad_set_blocked_async (stream->blockedpad, TRUE,
-        (GstPadBlockCallback) pad_blocked, src);
+    stream->blockid =
+        gst_pad_add_probe (stream->blockedpad, GST_PROBE_TYPE_BLOCK,
+        pad_blocked, src, NULL);
 
     if (stream->channelpad[0]) {
       GST_DEBUG_OBJECT (src, "connecting UDP source 0 to manager");
@@ -3136,11 +3091,10 @@ gst_rtspsrc_activate_streams (GstRTSPSrc * src)
   for (walk = src->streams; walk; walk = g_list_next (walk)) {
     GstRTSPStream *stream = (GstRTSPStream *) walk->data;
 
-    if (stream->blockedpad) {
+    if (stream->blockid) {
       GST_DEBUG_OBJECT (src, "unblocking stream pad %p", stream);
-      gst_pad_set_blocked_async (stream->blockedpad, FALSE,
-          (GstPadBlockCallback) pad_unblocked, src);
-      stream->blockedpad = NULL;
+      gst_pad_remove_probe (stream->blockedpad, stream->blockid);
+      stream->blockid = 0;
     }
   }
 
@@ -3156,7 +3110,7 @@ gst_rtspsrc_configure_caps (GstRTSPSrc * src, GstSegment * segment)
 
   GST_DEBUG_OBJECT (src, "configuring stream caps");
 
-  start = segment->last_stop;
+  start = segment->position;
   stop = segment->duration;
   play_speed = segment->rate;
   play_scale = segment->applied_rate;
@@ -3637,9 +3591,8 @@ gst_rtspsrc_loop_interleaved (GstRTSPSrc * src)
   size -= 1;
 
   buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = data;
-  GST_BUFFER_MALLOCDATA (buf) = data;
-  GST_BUFFER_SIZE (buf) = size;
+  gst_buffer_take_memory (buf, -1,
+      gst_memory_new_wrapped (0, data, g_free, size, 0, size));
 
   /* don't need message anymore */
   gst_rtsp_message_unset (&message);
@@ -3652,12 +3605,6 @@ gst_rtspsrc_loop_interleaved (GstRTSPSrc * src)
     src->need_activate = FALSE;
   }
 
-  if (!src->manager) {
-    /* set stream caps on buffer when we don't have a session manager to do it
-     * for us */
-    gst_buffer_set_caps (buf, stream->caps);
-  }
-
   if (src->base_time == -1) {
     /* Take current running_time. This timestamp will be put on
      * the first buffer of each stream because we are a live source and so we
@@ -4140,7 +4087,7 @@ pause:
       if (src->segment.flags & GST_SEEK_FLAG_SEGMENT) {
         gst_element_post_message (GST_ELEMENT_CAST (src),
             gst_message_new_segment_done (GST_OBJECT_CAST (src),
-                src->segment.format, src->segment.last_stop));
+                src->segment.format, src->segment.position));
       } else {
         gst_rtspsrc_push_event (src, gst_event_new_eos (), FALSE);
       }
@@ -5399,7 +5346,7 @@ gst_rtspsrc_parse_range (GstRTSPSrc * src, const gchar * range,
   /* we need to start playback without clipping from the position reported by
    * the server */
   segment->start = seconds;
-  segment->last_stop = seconds;
+  segment->position = seconds;
 
   if (therange->max.type == GST_RTSP_TIME_NOW)
     seconds = -1;
@@ -5425,7 +5372,7 @@ gst_rtspsrc_parse_range (GstRTSPSrc * src, const gchar * range,
   /* don't change duration with unknown value, we might have a valid value
    * there that we want to keep. */
   if (seconds != -1)
-    gst_segment_set_duration (segment, GST_FORMAT_TIME, seconds);
+    segment->duration = seconds;
 
   return TRUE;
 }
@@ -5951,11 +5898,11 @@ gen_range_header (GstRTSPSrc * src, GstSegment * segment)
   if (src->range && src->range->min.type == GST_RTSP_TIME_NOW) {
     g_strlcpy (val_str, "now", sizeof (val_str));
   } else {
-    if (segment->last_stop == 0) {
+    if (segment->position == 0) {
       g_strlcpy (val_str, "0", sizeof (val_str));
     } else {
       g_ascii_dtostr (val_str, sizeof (val_str),
-          ((gdouble) segment->last_stop) / GST_SECOND);
+          ((gdouble) segment->position) / GST_SECOND);
     }
   }
   return g_strdup_printf ("npt=%s-", val_str);
@@ -6107,7 +6054,7 @@ gst_rtspsrc_play (GstRTSPSrc * src, GstSegment * segment, gboolean async)
       /* NOTE the above also disables npt based eos detection */
       /* and below forces position to 0,
        * which is visible feedback we lost the plot */
-      segment->start = segment->last_stop = src->last_pos;
+      segment->start = segment->position = src->last_pos;
     }
 
     gst_rtsp_message_unset (&request);
@@ -6625,13 +6572,13 @@ gst_rtspsrc_send_event (GstElement * element, GstEvent * event)
 /*** GSTURIHANDLER INTERFACE *************************************************/
 
 static GstURIType
-gst_rtspsrc_uri_get_type (void)
+gst_rtspsrc_uri_get_type (GType type)
 {
   return GST_URI_SRC;
 }
 
 static gchar **
-gst_rtspsrc_uri_get_protocols (void)
+gst_rtspsrc_uri_get_protocols (GType type)
 {
   static const gchar *protocols[] =
       { "rtsp", "rtspu", "rtspt", "rtsph", "rtsp-sdp", NULL };
index 1d6f849..1ad9ec8 100644 (file)
@@ -112,6 +112,7 @@ struct _GstRTSPStream {
   /* our udp sources */
   GstElement   *udpsrc[2];
   GstPad       *blockedpad;
+  gulong        blockid;
   gboolean      is_ipv6;
 
   /* our udp sinks back to the server */
@@ -173,7 +174,6 @@ struct _GstRTSPSrc {
   gboolean         need_range;
   gboolean         skip;
   gint             free_channel;
-  GstEvent        *close_segment;
   GstEvent        *start_segment;
   GstClockTime     base_time;
 
index 83005a0..31cdba6 100644 (file)
@@ -96,11 +96,10 @@ enum
 #define DEFAULT_BORDER 0.0
 
 static GstStaticPadTemplate video_sink_pad_template =
-    GST_STATIC_PAD_TEMPLATE ("video_sink",
+GST_STATIC_PAD_TEMPLATE ("video_sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") " ; " GST_VIDEO_CAPS_ARGB " ; "
-        GST_VIDEO_CAPS_BGRA ";" GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA));
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, ARGB, BGRA, ABGR, RGBA }")));
 
 static GstStaticPadTemplate mask_sink_pad_template =
     GST_STATIC_PAD_TEMPLATE ("mask_sink",
@@ -116,33 +115,14 @@ static GstStaticPadTemplate mask_sink_pad_template =
         "height = " GST_VIDEO_SIZE_RANGE ", " "framerate = 0/1"));
 
 static GstStaticPadTemplate src_pad_template =
-    GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") " ; " GST_VIDEO_CAPS_ARGB " ; "
-        GST_VIDEO_CAPS_BGRA ";" GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA));
+GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, ARGB, BGRA, ABGR, RGBA }")));
 
 GST_DEBUG_CATEGORY_STATIC (gst_shape_wipe_debug);
 #define GST_CAT_DEFAULT gst_shape_wipe_debug
 
-GST_BOILERPLATE (GstShapeWipe, gst_shape_wipe, GstElement, GST_TYPE_ELEMENT);
-
-static void
-gst_shape_wipe_base_init (gpointer g_class)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (gstelement_class,
-      "Shape Wipe transition filter",
-      "Filter/Editor/Video",
-      "Adds a shape wipe transition to a video stream",
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&video_sink_pad_template));
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&mask_sink_pad_template));
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&src_pad_template));
-}
+#define gst_shape_wipe_parent_class parent_class
+G_DEFINE_TYPE (GstShapeWipe, gst_shape_wipe, GST_TYPE_ELEMENT);
 
 static void
 gst_shape_wipe_class_init (GstShapeWipeClass * klass)
@@ -165,10 +145,23 @@ gst_shape_wipe_class_init (GstShapeWipeClass * klass)
 
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_shape_wipe_change_state);
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "Shape Wipe transition filter",
+      "Filter/Editor/Video",
+      "Adds a shape wipe transition to a video stream",
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&video_sink_pad_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&mask_sink_pad_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_pad_template));
 }
 
 static void
-gst_shape_wipe_init (GstShapeWipe * self, GstShapeWipeClass * g_class)
+gst_shape_wipe_init (GstShapeWipe * self)
 {
   self->video_sinkpad =
       gst_pad_new_from_static_template (&video_sink_pad_template, "video_sink");
index 4d7250b..fbbdf36 100644 (file)
@@ -110,38 +110,17 @@ GST_DEBUG_CATEGORY_STATIC (gst_spectrum_debug);
 #define GST_CAT_DEFAULT gst_spectrum_debug
 
 /* elementfactory information */
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+# define FORMATS "{ S16_LE, S24_3LE, S32_LE, F32_LE, F64_LE }"
+#else
+# define FORMATS "{ S16_BE, S24_3BE, S32_BE, F32_BE, F64_BE }"
+#endif
 
 #define ALLOWED_CAPS \
-    "audio/x-raw-int, "                                               \
-    " width = (int) 16, "                                             \
-    " depth = (int) [ 1, 16 ], "                                      \
-    " signed = (boolean) true, "                                      \
-    " endianness = (int) BYTE_ORDER, "                                \
-    " rate = (int) [ 1, MAX ], "                                      \
-    " channels = (int) [ 1, MAX ]; "                                  \
-    "audio/x-raw-int, "                                               \
-    " width = (int) 24, "                                             \
-    " depth = (int) [ 1, 24 ], "                                      \
-    " signed = (boolean) true, "                                      \
-    " endianness = (int) BYTE_ORDER, "                                \
-    " rate = (int) [ 1, MAX ], "                                      \
-    " channels = (int) [ 1, MAX ]; "                                  \
-    "audio/x-raw-int, "                                               \
-    " width = (int) 32, "                                             \
-    " depth = (int) [ 1, 32 ], "                                      \
-    " signed = (boolean) true, "                                      \
-    " endianness = (int) BYTE_ORDER, "                                \
-    " rate = (int) [ 1, MAX ], "                                      \
-    " channels = (int) [ 1, MAX ]; "                                  \
-    "audio/x-raw-float, "                                             \
-    " width = (int) { 32, 64 }, "                                     \
-    " endianness = (int) BYTE_ORDER, "                                \
-    " rate = (int) [ 1, MAX ], "                                      \
-    " channels = (int) [ 1, MAX ]"
+  GST_AUDIO_CAPS_MAKE (FORMATS)
 
 /* Spectrum properties */
-#define DEFAULT_MESSAGE                        TRUE
-#define DEFAULT_POST_MESSAGES                  TRUE
+#define DEFAULT_POST_MESSAGES          TRUE
 #define DEFAULT_MESSAGE_MAGNITUDE      TRUE
 #define DEFAULT_MESSAGE_PHASE          FALSE
 #define DEFAULT_INTERVAL               (GST_SECOND / 10)
@@ -152,7 +131,6 @@ GST_DEBUG_CATEGORY_STATIC (gst_spectrum_debug);
 enum
 {
   PROP_0,
-  PROP_MESSAGE,
   PROP_POST_MESSAGES,
   PROP_MESSAGE_MAGNITUDE,
   PROP_MESSAGE_PHASE,
@@ -162,8 +140,8 @@ enum
   PROP_MULTI_CHANNEL
 };
 
-GST_BOILERPLATE (GstSpectrum, gst_spectrum, GstAudioFilter,
-    GST_TYPE_AUDIO_FILTER);
+#define gst_spectrum_parent_class parent_class
+G_DEFINE_TYPE (GstSpectrum, gst_spectrum, GST_TYPE_AUDIO_FILTER);
 
 static void gst_spectrum_finalize (GObject * object);
 static void gst_spectrum_set_property (GObject * object, guint prop_id,
@@ -175,33 +153,16 @@ static gboolean gst_spectrum_stop (GstBaseTransform * trans);
 static GstFlowReturn gst_spectrum_transform_ip (GstBaseTransform * trans,
     GstBuffer * in);
 static gboolean gst_spectrum_setup (GstAudioFilter * base,
-    GstRingBufferSpec * format);
-
-static void
-gst_spectrum_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-  GstCaps *caps;
-
-  gst_element_class_set_details_simple (element_class, "Spectrum analyzer",
-      "Filter/Analyzer/Audio",
-      "Run an FFT on the audio signal, output spectrum data",
-      "Erik Walthinsen <omega@cse.ogi.edu>, "
-      "Stefan Kost <ensonic@users.sf.net>, "
-      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
-
-  caps = gst_caps_from_string (ALLOWED_CAPS);
-  gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (g_class),
-      caps);
-  gst_caps_unref (caps);
-}
+    const GstAudioInfo * info);
 
 static void
 gst_spectrum_class_init (GstSpectrumClass * klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
   GstBaseTransformClass *trans_class = GST_BASE_TRANSFORM_CLASS (klass);
   GstAudioFilterClass *filter_class = GST_AUDIO_FILTER_CLASS (klass);
+  GstCaps *caps;
 
   gobject_class->set_property = gst_spectrum_set_property;
   gobject_class->get_property = gst_spectrum_get_property;
@@ -214,12 +175,6 @@ gst_spectrum_class_init (GstSpectrumClass * klass)
 
   filter_class->setup = GST_DEBUG_FUNCPTR (gst_spectrum_setup);
 
-  /* FIXME 0.11, remove in favour of post-messages */
-  g_object_class_install_property (gobject_class, PROP_MESSAGE,
-      g_param_spec_boolean ("message", "Message",
-          "Whether to post a 'spectrum' element message on the bus for each "
-          "passed interval (deprecated, use post-messages)", DEFAULT_MESSAGE,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   /**
    * GstSpectrum:post-messages
    *
@@ -277,10 +232,21 @@ gst_spectrum_class_init (GstSpectrumClass * klass)
 
   GST_DEBUG_CATEGORY_INIT (gst_spectrum_debug, "spectrum", 0,
       "audio spectrum analyser element");
+
+  gst_element_class_set_details_simple (element_class, "Spectrum analyzer",
+      "Filter/Analyzer/Audio",
+      "Run an FFT on the audio signal, output spectrum data",
+      "Erik Walthinsen <omega@cse.ogi.edu>, "
+      "Stefan Kost <ensonic@users.sf.net>, "
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+  caps = gst_caps_from_string (ALLOWED_CAPS);
+  gst_audio_filter_class_add_pad_templates (filter_class, caps);
+  gst_caps_unref (caps);
 }
 
 static void
-gst_spectrum_init (GstSpectrum * spectrum, GstSpectrumClass * g_class)
+gst_spectrum_init (GstSpectrum * spectrum)
 {
   spectrum->post_messages = DEFAULT_POST_MESSAGES;
   spectrum->message_magnitude = DEFAULT_MESSAGE_MAGNITUDE;
@@ -301,7 +267,7 @@ gst_spectrum_alloc_channel_data (GstSpectrum * spectrum)
   g_assert (spectrum->channel_data == NULL);
 
   spectrum->num_channels = (spectrum->multi_channel) ?
-      GST_AUDIO_FILTER (spectrum)->format.channels : 1;
+      GST_AUDIO_FILTER_CHANNELS (spectrum) : 1;
 
   GST_DEBUG_OBJECT (spectrum, "allocating data for %d channels",
       spectrum->num_channels);
@@ -378,7 +344,6 @@ gst_spectrum_set_property (GObject * object, guint prop_id,
   GstSpectrum *filter = GST_SPECTRUM (object);
 
   switch (prop_id) {
-    case PROP_MESSAGE:
     case PROP_POST_MESSAGES:
       filter->post_messages = g_value_get_boolean (value);
       break;
@@ -434,7 +399,6 @@ gst_spectrum_get_property (GObject * object, guint prop_id,
   GstSpectrum *filter = GST_SPECTRUM (object);
 
   switch (prop_id) {
-    case PROP_MESSAGE:
     case PROP_POST_MESSAGES:
       g_value_set_boolean (value, filter->post_messages);
       break;
@@ -519,23 +483,6 @@ input_data_mixed_double (const guint8 * _in, gfloat * out, guint len,
 }
 
 static void
-input_data_mixed_int32 (const guint8 * _in, gfloat * out, guint len,
-    guint channels, gfloat max_value, guint op, guint nfft)
-{
-  guint i, j, ip = 0;
-  gint32 *in = (gint32 *) _in;
-  gfloat v;
-
-  for (j = 0; j < len; j++) {
-    v = in[ip++] * 2 + 1;
-    for (i = 1; i < channels; i++)
-      v += in[ip++] * 2 + 1;
-    out[op] = v / channels;
-    op = (op + 1) % nfft;
-  }
-}
-
-static void
 input_data_mixed_int32_max (const guint8 * _in, gfloat * out, guint len,
     guint channels, gfloat max_value, guint op, guint nfft)
 {
@@ -553,30 +500,6 @@ input_data_mixed_int32_max (const guint8 * _in, gfloat * out, guint len,
 }
 
 static void
-input_data_mixed_int24 (const guint8 * _in, gfloat * out, guint len,
-    guint channels, gfloat max_value, guint op, guint nfft)
-{
-  guint i, j;
-  gfloat v = 0.0;
-
-  for (j = 0; j < len; j++) {
-    for (i = 0; i < channels; i++) {
-#if G_BYTE_ORDER == G_BIG_ENDIAN
-      gint32 value = GST_READ_UINT24_BE (_in);
-#else
-      gint32 value = GST_READ_UINT24_LE (_in);
-#endif
-      if (value & 0x00800000)
-        value |= 0xff000000;
-      v += value * 2 + 1;
-      _in += 3;
-    }
-    out[op] = v / channels;
-    op = (op + 1) % nfft;
-  }
-}
-
-static void
 input_data_mixed_int24_max (const guint8 * _in, gfloat * out, guint len,
     guint channels, gfloat max_value, guint op, guint nfft)
 {
@@ -601,23 +524,6 @@ input_data_mixed_int24_max (const guint8 * _in, gfloat * out, guint len,
 }
 
 static void
-input_data_mixed_int16 (const guint8 * _in, gfloat * out, guint len,
-    guint channels, gfloat max_value, guint op, guint nfft)
-{
-  guint i, j, ip = 0;
-  gint16 *in = (gint16 *) _in;
-  gfloat v;
-
-  for (j = 0; j < len; j++) {
-    v = in[ip++] * 2 + 1;
-    for (i = 1; i < channels; i++)
-      v += in[ip++] * 2 + 1;
-    out[op] = v / channels;
-    op = (op + 1) % nfft;
-  }
-}
-
-static void
 input_data_mixed_int16_max (const guint8 * _in, gfloat * out, guint len,
     guint channels, gfloat max_value, guint op, guint nfft)
 {
@@ -663,19 +569,6 @@ input_data_double (const guint8 * _in, gfloat * out, guint len, guint channels,
 }
 
 static void
-input_data_int32 (const guint8 * _in, gfloat * out, guint len, guint channels,
-    gfloat max_value, guint op, guint nfft)
-{
-  guint j, ip;
-  gint32 *in = (gint32 *) _in;
-
-  for (j = 0, ip = 0; j < len; j++, ip += channels) {
-    out[op] = in[ip] * 2 + 1;
-    op = (op + 1) % nfft;
-  }
-}
-
-static void
 input_data_int32_max (const guint8 * _in, gfloat * out, guint len,
     guint channels, gfloat max_value, guint op, guint nfft)
 {
@@ -689,26 +582,6 @@ input_data_int32_max (const guint8 * _in, gfloat * out, guint len,
 }
 
 static void
-input_data_int24 (const guint8 * _in, gfloat * out, guint len, guint channels,
-    gfloat max_value, guint op, guint nfft)
-{
-  guint j;
-
-  for (j = 0; j < len; j++) {
-#if G_BYTE_ORDER == G_BIG_ENDIAN
-    gint32 v = GST_READ_UINT24_BE (_in);
-#else
-    gint32 v = GST_READ_UINT24_LE (_in);
-#endif
-    if (v & 0x00800000)
-      v |= 0xff000000;
-    _in += 3 * channels;
-    out[op] = v * 2 + 1;
-    op = (op + 1) % nfft;
-  }
-}
-
-static void
 input_data_int24_max (const guint8 * _in, gfloat * out, guint len,
     guint channels, gfloat max_value, guint op, guint nfft)
 {
@@ -729,19 +602,6 @@ input_data_int24_max (const guint8 * _in, gfloat * out, guint len,
 }
 
 static void
-input_data_int16 (const guint8 * _in, gfloat * out, guint len, guint channels,
-    gfloat max_value, guint op, guint nfft)
-{
-  guint j, ip;
-  gint16 *in = (gint16 *) _in;
-
-  for (j = 0, ip = 0; j < len; j++, ip += channels) {
-    out[op] = in[ip] * 2 + 1;
-    op = (op + 1) % nfft;
-  }
-}
-
-static void
 input_data_int16_max (const guint8 * _in, gfloat * out, guint len,
     guint channels, gfloat max_value, guint op, guint nfft)
 {
@@ -755,54 +615,39 @@ input_data_int16_max (const guint8 * _in, gfloat * out, guint len,
 }
 
 static gboolean
-gst_spectrum_setup (GstAudioFilter * base, GstRingBufferSpec * format)
+gst_spectrum_setup (GstAudioFilter * base, const GstAudioInfo * info)
 {
   GstSpectrum *spectrum = GST_SPECTRUM (base);
-  guint width = format->width / 8;
-  gboolean is_float = (format->type == GST_BUFTYPE_FLOAT);
-  /* max_value will be 0 when depth is 1,
-   * interpret -1 and 0 as -1 and +1 if that's the case. */
-  guint max_value = (1UL << (format->depth - 1)) - 1;
   gboolean multi_channel = spectrum->multi_channel;
   GstSpectrumInputData input_data = NULL;
 
-  if (is_float) {
-    if (width == 4) {
+  switch (GST_AUDIO_INFO_FORMAT (info)) {
+    case GST_AUDIO_FORMAT_S16:
+      input_data =
+          multi_channel ? input_data_int16_max : input_data_mixed_int16_max;
+      break;
+    case GST_AUDIO_FORMAT_S24_3:
+      input_data =
+          multi_channel ? input_data_int24_max : input_data_mixed_int24_max;
+      break;
+    case GST_AUDIO_FORMAT_S32:
+      input_data =
+          multi_channel ? input_data_int32_max : input_data_mixed_int32_max;
+      break;
+    case GST_AUDIO_FORMAT_F32:
       input_data = multi_channel ? input_data_float : input_data_mixed_float;
-    } else if (width == 8) {
+      break;
+    case GST_AUDIO_FORMAT_F64:
       input_data = multi_channel ? input_data_double : input_data_mixed_double;
-    } else {
-      g_assert_not_reached ();
-    }
-  } else {
-    if (width == 4) {
-      if (max_value) {
-        input_data =
-            multi_channel ? input_data_int32_max : input_data_mixed_int32_max;
-      } else {
-        input_data = multi_channel ? input_data_int32 : input_data_mixed_int32;
-      }
-    } else if (width == 3) {
-      if (max_value) {
-        input_data =
-            multi_channel ? input_data_int24_max : input_data_mixed_int24_max;
-      } else {
-        input_data = multi_channel ? input_data_int24 : input_data_mixed_int24;
-      }
-    } else if (width == 2) {
-      if (max_value) {
-        input_data =
-            multi_channel ? input_data_int16_max : input_data_mixed_int16_max;
-      } else {
-        input_data = multi_channel ? input_data_int16 : input_data_mixed_int16;
-      }
-    } else {
+      break;
+    default:
       g_assert_not_reached ();
-    }
+      break;
   }
-
   spectrum->input_data = input_data;
+
   gst_spectrum_reset_state (spectrum);
+
   return TRUE;
 }
 
@@ -894,7 +739,7 @@ gst_spectrum_message_new (GstSpectrum * spectrum, GstClockTime timestamp,
     }
   } else {
     guint c;
-    guint channels = GST_AUDIO_FILTER (spectrum)->format.channels;
+    guint channels = GST_AUDIO_FILTER_CHANNELS (spectrum);
 
     if (spectrum->message_magnitude) {
       mcv = gst_spectrum_message_add_container (s, GST_TYPE_ARRAY, "magnitude");
@@ -1000,26 +845,27 @@ static GstFlowReturn
 gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
 {
   GstSpectrum *spectrum = GST_SPECTRUM (trans);
-  GstRingBufferSpec *format = &GST_AUDIO_FILTER (spectrum)->format;
-  guint rate = format->rate;
-  guint channels = format->channels;
+  guint rate = GST_AUDIO_FILTER_RATE (spectrum);
+  guint channels = GST_AUDIO_FILTER_CHANNELS (spectrum);
+  guint bps = GST_AUDIO_FILTER_BPS (spectrum);
+  guint bpf = GST_AUDIO_FILTER_BPF (spectrum);
   guint output_channels = spectrum->multi_channel ? channels : 1;
   guint c;
-  guint width = format->width / 8;
-  gfloat max_value = (1UL << (format->depth - 1)) - 1;
+  gfloat max_value = (1UL << ((bps << 3) - 1)) - 1;
   guint bands = spectrum->bands;
   guint nfft = 2 * bands - 2;
   guint input_pos;
   gfloat *input;
-  const guint8 *data = GST_BUFFER_DATA (buffer);
-  guint size = GST_BUFFER_SIZE (buffer);
-  guint frame_size = width * channels;
+  const guint8 *data, *mdata;
+  gsize size;
   guint fft_todo, msg_todo, block_size;
   gboolean have_full_interval;
   GstSpectrumChannel *cd;
   GstSpectrumInputData input_data;
 
-  GST_LOG_OBJECT (spectrum, "input size: %d bytes", GST_BUFFER_SIZE (buffer));
+  data = mdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
+  GST_LOG_OBJECT (spectrum, "input size: %" G_GSIZE_FORMAT " bytes", size);
 
   if (GST_BUFFER_IS_DISCONT (buffer)) {
     GST_DEBUG_OBJECT (spectrum, "Discontinuity detected -- flushing");
@@ -1061,16 +907,16 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
   input_pos = spectrum->input_pos;
   input_data = spectrum->input_data;
 
-  while (size >= frame_size) {
+  while (size >= bpf) {
     /* run input_data for a chunk of data */
     fft_todo = nfft - (spectrum->num_frames % nfft);
     msg_todo = spectrum->frames_todo - spectrum->num_frames;
     GST_LOG_OBJECT (spectrum,
         "message frames todo: %u, fft frames todo: %u, input frames %u",
-        msg_todo, fft_todo, (size / frame_size));
+        msg_todo, fft_todo, (size / bpf));
     block_size = msg_todo;
-    if (block_size > (size / frame_size))
-      block_size = (size / frame_size);
+    if (block_size > (size / bpf))
+      block_size = (size / bpf);
     if (block_size > fft_todo)
       block_size = fft_todo;
 
@@ -1078,11 +924,11 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
       cd = &spectrum->channel_data[c];
       input = cd->input;
       /* Move the current frames into our ringbuffers */
-      input_data (data + c * width, input, block_size, channels, max_value,
+      input_data (data + c * bps, input, block_size, channels, max_value,
           input_pos, nfft);
     }
-    data += block_size * frame_size;
-    size -= block_size * frame_size;
+    data += block_size * bpf;
+    size -= block_size * bpf;
     input_pos = (input_pos + block_size) % nfft;
     spectrum->num_frames += block_size;
 
@@ -1145,6 +991,8 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
 
   spectrum->input_pos = input_pos;
 
+  gst_buffer_unmap (buffer, (guint8 *) mdata, -1);
+
   g_assert (size == 0);
 
   return GST_FLOW_OK;
index d7b5678..a78f9d7 100644 (file)
@@ -78,9 +78,6 @@ G_STMT_START {                                                            \
   udpctx->sock = -1;                                                      \
 } G_STMT_END
 
-static void gst_dynudpsink_base_init (gpointer g_class);
-static void gst_dynudpsink_class_init (GstDynUDPSink * klass);
-static void gst_dynudpsink_init (GstDynUDPSink * udpsink);
 static void gst_dynudpsink_finalize (GObject * object);
 
 static GstFlowReturn gst_dynudpsink_render (GstBaseSink * sink,
@@ -94,52 +91,13 @@ static void gst_dynudpsink_set_property (GObject * object, guint prop_id,
 static void gst_dynudpsink_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-static GstElementClass *parent_class = NULL;
-
 static guint gst_dynudpsink_signals[LAST_SIGNAL] = { 0 };
 
-GType
-gst_dynudpsink_get_type (void)
-{
-  static GType dynudpsink_type = 0;
-
-  if (!dynudpsink_type) {
-    static const GTypeInfo dynudpsink_info = {
-      sizeof (GstDynUDPSinkClass),
-      gst_dynudpsink_base_init,
-      NULL,
-      (GClassInitFunc) gst_dynudpsink_class_init,
-      NULL,
-      NULL,
-      sizeof (GstDynUDPSink),
-      0,
-      (GInstanceInitFunc) gst_dynudpsink_init,
-      NULL
-    };
-
-    dynudpsink_type =
-        g_type_register_static (GST_TYPE_BASE_SINK, "GstDynUDPSink",
-        &dynudpsink_info, 0);
-  }
-  return dynudpsink_type;
-}
+#define gst_dynudpsink_parent_class parent_class
+G_DEFINE_TYPE (GstDynUDPSink, gst_dynudpsink, GST_TYPE_BASE_SINK);
 
 static void
-gst_dynudpsink_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template));
-
-  gst_element_class_set_details_simple (element_class, "UDP packet sender",
-      "Sink/Network",
-      "Send data over the network via UDP",
-      "Philippe Khalaf <burger@speedy.org>");
-}
-
-static void
-gst_dynudpsink_class_init (GstDynUDPSink * klass)
+gst_dynudpsink_class_init (GstDynUDPSinkClass * klass)
 {
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
@@ -173,6 +131,14 @@ gst_dynudpsink_class_init (GstDynUDPSink * klass)
 
   gstelement_class->change_state = gst_dynudpsink_change_state;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "UDP packet sender",
+      "Sink/Network",
+      "Send data over the network via UDP",
+      "Philippe Khalaf <burger@speedy.org>");
+
   gstbasesink_class->render = gst_dynudpsink_render;
 
   GST_DEBUG_CATEGORY_INIT (dynudpsink_debug, "dynudpsink", 0, "UDP sink");
@@ -209,31 +175,31 @@ static GstFlowReturn
 gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
 {
   GstDynUDPSink *sink;
-  gint ret, size;
+  gint ret;
+  gsize size;
   guint8 *data;
-  GstNetBuffer *netbuf;
+  GstMetaNetAddress *meta;
   struct sockaddr_in theiraddr;
   guint16 destport;
   guint32 destaddr;
 
   memset (&theiraddr, 0, sizeof (theiraddr));
 
-  if (GST_IS_NETBUFFER (buffer)) {
-    netbuf = GST_NETBUFFER (buffer);
-  } else {
+  meta = gst_buffer_get_meta_net_address (buffer);
+
+  if (meta == NULL) {
     GST_DEBUG ("Received buffer is not a GstNetBuffer, skipping");
     return GST_FLOW_OK;
   }
 
   sink = GST_DYNUDPSINK (bsink);
 
-  size = GST_BUFFER_SIZE (netbuf);
-  data = GST_BUFFER_DATA (netbuf);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   GST_DEBUG ("about to send %d bytes", size);
 
-  // let's get the address from the netbuffer
-  gst_netaddress_get_ip4_address (&netbuf->to, &destaddr, &destport);
+  /* let's get the address from the metaata */
+  gst_netaddress_get_ip4_address (&meta->naddr, &destaddr, &destport);
 
   GST_DEBUG ("sending %d bytes to client %d port %d", size, destaddr, destport);
 
@@ -247,6 +213,8 @@ gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
 #endif
       (struct sockaddr *) &theiraddr, sizeof (theiraddr));
 
+  gst_buffer_unmap (buffer, data, size);
+
   if (ret < 0) {
     if (errno != EINTR && errno != EAGAIN) {
       goto send_error;
index bcdb6cd..85bb47a 100644 (file)
@@ -113,17 +113,16 @@ G_STMT_START {                                                            \
   udpctx->sock = DEFAULT_SOCK;                                            \
 } G_STMT_END
 
-static void gst_multiudpsink_base_init (gpointer g_class);
-static void gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass);
-static void gst_multiudpsink_init (GstMultiUDPSink * udpsink);
 static void gst_multiudpsink_finalize (GObject * object);
 
 static GstFlowReturn gst_multiudpsink_render (GstBaseSink * sink,
     GstBuffer * buffer);
+#if 0
 #ifndef G_OS_WIN32              /* sendmsg() is not available on Windows */
 static GstFlowReturn gst_multiudpsink_render_list (GstBaseSink * bsink,
     GstBufferList * list);
 #endif
+#endif
 static GstStateChangeReturn gst_multiudpsink_change_state (GstElement *
     element, GstStateChange transition);
 
@@ -137,49 +136,10 @@ static void gst_multiudpsink_add_internal (GstMultiUDPSink * sink,
 static void gst_multiudpsink_clear_internal (GstMultiUDPSink * sink,
     gboolean lock);
 
-static GstElementClass *parent_class = NULL;
-
 static guint gst_multiudpsink_signals[LAST_SIGNAL] = { 0 };
 
-GType
-gst_multiudpsink_get_type (void)
-{
-  static GType multiudpsink_type = 0;
-
-  if (!multiudpsink_type) {
-    static const GTypeInfo multiudpsink_info = {
-      sizeof (GstMultiUDPSinkClass),
-      gst_multiudpsink_base_init,
-      NULL,
-      (GClassInitFunc) gst_multiudpsink_class_init,
-      NULL,
-      NULL,
-      sizeof (GstMultiUDPSink),
-      0,
-      (GInstanceInitFunc) gst_multiudpsink_init,
-      NULL
-    };
-
-    multiudpsink_type =
-        g_type_register_static (GST_TYPE_BASE_SINK, "GstMultiUDPSink",
-        &multiudpsink_info, 0);
-  }
-  return multiudpsink_type;
-}
-
-static void
-gst_multiudpsink_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template));
-
-  gst_element_class_set_details_simple (element_class, "UDP packet sender",
-      "Sink/Network",
-      "Send data over the network via UDP",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_multiudpsink_parent_class parent_class
+G_DEFINE_TYPE (GstMultiUDPSink, gst_multiudpsink, GST_TYPE_BASE_SINK);
 
 static void
 gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass)
@@ -358,10 +318,20 @@ gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass)
 
   gstelement_class->change_state = gst_multiudpsink_change_state;
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "UDP packet sender",
+      "Sink/Network",
+      "Send data over the network via UDP",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
   gstbasesink_class->render = gst_multiudpsink_render;
+#if 0
 #ifndef G_OS_WIN32
   gstbasesink_class->render_list = gst_multiudpsink_render_list;
 #endif
+#endif
   klass->add = gst_multiudpsink_add;
   klass->remove = gst_multiudpsink_remove;
   klass->clear = gst_multiudpsink_clear;
@@ -484,19 +454,21 @@ socket_last_error_message (void)
 #endif
 }
 
+#ifdef G_OS_WIN32
+/* version without sendmsg */
 static GstFlowReturn
 gst_multiudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
 {
   GstMultiUDPSink *sink;
-  gint ret, size, num = 0, no_clients = 0;
+  gint ret, num = 0, no_clients = 0;
+  gsize size;
   guint8 *data;
   GList *clients;
   gint len;
 
   sink = GST_MULTIUDPSINK (bsink);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   if (size > UDP_MAX_SIZE) {
     GST_WARNING ("Attempting to send a UDP packet larger than maximum "
@@ -554,109 +526,129 @@ gst_multiudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
   }
   g_mutex_unlock (sink->client_lock);
 
+  gst_buffer_unmap (buffer, data, size);
+
   GST_LOG_OBJECT (sink, "sent %d bytes to %d (of %d) clients", size, num,
       no_clients);
 
   return GST_FLOW_OK;
 }
-
-#ifndef G_OS_WIN32
+#else /* !G_OS_WIN32 */
+/* version with sendmsg */
 static GstFlowReturn
-gst_multiudpsink_render_list (GstBaseSink * bsink, GstBufferList * list)
+gst_multiudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
 {
   GstMultiUDPSink *sink;
   GList *clients;
   gint ret, size = 0, num = 0, no_clients = 0;
   struct iovec *iov;
   struct msghdr msg = { 0 };
-
-  GstBufferListIterator *it;
-  guint gsize;
-  GstBuffer *buf;
+  guint n_mem, i;
+  gpointer bdata;
+  gsize bsize;
+  GstMemory *mem;
 
   sink = GST_MULTIUDPSINK (bsink);
 
-  g_return_val_if_fail (list != NULL, GST_FLOW_ERROR);
+  msg.msg_iovlen = 0;
+  size = 0;
+
+  n_mem = gst_buffer_n_memory (buffer);
+  if (n_mem == 0)
+    goto no_data;
 
-  it = gst_buffer_list_iterate (list);
-  g_return_val_if_fail (it != NULL, GST_FLOW_ERROR);
+  iov = (struct iovec *) g_malloc (n_mem * sizeof (struct iovec));
+  msg.msg_iov = iov;
 
-  while (gst_buffer_list_iterator_next_group (it)) {
-    msg.msg_iovlen = 0;
-    size = 0;
+  for (i = 0; i < n_mem; i++) {
+    mem = gst_buffer_peek_memory (buffer, i, GST_MAP_READ);
+    bdata = gst_memory_map (mem, &bsize, NULL, GST_MAP_READ);
 
-    if ((gsize = gst_buffer_list_iterator_n_buffers (it)) == 0) {
-      goto invalid_list;
+    if (bsize > UDP_MAX_SIZE) {
+      GST_WARNING ("Attempting to send a UDP packet larger than maximum "
+          "size (%d > %d)", bsize, UDP_MAX_SIZE);
     }
 
-    iov = (struct iovec *) g_malloc (gsize * sizeof (struct iovec));
-    msg.msg_iov = iov;
+    msg.msg_iov[msg.msg_iovlen].iov_len = bsize;
+    msg.msg_iov[msg.msg_iovlen].iov_base = bdata;
+    msg.msg_iovlen++;
 
-    while ((buf = gst_buffer_list_iterator_next (it))) {
-      if (GST_BUFFER_SIZE (buf) > UDP_MAX_SIZE) {
-        GST_WARNING ("Attempting to send a UDP packet larger than maximum "
-            "size (%d > %d)", GST_BUFFER_SIZE (buf), UDP_MAX_SIZE);
-      }
+    size += bsize;
+  }
 
-      msg.msg_iov[msg.msg_iovlen].iov_len = GST_BUFFER_SIZE (buf);
-      msg.msg_iov[msg.msg_iovlen].iov_base = GST_BUFFER_DATA (buf);
-      msg.msg_iovlen++;
-      size += GST_BUFFER_SIZE (buf);
-    }
+  sink->bytes_to_serve += size;
 
-    sink->bytes_to_serve += size;
+  /* grab lock while iterating and sending to clients, this should be
+   * fast as UDP never blocks */
+  g_mutex_lock (sink->client_lock);
+  GST_LOG_OBJECT (bsink, "about to send %d bytes", size);
 
-    /* grab lock while iterating and sending to clients, this should be
-     * fast as UDP never blocks */
-    g_mutex_lock (sink->client_lock);
-    GST_LOG_OBJECT (bsink, "about to send %d bytes", size);
-
-    for (clients = sink->clients; clients; clients = g_list_next (clients)) {
-      GstUDPClient *client;
-      gint count;
-
-      client = (GstUDPClient *) clients->data;
-      no_clients++;
-      GST_LOG_OBJECT (sink, "sending %d bytes to client %p", size, client);
-
-      count = sink->send_duplicates ? client->refcount : 1;
-
-      while (count--) {
-        while (TRUE) {
-          msg.msg_name = (void *) &client->theiraddr;
-          msg.msg_namelen = sizeof (client->theiraddr);
-          ret = sendmsg (*client->sock, &msg, 0);
-
-          if (ret < 0) {
-            if (!socket_error_is_ignorable ()) {
-              break;
-            }
-          } else {
-            num++;
-            client->bytes_sent += ret;
-            client->packets_sent++;
-            sink->bytes_served += ret;
+  for (clients = sink->clients; clients; clients = g_list_next (clients)) {
+    GstUDPClient *client;
+    gint count;
+
+    client = (GstUDPClient *) clients->data;
+    no_clients++;
+    GST_LOG_OBJECT (sink, "sending %d bytes to client %p", size, client);
+
+    count = sink->send_duplicates ? client->refcount : 1;
+
+    while (count--) {
+      while (TRUE) {
+        msg.msg_name = (void *) &client->theiraddr;
+        msg.msg_namelen = sizeof (client->theiraddr);
+        ret = sendmsg (*client->sock, &msg, 0);
+
+        if (ret < 0) {
+          if (!socket_error_is_ignorable ()) {
+            gchar *errormessage = socket_last_error_message ();
+            GST_WARNING_OBJECT (sink, "client %p gave error %d (%s)", client,
+                socket_last_error_code (), errormessage);
+            g_free (errormessage);
+            break;
             break;
           }
+        } else {
+          num++;
+          client->bytes_sent += ret;
+          client->packets_sent++;
+          sink->bytes_served += ret;
+          break;
         }
       }
     }
-    g_mutex_unlock (sink->client_lock);
+  }
+  g_mutex_unlock (sink->client_lock);
 
-    g_free (iov);
-    msg.msg_iov = NULL;
+  /* unmap all memory again */
+  for (i = 0; i < n_mem; i++) {
+    mem = gst_buffer_peek_memory (buffer, i, GST_MAP_READ);
 
-    GST_LOG_OBJECT (sink, "sent %d bytes to %d (of %d) clients", size, num,
-        no_clients);
+    bsize = msg.msg_iov[i].iov_len;
+    bdata = msg.msg_iov[i].iov_base;
+
+    gst_memory_unmap (mem, bdata, bsize);
   }
+  g_free (iov);
 
-  gst_buffer_list_iterator_free (it);
+  GST_LOG_OBJECT (sink, "sent %d bytes to %d (of %d) clients", size, num,
+      no_clients);
 
   return GST_FLOW_OK;
 
-invalid_list:
-  gst_buffer_list_iterator_free (it);
-  return GST_FLOW_ERROR;
+no_data:
+  {
+    return GST_FLOW_OK;
+  }
+}
+#endif
+
+#if 0
+/* DISABLED, core sends buffers to our render one by one, we can't really do
+ * much better */
+static GstFlowReturn
+gst_multiudpsink_render_list (GstBaseSink * bsink, GstBufferList * list)
+{
 }
 #endif
 
index fbdbfea..3b77865 100644 (file)
@@ -36,9 +36,10 @@ plugin_init (GstPlugin * plugin)
     return FALSE;
 #endif
 
-  /* register type of the netbuffer so that we can use it from multiple threads
-   * right away. Note that the plugin loading is always serialized */
-  gst_netbuffer_get_type ();
+  /* register info of the netaddress metadata so that we can use it from
+   * multiple threads right away. Note that the plugin loading is always
+   * serialized */
+  gst_meta_net_address_get_info ();
 
   if (!gst_element_register (plugin, "udpsink", GST_RANK_NONE,
           GST_TYPE_UDPSINK))
index 26c70cd..91f0777 100644 (file)
@@ -62,9 +62,6 @@ enum
   /* FILL ME */
 };
 
-static void gst_udpsink_base_init (gpointer g_class);
-static void gst_udpsink_class_init (GstUDPSink * klass);
-static void gst_udpsink_init (GstUDPSink * udpsink);
 static void gst_udpsink_finalize (GstUDPSink * udpsink);
 
 static void gst_udpsink_uri_handler_init (gpointer g_iface,
@@ -75,63 +72,19 @@ static void gst_udpsink_set_property (GObject * object, guint prop_id,
 static void gst_udpsink_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-static GstElementClass *parent_class = NULL;
-
 /*static guint gst_udpsink_signals[LAST_SIGNAL] = { 0 }; */
-
-GType
-gst_udpsink_get_type (void)
-{
-  static GType udpsink_type = 0;
-
-  if (!udpsink_type) {
-    static const GTypeInfo udpsink_info = {
-      sizeof (GstUDPSinkClass),
-      gst_udpsink_base_init,
-      NULL,
-      (GClassInitFunc) gst_udpsink_class_init,
-      NULL,
-      NULL,
-      sizeof (GstUDPSink),
-      0,
-      (GInstanceInitFunc) gst_udpsink_init,
-      NULL
-    };
-    static const GInterfaceInfo urihandler_info = {
-      gst_udpsink_uri_handler_init,
-      NULL,
-      NULL
-    };
-
-    udpsink_type =
-        g_type_register_static (GST_TYPE_MULTIUDPSINK, "GstUDPSink",
-        &udpsink_info, 0);
-
-    g_type_add_interface_static (udpsink_type, GST_TYPE_URI_HANDLER,
-        &urihandler_info);
-
-  }
-  return udpsink_type;
-}
-
-static void
-gst_udpsink_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "UDP packet sender",
-      "Sink/Network",
-      "Send data over the network via UDP", "Wim Taymans <wim@fluendo.com>");
-}
+#define gst_udpsink_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstUDPSink, gst_udpsink, GST_TYPE_MULTIUDPSINK,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_udpsink_uri_handler_init));
 
 static void
-gst_udpsink_class_init (GstUDPSink * klass)
+gst_udpsink_class_init (GstUDPSinkClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
 
   gobject_class = (GObjectClass *) klass;
-
-  parent_class = g_type_class_peek_parent (klass);
+  gstelement_class = (GstElementClass *) klass;
 
   gobject_class->set_property = gst_udpsink_set_property;
   gobject_class->get_property = gst_udpsink_get_property;
@@ -146,8 +99,11 @@ gst_udpsink_class_init (GstUDPSink * klass)
       g_param_spec_int ("port", "port", "The port to send the packets to",
           0, 65535, UDP_DEFAULT_PORT,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
 
+  gst_element_class_set_details_simple (gstelement_class, "UDP packet sender",
+      "Sink/Network",
+      "Send data over the network via UDP", "Wim Taymans <wim@fluendo.com>");
+}
 
 static void
 gst_udpsink_init (GstUDPSink * udpsink)
@@ -251,13 +207,13 @@ gst_udpsink_get_property (GObject * object, guint prop_id, GValue * value,
 /*** GSTURIHANDLER INTERFACE *************************************************/
 
 static GstURIType
-gst_udpsink_uri_get_type (void)
+gst_udpsink_uri_get_type (GType type)
 {
   return GST_URI_SINK;
 }
 
 static gchar **
-gst_udpsink_uri_get_protocols (void)
+gst_udpsink_uri_get_protocols (GType type)
 {
   static gchar *protocols[] = { (char *) "udp", NULL };
 
index f3f47a8..51a0446 100644 (file)
@@ -177,7 +177,7 @@ G_STMT_START {                                                            \
 
 static void gst_udpsrc_uri_handler_init (gpointer g_iface, gpointer iface_data);
 
-static GstCaps *gst_udpsrc_getcaps (GstBaseSrc * src);
+static GstCaps *gst_udpsrc_getcaps (GstBaseSrc * src, GstCaps * filter);
 
 static GstFlowReturn gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf);
 
@@ -196,49 +196,25 @@ static void gst_udpsrc_set_property (GObject * object, guint prop_id,
 static void gst_udpsrc_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-static void
-_do_init (GType type)
-{
-  static const GInterfaceInfo urihandler_info = {
-    gst_udpsrc_uri_handler_init,
-    NULL,
-    NULL
-  };
-
-  g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
-
-  GST_DEBUG_CATEGORY_INIT (udpsrc_debug, "udpsrc", 0, "UDP src");
-}
-
-GST_BOILERPLATE_FULL (GstUDPSrc, gst_udpsrc, GstPushSrc, GST_TYPE_PUSH_SRC,
-    _do_init);
-
-static void
-gst_udpsrc_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_template));
-
-  gst_element_class_set_details_simple (element_class, "UDP packet receiver",
-      "Source/Network",
-      "Receive data over the network via UDP",
-      "Wim Taymans <wim@fluendo.com>, "
-      "Thijs Vermeir <thijs.vermeir@barco.com>");
-}
+#define gst_udpsrc_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstUDPSrc, gst_udpsrc, GST_TYPE_PUSH_SRC,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_udpsrc_uri_handler_init));
 
 static void
 gst_udpsrc_class_init (GstUDPSrcClass * klass)
 {
   GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
   GstBaseSrcClass *gstbasesrc_class;
   GstPushSrcClass *gstpushsrc_class;
 
   gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
   gstbasesrc_class = (GstBaseSrcClass *) klass;
   gstpushsrc_class = (GstPushSrcClass *) klass;
 
+  GST_DEBUG_CATEGORY_INIT (udpsrc_debug, "udpsrc", 0, "UDP src");
+
   gobject_class->set_property = gst_udpsrc_set_property;
   gobject_class->get_property = gst_udpsrc_get_property;
   gobject_class->finalize = gst_udpsrc_finalize;
@@ -301,6 +277,15 @@ gst_udpsrc_class_init (GstUDPSrcClass * klass)
       g_param_spec_boolean ("reuse", "Reuse", "Enable reuse of the port",
           UDP_DEFAULT_REUSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_template));
+
+  gst_element_class_set_details_simple (gstelement_class, "UDP packet receiver",
+      "Source/Network",
+      "Receive data over the network via UDP",
+      "Wim Taymans <wim@fluendo.com>, "
+      "Thijs Vermeir <thijs.vermeir@barco.com>");
+
   gstbasesrc_class->start = gst_udpsrc_start;
   gstbasesrc_class->stop = gst_udpsrc_stop;
   gstbasesrc_class->unlock = gst_udpsrc_unlock;
@@ -311,7 +296,7 @@ gst_udpsrc_class_init (GstUDPSrcClass * klass)
 }
 
 static void
-gst_udpsrc_init (GstUDPSrc * udpsrc, GstUDPSrcClass * g_class)
+gst_udpsrc_init (GstUDPSrc * udpsrc)
 {
   WSA_STARTUP (udpsrc);
 
@@ -362,7 +347,7 @@ gst_udpsrc_finalize (GObject * object)
 }
 
 static GstCaps *
-gst_udpsrc_getcaps (GstBaseSrc * src)
+gst_udpsrc_getcaps (GstBaseSrc * src, GstCaps * filter)
 {
   GstUDPSrc *udpsrc;
 
@@ -409,7 +394,8 @@ static GstFlowReturn
 gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
 {
   GstUDPSrc *udpsrc;
-  GstNetBuffer *outbuf;
+  GstMetaNetAddress *meta;
+  GstBuffer *outbuf;
   union gst_sockaddr
   {
     struct sockaddr sa;
@@ -420,6 +406,7 @@ gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
   socklen_t slen;
   guint8 *pktdata;
   gint pktsize;
+  gsize offset;
 #ifdef G_OS_UNIX
   gint readsize;
 #elif defined G_OS_WIN32
@@ -498,6 +485,7 @@ no_select:
 
   pktdata = g_malloc (readsize);
   pktsize = readsize;
+  offset = 0;
 
   while (TRUE) {
     slen = sizeof (sa);
@@ -527,25 +515,26 @@ no_select:
       break;
   }
 
-  /* special case buffer so receivers can also track the address */
-  outbuf = gst_netbuffer_new ();
-  GST_BUFFER_MALLOCDATA (outbuf) = pktdata;
-
   /* patch pktdata and len when stripping off the headers */
   if (G_UNLIKELY (udpsrc->skip_first_bytes != 0)) {
     if (G_UNLIKELY (readsize < udpsrc->skip_first_bytes))
       goto skip_error;
 
-    pktdata += udpsrc->skip_first_bytes;
+    offset += udpsrc->skip_first_bytes;
     ret -= udpsrc->skip_first_bytes;
   }
-  GST_BUFFER_DATA (outbuf) = pktdata;
-  GST_BUFFER_SIZE (outbuf) = ret;
+
+  outbuf = gst_buffer_new ();
+  gst_buffer_take_memory (outbuf, -1,
+      gst_memory_new_wrapped (0, pktdata, g_free, pktsize, offset, ret));
+
+  /* use buffer metadata so receivers can also track the address */
+  meta = gst_buffer_add_meta_net_address (outbuf);
 
   switch (sa.sa.sa_family) {
     case AF_INET:
     {
-      gst_netaddress_set_ip4_address (&outbuf->from, sa.sa_in.sin_addr.s_addr,
+      gst_netaddress_set_ip4_address (&meta->naddr, sa.sa_in.sin_addr.s_addr,
           sa.sa_in.sin_port);
     }
       break;
@@ -554,7 +543,7 @@ no_select:
       guint8 ip6[16];
 
       memcpy (ip6, &sa.sa_in6.sin6_addr, sizeof (ip6));
-      gst_netaddress_set_ip6_address (&outbuf->from, ip6, sa.sa_in6.sin6_port);
+      gst_netaddress_set_ip6_address (&meta->naddr, ip6, sa.sa_in6.sin6_port);
     }
       break;
     default:
@@ -1023,13 +1012,13 @@ gst_udpsrc_stop (GstBaseSrc * bsrc)
 /*** GSTURIHANDLER INTERFACE *************************************************/
 
 static GstURIType
-gst_udpsrc_uri_get_type (void)
+gst_udpsrc_uri_get_type (GType type)
 {
   return GST_URI_SRC;
 }
 
 static gchar **
-gst_udpsrc_uri_get_protocols (void)
+gst_udpsrc_uri_get_protocols (GType type)
 {
   static gchar *protocols[] = { (char *) "udp", NULL };
 
index 5915d5a..5873b4c 100644 (file)
@@ -71,49 +71,23 @@ enum
 #define DEFAULT_PROP_GAMMA  1
 
 static GstStaticPadTemplate gst_gamma_src_template =
-    GST_STATIC_PAD_TEMPLATE ("src",
+GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";"
-        GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
-        GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";"
-        GST_VIDEO_CAPS_YUV ("Y444") ";"
-        GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";"
-        GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";"
-        GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";"
-        GST_VIDEO_CAPS_YUV ("Y42B") ";"
-        GST_VIDEO_CAPS_YUV ("NV12") ";"
-        GST_VIDEO_CAPS_YUV ("NV21") ";"
-        GST_VIDEO_CAPS_YUV ("YUY2") ";"
-        GST_VIDEO_CAPS_YUV ("UYVY") ";"
-        GST_VIDEO_CAPS_YUV ("YVYU") ";"
-        GST_VIDEO_CAPS_YUV ("I420") ";"
-        GST_VIDEO_CAPS_YUV ("YV12") ";"
-        GST_VIDEO_CAPS_YUV ("IYUV") ";" GST_VIDEO_CAPS_YUV ("Y41B")
-    )
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, "
+            "ARGB, BGRA, ABGR, RGBA, ABGR, RGBA, Y444, "
+            "xRGB, RGBx, xBGR, BGRx, RGB, BGR, Y42B, NV12, "
+            "NV21, YUY2, UYVY, YVYU, I420, YV12, IYUV, Y41B }"))
     );
 
 static GstStaticPadTemplate gst_gamma_sink_template =
-    GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";"
-        GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
-        GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";"
-        GST_VIDEO_CAPS_YUV ("Y444") ";"
-        GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";"
-        GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";"
-        GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";"
-        GST_VIDEO_CAPS_YUV ("Y42B") ";"
-        GST_VIDEO_CAPS_YUV ("NV12") ";"
-        GST_VIDEO_CAPS_YUV ("NV21") ";"
-        GST_VIDEO_CAPS_YUV ("YUY2") ";"
-        GST_VIDEO_CAPS_YUV ("UYVY") ";"
-        GST_VIDEO_CAPS_YUV ("YVYU") ";"
-        GST_VIDEO_CAPS_YUV ("I420") ";"
-        GST_VIDEO_CAPS_YUV ("YV12") ";"
-        GST_VIDEO_CAPS_YUV ("IYUV") ";" GST_VIDEO_CAPS_YUV ("Y41B")
-    )
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, "
+            "ARGB, BGRA, ABGR, RGBA, ABGR, RGBA, Y444, "
+            "xRGB, RGBx, xBGR, BGRx, RGB, BGR, Y42B, NV12, "
+            "NV21, YUY2, UYVY, YVYU, I420, YV12, IYUV, Y41B }"))
     );
 
 static void gst_gamma_set_property (GObject * object, guint prop_id,
@@ -130,28 +104,13 @@ static void gst_gamma_before_transform (GstBaseTransform * transform,
 
 static void gst_gamma_calculate_tables (GstGamma * gamma);
 
-GST_BOILERPLATE (GstGamma, gst_gamma, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
-
-static void
-gst_gamma_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "Video gamma correction",
-      "Filter/Effect/Video",
-      "Adjusts gamma on a video stream",
-      "Arwed v. Merkatz <v.merkatz@gmx.net>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_gamma_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_gamma_src_template));
-}
+G_DEFINE_TYPE (GstGamma, gst_gamma, GST_TYPE_VIDEO_FILTER);
 
 static void
 gst_gamma_class_init (GstGammaClass * g_class)
 {
   GObjectClass *gobject_class = (GObjectClass *) g_class;
+  GstElementClass *gstelement_class = (GstElementClass *) g_class;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) g_class;
 
   GST_DEBUG_CATEGORY_INIT (gamma_debug, "gamma", 0, "gamma");
@@ -164,6 +123,15 @@ gst_gamma_class_init (GstGammaClass * g_class)
           0.01, 10, DEFAULT_PROP_GAMMA,
           GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
 
+  gst_element_class_set_details_simple (gstelement_class,
+      "Video gamma correction", "Filter/Effect/Video",
+      "Adjusts gamma on a video stream", "Arwed v. Merkatz <v.merkatz@gmx.net");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_gamma_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_gamma_src_template));
+
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_gamma_set_caps);
   trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_gamma_transform_ip);
   trans_class->before_transform =
@@ -171,7 +139,7 @@ gst_gamma_class_init (GstGammaClass * g_class)
 }
 
 static void
-gst_gamma_init (GstGamma * gamma, GstGammaClass * g_class)
+gst_gamma_init (GstGamma * gamma)
 {
   /* properties */
   gamma->gamma = DEFAULT_PROP_GAMMA;
@@ -241,21 +209,18 @@ gst_gamma_calculate_tables (GstGamma * gamma)
 }
 
 static void
-gst_gamma_planar_yuv_ip (GstGamma * gamma, guint8 * data)
+gst_gamma_planar_yuv_ip (GstGamma * gamma, GstVideoFrame * frame)
 {
   gint i, j, height;
-  gint width, row_stride, row_wrap;
+  gint width, stride, row_wrap;
   const guint8 *table = gamma->gamma_table;
+  guint8 *data;
 
-  data =
-      data + gst_video_format_get_component_offset (gamma->format, 0,
-      gamma->width, gamma->height);
-
-  width = gst_video_format_get_component_width (gamma->format, 0, gamma->width);
-  height = gst_video_format_get_component_height (gamma->format, 0,
-      gamma->height);
-  row_stride = gst_video_format_get_row_stride (gamma->format, 0, gamma->width);
-  row_wrap = row_stride - width;
+  data = GST_VIDEO_FRAME_COMP_DATA (frame, 0);
+  stride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0);
+  width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0);
+  height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0);
+  row_wrap = stride - width;
 
   for (i = 0; i < height; i++) {
     for (j = 0; j < width; j++) {
@@ -267,22 +232,20 @@ gst_gamma_planar_yuv_ip (GstGamma * gamma, guint8 * data)
 }
 
 static void
-gst_gamma_packed_yuv_ip (GstGamma * gamma, guint8 * data)
+gst_gamma_packed_yuv_ip (GstGamma * gamma, GstVideoFrame * frame)
 {
   gint i, j, height;
-  gint width, row_stride, row_wrap;
+  gint width, stride, row_wrap;
   gint pixel_stride;
   const guint8 *table = gamma->gamma_table;
+  guint8 *data;
 
-  data = data + gst_video_format_get_component_offset (gamma->format, 0,
-      gamma->width, gamma->height);
-
-  width = gst_video_format_get_component_width (gamma->format, 0, gamma->width);
-  height = gst_video_format_get_component_height (gamma->format, 0,
-      gamma->height);
-  row_stride = gst_video_format_get_row_stride (gamma->format, 0, gamma->width);
-  pixel_stride = gst_video_format_get_pixel_stride (gamma->format, 0);
-  row_wrap = row_stride - pixel_stride * width;
+  data = GST_VIDEO_FRAME_COMP_DATA (frame, 0);
+  stride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0);
+  width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0);
+  height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0);
+  pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0);
+  row_wrap = stride - pixel_stride * width;
 
   for (i = 0; i < height; i++) {
     for (j = 0; j < width; j++) {
@@ -308,29 +271,28 @@ static const gint cog_rgb_to_ycbcr_matrix_8bit_sdtv[] = {
 #define APPLY_MATRIX(m,o,v1,v2,v3) ((m[o*4] * v1 + m[o*4+1] * v2 + m[o*4+2] * v3 + m[o*4+3]) >> 8)
 
 static void
-gst_gamma_packed_rgb_ip (GstGamma * gamma, guint8 * data)
+gst_gamma_packed_rgb_ip (GstGamma * gamma, GstVideoFrame * frame)
 {
   gint i, j, height;
-  gint width, row_stride, row_wrap;
+  gint width, stride, row_wrap;
   gint pixel_stride;
   const guint8 *table = gamma->gamma_table;
   gint offsets[3];
   gint r, g, b;
   gint y, u, v;
+  guint8 *data;
+
+  data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0);
+  width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0);
+  height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0);
 
-  offsets[0] = gst_video_format_get_component_offset (gamma->format, 0,
-      gamma->width, gamma->height);
-  offsets[1] = gst_video_format_get_component_offset (gamma->format, 1,
-      gamma->width, gamma->height);
-  offsets[2] = gst_video_format_get_component_offset (gamma->format, 2,
-      gamma->width, gamma->height);
+  offsets[0] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 0);
+  offsets[1] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 1);
+  offsets[2] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 2);
 
-  width = gst_video_format_get_component_width (gamma->format, 0, gamma->width);
-  height = gst_video_format_get_component_height (gamma->format, 0,
-      gamma->height);
-  row_stride = gst_video_format_get_row_stride (gamma->format, 0, gamma->width);
-  pixel_stride = gst_video_format_get_pixel_stride (gamma->format, 0);
-  row_wrap = row_stride - pixel_stride * width;
+  pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0);
+  row_wrap = stride - pixel_stride * width;
 
   for (i = 0; i < height; i++) {
     for (j = 0; j < width; j++) {
@@ -361,19 +323,18 @@ gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstGamma *gamma = GST_GAMMA (base);
+  GstVideoInfo info;
 
   GST_DEBUG_OBJECT (gamma,
       "setting caps: in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps,
       outcaps);
 
-  if (!gst_video_format_parse_caps (incaps, &gamma->format, &gamma->width,
-          &gamma->height))
+  if (!gst_video_info_from_caps (&info, incaps))
     goto invalid_caps;
 
-  gamma->size =
-      gst_video_format_get_size (gamma->format, gamma->width, gamma->height);
+  gamma->info = info;
 
-  switch (gamma->format) {
+  switch (GST_VIDEO_INFO_FORMAT (&info)) {
     case GST_VIDEO_FORMAT_I420:
     case GST_VIDEO_FORMAT_YV12:
     case GST_VIDEO_FORMAT_Y41B:
@@ -409,8 +370,10 @@ gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps,
   return TRUE;
 
 invalid_caps:
-  GST_ERROR_OBJECT (gamma, "Invalid caps: %" GST_PTR_FORMAT, incaps);
-  return FALSE;
+  {
+    GST_ERROR_OBJECT (gamma, "Invalid caps: %" GST_PTR_FORMAT, incaps);
+    return FALSE;
+  }
 }
 
 static void
@@ -434,8 +397,7 @@ static GstFlowReturn
 gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
 {
   GstGamma *gamma = GST_GAMMA (base);
-  guint8 *data;
-  guint size;
+  GstVideoFrame frame;
 
   if (!gamma->process)
     goto not_negotiated;
@@ -443,24 +405,23 @@ gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
   if (base->passthrough)
     goto done;
 
-  data = GST_BUFFER_DATA (outbuf);
-  size = GST_BUFFER_SIZE (outbuf);
-
-  if (size != gamma->size)
-    goto wrong_size;
+  if (!gst_video_frame_map (&frame, &gamma->info, outbuf, GST_MAP_READWRITE))
+    goto wrong_buffer;
 
   GST_OBJECT_LOCK (gamma);
-  gamma->process (gamma, data);
+  gamma->process (gamma, &frame);
   GST_OBJECT_UNLOCK (gamma);
 
+  gst_video_frame_unmap (&frame);
+
 done:
   return GST_FLOW_OK;
 
   /* ERRORS */
-wrong_size:
+wrong_buffer:
   {
     GST_ELEMENT_ERROR (gamma, STREAM, FORMAT,
-        (NULL), ("Invalid buffer size %d, expected %d", size, gamma->size));
+        (NULL), ("Invalid buffer received"));
     return GST_FLOW_ERROR;
   }
 not_negotiated:
index 85d2e27..b76dd97 100644 (file)
@@ -56,10 +56,7 @@ struct _GstGamma
   /* < private > */
 
   /* format */
-  GstVideoFormat format;
-  gint width;
-  gint height;
-  gint size;
+  GstVideoInfo info;
 
   /* properties */
   gdouble gamma;
@@ -67,7 +64,7 @@ struct _GstGamma
   /* tables */
   guint8 gamma_table[256];
 
-  void (*process) (GstGamma *gamma, guint8 *data);
+  void (*process) (GstGamma *gamma, GstVideoFrame *frame);
 };
 
 struct _GstGammaClass
index 184b893..0c3eeb6 100644 (file)
@@ -71,78 +71,37 @@ enum
 };
 
 static GstStaticPadTemplate gst_video_balance_src_template =
-    GST_STATIC_PAD_TEMPLATE ("src",
+GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";"
-        GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
-        GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";"
-        GST_VIDEO_CAPS_YUV ("Y444") ";"
-        GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";"
-        GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";"
-        GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";"
-        GST_VIDEO_CAPS_YUV ("Y42B") ";"
-        GST_VIDEO_CAPS_YUV ("YUY2") ";"
-        GST_VIDEO_CAPS_YUV ("UYVY") ";"
-        GST_VIDEO_CAPS_YUV ("YVYU") ";"
-        GST_VIDEO_CAPS_YUV ("I420") ";"
-        GST_VIDEO_CAPS_YUV ("YV12") ";"
-        GST_VIDEO_CAPS_YUV ("IYUV") ";" GST_VIDEO_CAPS_YUV ("Y41B")
-    )
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, "
+            "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, RGBx, "
+            "xBGR, BGRx, RGB, BGR, Y42B, YUY2, UYVY, YVYU, "
+            "I420, YV12, IYUV, Y41B }"))
     );
 
 static GstStaticPadTemplate gst_video_balance_sink_template =
-    GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";"
-        GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
-        GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";"
-        GST_VIDEO_CAPS_YUV ("Y444") ";"
-        GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";"
-        GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";"
-        GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";"
-        GST_VIDEO_CAPS_YUV ("Y42B") ";"
-        GST_VIDEO_CAPS_YUV ("YUY2") ";"
-        GST_VIDEO_CAPS_YUV ("UYVY") ";"
-        GST_VIDEO_CAPS_YUV ("YVYU") ";"
-        GST_VIDEO_CAPS_YUV ("I420") ";"
-        GST_VIDEO_CAPS_YUV ("YV12") ";"
-        GST_VIDEO_CAPS_YUV ("IYUV") ";" GST_VIDEO_CAPS_YUV ("Y41B")
-    )
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, "
+            "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, RGBx, "
+            "xBGR, BGRx, RGB, BGR, Y42B, YUY2, UYVY, YVYU, "
+            "I420, YV12, IYUV, Y41B }"))
     );
 
 static void gst_video_balance_colorbalance_init (GstColorBalanceClass * iface);
-static void gst_video_balance_interface_init (GstImplementsInterfaceClass *
-    klass);
 
 static void gst_video_balance_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
 static void gst_video_balance_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-static void
-_do_init (GType video_balance_type)
-{
-  static const GInterfaceInfo iface_info = {
-    (GInterfaceInitFunc) gst_video_balance_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo colorbalance_info = {
-    (GInterfaceInitFunc) gst_video_balance_colorbalance_init,
-    NULL,
-    NULL,
-  };
-
-  g_type_add_interface_static (video_balance_type,
-      GST_TYPE_IMPLEMENTS_INTERFACE, &iface_info);
-  g_type_add_interface_static (video_balance_type, GST_TYPE_COLOR_BALANCE,
-      &colorbalance_info);
-}
-
-GST_BOILERPLATE_FULL (GstVideoBalance, gst_video_balance, GstVideoFilter,
-    GST_TYPE_VIDEO_FILTER, _do_init);
+#define gst_video_balance_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstVideoBalance, gst_video_balance,
+    GST_TYPE_VIDEO_FILTER,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_COLOR_BALANCE,
+        gst_video_balance_colorbalance_init));
 
 /*
  * look-up tables (LUT).
@@ -207,26 +166,24 @@ gst_video_balance_update_properties (GstVideoBalance * videobalance)
 }
 
 static void
-gst_video_balance_planar_yuv (GstVideoBalance * videobalance, guint8 * data)
+gst_video_balance_planar_yuv (GstVideoBalance * videobalance,
+    GstVideoFrame * frame)
 {
   gint x, y;
   guint8 *ydata;
   guint8 *udata, *vdata;
   gint ystride, ustride, vstride;
-  GstVideoFormat format;
   gint width, height;
   gint width2, height2;
   guint8 *tabley = videobalance->tabley;
   guint8 **tableu = videobalance->tableu;
   guint8 **tablev = videobalance->tablev;
 
-  format = videobalance->format;
-  width = videobalance->width;
-  height = videobalance->height;
+  width = GST_VIDEO_FRAME_WIDTH (frame);
+  height = GST_VIDEO_FRAME_HEIGHT (frame);
 
-  ydata =
-      data + gst_video_format_get_component_offset (format, 0, width, height);
-  ystride = gst_video_format_get_row_stride (format, 0, width);
+  ydata = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  ystride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0);
 
   for (y = 0; y < height; y++) {
     guint8 *yptr;
@@ -238,15 +195,13 @@ gst_video_balance_planar_yuv (GstVideoBalance * videobalance, guint8 * data)
     }
   }
 
-  width2 = gst_video_format_get_component_width (format, 1, width);
-  height2 = gst_video_format_get_component_height (format, 1, height);
+  width2 = GST_VIDEO_FRAME_COMP_WIDTH (frame, 1);
+  height2 = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 1);
 
-  udata =
-      data + gst_video_format_get_component_offset (format, 1, width, height);
-  vdata =
-      data + gst_video_format_get_component_offset (format, 2, width, height);
-  ustride = gst_video_format_get_row_stride (format, 1, width);
-  vstride = gst_video_format_get_row_stride (format, 1, width);
+  udata = GST_VIDEO_FRAME_PLANE_DATA (frame, 1);
+  vdata = GST_VIDEO_FRAME_PLANE_DATA (frame, 2);
+  ustride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 1);
+  vstride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 2);
 
   for (y = 0; y < height2; y++) {
     guint8 *uptr, *vptr;
@@ -266,57 +221,49 @@ gst_video_balance_planar_yuv (GstVideoBalance * videobalance, guint8 * data)
 }
 
 static void
-gst_video_balance_packed_yuv (GstVideoBalance * videobalance, guint8 * data)
+gst_video_balance_packed_yuv (GstVideoBalance * videobalance,
+    GstVideoFrame * frame)
 {
-  gint x, y;
-  guint8 *ydata;
-  guint8 *udata, *vdata;
-  gint ystride, ustride, vstride;
+  gint x, y, stride;
+  guint8 *ydata, *udata, *vdata;
   gint yoff, uoff, voff;
-  GstVideoFormat format;
   gint width, height;
   gint width2, height2;
   guint8 *tabley = videobalance->tabley;
   guint8 **tableu = videobalance->tableu;
   guint8 **tablev = videobalance->tablev;
 
-  format = videobalance->format;
-  width = videobalance->width;
-  height = videobalance->height;
+  width = GST_VIDEO_FRAME_WIDTH (frame);
+  height = GST_VIDEO_FRAME_HEIGHT (frame);
 
-  ydata =
-      data + gst_video_format_get_component_offset (format, 0, width, height);
-  ystride = gst_video_format_get_row_stride (format, 0, width);
-  yoff = gst_video_format_get_pixel_stride (format, 0);
+  stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0);
+  ydata = GST_VIDEO_FRAME_COMP_DATA (frame, 0);
+  yoff = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0);
 
   for (y = 0; y < height; y++) {
     guint8 *yptr;
 
-    yptr = ydata + y * ystride;
+    yptr = ydata + y * stride;
     for (x = 0; x < width; x++) {
       *yptr = tabley[*yptr];
       yptr += yoff;
     }
   }
 
-  width2 = gst_video_format_get_component_width (format, 1, width);
-  height2 = gst_video_format_get_component_height (format, 1, height);
+  width2 = GST_VIDEO_FRAME_COMP_WIDTH (frame, 1);
+  height2 = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 1);
 
-  udata =
-      data + gst_video_format_get_component_offset (format, 1, width, height);
-  vdata =
-      data + gst_video_format_get_component_offset (format, 2, width, height);
-  ustride = gst_video_format_get_row_stride (format, 1, width);
-  vstride = gst_video_format_get_row_stride (format, 1, width);
-  uoff = gst_video_format_get_pixel_stride (format, 1);
-  voff = gst_video_format_get_pixel_stride (format, 2);
+  udata = GST_VIDEO_FRAME_COMP_DATA (frame, 1);
+  vdata = GST_VIDEO_FRAME_COMP_DATA (frame, 2);
+  uoff = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 1);
+  voff = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 2);
 
   for (y = 0; y < height2; y++) {
     guint8 *uptr, *vptr;
     guint8 u1, v1;
 
-    uptr = udata + y * ustride;
-    vptr = vdata + y * vstride;
+    uptr = udata + y * stride;
+    vptr = vdata + y * stride;
 
     for (x = 0; x < width2; x++) {
       u1 = *uptr;
@@ -346,11 +293,13 @@ static const gint cog_rgb_to_ycbcr_matrix_8bit_sdtv[] = {
 #define APPLY_MATRIX(m,o,v1,v2,v3) ((m[o*4] * v1 + m[o*4+1] * v2 + m[o*4+2] * v3 + m[o*4+3]) >> 8)
 
 static void
-gst_video_balance_packed_rgb (GstVideoBalance * videobalance, guint8 * data)
+gst_video_balance_packed_rgb (GstVideoBalance * videobalance,
+    GstVideoFrame * frame)
 {
   gint i, j, height;
-  gint width, row_stride, row_wrap;
+  gint width, stride, row_wrap;
   gint pixel_stride;
+  guint8 *data;
   gint offsets[3];
   gint r, g, b;
   gint y, u, v;
@@ -359,24 +308,18 @@ gst_video_balance_packed_rgb (GstVideoBalance * videobalance, guint8 * data)
   guint8 **tableu = videobalance->tableu;
   guint8 **tablev = videobalance->tablev;
 
-  offsets[0] = gst_video_format_get_component_offset (videobalance->format, 0,
-      videobalance->width, videobalance->height);
-  offsets[1] = gst_video_format_get_component_offset (videobalance->format, 1,
-      videobalance->width, videobalance->height);
-  offsets[2] = gst_video_format_get_component_offset (videobalance->format, 2,
-      videobalance->width, videobalance->height);
-
-  width =
-      gst_video_format_get_component_width (videobalance->format, 0,
-      videobalance->width);
-  height =
-      gst_video_format_get_component_height (videobalance->format, 0,
-      videobalance->height);
-  row_stride =
-      gst_video_format_get_row_stride (videobalance->format, 0,
-      videobalance->width);
-  pixel_stride = gst_video_format_get_pixel_stride (videobalance->format, 0);
-  row_wrap = row_stride - pixel_stride * width;
+  width = GST_VIDEO_FRAME_WIDTH (frame);
+  height = GST_VIDEO_FRAME_HEIGHT (frame);
+
+  offsets[0] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 0);
+  offsets[1] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 1);
+  offsets[2] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 2);
+
+  data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0);
+
+  pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0);
+  row_wrap = stride - pixel_stride * width;
 
   for (i = 0; i < height; i++) {
     for (j = 0; j < width; j++) {
@@ -415,21 +358,17 @@ gst_video_balance_set_caps (GstBaseTransform * base, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstVideoBalance *videobalance = GST_VIDEO_BALANCE (base);
+  GstVideoInfo info;
 
   GST_DEBUG_OBJECT (videobalance,
       "in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps, outcaps);
 
   videobalance->process = NULL;
 
-  if (!gst_video_format_parse_caps (incaps, &videobalance->format,
-          &videobalance->width, &videobalance->height))
+  if (!gst_video_info_from_caps (&info, incaps))
     goto invalid_caps;
 
-  videobalance->size =
-      gst_video_format_get_size (videobalance->format, videobalance->width,
-      videobalance->height);
-
-  switch (videobalance->format) {
+  switch (GST_VIDEO_INFO_FORMAT (&info)) {
     case GST_VIDEO_FORMAT_I420:
     case GST_VIDEO_FORMAT_YV12:
     case GST_VIDEO_FORMAT_Y41B:
@@ -456,14 +395,24 @@ gst_video_balance_set_caps (GstBaseTransform * base, GstCaps * incaps,
       videobalance->process = gst_video_balance_packed_rgb;
       break;
     default:
+      goto unknown_format;
       break;
   }
 
-  return videobalance->process != NULL;
+  videobalance->info = info;
+
+  return TRUE;
 
 invalid_caps:
-  GST_ERROR_OBJECT (videobalance, "Invalid caps: %" GST_PTR_FORMAT, incaps);
-  return FALSE;
+  {
+    GST_ERROR_OBJECT (videobalance, "Invalid caps: %" GST_PTR_FORMAT, incaps);
+    return FALSE;
+  }
+unknown_format:
+  {
+    GST_ERROR_OBJECT (videobalance, "unknown format %" GST_PTR_FORMAT, incaps);
+    return FALSE;
+  }
 }
 
 static void
@@ -487,8 +436,7 @@ static GstFlowReturn
 gst_video_balance_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
 {
   GstVideoBalance *videobalance = GST_VIDEO_BALANCE (base);
-  guint8 *data;
-  guint size;
+  GstVideoFrame frame;
 
   if (!videobalance->process)
     goto not_negotiated;
@@ -497,46 +445,31 @@ gst_video_balance_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
   if (base->passthrough)
     goto done;
 
-  data = GST_BUFFER_DATA (outbuf);
-  size = GST_BUFFER_SIZE (outbuf);
-
-  if (size != videobalance->size)
-    goto wrong_size;
+  if (!gst_video_frame_map (&frame, &videobalance->info, outbuf,
+          GST_MAP_READWRITE))
+    goto wrong_frame;
 
   GST_OBJECT_LOCK (videobalance);
-  videobalance->process (videobalance, data);
+  videobalance->process (videobalance, &frame);
   GST_OBJECT_UNLOCK (videobalance);
 
+  gst_video_frame_unmap (&frame);
+
 done:
   return GST_FLOW_OK;
 
   /* ERRORS */
-wrong_size:
+wrong_frame:
   {
     GST_ELEMENT_ERROR (videobalance, STREAM, FORMAT,
-        (NULL), ("Invalid buffer size %d, expected %d", size,
-            videobalance->size));
+        (NULL), ("Invalid buffer received"));
     return GST_FLOW_ERROR;
   }
 not_negotiated:
-  GST_ERROR_OBJECT (videobalance, "Not negotiated yet");
-  return GST_FLOW_NOT_NEGOTIATED;
-}
-
-static void
-gst_video_balance_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "Video balance",
-      "Filter/Effect/Video",
-      "Adjusts brightness, contrast, hue, saturation on a video stream",
-      "David Schleef <ds@schleef.org>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_video_balance_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_video_balance_src_template));
+  {
+    GST_ERROR_OBJECT (videobalance, "Not negotiated yet");
+    return GST_FLOW_NOT_NEGOTIATED;
+  }
 }
 
 static void
@@ -566,6 +499,7 @@ static void
 gst_video_balance_class_init (GstVideoBalanceClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
   GST_DEBUG_CATEGORY_INIT (videobalance_debug, "videobalance", 0,
@@ -591,6 +525,16 @@ gst_video_balance_class_init (GstVideoBalanceClass * klass)
           DEFAULT_PROP_SATURATION,
           GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "Video balance",
+      "Filter/Effect/Video",
+      "Adjusts brightness, contrast, hue, saturation on a video stream",
+      "David Schleef <ds@schleef.org>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_video_balance_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_video_balance_src_template));
+
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_balance_set_caps);
   trans_class->transform_ip =
       GST_DEBUG_FUNCPTR (gst_video_balance_transform_ip);
@@ -599,8 +543,7 @@ gst_video_balance_class_init (GstVideoBalanceClass * klass)
 }
 
 static void
-gst_video_balance_init (GstVideoBalance * videobalance,
-    GstVideoBalanceClass * klass)
+gst_video_balance_init (GstVideoBalance * videobalance)
 {
   const gchar *channels[4] = { "HUE", "SATURATION",
     "BRIGHTNESS", "CONTRAST"
@@ -637,20 +580,6 @@ gst_video_balance_init (GstVideoBalance * videobalance,
   }
 }
 
-static gboolean
-gst_video_balance_interface_supported (GstImplementsInterface * iface,
-    GType type)
-{
-  g_assert (type == GST_TYPE_COLOR_BALANCE);
-  return TRUE;
-}
-
-static void
-gst_video_balance_interface_init (GstImplementsInterfaceClass * klass)
-{
-  klass->supported = gst_video_balance_interface_supported;
-}
-
 static const GList *
 gst_video_balance_colorbalance_list_channels (GstColorBalance * balance)
 {
index c9484e3..1d3375a 100644 (file)
@@ -61,17 +61,14 @@ struct _GstVideoBalance {
   gdouble saturation;
 
   /* format */
-  GstVideoFormat format;
-  gint width;
-  gint height;
-  gint size;
+  GstVideoInfo info;
 
   /* tables */
   guint8 tabley[256];
   guint8 *tableu[256];
   guint8 *tablev[256];
 
-  void (*process) (GstVideoBalance *balance, guint8 *data);
+  void (*process) (GstVideoBalance *balance, GstVideoFrame *frame);
 };
 
 struct _GstVideoBalanceClass {
index 47ab784..7de5708 100644 (file)
@@ -65,40 +65,21 @@ GST_DEBUG_CATEGORY_STATIC (video_flip_debug);
 #define GST_CAT_DEFAULT video_flip_debug
 
 static GstStaticPadTemplate gst_video_flip_src_template =
-    GST_STATIC_PAD_TEMPLATE ("src",
+GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";"
-        GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
-        GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";"
-        GST_VIDEO_CAPS_YUV ("Y444") ";"
-        GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";"
-        GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";"
-        GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";"
-        GST_VIDEO_CAPS_YUV ("I420") ";"
-        GST_VIDEO_CAPS_YUV ("YV12") ";" GST_VIDEO_CAPS_YUV ("IYUV") ";"
-        GST_VIDEO_CAPS_YUV ("YUY2") ";" GST_VIDEO_CAPS_YUV ("UYVY") ";"
-        GST_VIDEO_CAPS_YUV ("YVYU")
-
-    )
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, "
+            "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, RGBx,xBGR, BGRx, "
+            "RGB, BGR, I420, YV12, IYUV, YUY2, UYVY, YVYU }"))
     );
 
 static GstStaticPadTemplate gst_video_flip_sink_template =
-    GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";"
-        GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
-        GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";"
-        GST_VIDEO_CAPS_YUV ("Y444") ";"
-        GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";"
-        GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";"
-        GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";"
-        GST_VIDEO_CAPS_YUV ("I420") ";"
-        GST_VIDEO_CAPS_YUV ("YV12") ";" GST_VIDEO_CAPS_YUV ("IYUV") ";"
-        GST_VIDEO_CAPS_YUV ("YUY2") ";" GST_VIDEO_CAPS_YUV ("UYVY") ";"
-        GST_VIDEO_CAPS_YUV ("YVYU")
-    )
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, "
+            "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, RGBx,xBGR, BGRx, "
+            "RGB, BGR, I420, YV12, IYUV, YUY2, UYVY, YVYU }"))
     );
 
 #define GST_TYPE_VIDEO_FLIP_METHOD (gst_video_flip_method_get_type())
@@ -130,12 +111,12 @@ gst_video_flip_method_get_type (void)
   return video_flip_method_type;
 }
 
-GST_BOILERPLATE (GstVideoFlip, gst_video_flip, GstVideoFilter,
-    GST_TYPE_VIDEO_FILTER);
+#define gst_video_flip_parent_class parent_class
+G_DEFINE_TYPE (GstVideoFlip, gst_video_flip, GST_TYPE_VIDEO_FILTER);
 
 static GstCaps *
 gst_video_flip_transform_caps (GstBaseTransform * trans,
-    GstPadDirection direction, GstCaps * caps)
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter)
 {
   GstVideoFlip *videoflip = GST_VIDEO_FLIP (trans);
   GstCaps *ret;
@@ -186,85 +167,80 @@ gst_video_flip_transform_caps (GstBaseTransform * trans,
   GST_DEBUG_OBJECT (videoflip, "transformed %" GST_PTR_FORMAT " to %"
       GST_PTR_FORMAT, caps, ret);
 
+  if (filter) {
+    GstCaps *intersection;
+
+    GST_DEBUG_OBJECT (videoflip, "Using filter caps %" GST_PTR_FORMAT, filter);
+    intersection =
+        gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (ret);
+    ret = intersection;
+    GST_DEBUG_OBJECT (videoflip, "Intersection %" GST_PTR_FORMAT, ret);
+  }
+
   return ret;
 }
 
 static gboolean
 gst_video_flip_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
-    guint * size)
+    gsize * size)
 {
-  GstVideoFormat format;
-  gint width, height;
+  GstVideoInfo info;
 
-  if (!gst_video_format_parse_caps (caps, &format, &width, &height))
+  if (!gst_video_info_from_caps (&info, caps))
     return FALSE;
 
-  *size = gst_video_format_get_size (format, width, height);
+  *size = info.size;
 
   GST_DEBUG_OBJECT (btrans, "our frame size is %d bytes (%dx%d)", *size,
-      width, height);
+      info.width, info.height);
 
   return TRUE;
 }
 
 static void
-gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
-    const guint8 * src)
+gst_video_flip_planar_yuv (GstVideoFlip * videoflip, GstVideoFrame * dest,
+    const GstVideoFrame * src)
 {
   gint x, y;
   guint8 const *s;
   guint8 *d;
-  GstVideoFormat format = videoflip->format;
-  gint sw = videoflip->from_width;
-  gint sh = videoflip->from_height;
-  gint dw = videoflip->to_width;
-  gint dh = videoflip->to_height;
   gint src_y_stride, src_u_stride, src_v_stride;
-  gint src_y_offset, src_u_offset, src_v_offset;
   gint src_y_height, src_u_height, src_v_height;
   gint src_y_width, src_u_width, src_v_width;
   gint dest_y_stride, dest_u_stride, dest_v_stride;
-  gint dest_y_offset, dest_u_offset, dest_v_offset;
   gint dest_y_height, dest_u_height, dest_v_height;
   gint dest_y_width, dest_u_width, dest_v_width;
 
-  src_y_stride = gst_video_format_get_row_stride (format, 0, sw);
-  src_u_stride = gst_video_format_get_row_stride (format, 1, sw);
-  src_v_stride = gst_video_format_get_row_stride (format, 2, sw);
-
-  dest_y_stride = gst_video_format_get_row_stride (format, 0, dw);
-  dest_u_stride = gst_video_format_get_row_stride (format, 1, dw);
-  dest_v_stride = gst_video_format_get_row_stride (format, 2, dw);
+  src_y_stride = GST_VIDEO_FRAME_PLANE_STRIDE (src, 0);
+  src_u_stride = GST_VIDEO_FRAME_PLANE_STRIDE (src, 1);
+  src_v_stride = GST_VIDEO_FRAME_PLANE_STRIDE (src, 2);
 
-  src_y_offset = gst_video_format_get_component_offset (format, 0, sw, sh);
-  src_u_offset = gst_video_format_get_component_offset (format, 1, sw, sh);
-  src_v_offset = gst_video_format_get_component_offset (format, 2, sw, sh);
+  dest_y_stride = GST_VIDEO_FRAME_PLANE_STRIDE (dest, 0);
+  dest_u_stride = GST_VIDEO_FRAME_PLANE_STRIDE (dest, 1);
+  dest_v_stride = GST_VIDEO_FRAME_PLANE_STRIDE (dest, 2);
 
-  dest_y_offset = gst_video_format_get_component_offset (format, 0, dw, dh);
-  dest_u_offset = gst_video_format_get_component_offset (format, 1, dw, dh);
-  dest_v_offset = gst_video_format_get_component_offset (format, 2, dw, dh);
+  src_y_width = GST_VIDEO_FRAME_COMP_WIDTH (src, 0);
+  src_u_width = GST_VIDEO_FRAME_COMP_WIDTH (src, 1);
+  src_v_width = GST_VIDEO_FRAME_COMP_WIDTH (src, 2);
 
-  src_y_width = gst_video_format_get_component_width (format, 0, sw);
-  src_u_width = gst_video_format_get_component_width (format, 1, sw);
-  src_v_width = gst_video_format_get_component_width (format, 2, sw);
+  dest_y_width = GST_VIDEO_FRAME_COMP_WIDTH (dest, 0);
+  dest_u_width = GST_VIDEO_FRAME_COMP_WIDTH (dest, 1);
+  dest_v_width = GST_VIDEO_FRAME_COMP_WIDTH (dest, 2);
 
-  dest_y_width = gst_video_format_get_component_width (format, 0, dw);
-  dest_u_width = gst_video_format_get_component_width (format, 1, dw);
-  dest_v_width = gst_video_format_get_component_width (format, 2, dw);
+  src_y_height = GST_VIDEO_FRAME_COMP_HEIGHT (src, 0);
+  src_u_height = GST_VIDEO_FRAME_COMP_HEIGHT (src, 1);
+  src_v_height = GST_VIDEO_FRAME_COMP_HEIGHT (src, 2);
 
-  src_y_height = gst_video_format_get_component_height (format, 0, sh);
-  src_u_height = gst_video_format_get_component_height (format, 1, sh);
-  src_v_height = gst_video_format_get_component_height (format, 2, sh);
-
-  dest_y_height = gst_video_format_get_component_height (format, 0, dh);
-  dest_u_height = gst_video_format_get_component_height (format, 1, dh);
-  dest_v_height = gst_video_format_get_component_height (format, 2, dh);
+  dest_y_height = GST_VIDEO_FRAME_COMP_HEIGHT (dest, 0);
+  dest_u_height = GST_VIDEO_FRAME_COMP_HEIGHT (dest, 1);
+  dest_v_height = GST_VIDEO_FRAME_COMP_HEIGHT (dest, 2);
 
   switch (videoflip->method) {
     case GST_VIDEO_FLIP_METHOD_90R:
       /* Flip Y */
-      s = src + src_y_offset;
-      d = dest + dest_y_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 0);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0);
       for (y = 0; y < dest_y_height; y++) {
         for (x = 0; x < dest_y_width; x++) {
           d[y * dest_y_stride + x] =
@@ -272,8 +248,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip U */
-      s = src + src_u_offset;
-      d = dest + dest_u_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 1);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1);
       for (y = 0; y < dest_u_height; y++) {
         for (x = 0; x < dest_u_width; x++) {
           d[y * dest_u_stride + x] =
@@ -281,8 +257,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip V */
-      s = src + src_v_offset;
-      d = dest + dest_v_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 2);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2);
       for (y = 0; y < dest_v_height; y++) {
         for (x = 0; x < dest_v_width; x++) {
           d[y * dest_v_stride + x] =
@@ -292,8 +268,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
       break;
     case GST_VIDEO_FLIP_METHOD_90L:
       /* Flip Y */
-      s = src + src_y_offset;
-      d = dest + dest_y_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 0);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0);
       for (y = 0; y < dest_y_height; y++) {
         for (x = 0; x < dest_y_width; x++) {
           d[y * dest_y_stride + x] =
@@ -301,8 +277,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip U */
-      s = src + src_u_offset;
-      d = dest + dest_u_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 1);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1);
       for (y = 0; y < dest_u_height; y++) {
         for (x = 0; x < dest_u_width; x++) {
           d[y * dest_u_stride + x] =
@@ -310,8 +286,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip V */
-      s = src + src_v_offset;
-      d = dest + dest_v_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 2);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2);
       for (y = 0; y < dest_v_height; y++) {
         for (x = 0; x < dest_v_width; x++) {
           d[y * dest_v_stride + x] =
@@ -321,8 +297,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
       break;
     case GST_VIDEO_FLIP_METHOD_180:
       /* Flip Y */
-      s = src + src_y_offset;
-      d = dest + dest_y_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 0);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0);
       for (y = 0; y < dest_y_height; y++) {
         for (x = 0; x < dest_y_width; x++) {
           d[y * dest_y_stride + x] =
@@ -330,8 +306,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip U */
-      s = src + src_u_offset;
-      d = dest + dest_u_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 1);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1);
       for (y = 0; y < dest_u_height; y++) {
         for (x = 0; x < dest_u_width; x++) {
           d[y * dest_u_stride + x] =
@@ -339,8 +315,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip V */
-      s = src + src_v_offset;
-      d = dest + dest_v_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 2);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2);
       for (y = 0; y < dest_v_height; y++) {
         for (x = 0; x < dest_v_width; x++) {
           d[y * dest_v_stride + x] =
@@ -350,8 +326,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
       break;
     case GST_VIDEO_FLIP_METHOD_HORIZ:
       /* Flip Y */
-      s = src + src_y_offset;
-      d = dest + dest_y_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 0);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0);
       for (y = 0; y < dest_y_height; y++) {
         for (x = 0; x < dest_y_width; x++) {
           d[y * dest_y_stride + x] =
@@ -359,8 +335,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip U */
-      s = src + src_u_offset;
-      d = dest + dest_u_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 1);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1);
       for (y = 0; y < dest_u_height; y++) {
         for (x = 0; x < dest_u_width; x++) {
           d[y * dest_u_stride + x] =
@@ -368,8 +344,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip V */
-      s = src + src_v_offset;
-      d = dest + dest_v_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 2);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2);
       for (y = 0; y < dest_v_height; y++) {
         for (x = 0; x < dest_v_width; x++) {
           d[y * dest_v_stride + x] =
@@ -379,8 +355,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
       break;
     case GST_VIDEO_FLIP_METHOD_VERT:
       /* Flip Y */
-      s = src + src_y_offset;
-      d = dest + dest_y_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 0);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0);
       for (y = 0; y < dest_y_height; y++) {
         for (x = 0; x < dest_y_width; x++) {
           d[y * dest_y_stride + x] =
@@ -388,8 +364,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip U */
-      s = src + src_u_offset;
-      d = dest + dest_u_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 1);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1);
       for (y = 0; y < dest_u_height; y++) {
         for (x = 0; x < dest_u_width; x++) {
           d[y * dest_u_stride + x] =
@@ -397,8 +373,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip V */
-      s = src + src_v_offset;
-      d = dest + dest_v_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 2);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2);
       for (y = 0; y < dest_v_height; y++) {
         for (x = 0; x < dest_v_width; x++) {
           d[y * dest_v_stride + x] =
@@ -408,24 +384,24 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
       break;
     case GST_VIDEO_FLIP_METHOD_TRANS:
       /* Flip Y */
-      s = src + src_y_offset;
-      d = dest + dest_y_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 0);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0);
       for (y = 0; y < dest_y_height; y++) {
         for (x = 0; x < dest_y_width; x++) {
           d[y * dest_y_stride + x] = s[x * src_y_stride + y];
         }
       }
       /* Flip U */
-      s = src + src_u_offset;
-      d = dest + dest_u_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 1);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1);
       for (y = 0; y < dest_u_height; y++) {
         for (x = 0; x < dest_u_width; x++) {
           d[y * dest_u_stride + x] = s[x * src_u_stride + y];
         }
       }
       /* Flip V */
-      s = src + src_v_offset;
-      d = dest + dest_v_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 2);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2);
       for (y = 0; y < dest_u_height; y++) {
         for (x = 0; x < dest_u_width; x++) {
           d[y * dest_v_stride + x] = s[x * src_v_stride + y];
@@ -434,8 +410,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
       break;
     case GST_VIDEO_FLIP_METHOD_OTHER:
       /* Flip Y */
-      s = src + src_y_offset;
-      d = dest + dest_y_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 0);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0);
       for (y = 0; y < dest_y_height; y++) {
         for (x = 0; x < dest_y_width; x++) {
           d[y * dest_y_stride + x] =
@@ -443,8 +419,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip U */
-      s = src + src_u_offset;
-      d = dest + dest_u_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 1);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1);
       for (y = 0; y < dest_u_height; y++) {
         for (x = 0; x < dest_u_width; x++) {
           d[y * dest_u_stride + x] =
@@ -452,8 +428,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
         }
       }
       /* Flip V */
-      s = src + src_v_offset;
-      d = dest + dest_v_offset;
+      s = GST_VIDEO_FRAME_PLANE_DATA (src, 2);
+      d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2);
       for (y = 0; y < dest_v_height; y++) {
         for (x = 0; x < dest_v_width; x++) {
           d[y * dest_v_stride + x] =
@@ -471,24 +447,26 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest,
 }
 
 static void
-gst_video_flip_packed_simple (GstVideoFlip * videoflip, guint8 * dest,
-    const guint8 * src)
+gst_video_flip_packed_simple (GstVideoFlip * videoflip, GstVideoFrame * dest,
+    const GstVideoFrame * src)
 {
   gint x, y, z;
-  guint8 const *s = src;
-  guint8 *d = dest;
-  GstVideoFormat format = videoflip->format;
-  gint sw = videoflip->from_width;
-  gint sh = videoflip->from_height;
-  gint dw = videoflip->to_width;
-  gint dh = videoflip->to_height;
+  guint8 const *s;
+  guint8 *d;
+  gint sw = GST_VIDEO_FRAME_WIDTH (src);
+  gint sh = GST_VIDEO_FRAME_HEIGHT (src);
+  gint dw = GST_VIDEO_FRAME_WIDTH (dest);
+  gint dh = GST_VIDEO_FRAME_HEIGHT (dest);
   gint src_stride, dest_stride;
   gint bpp;
 
-  src_stride = gst_video_format_get_row_stride (format, 0, sw);
-  dest_stride = gst_video_format_get_row_stride (format, 0, dw);
+  s = GST_VIDEO_FRAME_PLANE_DATA (src, 0);
+  d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0);
+
+  src_stride = GST_VIDEO_FRAME_PLANE_STRIDE (src, 0);
+  dest_stride = GST_VIDEO_FRAME_PLANE_STRIDE (dest, 0);
   /* This is only true for non-subsampled formats! */
-  bpp = gst_video_format_get_pixel_stride (format, 0);
+  bpp = GST_VIDEO_FRAME_COMP_PSTRIDE (src, 0);
 
   switch (videoflip->method) {
     case GST_VIDEO_FLIP_METHOD_90R:
@@ -571,17 +549,16 @@ gst_video_flip_packed_simple (GstVideoFlip * videoflip, guint8 * dest,
 
 
 static void
-gst_video_flip_y422 (GstVideoFlip * videoflip, guint8 * dest,
-    const guint8 * src)
+gst_video_flip_y422 (GstVideoFlip * videoflip, GstVideoFrame * dest,
+    const GstVideoFrame * src)
 {
   gint x, y;
-  guint8 const *s = src;
-  guint8 *d = dest;
-  GstVideoFormat format = videoflip->format;
-  gint sw = videoflip->from_width;
-  gint sh = videoflip->from_height;
-  gint dw = videoflip->to_width;
-  gint dh = videoflip->to_height;
+  guint8 const *s;
+  guint8 *d;
+  gint sw = GST_VIDEO_FRAME_WIDTH (src);
+  gint sh = GST_VIDEO_FRAME_HEIGHT (src);
+  gint dw = GST_VIDEO_FRAME_WIDTH (dest);
+  gint dh = GST_VIDEO_FRAME_HEIGHT (dest);
   gint src_stride, dest_stride;
   gint bpp;
   gint y_offset;
@@ -589,13 +566,16 @@ gst_video_flip_y422 (GstVideoFlip * videoflip, guint8 * dest,
   gint v_offset;
   gint y_stride;
 
-  src_stride = gst_video_format_get_row_stride (format, 0, sw);
-  dest_stride = gst_video_format_get_row_stride (format, 0, dw);
+  s = GST_VIDEO_FRAME_PLANE_DATA (src, 0);
+  d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0);
 
-  y_offset = gst_video_format_get_component_offset (format, 0, sw, sh);
-  u_offset = gst_video_format_get_component_offset (format, 1, sw, sh);
-  v_offset = gst_video_format_get_component_offset (format, 2, sw, sh);
-  y_stride = gst_video_format_get_pixel_stride (format, 0);
+  src_stride = GST_VIDEO_FRAME_PLANE_STRIDE (src, 0);
+  dest_stride = GST_VIDEO_FRAME_PLANE_STRIDE (dest, 0);
+
+  y_offset = GST_VIDEO_FRAME_COMP_OFFSET (src, 0);
+  u_offset = GST_VIDEO_FRAME_COMP_OFFSET (src, 1);
+  v_offset = GST_VIDEO_FRAME_COMP_OFFSET (src, 2);
+  y_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (src, 0);
   bpp = y_stride;
 
   switch (videoflip->method) {
@@ -789,20 +769,17 @@ gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     GstCaps * outcaps)
 {
   GstVideoFlip *vf = GST_VIDEO_FLIP (btrans);
-  GstVideoFormat in_format, out_format;
+  GstVideoInfo in_info, out_info;
   gboolean ret = FALSE;
 
   vf->process = NULL;
 
-  if (!gst_video_format_parse_caps (incaps, &in_format, &vf->from_width,
-          &vf->from_height)
-      || !gst_video_format_parse_caps (outcaps, &out_format, &vf->to_width,
-          &vf->to_height))
+  if (!gst_video_info_from_caps (&in_info, incaps)
+      || !gst_video_info_from_caps (&out_info, outcaps))
     goto invalid_caps;
 
-  if (in_format != out_format)
+  if (GST_VIDEO_INFO_FORMAT (&in_info) != GST_VIDEO_INFO_FORMAT (&out_info))
     goto invalid_caps;
-  vf->format = in_format;
 
   /* Check that they are correct */
   switch (vf->method) {
@@ -810,11 +787,11 @@ gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     case GST_VIDEO_FLIP_METHOD_90L:
     case GST_VIDEO_FLIP_METHOD_TRANS:
     case GST_VIDEO_FLIP_METHOD_OTHER:
-      if ((vf->from_width != vf->to_height) ||
-          (vf->from_height != vf->to_width)) {
+      if ((in_info.width != out_info.height) ||
+          (in_info.height != out_info.width)) {
         GST_ERROR_OBJECT (vf, "we are inverting width and height but caps "
-            "are not correct : %dx%d to %dx%d", vf->from_width,
-            vf->from_height, vf->to_width, vf->to_height);
+            "are not correct : %dx%d to %dx%d", in_info.width,
+            in_info.height, out_info.width, out_info.height);
         goto beach;
       }
       break;
@@ -824,11 +801,11 @@ gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
     case GST_VIDEO_FLIP_METHOD_180:
     case GST_VIDEO_FLIP_METHOD_HORIZ:
     case GST_VIDEO_FLIP_METHOD_VERT:
-      if ((vf->from_width != vf->to_width) ||
-          (vf->from_height != vf->to_height)) {
+      if ((in_info.width != out_info.width) ||
+          (in_info.height != out_info.height)) {
         GST_ERROR_OBJECT (vf, "we are keeping width and height but caps "
-            "are not correct : %dx%d to %dx%d", vf->from_width,
-            vf->from_height, vf->to_width, vf->to_height);
+            "are not correct : %dx%d to %dx%d", in_info.width,
+            in_info.height, out_info.width, out_info.height);
         goto beach;
       }
       break;
@@ -838,8 +815,10 @@ gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
   }
 
   ret = TRUE;
+  vf->in_info = in_info;
+  vf->out_info = out_info;
 
-  switch (vf->format) {
+  switch (GST_VIDEO_INFO_FORMAT (&in_info)) {
     case GST_VIDEO_FORMAT_I420:
     case GST_VIDEO_FORMAT_YV12:
     case GST_VIDEO_FORMAT_Y444:
@@ -898,28 +877,48 @@ gst_video_flip_transform (GstBaseTransform * trans, GstBuffer * in,
     GstBuffer * out)
 {
   GstVideoFlip *videoflip = GST_VIDEO_FLIP (trans);
-  guint8 *dest;
-  const guint8 *src;
+  GstVideoFrame dest;
+  GstVideoFrame src;
 
   if (G_UNLIKELY (videoflip->process == NULL))
     goto not_negotiated;
 
-  src = GST_BUFFER_DATA (in);
-  dest = GST_BUFFER_DATA (out);
+  if (!gst_video_frame_map (&src, &videoflip->in_info, in, GST_MAP_READ))
+    goto invalid_in;
+
+  if (!gst_video_frame_map (&dest, &videoflip->out_info, out, GST_MAP_WRITE))
+    goto invalid_out;
 
   GST_LOG_OBJECT (videoflip, "videoflip: flipping %dx%d to %dx%d (%s)",
-      videoflip->from_width, videoflip->from_height, videoflip->to_width,
-      videoflip->to_height, video_flip_methods[videoflip->method].value_nick);
+      videoflip->in_info.width, videoflip->in_info.height,
+      videoflip->out_info.width, videoflip->out_info.height,
+      video_flip_methods[videoflip->method].value_nick);
 
   GST_OBJECT_LOCK (videoflip);
-  videoflip->process (videoflip, dest, src);
+  videoflip->process (videoflip, &dest, &src);
   GST_OBJECT_UNLOCK (videoflip);
 
+  gst_video_frame_unmap (&src);
+  gst_video_frame_unmap (&dest);
+
   return GST_FLOW_OK;
 
 not_negotiated:
-  GST_ERROR_OBJECT (videoflip, "Not negotiated yet");
-  return GST_FLOW_NOT_NEGOTIATED;
+  {
+    GST_ERROR_OBJECT (videoflip, "Not negotiated yet");
+    return GST_FLOW_NOT_NEGOTIATED;
+  }
+invalid_in:
+  {
+    GST_ERROR_OBJECT (videoflip, "invalid input frame");
+    return GST_FLOW_OK;
+  }
+invalid_out:
+  {
+    GST_ERROR_OBJECT (videoflip, "invalid output frame");
+    gst_video_frame_unmap (&src);
+    return GST_FLOW_OK;
+  }
 }
 
 static gboolean
@@ -944,31 +943,31 @@ gst_video_flip_src_event (GstBaseTransform * trans, GstEvent * event)
         switch (vf->method) {
           case GST_VIDEO_FLIP_METHOD_90R:
             new_x = y;
-            new_y = vf->to_width - x;
+            new_y = vf->out_info.width - x;
             break;
           case GST_VIDEO_FLIP_METHOD_90L:
-            new_x = vf->to_height - y;
+            new_x = vf->out_info.height - y;
             new_y = x;
             break;
           case GST_VIDEO_FLIP_METHOD_OTHER:
-            new_x = vf->to_height - y;
-            new_y = vf->to_width - x;
+            new_x = vf->out_info.height - y;
+            new_y = vf->out_info.width - x;
             break;
           case GST_VIDEO_FLIP_METHOD_TRANS:
             new_x = y;
             new_y = x;
             break;
           case GST_VIDEO_FLIP_METHOD_180:
-            new_x = vf->to_width - x;
-            new_y = vf->to_height - y;
+            new_x = vf->out_info.width - x;
+            new_y = vf->out_info.height - y;
             break;
           case GST_VIDEO_FLIP_METHOD_HORIZ:
-            new_x = vf->to_width - x;
+            new_x = vf->out_info.width - x;
             new_y = y;
             break;
           case GST_VIDEO_FLIP_METHOD_VERT:
             new_x = x;
-            new_y = vf->to_height - y;
+            new_y = vf->out_info.height - y;
             break;
           default:
             new_x = x;
@@ -1043,24 +1042,10 @@ gst_video_flip_get_property (GObject * object, guint prop_id, GValue * value,
 }
 
 static void
-gst_video_flip_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "Video flipper",
-      "Filter/Effect/Video",
-      "Flips and rotates video", "David Schleef <ds@schleef.org>");
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_video_flip_sink_template));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&gst_video_flip_src_template));
-}
-
-static void
 gst_video_flip_class_init (GstVideoFlipClass * klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
 
   GST_DEBUG_CATEGORY_INIT (video_flip_debug, "videoflip", 0, "videoflip");
@@ -1073,6 +1058,15 @@ gst_video_flip_class_init (GstVideoFlipClass * klass)
           GST_TYPE_VIDEO_FLIP_METHOD, PROP_METHOD_DEFAULT,
           GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (gstelement_class, "Video flipper",
+      "Filter/Effect/Video",
+      "Flips and rotates video", "David Schleef <ds@schleef.org>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_video_flip_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_video_flip_src_template));
+
   trans_class->transform_caps =
       GST_DEBUG_FUNCPTR (gst_video_flip_transform_caps);
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_flip_set_caps);
@@ -1084,7 +1078,7 @@ gst_video_flip_class_init (GstVideoFlipClass * klass)
 }
 
 static void
-gst_video_flip_init (GstVideoFlip * videoflip, GstVideoFlipClass * klass)
+gst_video_flip_init (GstVideoFlip * videoflip)
 {
   videoflip->method = PROP_METHOD_DEFAULT;
   gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (videoflip), TRUE);
index a998fa7..d520b03 100644 (file)
@@ -73,12 +73,11 @@ struct _GstVideoFlip {
   GstVideoFilter videofilter;
   
   /* < private > */
-  GstVideoFormat format;
-  gint from_width, from_height;
-  gint to_width, to_height;
+  GstVideoInfo in_info;
+  GstVideoInfo out_info;
   
   GstVideoFlipMethod method;
-  void (*process) (GstVideoFlip *videoflip, guint8 *dest, const guint8 *src);
+  void (*process) (GstVideoFlip *videoflip, GstVideoFrame *dest, const GstVideoFrame *src);
 };
 
 struct _GstVideoFlipClass {
index 8ac21d3..df8dd51 100644 (file)
@@ -1198,7 +1198,7 @@ gst_collect_pads2_set_waiting (GstCollectPads2 * pads, GstCollectData2 * data,
   /* Do something only on a change and if not locked */
   if (!GST_COLLECT_PADS2_STATE_IS_SET (data, GST_COLLECT_PADS2_STATE_LOCKED) &&
       (GST_COLLECT_PADS2_STATE_IS_SET (data, GST_COLLECT_PADS2_STATE_WAITING) !=
-          ! !waiting)) {
+          !!waiting)) {
     /* Set waiting state for this pad */
     if (waiting)
       GST_COLLECT_PADS2_STATE_SET (data, GST_COLLECT_PADS2_STATE_WAITING);
index bd45380..0608e06 100644 (file)
@@ -134,7 +134,8 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
     GST_STATIC_CAPS ("audio/x-wav")
     );
 
-GST_BOILERPLATE (GstWavEnc, gst_wavenc, GstElement, GST_TYPE_ELEMENT);
+#define gst_wavenc_parent_class parent_class
+G_DEFINE_TYPE (GstWavEnc, gst_wavenc, GST_TYPE_ELEMENT);
 
 static GstFlowReturn gst_wavenc_chain (GstPad * pad, GstBuffer * buf);
 static gboolean gst_wavenc_event (GstPad * pad, GstEvent * event);
@@ -143,9 +144,13 @@ static GstStateChangeReturn gst_wavenc_change_state (GstElement * element,
 static gboolean gst_wavenc_sink_setcaps (GstPad * pad, GstCaps * caps);
 
 static void
-gst_wavenc_base_init (gpointer g_class)
+gst_wavenc_class_init (GstWavEncClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  GstElementClass *element_class;
+
+  element_class = (GstElementClass *) klass;
+
+  element_class->change_state = GST_DEBUG_FUNCPTR (gst_wavenc_change_state);
 
   gst_element_class_set_details_simple (element_class, "WAV audio muxer",
       "Codec/Muxer/Audio",
@@ -160,25 +165,13 @@ gst_wavenc_base_init (gpointer g_class)
 }
 
 static void
-gst_wavenc_class_init (GstWavEncClass * klass)
-{
-  GstElementClass *element_class;
-
-  element_class = (GstElementClass *) klass;
-
-  element_class->change_state = GST_DEBUG_FUNCPTR (gst_wavenc_change_state);
-}
-
-static void
-gst_wavenc_init (GstWavEnc * wavenc, GstWavEncClass * klass)
+gst_wavenc_init (GstWavEnc * wavenc)
 {
   wavenc->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
   gst_pad_set_chain_function (wavenc->sinkpad,
       GST_DEBUG_FUNCPTR (gst_wavenc_chain));
   gst_pad_set_event_function (wavenc->sinkpad,
       GST_DEBUG_FUNCPTR (gst_wavenc_event));
-  gst_pad_set_setcaps_function (wavenc->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_wavenc_sink_setcaps));
   gst_pad_use_fixed_caps (wavenc->sinkpad);
   gst_element_add_pad (GST_ELEMENT (wavenc), wavenc->sinkpad);
 
@@ -199,7 +192,7 @@ gst_wavenc_create_header_buf (GstWavEnc * wavenc, guint audio_data_size)
   guint8 *header;
 
   buf = gst_buffer_new_and_alloc (WAV_HEADER_LEN);
-  header = GST_BUFFER_DATA (buf);
+  header = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
   memset (header, 0, WAV_HEADER_LEN);
 
   wave.common.wChannels = wavenc->channels;
@@ -236,7 +229,7 @@ gst_wavenc_create_header_buf (GstWavEnc * wavenc, guint audio_data_size)
   memcpy (header + 36, (char *) wave.data.id, 4);
   GST_WRITE_UINT32_LE (header + 40, wave.data.len);
 
-  gst_buffer_set_caps (buf, GST_PAD_CAPS (wavenc->srcpad));
+  gst_buffer_unmap (buf, header, -1);
 
   return buf;
 }
@@ -246,10 +239,11 @@ gst_wavenc_push_header (GstWavEnc * wavenc, guint audio_data_size)
 {
   GstFlowReturn ret;
   GstBuffer *outbuf;
+  GstSegment segment;
 
   /* seek to beginning of file */
-  gst_pad_push_event (wavenc->srcpad,
-      gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
+  gst_segment_init (&segment, GST_FORMAT_BYTES);
+  gst_pad_push_event (wavenc->srcpad, gst_event_new_segment (&segment));
 
   GST_DEBUG_OBJECT (wavenc, "writing header with datasize=%u", audio_data_size);
 
@@ -273,13 +267,18 @@ gst_wavenc_sink_setcaps (GstPad * pad, GstCaps * caps)
   GstStructure *structure;
   const gchar *name;
   gint chans, rate, width;
+  GstCaps *ccaps;
 
   wavenc = GST_WAVENC (gst_pad_get_parent (pad));
 
-  if (wavenc->sent_header && !gst_caps_can_intersect (caps, GST_PAD_CAPS (pad))) {
+  ccaps = gst_pad_get_current_caps (pad);
+  if (wavenc->sent_header && ccaps && !gst_caps_can_intersect (caps, ccaps)) {
+    gst_caps_unref (ccaps);
     GST_WARNING_OBJECT (wavenc, "cannot change format in middle of stream");
     goto fail;
   }
+  if (ccaps)
+    gst_caps_unref (ccaps);
 
   GST_DEBUG_OBJECT (wavenc, "got caps: %" GST_PTR_FORMAT, caps);
 
@@ -621,6 +620,17 @@ gst_wavenc_event (GstPad * pad, GstEvent * event)
   wavenc = GST_WAVENC (gst_pad_get_parent (pad));
 
   switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+
+      gst_event_parse_caps (event, &caps);
+      gst_wavenc_sink_setcaps (pad, caps);
+
+      /* have our own src caps */
+      gst_event_unref (event);
+      break;
+    }
     case GST_EVENT_EOS:{
       GST_DEBUG_OBJECT (wavenc, "got EOS");
 #if 0
@@ -641,7 +651,7 @@ gst_wavenc_event (GstPad * pad, GstEvent * event)
       res = gst_pad_event_default (pad, event);
       break;
     }
-    case GST_EVENT_NEWSEGMENT:
+    case GST_EVENT_SEGMENT:
       /* Just drop it, it's probably in TIME format
        * anyway. We'll send our own newsegment event */
       gst_event_unref (event);
@@ -679,15 +689,14 @@ gst_wavenc_chain (GstPad * pad, GstBuffer * buf)
   }
 
   GST_LOG_OBJECT (wavenc, "pushing %u bytes raw audio, ts=%" GST_TIME_FORMAT,
-      GST_BUFFER_SIZE (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
+      gst_buffer_get_size (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
 
-  buf = gst_buffer_make_metadata_writable (buf);
+  buf = gst_buffer_make_writable (buf);
 
-  gst_buffer_set_caps (buf, GST_PAD_CAPS (wavenc->srcpad));
   GST_BUFFER_OFFSET (buf) = WAV_HEADER_LEN + wavenc->length;
   GST_BUFFER_OFFSET_END (buf) = GST_BUFFER_OFFSET_NONE;
 
-  wavenc->length += GST_BUFFER_SIZE (buf);
+  wavenc->length += gst_buffer_get_size (buf);
 
   flow = gst_pad_push (wavenc->srcpad, buf);
 
@@ -715,7 +724,7 @@ gst_wavenc_change_state (GstElement * element, GstStateChange transition)
       break;
   }
 
-  ret = parent_class->change_state (element, transition);
+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
   if (ret != GST_STATE_CHANGE_SUCCESS)
     return ret;
 
index 5f8a789..3377eae 100644 (file)
@@ -83,44 +83,25 @@ static void gst_wavparse_loop (GstPad * pad);
 static gboolean gst_wavparse_srcpad_event (GstPad * pad, GstEvent * event);
 
 static GstStaticPadTemplate sink_template_factory =
-GST_STATIC_PAD_TEMPLATE ("wavparse_sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS ("audio/x-wav")
     );
 
-#define DEBUG_INIT(bla) \
+#define DEBUG_INIT \
   GST_DEBUG_CATEGORY_INIT (wavparse_debug, "wavparse", 0, "WAV parser");
 
-GST_BOILERPLATE_FULL (GstWavParse, gst_wavparse, GstElement,
-    GST_TYPE_ELEMENT, DEBUG_INIT);
-
-static void
-gst_wavparse_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-  GstPadTemplate *src_template;
-
-  /* register pads */
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_template_factory));
-
-  src_template = gst_pad_template_new ("wavparse_src", GST_PAD_SRC,
-      GST_PAD_SOMETIMES, gst_riff_create_audio_template_caps ());
-  gst_element_class_add_pad_template (element_class, src_template);
-  gst_object_unref (src_template);
-
-  gst_element_class_set_details_simple (element_class, "WAV audio demuxer",
-      "Codec/Demuxer/Audio",
-      "Parse a .wav file into raw audio",
-      "Erik Walthinsen <omega@cse.ogi.edu>");
-}
+#define gst_wavparse_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstWavParse, gst_wavparse, GST_TYPE_ELEMENT,
+    DEBUG_INIT);
 
 static void
 gst_wavparse_class_init (GstWavParseClass * klass)
 {
   GstElementClass *gstelement_class;
   GObjectClass *object_class;
+  GstPadTemplate *src_template;
 
   gstelement_class = (GstElementClass *) klass;
   object_class = (GObjectClass *) klass;
@@ -131,6 +112,19 @@ gst_wavparse_class_init (GstWavParseClass * klass)
 
   gstelement_class->change_state = gst_wavparse_change_state;
   gstelement_class->send_event = gst_wavparse_send_event;
+
+  /* register pads */
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_template_factory));
+
+  src_template = gst_pad_template_new ("src", GST_PAD_SRC,
+      GST_PAD_ALWAYS, gst_riff_create_audio_template_caps ());
+  gst_element_class_add_pad_template (gstelement_class, src_template);
+
+  gst_element_class_set_details_simple (gstelement_class, "WAV audio demuxer",
+      "Codec/Demuxer/Audio",
+      "Parse a .wav file into raw audio",
+      "Erik Walthinsen <omega@cse.ogi.edu>");
 }
 
 static void
@@ -172,9 +166,6 @@ gst_wavparse_reset (GstWavParse * wav)
   if (wav->start_segment)
     gst_event_unref (wav->start_segment);
   wav->start_segment = NULL;
-  if (wav->close_segment)
-    gst_event_unref (wav->close_segment);
-  wav->close_segment = NULL;
 }
 
 static void
@@ -189,7 +180,7 @@ gst_wavparse_dispose (GObject * object)
 }
 
 static void
-gst_wavparse_init (GstWavParse * wavparse, GstWavParseClass * g_class)
+gst_wavparse_init (GstWavParse * wavparse)
 {
   gst_wavparse_reset (wavparse);
 
@@ -206,8 +197,18 @@ gst_wavparse_init (GstWavParse * wavparse, GstWavParseClass * g_class)
       GST_DEBUG_FUNCPTR (gst_wavparse_sink_event));
   gst_element_add_pad (GST_ELEMENT_CAST (wavparse), wavparse->sinkpad);
 
-  /* src, will be created later */
-  wavparse->srcpad = NULL;
+  /* src */
+  wavparse->srcpad =
+      gst_pad_new_from_template (gst_element_class_get_pad_template
+      (GST_ELEMENT_GET_CLASS (wavparse), "src"), "src");
+  gst_pad_use_fixed_caps (wavparse->srcpad);
+  gst_pad_set_query_type_function (wavparse->srcpad,
+      GST_DEBUG_FUNCPTR (gst_wavparse_get_query_types));
+  gst_pad_set_query_function (wavparse->srcpad,
+      GST_DEBUG_FUNCPTR (gst_wavparse_pad_query));
+  gst_pad_set_event_function (wavparse->srcpad,
+      GST_DEBUG_FUNCPTR (gst_wavparse_srcpad_event));
+  gst_element_add_pad (GST_ELEMENT_CAST (wavparse), wavparse->srcpad);
 }
 
 static void
@@ -219,29 +220,6 @@ gst_wavparse_destroy_sourcepad (GstWavParse * wavparse)
   }
 }
 
-static void
-gst_wavparse_create_sourcepad (GstWavParse * wavparse)
-{
-  GstElementClass *klass = GST_ELEMENT_GET_CLASS (wavparse);
-  GstPadTemplate *src_template;
-
-  /* destroy previous one */
-  gst_wavparse_destroy_sourcepad (wavparse);
-
-  /* source */
-  src_template = gst_element_class_get_pad_template (klass, "wavparse_src");
-  wavparse->srcpad = gst_pad_new_from_template (src_template, "src");
-  gst_pad_use_fixed_caps (wavparse->srcpad);
-  gst_pad_set_query_type_function (wavparse->srcpad,
-      GST_DEBUG_FUNCPTR (gst_wavparse_get_query_types));
-  gst_pad_set_query_function (wavparse->srcpad,
-      GST_DEBUG_FUNCPTR (gst_wavparse_pad_query));
-  gst_pad_set_event_function (wavparse->srcpad,
-      GST_DEBUG_FUNCPTR (gst_wavparse_srcpad_event));
-
-  GST_DEBUG_OBJECT (wavparse, "srcpad created");
-}
-
 /* Compute (value * nom) % denom, avoiding overflow.  This can be used
  * to perform ceiling or rounding division together with
  * gst_util_uint64_scale[_int]. */
@@ -804,11 +782,11 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
       if (cur_type != GST_SEEK_TYPE_NONE)
         res =
             gst_pad_query_convert (wav->srcpad, format, cur,
-            &wav->segment.format, &cur);
+            wav->segment.format, &cur);
       if (res && stop_type != GST_SEEK_TYPE_NONE)
         res =
             gst_pad_query_convert (wav->srcpad, format, stop,
-            &wav->segment.format, &stop);
+            wav->segment.format, &stop);
       if (!res)
         goto no_format;
 
@@ -830,10 +808,11 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
     if (!event || wav->state != GST_WAVPARSE_DATA) {
       if (wav->start_segment)
         gst_event_unref (wav->start_segment);
-      wav->start_segment =
+      // TODO
+/*      wav->start_segment =
           gst_event_new_new_segment (FALSE, wav->segment.rate,
           wav->segment.format, wav->segment.last_stop, wav->segment.duration,
-          wav->segment.last_stop);
+          wav->segment.last_stop);*/
       res = TRUE;
     } else {
       /* convert seek positions to byte positions in data sections */
@@ -887,7 +866,7 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
   GST_PAD_STREAM_LOCK (wav->sinkpad);
 
   /* save current position */
-  last_stop = wav->segment.last_stop;
+  last_stop = wav->segment.position;
 
   GST_DEBUG_OBJECT (wav, "stopped streaming at %" G_GINT64_FORMAT, last_stop);
 
@@ -899,7 +878,7 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
    * right values in the segment to perform the seek */
   if (event) {
     GST_DEBUG_OBJECT (wav, "configuring seek");
-    gst_segment_set_seek (&seeksegment, rate, format, flags,
+    gst_segment_do_seek (&seeksegment, rate, format, flags,
         cur_type, cur, stop_type, stop, &update);
   }
 
@@ -913,9 +892,9 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
     /* bring offset to bytes, if the bps is 0, we have the segment in BYTES and
      * we can just copy the last_stop. If not, we use the bps to convert TIME to
      * bytes. */
-    if (!gst_wavparse_time_to_bytepos (wav, seeksegment.last_stop,
+    if (!gst_wavparse_time_to_bytepos (wav, seeksegment.position,
             (gint64 *) & wav->offset))
-      wav->offset = seeksegment.last_stop;
+      wav->offset = seeksegment.position;
     GST_LOG_OBJECT (wav, "offset=%" G_GUINT64_FORMAT, wav->offset);
     wav->offset -= (wav->offset % wav->bytes_per_sample);
     GST_LOG_OBJECT (wav, "offset=%" G_GUINT64_FORMAT, wav->offset);
@@ -942,7 +921,7 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
   /* make sure filesize is not exceeded due to rounding errors or so,
    * same precaution as in _stream_headers */
   bformat = GST_FORMAT_BYTES;
-  if (gst_pad_query_peer_duration (wav->sinkpad, &bformat, &upstream_size))
+  if (gst_pad_query_peer_duration (wav->sinkpad, bformat, &upstream_size))
     wav->end_offset = MIN (wav->end_offset, upstream_size);
 
   /* this is the range of bytes we will use for playback */
@@ -959,19 +938,7 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
     if (flush) {
       /* if we sent a FLUSH_START, we now send a FLUSH_STOP */
       GST_DEBUG_OBJECT (wav, "sending flush stop");
-      gst_pad_push_event (wav->srcpad, gst_event_new_flush_stop ());
-    } else if (wav->segment_running) {
-      /* we are running the current segment and doing a non-flushing seek,
-       * close the segment first based on the previous last_stop. */
-      GST_DEBUG_OBJECT (wav, "closing running segment %" G_GINT64_FORMAT
-          " to %" G_GINT64_FORMAT, wav->segment.start, wav->segment.last_stop);
-
-      /* queue the segment for sending in the stream thread */
-      if (wav->close_segment)
-        gst_event_unref (wav->close_segment);
-      wav->close_segment = gst_event_new_new_segment (TRUE,
-          wav->segment.rate, wav->segment.format,
-          wav->segment.start, wav->segment.last_stop, wav->segment.start);
+      gst_pad_push_event (wav->srcpad, gst_event_new_flush_stop (TRUE));
     }
   }
 
@@ -982,29 +949,25 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
   if (wav->segment.flags & GST_SEEK_FLAG_SEGMENT) {
     gst_element_post_message (GST_ELEMENT_CAST (wav),
         gst_message_new_segment_start (GST_OBJECT_CAST (wav),
-            wav->segment.format, wav->segment.last_stop));
+            wav->segment.format, wav->segment.position));
   }
 
   /* now create the newsegment */
   GST_DEBUG_OBJECT (wav, "Creating newsegment from %" G_GINT64_FORMAT
-      " to %" G_GINT64_FORMAT, wav->segment.last_stop, stop);
+      " to %" G_GINT64_FORMAT, wav->segment.position, stop);
 
   /* store the newsegment event so it can be sent from the streaming thread. */
   if (wav->start_segment)
     gst_event_unref (wav->start_segment);
-  wav->start_segment =
-      gst_event_new_new_segment (FALSE, wav->segment.rate,
-      wav->segment.format, wav->segment.last_stop, stop,
-      wav->segment.last_stop);
+  wav->start_segment = gst_event_new_segment (&wav->segment);
 
   /* mark discont if we are going to stream from another position. */
-  if (last_stop != wav->segment.last_stop) {
+  if (last_stop != wav->segment.position) {
     GST_DEBUG_OBJECT (wav, "mark DISCONT, we did a seek to another position");
     wav->discont = TRUE;
   }
 
   /* and start the streaming task again */
-  wav->segment_running = TRUE;
   if (!wav->streaming) {
     gst_pad_start_task (wav->sinkpad, (GstTaskFunction) gst_wavparse_loop,
         wav->sinkpad);
@@ -1051,9 +1014,10 @@ gst_wavparse_peek_chunk_info (GstWavParse * wav, guint32 * tag, guint32 * size)
   if (gst_adapter_available (wav->adapter) < 8)
     return FALSE;
 
-  data = gst_adapter_peek (wav->adapter, 8);
+  data = gst_adapter_map (wav->adapter, 8);
   *tag = GST_READ_UINT32_LE (data);
   *size = GST_READ_UINT32_LE (data + 4);
+  gst_adapter_unmap (wav->adapter, 0);
 
   GST_DEBUG ("Next chunk size is %d bytes, type %" GST_FOURCC_FORMAT, *size,
       GST_FOURCC_ARGS (*tag));
@@ -1169,7 +1133,6 @@ gst_wavparse_stream_headers (GstWavParse * wav)
   GstCaps *caps = NULL;
   gchar *codec_name = NULL;
   GstEvent **event_p;
-  GstFormat bformat;
   gint64 upstream_size = 0;
 
   /* search for "_fmt" chunk, which should be first */
@@ -1314,8 +1277,7 @@ gst_wavparse_stream_headers (GstWavParse * wav)
 
   }
 
-  bformat = GST_FORMAT_BYTES;
-  gst_pad_query_peer_duration (wav->sinkpad, &bformat, &upstream_size);
+  gst_pad_query_peer_duration (wav->sinkpad, GST_FORMAT_BYTES, &upstream_size);
   GST_DEBUG_OBJECT (wav, "upstream size %" G_GUINT64_FORMAT, upstream_size);
 
   /* loop headers until we get data */
@@ -1324,12 +1286,16 @@ gst_wavparse_stream_headers (GstWavParse * wav)
       if (!gst_wavparse_peek_chunk_info (wav, &tag, &size))
         goto exit;
     } else {
+      guint8 *data;
+
       if ((res =
               gst_pad_pull_range (wav->sinkpad, wav->offset, 8,
                   &buf)) != GST_FLOW_OK)
         goto header_read_error;
-      tag = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf));
-      size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf) + 4);
+      data = gst_buffer_map (buf, NULL, NULL, -1);
+      tag = GST_READ_UINT32_LE (data);
+      size = GST_READ_UINT32_LE (data + 4);
+      gst_buffer_unmap (buf, data, -1);
     }
 
     GST_INFO_OBJECT (wav,
@@ -1392,16 +1358,17 @@ gst_wavparse_stream_headers (GstWavParse * wav)
               goto exit;
             }
             gst_adapter_flush (wav->adapter, 8);
-            data = gst_adapter_peek (wav->adapter, data_size);
+            data = gst_adapter_map (wav->adapter, data_size);
             wav->fact = GST_READ_UINT32_LE (data);
-            gst_adapter_flush (wav->adapter, GST_ROUND_UP_2 (size));
+            gst_adapter_unmap (wav->adapter, GST_ROUND_UP_2 (size));
           } else {
             gst_buffer_unref (buf);
             if ((res =
                     gst_pad_pull_range (wav->sinkpad, wav->offset + 8,
                         data_size, &buf)) != GST_FLOW_OK)
               goto header_read_error;
-            wav->fact = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf));
+            gst_buffer_extract (buf, 0, &wav->fact, 4);
+            wav->fact = GUINT32_FROM_LE (wav->fact);
             gst_buffer_unref (buf);
           }
           GST_DEBUG_OBJECT (wav, "have fact %u", wav->fact);
@@ -1418,6 +1385,7 @@ gst_wavparse_stream_headers (GstWavParse * wav)
       case GST_RIFF_TAG_acid:{
         const gst_riff_acid *acid = NULL;
         const guint data_size = sizeof (gst_riff_acid);
+        gfloat tempo;
 
         GST_INFO_OBJECT (wav, "Have acid chunk");
         if (size < data_size) {
@@ -1434,21 +1402,26 @@ gst_wavparse_stream_headers (GstWavParse * wav)
             goto exit;
           }
           gst_adapter_flush (wav->adapter, 8);
-          acid = (const gst_riff_acid *) gst_adapter_peek (wav->adapter,
+          acid = (const gst_riff_acid *) gst_adapter_map (wav->adapter,
               data_size);
+          tempo = acid->tempo;
+          gst_adapter_unmap (wav->adapter, 0);
         } else {
           gst_buffer_unref (buf);
           if ((res =
                   gst_pad_pull_range (wav->sinkpad, wav->offset + 8,
                       size, &buf)) != GST_FLOW_OK)
             goto header_read_error;
-          acid = (const gst_riff_acid *) GST_BUFFER_DATA (buf);
+          acid = (const gst_riff_acid *) gst_buffer_map (buf, NULL, NULL,
+              GST_MAP_READ);
+          tempo = acid->tempo;
+          gst_buffer_unmap (buf, (guint8 *) acid, -1);
         }
         /* send data as tags */
         if (!wav->tags)
           wav->tags = gst_tag_list_new ();
         gst_tag_list_add (wav->tags, GST_TAG_MERGE_REPLACE,
-            GST_TAG_BEATS_PER_MINUTE, acid->tempo, NULL);
+            GST_TAG_BEATS_PER_MINUTE, tempo, NULL);
 
         size = GST_ROUND_UP_2 (size);
         if (wav->streaming) {
@@ -1469,15 +1442,17 @@ gst_wavparse_stream_headers (GstWavParse * wav)
           if (gst_adapter_available (wav->adapter) < 12) {
             goto exit;
           }
-          data = gst_adapter_peek (wav->adapter, 12);
+          data = gst_adapter_map (wav->adapter, 12);
           ltag = GST_READ_UINT32_LE (data + 8);
+          gst_adapter_unmap (wav->adapter, 0);
         } else {
           gst_buffer_unref (buf);
           if ((res =
                   gst_pad_pull_range (wav->sinkpad, wav->offset, 12,
                       &buf)) != GST_FLOW_OK)
             goto header_read_error;
-          ltag = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf) + 8);
+          gst_buffer_extract (buf, 8, &ltag, 4);
+          ltag = GUINT32_FROM_LE (ltag);
         }
         switch (ltag) {
           case GST_RIFF_LIST_INFO:{
@@ -1560,11 +1535,11 @@ gst_wavparse_stream_headers (GstWavParse * wav)
 
   if (gst_wavparse_calculate_duration (wav)) {
     gst_segment_init (&wav->segment, GST_FORMAT_TIME);
-    gst_segment_set_duration (&wav->segment, GST_FORMAT_TIME, wav->duration);
+    wav->segment.duration = wav->duration;
   } else {
     /* no bitrate, let downstream peer do the math, we'll feed it bytes. */
     gst_segment_init (&wav->segment, GST_FORMAT_BYTES);
-    gst_segment_set_duration (&wav->segment, GST_FORMAT_BYTES, wav->datasize);
+    wav->segment.duration = wav->datasize;
   }
 
   /* now we have all the info to perform a pending seek if any, if no
@@ -1791,19 +1766,9 @@ gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf)
     }
   }
 
-  gst_wavparse_create_sourcepad (wav);
-  gst_pad_set_active (wav->srcpad, TRUE);
   gst_pad_set_caps (wav->srcpad, wav->caps);
   gst_caps_replace (&wav->caps, NULL);
 
-  gst_element_add_pad (GST_ELEMENT_CAST (wav), wav->srcpad);
-  gst_element_no_more_pads (GST_ELEMENT_CAST (wav));
-
-  if (wav->close_segment) {
-    GST_DEBUG_OBJECT (wav, "Send close segment event on newpad");
-    gst_pad_push_event (wav->srcpad, wav->close_segment);
-    wav->close_segment = NULL;
-  }
   if (wav->start_segment) {
     GST_DEBUG_OBJECT (wav, "Send start segment event on newpad");
     gst_pad_push_event (wav->srcpad, wav->start_segment);
@@ -1839,7 +1804,7 @@ iterate_adapter:
    * amounts of data regardless of the playback rate */
   desired =
       MIN (gst_guint64_to_gdouble (wav->dataleft),
-      wav->max_buf_size * wav->segment.abs_rate);
+      wav->max_buf_size * ABS (wav->segment.rate));
 
   if (desired >= wav->blockalign && wav->blockalign > 0)
     desired -= (desired % wav->blockalign);
@@ -1888,11 +1853,13 @@ iterate_adapter:
       goto pull_error;
 
     /* we may get a short buffer at the end of the file */
-    if (GST_BUFFER_SIZE (buf) < desired) {
-      GST_LOG_OBJECT (wav, "Got only %u bytes of data", GST_BUFFER_SIZE (buf));
-      if (GST_BUFFER_SIZE (buf) >= wav->blockalign) {
-        buf = gst_buffer_make_metadata_writable (buf);
-        GST_BUFFER_SIZE (buf) -= (GST_BUFFER_SIZE (buf) % wav->blockalign);
+    if (gst_buffer_get_size (buf) < desired) {
+      gsize size = gst_buffer_get_size (buf);
+
+      GST_LOG_OBJECT (wav, "Got only %" G_GSIZE_FORMAT " bytes of data", size);
+      if (size >= wav->blockalign) {
+        buf = gst_buffer_make_writable (buf);
+        gst_buffer_resize (buf, 0, size - (size % wav->blockalign));
       } else {
         gst_buffer_unref (buf);
         goto found_eos;
@@ -1900,13 +1867,14 @@ iterate_adapter:
     }
   }
 
-  obtained = GST_BUFFER_SIZE (buf);
+  obtained = gst_buffer_get_size (buf);
 
   /* our positions in bytes */
   pos = wav->offset - wav->datastart;
   nextpos = pos + obtained;
 
   /* update offsets, does not overflow. */
+  buf = gst_buffer_make_writable (buf);
   GST_BUFFER_OFFSET (buf) = pos / wav->bytes_per_sample;
   GST_BUFFER_OFFSET_END (buf) = nextpos / wav->bytes_per_sample;
 
@@ -1917,11 +1885,7 @@ iterate_adapter:
     /* this will also push the segment events */
     gst_wavparse_add_src_pad (wav, buf);
   } else {
-    /* If we have a pending close/start segment, send it now. */
-    if (G_UNLIKELY (wav->close_segment != NULL)) {
-      gst_pad_push_event (wav->srcpad, wav->close_segment);
-      wav->close_segment = NULL;
-    }
+    /* If we have a pending start segment, send it now. */
     if (G_UNLIKELY (wav->start_segment != NULL)) {
       gst_pad_push_event (wav->srcpad, wav->start_segment);
       wav->start_segment = NULL;
@@ -1937,8 +1901,7 @@ iterate_adapter:
 
     /* update current running segment position */
     if (G_LIKELY (next_timestamp >= wav->segment.start))
-      gst_segment_set_last_stop (&wav->segment, GST_FORMAT_TIME,
-          next_timestamp);
+      wav->segment.position = next_timestamp;
   } else if (wav->fact) {
     guint64 bps =
         gst_util_uint64_scale_int (wav->datasize, wav->rate, wav->fact);
@@ -1956,7 +1919,7 @@ iterate_adapter:
     duration = GST_CLOCK_TIME_NONE;
     /* update current running segment position with byte offset */
     if (G_LIKELY (nextpos >= wav->segment.start))
-      gst_segment_set_last_stop (&wav->segment, GST_FORMAT_BYTES, nextpos);
+      wav->segment.position = nextpos;
   }
   if ((pos > 0) && wav->vbr) {
     /* don't set timestamps for VBR files if it's not the first buffer */
@@ -1972,13 +1935,10 @@ iterate_adapter:
   GST_BUFFER_TIMESTAMP (buf) = timestamp;
   GST_BUFFER_DURATION (buf) = duration;
 
-  /* don't forget to set the caps on the buffer */
-  gst_buffer_set_caps (buf, GST_PAD_CAPS (wav->srcpad));
-
   GST_LOG_OBJECT (wav,
       "Got buffer. timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT
       ", size:%u", GST_TIME_ARGS (timestamp), GST_TIME_ARGS (duration),
-      GST_BUFFER_SIZE (buf));
+      gst_buffer_get_size (buf));
 
   if ((res = gst_pad_push (wav->srcpad, buf)) != GST_FLOW_OK)
     goto push_error;
@@ -2068,10 +2028,19 @@ pause:
     const gchar *reason = gst_flow_get_name (ret);
 
     GST_DEBUG_OBJECT (wav, "pausing task, reason %s", reason);
-    wav->segment_running = FALSE;
     gst_pad_pause_task (pad);
 
     if (ret == GST_FLOW_UNEXPECTED) {
+      /* handle end-of-stream/segment */
+      /* so align our position with the end of it, if there is one
+       * this ensures a subsequent will arrive at correct base/acc time */
+      if (wav->segment.format == GST_FORMAT_TIME) {
+        if (wav->segment.rate > 0.0 &&
+            GST_CLOCK_TIME_IS_VALID (wav->segment.stop))
+          wav->segment.position = wav->segment.stop;
+        else if (wav->segment.rate < 0.0)
+          wav->segment.position = wav->segment.start;
+      }
       /* add pad before we perform EOS */
       if (G_UNLIKELY (wav->first)) {
         wav->first = FALSE;
@@ -2115,7 +2084,7 @@ gst_wavparse_chain (GstPad * pad, GstBuffer * buf)
   GstFlowReturn ret;
   GstWavParse *wav = GST_WAVPARSE (GST_PAD_PARENT (pad));
 
-  GST_LOG_OBJECT (wav, "adapter_push %u bytes", GST_BUFFER_SIZE (buf));
+  GST_LOG_OBJECT (wav, "adapter_push %u bytes", gst_buffer_get_size (buf));
 
   gst_adapter_push (wav->adapter, buf);
 
@@ -2185,22 +2154,20 @@ gst_wavparse_sink_event (GstPad * pad, GstEvent * event)
   GST_LOG_OBJECT (wav, "handling %s event", GST_EVENT_TYPE_NAME (event));
 
   switch (GST_EVENT_TYPE (event)) {
-    case GST_EVENT_NEWSEGMENT:
+    case GST_EVENT_CAPS:
     {
-      GstFormat format;
-      gdouble rate, arate;
-      gint64 start, stop, time, offset = 0, end_offset = -1;
-      gboolean update;
+      /* discard, we'll come up with proper src caps */
+      gst_event_unref (event);
+      break;
+    }
+    case GST_EVENT_SEGMENT:
+    {
+      gint64 start, stop, offset = 0, end_offset = -1;
       GstSegment segment;
 
       /* some debug output */
-      gst_segment_init (&segment, GST_FORMAT_UNDEFINED);
-      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
-          &start, &stop, &time);
-      gst_segment_set_newsegment_full (&segment, update, rate, arate, format,
-          start, stop, time);
-      GST_DEBUG_OBJECT (wav,
-          "received format %d newsegment %" GST_SEGMENT_FORMAT, format,
+      gst_event_copy_segment (event, &segment);
+      GST_DEBUG_OBJECT (wav, "received newsegment %" GST_SEGMENT_FORMAT,
           &segment);
 
       if (wav->state != GST_WAVPARSE_DATA) {
@@ -2210,7 +2177,10 @@ gst_wavparse_sink_event (GstPad * pad, GstEvent * event)
 
       /* now we are either committed to TIME or BYTE format,
        * and we only expect a BYTE segment, e.g. following a seek */
-      if (format == GST_FORMAT_BYTES) {
+      if (segment.format == GST_FORMAT_BYTES) {
+        /* handle (un)signed issues */
+        start = segment.start;
+        stop = segment.stop;
         if (start > 0) {
           offset = start;
           start -= wav->datastart;
@@ -2218,8 +2188,8 @@ gst_wavparse_sink_event (GstPad * pad, GstEvent * event)
         }
         if (stop > 0) {
           end_offset = stop;
-          stop -= wav->datastart;
-          stop = MAX (stop, 0);
+          segment.stop -= wav->datastart;
+          segment.stop = MAX (stop, 0);
         }
         if (wav->segment.format == GST_FORMAT_TIME) {
           guint64 bps = wav->bps;
@@ -2242,19 +2212,22 @@ gst_wavparse_sink_event (GstPad * pad, GstEvent * event)
         goto exit;
       }
 
+      segment.start = start;
+      segment.stop = stop;
+
       /* accept upstream's notion of segment and distribute along */
-      gst_segment_set_newsegment_full (&wav->segment, update, rate, arate,
-          wav->segment.format, start, stop, start);
+      segment.time = segment.start = segment.position;
+      segment.duration = wav->segment.duration;
+      segment.base = gst_segment_to_running_time (&wav->segment,
+          GST_FORMAT_TIME, wav->segment.position);
+
+      gst_segment_copy_into (&segment, &wav->segment);
+
       /* also store the newsegment event for the streaming thread */
       if (wav->start_segment)
         gst_event_unref (wav->start_segment);
-      wav->start_segment =
-          gst_event_new_new_segment_full (update, rate, arate,
-          wav->segment.format, start, stop, start);
-      GST_DEBUG_OBJECT (wav, "Pushing newseg update %d, rate %g, "
-          "applied rate %g, format %d, start %" G_GINT64_FORMAT ", "
-          "stop %" G_GINT64_FORMAT, update, rate, arate, wav->segment.format,
-          start, stop);
+      GST_DEBUG_OBJECT (wav, "Storing newseg %" GST_SEGMENT_FORMAT, &segment);
+      wav->start_segment = gst_event_new_segment (&segment);
 
       /* stream leftover data in current segment */
       gst_wavparse_flush_data (wav);
@@ -2287,9 +2260,16 @@ gst_wavparse_sink_event (GstPad * pad, GstEvent * event)
 
       /* fall-through */
     case GST_EVENT_FLUSH_STOP:
+    {
+      GstClockTime dur;
+
       gst_adapter_clear (wav->adapter);
       wav->discont = TRUE;
+      dur = wav->segment.duration;
+      gst_segment_init (&wav->segment, wav->segment.format);
+      wav->segment.duration = dur;
       /* fall-through */
+    }
     default:
       ret = gst_pad_event_default (wav->sinkpad, event);
       break;
@@ -2577,7 +2557,8 @@ static gboolean
 gst_wavparse_sink_activate (GstPad * sinkpad)
 {
   GstWavParse *wav = GST_WAVPARSE (gst_pad_get_parent (sinkpad));
-  gboolean res;
+  GstQuery *query;
+  gboolean pull_mode;
 
   if (wav->adapter) {
     gst_adapter_clear (wav->adapter);
@@ -2585,33 +2566,43 @@ gst_wavparse_sink_activate (GstPad * sinkpad)
     wav->adapter = NULL;
   }
 
-  if (gst_pad_check_pull_range (sinkpad)) {
-    GST_DEBUG ("going to pull mode");
-    wav->streaming = FALSE;
-    res = gst_pad_activate_pull (sinkpad, TRUE);
-  } else {
-    GST_DEBUG ("going to push (streaming) mode");
+  query = gst_query_new_scheduling ();
+
+  if (!gst_pad_peer_query (sinkpad, query)) {
+    gst_query_unref (query);
+    goto activate_push;
+  }
+
+  gst_query_parse_scheduling (query, &pull_mode, NULL, NULL, NULL, NULL, NULL);
+  gst_query_unref (query);
+
+  if (!pull_mode)
+    goto activate_push;
+
+  GST_DEBUG_OBJECT (sinkpad, "activating pull");
+  wav->streaming = FALSE;
+  gst_object_unref (wav);
+  return gst_pad_activate_pull (sinkpad, TRUE);
+
+activate_push:
+  {
+    GST_DEBUG_OBJECT (sinkpad, "activating push");
     wav->streaming = TRUE;
     wav->adapter = gst_adapter_new ();
-    res = gst_pad_activate_push (sinkpad, TRUE);
+    gst_object_unref (wav);
+    return gst_pad_activate_push (sinkpad, TRUE);
   }
-  gst_object_unref (wav);
-  return res;
 }
 
 
 static gboolean
 gst_wavparse_sink_activate_pull (GstPad * sinkpad, gboolean active)
 {
-  GstWavParse *wav = GST_WAVPARSE (GST_OBJECT_PARENT (sinkpad));
-
   if (active) {
     /* if we have a scheduler we can start the task */
-    wav->segment_running = TRUE;
     return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_wavparse_loop,
         sinkpad);
   } else {
-    wav->segment_running = FALSE;
     return gst_pad_stop_task (sinkpad);
   }
 };
index ecac968..54d0a0f 100644 (file)
@@ -66,7 +66,6 @@ struct _GstWavParse {
    * the format for sure */
   GstCaps     *caps;
   GstTagList  *tags;
-  GstEvent    *close_segment;
   GstEvent    *start_segment;
 
   /* WAVE decoding state */
@@ -110,9 +109,8 @@ struct _GstWavParse {
   gboolean got_fmt;
   gboolean streaming;
 
-  /* configured segment, start/stop expressed in time */
+  /* configured segment, start/stop expressed in time or bytes */
   GstSegment segment;
-  gboolean segment_running;
 
   /* for late pad configuration */
   gboolean first;
index 3548d8d..c81703a 100644 (file)
@@ -3,7 +3,7 @@ plugin_LTLIBRARIES = libgsty4menc.la
 
 libgsty4menc_la_SOURCES = gsty4mencode.c
 libgsty4menc_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
-libgsty4menc_la_LIBADD = $(GST_LIBS)
+libgsty4menc_la_LIBADD = $(GST_LIBS) -lgstvideo-$(GST_MAJORMINOR)
 libgsty4menc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgsty4menc_la_LIBTOOLFLAGS = --tag=disable-static
 
index 4adaa5a..ed49fc6 100644 (file)
@@ -70,7 +70,7 @@ static GstStaticPadTemplate y4mencode_sink_factory =
 GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ IYUV, I420, Y42B, Y41B, Y444 }"))
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ IYUV, I420, Y42B, Y41B, Y444 }"))
     );
 
 
@@ -81,28 +81,13 @@ static void gst_y4m_encode_get_property (GObject * object,
 
 static void gst_y4m_encode_reset (GstY4mEncode * filter);
 
-static gboolean gst_y4m_encode_setcaps (GstPad * pad, GstCaps * vscaps);
+static gboolean gst_y4m_encode_sink_event (GstPad * pad, GstEvent * event);
 static GstFlowReturn gst_y4m_encode_chain (GstPad * pad, GstBuffer * buf);
 static GstStateChangeReturn gst_y4m_encode_change_state (GstElement * element,
     GstStateChange transition);
 
-GST_BOILERPLATE (GstY4mEncode, gst_y4m_encode, GstElement, GST_TYPE_ELEMENT);
-
-
-static void
-gst_y4m_encode_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&y4mencode_src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&y4mencode_sink_factory));
-  gst_element_class_set_details_simple (element_class, "YUV4MPEG video encoder",
-      "Codec/Encoder/Video",
-      "Encodes a YUV frame into the yuv4mpeg format (mjpegtools)",
-      "Wim Taymans <wim.taymans@gmail.com>");
-}
+#define gst_y4m_encode_parent_class parent_class
+G_DEFINE_TYPE (GstY4mEncode, gst_y4m_encode, GST_TYPE_ELEMENT);
 
 static void
 gst_y4m_encode_class_init (GstY4mEncodeClass * klass)
@@ -113,23 +98,33 @@ gst_y4m_encode_class_init (GstY4mEncodeClass * klass)
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
 
+  gobject_class->set_property = gst_y4m_encode_set_property;
+  gobject_class->get_property = gst_y4m_encode_get_property;
+
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_y4m_encode_change_state);
 
-  gobject_class->set_property = gst_y4m_encode_set_property;
-  gobject_class->get_property = gst_y4m_encode_get_property;
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&y4mencode_src_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&y4mencode_sink_factory));
+
+  gst_element_class_set_details_simple (gstelement_class,
+      "YUV4MPEG video encoder", "Codec/Encoder/Video",
+      "Encodes a YUV frame into the yuv4mpeg format (mjpegtools)",
+      "Wim Taymans <wim.taymans@gmail.com>");
 }
 
 static void
-gst_y4m_encode_init (GstY4mEncode * filter, GstY4mEncodeClass * klass)
+gst_y4m_encode_init (GstY4mEncode * filter)
 {
   filter->sinkpad =
       gst_pad_new_from_static_template (&y4mencode_sink_factory, "sink");
   gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
   gst_pad_set_chain_function (filter->sinkpad,
       GST_DEBUG_FUNCPTR (gst_y4m_encode_chain));
-  gst_pad_set_setcaps_function (filter->sinkpad,
-      GST_DEBUG_FUNCPTR (gst_y4m_encode_setcaps));
+  gst_pad_set_event_function (filter->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_y4m_encode_sink_event));
 
   filter->srcpad =
       gst_pad_new_from_static_template (&y4mencode_src_factory, "src");
@@ -143,103 +138,107 @@ gst_y4m_encode_init (GstY4mEncode * filter, GstY4mEncodeClass * klass)
 static void
 gst_y4m_encode_reset (GstY4mEncode * filter)
 {
-  filter->width = filter->height = -1;
-  filter->fps_num = filter->fps_den = 1;
-  filter->par_num = filter->par_den = 1;
-  filter->colorspace = "unknown";
+  filter->negotiated = FALSE;
 }
 
 static gboolean
 gst_y4m_encode_setcaps (GstPad * pad, GstCaps * vscaps)
 {
+  gboolean ret;
   GstY4mEncode *filter;
-  GstStructure *structure;
-  gboolean res;
-  gint w, h;
-  guint32 fourcc;
-  const GValue *fps, *par, *interlaced;
+  GstVideoInfo info;
 
   filter = GST_Y4M_ENCODE (GST_PAD_PARENT (pad));
 
-  structure = gst_caps_get_structure (vscaps, 0);
+  if (!gst_video_info_from_caps (&info, vscaps))
+    goto invalid_format;
 
-  res = gst_structure_get_int (structure, "width", &w);
-  res &= gst_structure_get_int (structure, "height", &h);
-  res &= ((fps = gst_structure_get_value (structure, "framerate")) != NULL);
-  res &= gst_structure_get_fourcc (structure, "format", &fourcc);
+  filter->info = info;
 
-  switch (fourcc) {             /* Translate fourcc to Y4M colorspace code */
-    case GST_MAKE_FOURCC ('I', '4', '2', '0'):
-    case GST_MAKE_FOURCC ('I', 'Y', 'U', 'V'):
+  switch (GST_VIDEO_INFO_FORMAT (&filter->info)) {
+    case GST_VIDEO_FORMAT_I420:
       filter->colorspace = "420";
       break;
-    case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
+    case GST_VIDEO_FORMAT_Y42B:
       filter->colorspace = "422";
       break;
-    case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
+    case GST_VIDEO_FORMAT_Y41B:
       filter->colorspace = "411";
       break;
-    case GST_MAKE_FOURCC ('Y', '4', '4', '4'):
+    case GST_VIDEO_FORMAT_Y444:
       filter->colorspace = "444";
       break;
     default:
-      res = FALSE;
-      break;
+      goto invalid_format;
   }
 
-  if (!res || w <= 0 || h <= 0 || !GST_VALUE_HOLDS_FRACTION (fps))
-    return FALSE;
+  /* the template caps will do for the src pad, should always accept */
+  ret = gst_pad_set_caps (filter->srcpad,
+      gst_static_pad_template_get_caps (&y4mencode_src_factory));
+
+  filter->negotiated = ret;
 
-  /* optional interlaced info */
-  interlaced = gst_structure_get_value (structure, "interlaced");
-
-  /* optional par info */
-  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
-
-  filter->width = w;
-  filter->height = h;
-  filter->fps_num = gst_value_get_fraction_numerator (fps);
-  filter->fps_den = gst_value_get_fraction_denominator (fps);
-  if ((par != NULL) && GST_VALUE_HOLDS_FRACTION (par)) {
-    filter->par_num = gst_value_get_fraction_numerator (par);
-    filter->par_den = gst_value_get_fraction_denominator (par);
-  } else {                      /* indicates unknown */
-    filter->par_num = 0;
-    filter->par_den = 0;
+  return ret;
+
+  /* ERRORS */
+invalid_format:
+  {
+    GST_ERROR_OBJECT (filter, "got invalid caps");
+    return FALSE;
   }
-  if ((interlaced != NULL) && G_VALUE_HOLDS (interlaced, G_TYPE_BOOLEAN)) {
-    filter->interlaced = g_value_get_boolean (interlaced);
-  } else {
-    /* assume progressive if no interlaced property in caps */
-    filter->interlaced = FALSE;
+}
+
+static gboolean
+gst_y4m_encode_sink_event (GstPad * pad, GstEvent * event)
+{
+  gboolean res;
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+
+      gst_event_parse_caps (event, &caps);
+      res = gst_y4m_encode_setcaps (pad, caps);
+      gst_event_unref (event);
+      break;
+    }
+    default:
+      res = gst_pad_event_default (pad, event);
+      break;
   }
-  /* the template caps will do for the src pad, should always accept */
-  return gst_pad_set_caps (filter->srcpad,
-      gst_static_pad_template_get_caps (&y4mencode_src_factory));
+  return res;
 }
 
 static inline GstBuffer *
-gst_y4m_encode_get_stream_header (GstY4mEncode * filter)
+gst_y4m_encode_get_stream_header (GstY4mEncode * filter, gboolean tff)
 {
   gpointer header;
   GstBuffer *buf;
   gchar interlaced;
+  gsize len;
 
-  interlaced = 'p';
-
-  if (filter->interlaced && filter->top_field_first)
-    interlaced = 't';
-  else if (filter->interlaced)
-    interlaced = 'b';
+  if (filter->info.flags & GST_VIDEO_FLAG_INTERLACED) {
+    if (tff)
+      interlaced = 't';
+    else
+      interlaced = 'b';
+  } else {
+    interlaced = 'p';
+  }
 
   header = g_strdup_printf ("YUV4MPEG2 C%s W%d H%d I%c F%d:%d A%d:%d\n",
-      filter->colorspace, filter->width, filter->height, interlaced,
-      filter->fps_num, filter->fps_den, filter->par_num, filter->par_den);
+      filter->colorspace, GST_VIDEO_INFO_WIDTH (&filter->info),
+      GST_VIDEO_INFO_HEIGHT (&filter->info), interlaced,
+      GST_VIDEO_INFO_FPS_N (&filter->info),
+      GST_VIDEO_INFO_FPS_D (&filter->info),
+      GST_VIDEO_INFO_PAR_N (&filter->info),
+      GST_VIDEO_INFO_PAR_D (&filter->info));
+  len = strlen (header);
 
   buf = gst_buffer_new ();
-  gst_buffer_set_data (buf, header, strlen (header));
-  /* so it gets free'd when needed */
-  GST_BUFFER_MALLOCDATA (buf) = header;
+  gst_buffer_take_memory (buf, -1,
+      gst_memory_new_wrapped (0, header, g_free, len, 0, len));
 
   return buf;
 }
@@ -249,13 +248,14 @@ gst_y4m_encode_get_frame_header (GstY4mEncode * filter)
 {
   gpointer header;
   GstBuffer *buf;
+  gsize len;
 
   header = g_strdup_printf ("FRAME\n");
+  len = strlen (header);
 
   buf = gst_buffer_new ();
-  gst_buffer_set_data (buf, header, strlen (header));
-  /* so it gets free'd when needed */
-  GST_BUFFER_MALLOCDATA (buf) = header;
+  gst_buffer_take_memory (buf, -1,
+      gst_memory_new_wrapped (0, header, g_free, len, 0, len));
 
   return buf;
 }
@@ -268,38 +268,40 @@ gst_y4m_encode_chain (GstPad * pad, GstBuffer * buf)
   GstClockTime timestamp;
 
   /* check we got some decent info from caps */
-  if (filter->width < 0) {
-    GST_ELEMENT_ERROR ("filter", CORE, NEGOTIATION, (NULL),
-        ("format wasn't negotiated before chain function"));
-    gst_buffer_unref (buf);
-    return GST_FLOW_NOT_NEGOTIATED;
-  }
+  if (GST_VIDEO_INFO_FORMAT (&filter->info) != GST_VIDEO_FORMAT_UNKNOWN)
+    goto not_negotiated;
 
   timestamp = GST_BUFFER_TIMESTAMP (buf);
 
   if (G_UNLIKELY (!filter->header)) {
-    if (filter->interlaced == TRUE) {
-      if (GST_BUFFER_FLAG_IS_SET (buf, GST_VIDEO_BUFFER_TFF)) {
-        filter->top_field_first = TRUE;
-      } else {
-        filter->top_field_first = FALSE;
-      }
+    gboolean tff;
+
+    if (filter->info.flags & GST_VIDEO_FLAG_INTERLACED) {
+      tff = GST_BUFFER_FLAG_IS_SET (buf, GST_VIDEO_BUFFER_FLAG_TFF);
     }
-    outbuf = gst_y4m_encode_get_stream_header (filter);
+    outbuf = gst_y4m_encode_get_stream_header (filter, tff);
     filter->header = TRUE;
     outbuf = gst_buffer_join (outbuf, gst_y4m_encode_get_frame_header (filter));
   } else {
     outbuf = gst_y4m_encode_get_frame_header (filter);
   }
-  /* join with data */
+  /* join with data, FIXME, strides are all wrong etc */
   outbuf = gst_buffer_join (outbuf, buf);
   /* decorate */
-  gst_buffer_make_metadata_writable (outbuf);
-  gst_buffer_set_caps (outbuf, GST_PAD_CAPS (filter->srcpad));
+  outbuf = gst_buffer_make_writable (outbuf);
 
   GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
 
   return gst_pad_push (filter->srcpad, outbuf);
+
+  /* ERRORS */
+not_negotiated:
+  {
+    GST_ELEMENT_ERROR ("filter", CORE, NEGOTIATION, (NULL),
+        ("format wasn't negotiated before chain function"));
+    gst_buffer_unref (buf);
+    return GST_FLOW_NOT_NEGOTIATED;
+  }
 }
 
 static void
index 624ab37..9eb820e 100644 (file)
@@ -48,11 +48,9 @@ struct _GstY4mEncode {
   GstPad *sinkpad,*srcpad;
 
   /* caps information */
-  gint width, height;
-  gint fps_num, fps_den;
-  gint par_num, par_den;
-  gboolean interlaced;
-  gboolean top_field_first;
+  GstVideoInfo info;
+  gboolean negotiated;
+
   const gchar *colorspace;
   /* state information */
   gboolean header;
index a2a60f8..53032c3 100644 (file)
@@ -1,15 +1,12 @@
 EXTRA_DIST = \
        a52.m4 \
        aalib.m4 \
-       as-arts.m4 \
        as-ffmpeg.m4 \
        as-liblame.m4 \
        as-slurp-ffmpeg.m4 \
        check-libheader.m4 \
        codeset.m4 \
-       esd.m4 \
        freetype2.m4 \
-       gconf-2.m4 \
        gettext.m4 \
        glibc21.m4 \
        glib.m4 \
diff --git a/m4/as-arts.m4 b/m4/as-arts.m4
deleted file mode 100644 (file)
index a66a8c2..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-dnl as-arts.m4 0.1.0
-
-dnl $Id: as-arts.m4,v 1.5 2004/05/21 11:20:49 thomasvs Exp $
-dnl if you copy this file to your cvs,
-dnl add this file using cvs -ko add to retain this header
-
-dnl This is an example arts .m4 adapted and scrubbed by thomasvs
-
-# Configure paths for ARTS
-# Philip Stadermann   2001-06-21
-# stolen from esd.m4
-
-dnl AM_PATH_ARTS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
-dnl Test for ARTS, and define ARTS_CXXFLAGS and ARTS_LIBS
-dnl
-AC_DEFUN([AM_PATH_ARTS],
-[dnl 
-dnl Get the cflags and libraries from the artsc-config script
-dnl
-AC_ARG_WITH(arts-prefix,
-  AC_HELP_STRING([--with-arts-prefix=PFX],
-                 [prefix where ARTS is installed (optional)]),
-  arts_prefix="$withval", arts_prefix="")
-
-AC_ARG_WITH(arts-exec-prefix,
-  AC_HELP_STRING([--with-arts-exec-prefix=PFX],
-                 [exec prefix where ARTS is installed (optional)]),
-  arts_exec_prefix="$withval", arts_exec_prefix="")
-
-AC_ARG_ENABLE(artstest, 
-  AC_HELP_STRING([--disable-artstest],
-                 [do not try to compile and run a test ARTS program]),
-  , enable_artstest=yes)
-
-  if test x$arts_exec_prefix != x ; then
-    arts_args="$arts_args --exec-prefix=$arts_exec_prefix"
-    if test x${ARTS_CONFIG+set} != xset ; then
-      ARTS_CONFIG=$arts_exec_prefix/bin/artsc-config
-    fi
-  fi
-  if test x$arts_prefix != x ; then
-    arts_args="$arts_args --prefix=$arts_prefix"
-    if test x${ARTS_CONFIG+set} != xset ; then
-      ARTS_CONFIG=$arts_prefix/bin/artsc-config
-    fi
-  fi
-
-  AC_PATH_PROG(ARTS_CONFIG, artsc-config, no)
-  min_arts_version=ifelse([$1], ,0.9.5,$1)
-  AC_MSG_CHECKING(for ARTS artsc - version >= $min_arts_version)
-  no_arts=""
-  if test "$ARTS_CONFIG" = "no" ; then
-    no_arts=yes
-  else
-    # FIXME: thomas added this sed to get arts path instead of artsc
-    # replace -I.../artsc with -I.../arts
-    ARTS_CXXFLAGS=`$ARTS_CONFIG $artsconf_args --cflags | artsc-config --cflags | sed 's/\(-I.*\)artsc/\1arts/'`
-    ARTS_LIBS=`$ARTS_CONFIG $artsconf_args --libs | sed 's/artsc$/arts/'`
-
-    arts_major_version=`$ARTS_CONFIG $arts_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
-    arts_minor_version=`$ARTS_CONFIG $arts_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
-    arts_micro_version=`$ARTS_CONFIG $arts_config_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
-    if test "x$enable_artstest" = "xyes" ; then
-      dnl ac_save_CXXFLAGS="$CXXFLAGS"
-      dnl ac_save_LIBS="$LIBS"
-      dnl CFLAGS="$CFLAGS $ARTS_CXXFLAGS"
-      dnl LIBS="$LIBS $ARTS_LIBS"
-dnl
-dnl Now check if the installed ARTS is sufficiently new. (Also sanity
-dnl checks the results of artsc-config to some extent)
-dnl
-
-dnl a*s: to successfully compile the C++ test app, we need to 
-dnl first make sure we're going to compile it as C++ (with AC_LANG_PUSH),
-dnl then add the CFLAGS and CLIBS of arts which we just discovered to the
-dnl C++ compilation and linking flags.
-dnl We also need to clean up after the test; this means using AC_LANG_POP
-dnl and restoring the CPPFLAGS and LDFLAGS from the saved values we take 
-dnl here.
-
-dnl ask nicely for C++ compilation
-      AC_LANG_PUSH(C++)
-
-dnl save compilation and link flags and make our own
-      ac_save_CPPFLAGS="$CPPFLAGS"
-      ac_save_LDFLAGS="$LDFLAGS"
-      AC_SUBST(CPPFLAGS,"$CPPFLAGS $ARTS_CXXFLAGS")
-      AC_SUBST(LDFLAGS,"$LDFLAGS $ARTS_CLIBS")
-      rm -f conf.artstest
-      AC_TRY_RUN([
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <artsflow.h>
-
-char*
-my_strdup (char *str)
-{
-  char *new_str;
-  
-  if (str)
-    {
-      // thomas: the original test did not have the typecast
-      new_str = (char *) malloc ((strlen (str) + 1) * sizeof(char));
-      strcpy (new_str, str);
-    }
-  else
-    new_str = NULL;
-  
-  return new_str;
-}
-
-int main ()
-{
-  int major, minor, micro;
-  char *tmp_version;
-
-  system ("touch conf.artstest");
-
-  /* HP/UX 9 (%@#!) writes to sscanf strings */
-  tmp_version = my_strdup("$min_arts_version");
-  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
-     printf("%s, bad version string\n", "$min_arts_version");
-     exit(1);
-   }
-
-   if (($arts_major_version > major) ||
-      (($arts_major_version == major) && ($arts_minor_version > minor)) ||
-      (($arts_major_version == major) && ($arts_minor_version == minor) && ($arts_micro_version >= micro)))
-    {
-      return 0;
-    }
-  else
-    {
-      printf("\n*** 'artsc-config --version' returned %d.%d.%d, but the minimum version\n", $arts_major_version, $arts_minor_version, $arts_micro_version);
-      printf("*** of ARTS required is %d.%d.%d. If artsc-config is correct, then it is\n", major, minor, micro);
-      printf("*** best to upgrade to the required version.\n");
-      printf("*** If artsc-config was wrong, set the environment variable ARTS_CONFIG\n");
-      printf("*** to point to the correct copy of artsc-config, and remove the file\n");
-      printf("*** config.cache before re-running configure\n");
-      return 1;
-    }
-}
-
-],, no_arts=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
-      dnl CFLAGS="$ac_save_CFLAGS"
-      dnl LIBS="$ac_save_LIBS"
-      dnl a*s this is were we clean up after the test
-      AC_LANG_POP(C++)
-      CXXFLAGS="$ac_save_CXXFLAGS"
-      LDFLAGS="$ac_save_LDFLAGS"
-      dnl a*s we are sure that these are right, so we make them active
-      AC_SUBST(CXXFLAGS,"$CXXFLAGS")
-      AC_SUBST(LDFLAGS,"$LDFLAGS")
-    fi
-  fi
-  if test "x$no_arts" = x ; then
-    AC_MSG_RESULT(yes)
-    ifelse([$2], , :, [$2])     
-  else
-    AC_MSG_RESULT(no)
-    if test "$ARTS_CONFIG" = "no" ; then
-      echo "*** The artsc-config script installed by ARTS could not be found"
-      echo "*** If ARTS was installed in PREFIX, make sure PREFIX/bin is in"
-      echo "*** your path, or set the ARTS_CONFIG environment variable to the"
-      echo "*** full path to artsc-config."
-    else
-      if test -f conf.artstest ; then
-        :
-      else
-         echo "*** Could not run ARTS test program, checking why..."
-         CFLAGS="$CFLAGS $ARTS_CXXFLAGS"
-         LIBS="$LIBS $ARTS_LIBS"
-         AC_TRY_LINK([
-#include <stdio.h>
-#include <artsflow.h>
-],      [ return 0; ],
-        [ echo "*** The test program compiled, but did not run. This usually means"
-          echo "*** that the run-time linker is not finding ARTS or finding the wrong"
-          echo "*** version of ARTS. If it is not finding ARTS, you'll need to set your"
-          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
-          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
-          echo "*** is required on your system"
-         echo "***"
-          echo "*** If you have an old version installed, it is best to remove it, although"
-          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
-        [ echo "*** The test program failed to compile or link. See the file config.log for the"
-          echo "*** exact error that occured. This usually means ARTS was incorrectly installed"
-          echo "*** or that you have moved ARTS since it was installed. In the latter case, you"
-          echo "*** may want to edit the artsc-config script: $ARTS_CONFIG" ])
-          CFLAGS="$ac_save_CFLAGS"
-          LIBS="$ac_save_LIBS"
-      fi
-    fi
-    ARTS_CXXFLAGS=""
-    ARTS_LIBS=""
-    ifelse([$3], , :, [$3])
-  fi
-  AC_SUBST(ARTS_CXXFLAGS)
-  AC_SUBST(ARTS_LIBS)
-  rm -f conf.artstest
-])
-
-dnl release C++ question
-
diff --git a/m4/esd.m4 b/m4/esd.m4
deleted file mode 100644 (file)
index 1812fd0..0000000
--- a/m4/esd.m4
+++ /dev/null
@@ -1,202 +0,0 @@
-# Configure paths for ESD
-# Manish Singh    98-9-30
-# stolen back from Frank Belew
-# stolen from Manish Singh
-# Shamelessly stolen from Owen Taylor
-
-dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
-dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS
-dnl
-AC_DEFUN([AM_PATH_ESD],
-[dnl 
-dnl Get the cflags and libraries from the esd-config script
-dnl
-AC_ARG_WITH(esd-prefix,
-  AC_HELP_STRING([--with-esd-prefix=PFX],
-                 [prefix where ESD is installed (optional)]),
-  esd_prefix="$withval", esd_prefix="")
-
-AC_ARG_WITH(esd-exec-prefix,
-  AC_HELP_STRING([--with-esd-exec-prefix=PFX],
-                 [exec prefix where ESD is installed (optional)]),
-  esd_exec_prefix="$withval", esd_exec_prefix="")
-
-AC_ARG_ENABLE(esdtest,
-  AC_HELP_STRING([--disable-esdtest],
-                 [do not try to compile and run a test ESD program]),
-  , enable_esdtest=yes)
-
-  if test x$esd_exec_prefix != x ; then
-     esd_args="$esd_args --exec-prefix=$esd_exec_prefix"
-     if test x${ESD_CONFIG+set} != xset ; then
-        ESD_CONFIG=$esd_exec_prefix/bin/esd-config
-     fi
-  fi
-  if test x$esd_prefix != x ; then
-     esd_args="$esd_args --prefix=$esd_prefix"
-     if test x${ESD_CONFIG+set} != xset ; then
-        ESD_CONFIG=$esd_prefix/bin/esd-config
-     fi
-  fi
-
-  AC_PATH_PROG(ESD_CONFIG, esd-config, no)
-  min_esd_version=ifelse([$1], ,0.2.7,$1)
-  AC_MSG_CHECKING(for ESD - version >= $min_esd_version)
-  no_esd=""
-  if test "$ESD_CONFIG" = "no" ; then
-    no_esd=yes
-  else
-    AC_LANG_SAVE
-    AC_LANG_C
-    ESD_CFLAGS=`$ESD_CONFIG $esdconf_args --cflags`
-    ESD_LIBS=`$ESD_CONFIG $esdconf_args --libs`
-
-    esd_major_version=`$ESD_CONFIG $esd_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
-    esd_minor_version=`$ESD_CONFIG $esd_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
-    esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
-    if test "x$enable_esdtest" = "xyes" ; then
-      ac_save_CFLAGS="$CFLAGS"
-      ac_save_LIBS="$LIBS"
-      CFLAGS="$CFLAGS $ESD_CFLAGS"
-      LIBS="$LIBS $ESD_LIBS"
-dnl
-dnl Now check if the installed ESD is sufficiently new. (Also sanity
-dnl checks the results of esd-config to some extent
-dnl
-      rm -f conf.esdtest
-      AC_TRY_RUN([
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <esd.h>
-
-char*
-my_strdup (char *str)
-{
-  char *new_str;
-  
-  if (str)
-    {
-      new_str = malloc ((strlen (str) + 1) * sizeof(char));
-      strcpy (new_str, str);
-    }
-  else
-    new_str = NULL;
-  
-  return new_str;
-}
-
-int main ()
-{
-  int major, minor, micro;
-  char *tmp_version;
-
-  system ("touch conf.esdtest");
-
-  /* HP/UX 9 (%@#!) writes to sscanf strings */
-  tmp_version = my_strdup("$min_esd_version");
-  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
-     printf("%s, bad version string\n", "$min_esd_version");
-     exit(1);
-   }
-
-   if (($esd_major_version > major) ||
-      (($esd_major_version == major) && ($esd_minor_version > minor)) ||
-      (($esd_major_version == major) && ($esd_minor_version == minor) && ($esd_micro_version >= micro)))
-    {
-      return 0;
-    }
-  else
-    {
-      printf("\n*** 'esd-config --version' returned %d.%d.%d, but the minimum version\n", $esd_major_version, $esd_minor_version, $esd_micro_version);
-      printf("*** of ESD required is %d.%d.%d. If esd-config is correct, then it is\n", major, minor, micro);
-      printf("*** best to upgrade to the required version.\n");
-      printf("*** If esd-config was wrong, set the environment variable ESD_CONFIG\n");
-      printf("*** to point to the correct copy of esd-config, and remove the file\n");
-      printf("*** config.cache before re-running configure\n");
-      return 1;
-    }
-}
-
-],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
-       CFLAGS="$ac_save_CFLAGS"
-       LIBS="$ac_save_LIBS"
-       AC_LANG_RESTORE
-     fi
-  fi
-  if test "x$no_esd" = x ; then
-     AC_MSG_RESULT(yes)
-     ifelse([$2], , :, [$2])     
-  else
-     AC_MSG_RESULT(no)
-     if test "$ESD_CONFIG" = "no" ; then
-       echo "*** The esd-config script installed by ESD could not be found"
-       echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in"
-       echo "*** your path, or set the ESD_CONFIG environment variable to the"
-       echo "*** full path to esd-config."
-     else
-       if test -f conf.esdtest ; then
-        :
-       else
-          echo "*** Could not run ESD test program, checking why..."
-          CFLAGS="$CFLAGS $ESD_CFLAGS"
-          LIBS="$LIBS $ESD_LIBS"
-          AC_LANG_SAVE
-          AC_LANG_C
-          AC_TRY_LINK([
-#include <stdio.h>
-#include <esd.h>
-],      [ return 0; ],
-        [ echo "*** The test program compiled, but did not run. This usually means"
-          echo "*** that the run-time linker is not finding ESD or finding the wrong"
-          echo "*** version of ESD. If it is not finding ESD, you'll need to set your"
-          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
-          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
-          echo "*** is required on your system"
-         echo "***"
-          echo "*** If you have an old version installed, it is best to remove it, although"
-          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
-        [ echo "*** The test program failed to compile or link. See the file config.log for the"
-          echo "*** exact error that occured. This usually means ESD was incorrectly installed"
-          echo "*** or that you have moved ESD since it was installed. In the latter case, you"
-          echo "*** may want to edit the esd-config script: $ESD_CONFIG" ])
-          CFLAGS="$ac_save_CFLAGS"
-          LIBS="$ac_save_LIBS"
-          AC_LANG_RESTORE
-       fi
-     fi
-     ESD_CFLAGS=""
-     ESD_LIBS=""
-     ifelse([$3], , :, [$3])
-  fi
-  AC_SUBST(ESD_CFLAGS)
-  AC_SUBST(ESD_LIBS)
-  rm -f conf.esdtest
-])
-
-dnl AM_ESD_SUPPORTS_MULTIPLE_RECORD([ACTION-IF-SUPPORTS [, ACTION-IF-NOT-SUPPORTS]])
-dnl Test, whether esd supports multiple recording clients (version >=0.2.21)
-dnl
-AC_DEFUN([AM_ESD_SUPPORTS_MULTIPLE_RECORD],
-[dnl
-  AC_MSG_NOTICE([whether installed esd version supports multiple recording clients])
-  ac_save_ESD_CFLAGS="$ESD_CFLAGS"
-  ac_save_ESD_LIBS="$ESD_LIBS"
-  AM_PATH_ESD(0.2.21,
-    ifelse([$1], , [
-      AM_CONDITIONAL(ESD_SUPPORTS_MULTIPLE_RECORD, true)
-      AC_DEFINE(ESD_SUPPORTS_MULTIPLE_RECORD, 1,
-       [Define if you have esound with support of multiple recording clients.])],
-    [$1]),
-    ifelse([$2], , [AM_CONDITIONAL(ESD_SUPPORTS_MULTIPLE_RECORD, false)], [$2])
-    if test "x$ac_save_ESD_CFLAGS" != x ; then
-       ESD_CFLAGS="$ac_save_ESD_CFLAGS"
-    fi
-    if test "x$ac_save_ESD_LIBS" != x ; then
-       ESD_LIBS="$ac_save_ESD_LIBS"
-    fi
-  )
-])
diff --git a/m4/gconf-2.m4 b/m4/gconf-2.m4
deleted file mode 100644 (file)
index 088c93f..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-dnl AM_GCONF_SOURCE_2
-dnl Defines GCONF_SCHEMA_CONFIG_SOURCE which is where you should install schemas
-dnl  (i.e. pass to gconftool-2
-dnl Defines GCONF_SCHEMA_FILE_DIR which is a filesystem directory where
-dnl  you should install foo.schemas files
-dnl
-
-AC_DEFUN([AM_GCONF_SOURCE_2],
-[
-  if test "x$GCONF_SCHEMA_INSTALL_SOURCE" = "x"; then
-    GCONF_SCHEMA_CONFIG_SOURCE=`gconftool-2 --get-default-source`
-  else
-    GCONF_SCHEMA_CONFIG_SOURCE=$GCONF_SCHEMA_INSTALL_SOURCE
-  fi
-
-  AC_ARG_WITH(gconf-source, 
-  [  --with-gconf-source=sourceaddress      Config database for installing schema files.],GCONF_SCHEMA_CONFIG_SOURCE="$withval",)
-
-  AC_SUBST(GCONF_SCHEMA_CONFIG_SOURCE)
-  AC_MSG_RESULT([Using config source $GCONF_SCHEMA_CONFIG_SOURCE for schema installation])
-
-  if test "x$GCONF_SCHEMA_FILE_DIR" = "x"; then
-    GCONF_SCHEMA_FILE_DIR='$(sysconfdir)/gconf/schemas'
-  fi
-
-  AC_ARG_WITH(gconf-schema-file-dir, 
-  [  --with-gconf-schema-file-dir=dir        Directory for installing schema files.],GCONF_SCHEMA_FILE_DIR="$withval",)
-
-  AC_SUBST(GCONF_SCHEMA_FILE_DIR)
-  AC_MSG_RESULT([Using $GCONF_SCHEMA_FILE_DIR as install directory for schema files])
-
-  AC_ARG_ENABLE(schemas-install,
-     [  --disable-schemas-install      Disable the schemas installation],
-     [case "${enableval}" in
-       yes) schemas_install=true ;;
-       no)  schemas_install=false ;;
-       *) AC_MSG_ERROR(bad value ${enableval} for --disable-schemas-install) ;;
-     esac],[schemas_install=true])
-     AM_CONDITIONAL(GCONF_SCHEMAS_INSTALL, test x$schemas_install = xtrue)
-])
index 95fc75e..57e8e43 100644 (file)
@@ -1,4 +1,3 @@
-ext/esd/esdsink.c
 ext/pulse/pulsesink.c
 ext/flac/gstflacdec.c
 ext/jpeg/gstjpegdec.c
@@ -6,7 +5,6 @@ ext/libpng/gstpngdec.c
 ext/shout2/gstshout2.c
 ext/soup/gstsouphttpsrc.c
 ext/wavpack/gstwavpackparse.c
-gconf/gstreamer.schemas.in
 gst/avi/gstavidemux.c
 gst/avi/gstavimux.c
 gst/isomp4/qtdemux.c
@@ -20,7 +18,8 @@ sys/oss4/oss4-mixer.c
 sys/oss4/oss4-sink.c
 sys/oss4/oss4-source.c
 sys/sunaudio/gstsunaudiomixertrack.c
-sys/v4l2/gstv4l2src.c
+sys/v4l2/gstv4l2bufferpool.c
+sys/v4l2/gstv4l2object.c
+sys/v4l2/gstv4l2radio.c
 sys/v4l2/v4l2_calls.c
-sys/v4l2/v4l2src_calls.c
 sys/ximage/gstximagesrc.c
index ced1f84..5086b53 100644 (file)
--- a/po/af.po
+++ b/po/af.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins 0.7.6\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2004-03-18 14:16+0200\n"
 "Last-Translator: Petri Jooste <rkwjpj@puk.ac.za>\n"
 "Language-Team: Afrikaans <i18n@af.org.za>\n"
@@ -16,12 +16,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr ""
-
-msgid "Failed to query sound server capabilities"
-msgstr ""
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -548,13 +542,79 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Kon nie buffers vanaf toestel \"%s\" verkry nie."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Kon nie buffers vanaf toestel \"%s\" verkry nie."
+
+#, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+
+#, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Toestel \"%s\" is nie 'n vasleggingtoestel nie."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Toestel \"%s\" is nie 'n vasleggingtoestel nie."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Toestel \"%s\" is nie 'n vasleggingtoestel nie."
+
+#, fuzzy, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Kon nie buffers vanaf toestel \"%s\" verkry nie."
+
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Kon nie genoeg buffers vanaf toestel \"%s\" kry nie."
+
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed after %d tries. device %s. system error: %s"
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Kon nie genoeg buffers vanaf toestel \"%s\" kry nie."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Kon nie buffers vanaf toestel \"%s\" verkry nie."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Toestel \"%s\" is nie 'n vasleggingtoestel nie."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Kon nie oudio-toestel \"%s\" toemaak nie."
+
+#, fuzzy, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Kon nie oudio-toestel \"%s\" toemaak nie."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Kon nie buffers vanaf toestel \"%s\" verkry nie."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -626,10 +686,6 @@ msgid "Failed to get current input on device '%s'. May be it is a radio device"
 msgstr ""
 
 #, fuzzy, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Kon nie oudio-toestel \"%s\" toemaak nie."
-
-#, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr "Kon nie genoeg buffers vanaf toestel \"%s\" kry nie."
@@ -638,39 +694,16 @@ msgstr "Kon nie genoeg buffers vanaf toestel \"%s\" kry nie."
 msgid "Failed to set output %d on device %s."
 msgstr "Kon nie oudio-toestel \"%s\" toemaak nie."
 
-#, fuzzy, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Kon nie buffers vanaf toestel \"%s\" verkry nie."
-
-#, fuzzy, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Kon nie genoeg buffers vanaf toestel \"%s\" kry nie."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Kon nie buffers vanaf toestel \"%s\" verkry nie."
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Kon nie buffers vanaf toestel \"%s\" verkry nie."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 
 msgid "Cannot operate without a clock"
 msgstr ""
 
+#, fuzzy
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Kon nie buffers vanaf toestel \"%s\" verkry nie."
+
 #~ msgid "Could not open file \"%s\" for writing."
 #~ msgstr "Kon nie lêer \"%s\" oopmaak om in te skryf nie."
 
index 26f77d9..80d6795 100644 (file)
--- a/po/az.po
+++ b/po/az.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-0.8.0\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2004-03-19 18:29+0200\n"
 "Last-Translator: Metin Amiroff <metin@karegen.com>\n"
 "Language-Team: Azerbaijani <translation-team-az@lists.sourceforge.net>\n"
@@ -17,12 +17,6 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "X-Generator: KBabel 1.0.2\n"
 
-msgid "Could not establish connection to sound server"
-msgstr ""
-
-msgid "Failed to query sound server capabilities"
-msgstr ""
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -549,13 +543,79 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "\"%s\" avadanlığından bufferlər alına bilmədi."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "\"%s\" avadanlığından bufferlər alına bilmədi."
+
+#, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+
+#, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "\"%s\" avadanlığı capture avadanlığı deyil."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "\"%s\" avadanlığı capture avadanlığı deyil."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "\"%s\" avadanlığı capture avadanlığı deyil."
+
+#, fuzzy, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "\"%s\" avadanlığından bufferlər alına bilmədi."
+
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "\"%s\" avadanlığından kifayət qədər bufferlər alına bilmədi."
+
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed after %d tries. device %s. system error: %s"
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "\"%s\" avadanlığından kifayət qədər bufferlər alına bilmədi."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "\"%s\" avadanlığından bufferlər alına bilmədi."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "\"%s\" avadanlığı capture avadanlığı deyil."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "\"%s\" audio avadanlığı bağlana bilmədi."
+
+#, fuzzy, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "\"%s\" audio avadanlığı bağlana bilmədi."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "\"%s\" avadanlığından bufferlər alına bilmədi."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -627,10 +687,6 @@ msgid "Failed to get current input on device '%s'. May be it is a radio device"
 msgstr ""
 
 #, fuzzy, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "\"%s\" audio avadanlığı bağlana bilmədi."
-
-#, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr "\"%s\" avadanlığından kifayət qədər bufferlər alına bilmədi."
@@ -639,39 +695,16 @@ msgstr "\"%s\" avadanlığından kifayət qədər bufferlər alına bilmədi."
 msgid "Failed to set output %d on device %s."
 msgstr "\"%s\" audio avadanlığı bağlana bilmədi."
 
-#, fuzzy, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "\"%s\" avadanlığından bufferlər alına bilmədi."
-
-#, fuzzy, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "\"%s\" avadanlığından kifayət qədər bufferlər alına bilmədi."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "\"%s\" avadanlığından bufferlər alına bilmədi."
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "\"%s\" avadanlığından bufferlər alına bilmədi."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 
 msgid "Cannot operate without a clock"
 msgstr ""
 
+#, fuzzy
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "\"%s\" avadanlığından bufferlər alına bilmədi."
+
 #~ msgid "Could not open file \"%s\" for writing."
 #~ msgstr "\"%s\" faylı yazma üçün açıla bilmədi."
 
index 59b85c9..5788109 100644 (file)
--- a/po/bg.po
+++ b/po/bg.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.28.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-04-26 22:35+0300\n"
 "Last-Translator: Alexander Shopov <ash@kambanaria.org>\n"
 "Language-Team: Bulgarian <dict@fsa-bg.org>\n"
@@ -18,12 +18,6 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=n != 1;\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Не може да се осъществи връзка към звуковия сървър."
-
-msgid "Failed to query sound server capabilities"
-msgstr "Неуспешно запитване за възможностите на звуковия сървър."
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -539,12 +533,80 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Грешка при прочитане %d байта от устройство „%s“."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Не могат да се получат буферите от устройството „%s“."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr "Драйверът за устройството „%s“ не поддържа познати методи за запис."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr "Драйверът за устройството „%s“ не поддържа познати методи за запис."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Устройството „%s“ не е изходно устройство."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Устройството „%s“ не е устройство за запис."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Устройството „%s“ не е устройство за запис."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Не могат да се получат параметрите на устройството „%s“."
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Устройството за видео вход не приема новите настройки за честотата на кадри."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Получена е рамка с размер %u вместо очаквания %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Грешка при прочитане на %d байта на устройство „%s“."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Неуспешен опит за получаване на видео кадрите от устройство „%s“."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Неуспех след %d опита. Устройство „%s“. Системна грешка: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Неуспешно получаване на настройките на тунер %d на устройство „%s“."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Грешка при прочитане %d байта от устройство „%s“."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Устройството „%s“ не е изходно устройство."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Неуспешно задаване на вход %d на устройство „%s“."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Неуспешно задаване на вход %d на устройство „%s“."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Неуспешно получаване на силата на сигнала на устройство „%s“."
 
 #, c-format
 msgid ""
@@ -623,10 +685,6 @@ msgstr ""
 "Неуспешно получаване на текущия вход на устройство „%s“. Може би е радио."
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Неуспешно задаване на вход %d на устройство „%s“."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -636,34 +694,6 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Неуспешно задаване на изход %d на устройство „%s“."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Буферите в устройство „%s“ не могат да се подредят в опашка."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Неуспешен опит за получаване на видео кадрите от устройство „%s“."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Неуспех след %d опита. Устройство „%s“. Системна грешка: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Не могат да се получат параметрите на устройството „%s“."
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Устройството за видео вход не приема новите настройки за честотата на кадри."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Не могат да се получат буферите от устройството „%s“."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr "Драйверът за устройството „%s“ не поддържа познати методи за запис."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 "Промяната на разделителната способност по време на работа все още не се "
@@ -671,3 +701,15 @@ msgstr ""
 
 msgid "Cannot operate without a clock"
 msgstr "Работата без часовник е невъзможна."
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Грешка при прочитане на %d байта на устройство „%s“."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Буферите в устройство „%s“ не могат да се подредят в опашка."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Не може да се осъществи връзка към звуковия сървър."
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Неуспешно запитване за възможностите на звуковия сървър."
index 4cb58a9..358561e 100644 (file)
--- a/po/ca.po
+++ b/po/ca.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.9.7\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2005-12-04 21:54+0100\n"
 "Last-Translator: Jordi Mallach <jordi@sindominio.net>\n"
 "Language-Team: Catalan <ca@dodds.net>\n"
@@ -16,12 +16,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr ""
-
-msgid "Failed to query sound server capabilities"
-msgstr ""
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -541,121 +535,156 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Got unexpected frame size of %u instead of %u."
+msgid "Failed to enumerate possible video formats device '%s' can work with"
 msgstr ""
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Could not map buffers from device '%s'"
 msgstr ""
 
 #, c-format
-msgid ""
-"Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
-"it is a v4l1 driver."
+msgid "The driver of device '%s' does not support the IO method %d"
 msgstr ""
 
 #, c-format
-msgid "Failed to query attributes of input %d in device %s"
+msgid "The driver of device '%s' does not support any known IO method."
 msgstr ""
 
 #, c-format
-msgid "Failed to get setting of tuner %d on device '%s'."
+msgid "Device '%s' does not support video capture"
 msgstr ""
 
 #, c-format
-msgid "Failed to query norm on device '%s'."
+msgid "Device '%s' cannot capture at %dx%d"
 msgstr ""
 
 #, c-format
-msgid "Failed getting controls attributes on device '%s'."
+msgid "Device '%s' cannot capture in the specified format"
 msgstr ""
 
 #, c-format
-msgid "Cannot identify device '%s'."
+msgid "Could not get parameters on device '%s'"
+msgstr ""
+
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+
+msgid "Video device could not create buffer pool."
 msgstr ""
 
 #, c-format
-msgid "This isn't a device '%s'."
+msgid "Got unexpected frame size of %u instead of %u."
 msgstr ""
 
 #, c-format
-msgid "Could not open device '%s' for reading and writing."
+msgid "Failed trying to get video frames from device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Device '%s' is not a capture device."
+msgid "Failed after %d tries. device %s. system error: %s"
 msgstr ""
 
 #, c-format
-msgid "Device '%s' is not a output device."
+msgid "Failed to get settings of tuner %d on device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to set norm for device '%s'."
+msgid "Error getting capabilities for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to get current tuner frequency for device '%s'."
+msgid "Device '%s' is not a tuner."
 msgstr ""
 
 #, c-format
-msgid "Failed to set current tuner frequency for device '%s' to %lu Hz."
+msgid "Failed to get radio input on device '%s'. "
 msgstr ""
 
 #, c-format
-msgid "Failed to get signal strength for device '%s'."
+msgid "Failed to set input %d on device %s."
 msgstr ""
 
 #, c-format
-msgid "Failed to get value for control %d on device '%s'."
+msgid "Failed to change mute state for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to set value %d for control %d on device '%s'."
+msgid ""
+"Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
+"it is a v4l1 driver."
 msgstr ""
 
 #, c-format
-msgid "Failed to get current input on device '%s'. May be it is a radio device"
+msgid "Failed to query attributes of input %d in device %s"
 msgstr ""
 
 #, c-format
-msgid "Failed to set input %d on device %s."
+msgid "Failed to get setting of tuner %d on device '%s'."
 msgstr ""
 
 #, c-format
-msgid ""
-"Failed to get current output on device '%s'. May be it is a radio device"
+msgid "Failed to query norm on device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to set output %d on device %s."
+msgid "Failed getting controls attributes on device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Could not enqueue buffers in device '%s'."
+msgid "Cannot identify device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed trying to get video frames from device '%s'."
+msgid "This isn't a device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
+msgid "Could not open device '%s' for reading and writing."
 msgstr ""
 
 #, c-format
-msgid "Could not get parameters on device '%s'"
+msgid "Device '%s' is not a capture device."
+msgstr ""
+
+#, c-format
+msgid "Device '%s' is not a output device."
 msgstr ""
 
-msgid "Video input device did not accept new frame rate setting."
+#, c-format
+msgid "Failed to set norm for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Could not map buffers from device '%s'"
+msgid "Failed to get current tuner frequency for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "The driver of device '%s' does not support any known capture method."
+msgid "Failed to set current tuner frequency for device '%s' to %lu Hz."
+msgstr ""
+
+#, c-format
+msgid "Failed to get signal strength for device '%s'."
+msgstr ""
+
+#, c-format
+msgid "Failed to get value for control %d on device '%s'."
+msgstr ""
+
+#, c-format
+msgid "Failed to set value %d for control %d on device '%s'."
+msgstr ""
+
+#, c-format
+msgid "Failed to get current input on device '%s'. May be it is a radio device"
+msgstr ""
+
+#, c-format
+msgid ""
+"Failed to get current output on device '%s'. May be it is a radio device"
+msgstr ""
+
+#, c-format
+msgid "Failed to set output %d on device %s."
 msgstr ""
 
 msgid "Changing resolution at runtime is not yet supported."
index 9a92b87..a83055f 100644 (file)
--- a/po/cs.po
+++ b/po/cs.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good-0.10.26.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-01-12 23:07+0100\n"
 "Last-Translator: Petr Kovar <pknbe@volny.cz>\n"
 "Language-Team: Czech <translation-team-cs@lists.sourceforge.net>\n"
@@ -19,12 +19,6 @@ msgstr ""
 "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
 "X-Generator: Lokalize 1.1\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Nezdařilo se navázání spojení se zvukovým serverem"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Nezdařil se dotaz na schopnosti zvukového serveru"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -543,13 +537,80 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Chyba při čtení %d bajtů na zařízení \"%s\"."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Nezdařilo se mapování vyrovnávací paměti ze zařízení \"%s\""
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr "Ovladač zařízení \"%s\" nepodporuje žádnou známou záznamovou metodu."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr "Ovladač zařízení \"%s\" nepodporuje žádnou známou záznamovou metodu."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Zařízení \"%s\" není výstupním zařízením."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Zařízení \"%s\" není záznamovým zařízením."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Zařízení \"%s\" není záznamovým zařízením."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Nezdařilo se zjištění parametrů na zařízení \"%s\""
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "Vstupní videozařízení nepřijalo nové nastavení vzorkovací frekvence."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Získána neočekávaná velikost snímku %u namísto %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Nezdařil se pokus o získání videosnímků ze zařízení \"%s\"."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Selhání po %d pokusech. Zařízení %s. Systémová chyba: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Selhalo zjištění nastavení tuneru %d na zařízení \"%s\"."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Chyba při čtení %d bajtů na zařízení \"%s\"."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Zařízení \"%s\" není výstupním zařízením."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Nezdařilo se nastavení vstupu \"%d\" na zařízení \"%s\"."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Nezdařilo se nastavení vstupu \"%d\" na zařízení \"%s\"."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Nezdařilo se zjištění síly signálu u zařízení \"%s\"."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -629,10 +690,6 @@ msgstr ""
 "radiopřijímač."
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Nezdařilo se nastavení vstupu \"%d\" na zařízení \"%s\"."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -643,35 +700,20 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Nezdařilo se nastavení výstupu %d na zařízení %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Nezdařilo se zařazení vyrovnávací paměti na zařízení \"%s\"."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Nezdařil se pokus o získání videosnímků ze zařízení \"%s\"."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Selhání po %d pokusech. Zařízení %s. Systémová chyba: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Nezdařilo se zjištění parametrů na zařízení \"%s\""
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "Vstupní videozařízení nepřijalo nové nastavení vzorkovací frekvence."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Nezdařilo se mapování vyrovnávací paměti ze zařízení \"%s\""
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr "Ovladač zařízení \"%s\" nepodporuje žádnou známou záznamovou metodu."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Změna rozlišení za běhu doposud není podporována."
 
 msgid "Cannot operate without a clock"
 msgstr "Není možné fungovat bez hodin"
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Chyba při čtení %d bajtů na zařízení \"%s\"."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Nezdařilo se zařazení vyrovnávací paměti na zařízení \"%s\"."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Nezdařilo se navázání spojení se zvukovým serverem"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Nezdařil se dotaz na schopnosti zvukového serveru"
index 1ee58b3..7a22a4b 100644 (file)
--- a/po/da.po
+++ b/po/da.po
@@ -12,7 +12,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good-0.10.26.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-01-07 23:54+0200\n"
 "Last-Translator: Joe Hansen <joedalton2@yahoo.dk>\n"
 "Language-Team: Danish <dansk@dansk-gruppen.dk>\n"
@@ -21,12 +21,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Kunne ikke skabe kontakt til lyd-serveren"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Listning af lydservers egenskaber fejlede"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -550,6 +544,46 @@ msgstr "Hovedtelefon"
 msgid "Error reading %d bytes from device '%s'."
 msgstr "Fejl ved læsning af %d byte på enhed '%s'."
 
+#, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Kunne ikke afbilde mellemlager fra enhed '%s'"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr "Driveren til enhed '%s' understøtter ingen kendt optagemetode."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr "Driveren til enhed '%s' understøtter ingen kendt optagemetode."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Enhed '%s' er ikke en uddataenhed."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Enhed '%s' er ikke en optageenhed."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Enhed '%s' er ikke en optageenhed."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Kunne ikke hente parametre fra enhed '%s'"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Enheden til videoinddata accepterede ikke ny indstilling for billedrate."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
 # Er rammestørrelse ikke mere passende? Jeg er dog ikke helt sikker på
 # konteksten her. 
 #, c-format
@@ -557,9 +591,37 @@ msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Fik uventet billedstørrelse på %u i steden for %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Forsøg på at hente videorammer fra enhed '%s' mislykkedes."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Fejlede efter %d forsøg. enhed %s. systemfejl: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Hentning af indstillinger for tuner %d på enhed '%s' fejlede."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Fejl ved læsning af %d byte på enhed '%s'."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Enhed '%s' er ikke en uddataenhed."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Kunne ikke sætte inddata %d for enhed %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Kunne ikke sætte inddata %d for enhed %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Kunne ikke hente signalstyrke for enhed '%s'."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -634,10 +696,6 @@ msgstr ""
 "Kunne ikke hente nuværende inddata for enhed '%s'. Måske er det en radioenhed"
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Kunne ikke sætte inddata %d for enhed %s."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -647,36 +705,20 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Kunne ikke sætte uddata %d for enhed %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Kunne ikke sætte mellemlager fra enhed '%s' i kø."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Forsøg på at hente videorammer fra enhed '%s' mislykkedes."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Fejlede efter %d forsøg. enhed %s. systemfejl: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Kunne ikke hente parametre fra enhed '%s'"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Enheden til videoinddata accepterede ikke ny indstilling for billedrate."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Kunne ikke afbilde mellemlager fra enhed '%s'"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr "Driveren til enhed '%s' understøtter ingen kendt optagemetode."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Ændring af opløsning under kørsel er endnu ikke understøttet."
 
 msgid "Cannot operate without a clock"
 msgstr "Kan ikke fungere uden et ur"
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Fejl ved læsning af %d byte på enhed '%s'."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Kunne ikke sætte mellemlager fra enhed '%s' i kø."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Kunne ikke skabe kontakt til lyd-serveren"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Listning af lydservers egenskaber fejlede"
index d02c6d9..f17a5a4 100644 (file)
--- a/po/de.po
+++ b/po/de.po
@@ -14,7 +14,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.26.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-01-21 22:36+0100\n"
 "Last-Translator: Christian Kirbach <christian.kirbach@googlemail.com>\n"
 "Language-Team: German <translation-team-de@lists.sourceforge.net>\n"
@@ -26,12 +26,6 @@ msgstr ""
 "X-Poedit-Country: GERMANY\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Es konnte keine Verbindung zum Audio-Server hergestellt werden"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Abfrage der Fähigkeiten des Audio-Servers ist fehlgeschlagen"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -555,14 +549,89 @@ msgstr "Kopfhörer"
 msgid "Error reading %d bytes from device '%s'."
 msgstr "Fehler beim Lesen von %d Bytes von Gerät »%s«."
 
+#, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+"Aufzählen möglicher Videoformate, mit denen Gerät »%s« arbeiten kann, schlug "
+"fehl"
+
+# »Geholt« ist auch noch nicht optimal, aber »abgebildet« geht auch nicht wirklich.
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Die Puffer des Gerätes »%s« konnten nicht geholt werden."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Der Treiber von Gerät »%s« unterstützt keine der bekannten Aufnahmemethoden."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Der Treiber von Gerät »%s« unterstützt keine der bekannten Aufnahmemethoden."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "»%s« ist kein Wiedergabegerät."
+
+#, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Das Gerät »%s« kann nicht bei %dx%d aufnehmen"
+
+#, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Das angegebene Format kann nicht vom Gerät »%s« ausgelesen werden"
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Parameter konnten nicht von Gerät »%s« ausgelesen werden"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Vom Video-Eingabegerät wurde die Einstellung zur Bildwiederholungsrate nicht "
+"akzeptiert."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
 # »Frame« sollten wir im Zusammenhang mit Videos vielleicht besser so belassen. Habe ich in gnome-subtitles auch so gemacht.
 #, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Unerwartete Frame-Größe von %u anstatt %u wurde erhalten."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Fehler beim Lesen von %d Bytes auf Gerät »%s«."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Der Versuch Videobilder von Gerät »%s« auszulesen schlug fehl."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "%d Versuche sind fehlgeschlagen. Gerät »%s«. Systemfehler: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr ""
+"Auslesen der Einstellungen der Senderwahl »%d« auf Gerät »%s« schlug fehl."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Fehler beim Lesen von %d Bytes von Gerät »%s«."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "»%s« ist kein Wiedergabegerät."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Festlegen der Eingabe »%d« des Geräts »%s« schlug fehl."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Festlegen der Eingabe »%d« des Geräts »%s« schlug fehl."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Auslesen der aktuellen Signalstärke des Geräts »%s« schlug fehl."
 
 #, c-format
 msgid ""
@@ -642,10 +711,6 @@ msgstr ""
 "Auslesen der aktuellen Eingabe auf dem Gerät »%s« schlug fehl. Vielleicht "
 "ist es ein Funkgerät."
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Festlegen der Eingabe »%d« des Geräts »%s« schlug fehl."
-
 # Sendegerät sicherlich nicht, eben eher ein Radio. Warum diese Fehlermeldung beie einem Radiogerät kommen könnte, weiß ich allerdings auch nicht.
 #, c-format
 msgid ""
@@ -658,37 +723,6 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Festlegen der Ausgabe »%d« des Geräts »%s« schlug fehl."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Auf Gerät »%s« konnten keine Puffer eingereiht werden."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Der Versuch Videobilder von Gerät »%s« auszulesen schlug fehl."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "%d Versuche sind fehlgeschlagen. Gerät »%s«. Systemfehler: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Parameter konnten nicht von Gerät »%s« ausgelesen werden"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Vom Video-Eingabegerät wurde die Einstellung zur Bildwiederholungsrate nicht "
-"akzeptiert."
-
-# »Geholt« ist auch noch nicht optimal, aber »abgebildet« geht auch nicht wirklich.
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Die Puffer des Gerätes »%s« konnten nicht geholt werden."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Der Treiber von Gerät »%s« unterstützt keine der bekannten Aufnahmemethoden."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Ein Wechsel der Auflösung zur Laufzeit wird noch nicht unterstützt."
 
@@ -696,10 +730,17 @@ msgstr "Ein Wechsel der Auflösung zur Laufzeit wird noch nicht unterstützt."
 msgid "Cannot operate without a clock"
 msgstr "Es kann nicht ohne einen Taktgeber gearbeitet werden."
 
-#~ msgid "Failed to enumerate possible video formats device '%s' can work with"
-#~ msgstr ""
-#~ "Aufzählen möglicher Videoformate, mit denen Gerät »%s« arbeiten kann, "
-#~ "schlug fehl"
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Fehler beim Lesen von %d Bytes auf Gerät »%s«."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Auf Gerät »%s« konnten keine Puffer eingereiht werden."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Es konnte keine Verbindung zum Audio-Server hergestellt werden"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Abfrage der Fähigkeiten des Audio-Servers ist fehlgeschlagen"
 
 #~ msgid ""
 #~ "The buffer type is not supported, or the index is out of bounds, or no "
@@ -726,12 +767,6 @@ msgstr "Es kann nicht ohne einen Taktgeber gearbeitet werden."
 #~ msgid "No free buffers found in the pool at index %d."
 #~ msgstr "Es wurden keine freien Puffer im Vorrat bei Index %d gefunden."
 
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "Das Gerät »%s« kann nicht bei %dx%d aufnehmen"
-
-#~ msgid "Device '%s' cannot capture in the specified format"
-#~ msgstr "Das angegebene Format kann nicht vom Gerät »%s« ausgelesen werden"
-
 #~ msgid "Could not get buffers from device '%s'."
 #~ msgstr "Die Puffer konnten nicht von Gerät »%s« ausgelesen werden."
 
index 666c90b..24f4d34 100644 (file)
--- a/po/el.po
+++ b/po/el.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.25.3\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2010-10-27 12:16+0200\n"
 "Last-Translator: Michael Kotsarinis <mk73628@gmail.com>\n"
 "Language-Team: Greek <team@lists.gnome.gr>\n"
@@ -18,12 +18,6 @@ msgstr ""
 "X-Generator: Lokalize 0.3\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Δεν ήταν δυνατή η σύνδεση με τον διακομιστή ήχου"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Αποτυχία αναζήτησης των δυνατοτήτων του διακομιστή ήχου"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -545,12 +539,79 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Σφάλμα κατά την ανάγνωση %d bytes απο την συσκευή '%s'."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Αδυναμία χαρτογράφησης buffer για τη συσκευή '%s'"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr "Ο οδηγός της συσκευής '%s' δεν υποστηρίζει κάποια γνωστή μέθοδο λήψης."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr "Ο οδηγός της συσκευής '%s' δεν υποστηρίζει κάποια γνωστή μέθοδο λήψης."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Η συσκευή '%s' δεν είναι συσκευή εξόδου."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Η συσκευή '%s' δεν είναι μια συσκευή λήψης."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Η συσκευή '%s' δεν είναι μια συσκευή λήψης."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Δεν ήταν δυνατή η ανάγνωση των παραμέτρων στην συσκευή '%s'"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "Η συσκευή εισόδου βίντεο δεν αποδέχθηκε τη νέα ρύθμιση ταχύτητας καρέ."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Απροσδόκητο μέγεθος πλαισίου από %u αντί του %u"
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Σφάλμα κατά την ανάγνωση %d bytes στην συσκευή '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Αποτυχία ανάγνωσης πλαισίων βίντεο από την συσκευή '%s'."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Αποτυχία έπειτα από %d προσπάθειες. συσκευή %s. σφάλμα συστήματος: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Αποτυχία ανάγνωσης των ρυθμίσεων δέκτη %d στην συσκευή '%s'."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Σφάλμα κατά την ανάγνωση %d bytes απο την συσκευή '%s'."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Η συσκευή '%s' δεν είναι συσκευή εξόδου."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Αποτυχία ρύθμισης εισαγωγής %d στην συσκευή %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Αποτυχία ρύθμισης εισαγωγής %d στην συσκευή %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Αποτυχία ανάγνωσης ισχύς σήματος για την συσκευή '%s'."
 
 #, c-format
 msgid ""
@@ -630,10 +691,6 @@ msgstr ""
 "Αποτυχία ανάγνωσης της τρέχουσας εισαγωγής στην συσκευή '%s'. Πιθανόν να "
 "είναι μια συσκευή ράδιο"
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Αποτυχία ρύθμισης εισαγωγής %d στην συσκευή %s."
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -645,33 +702,6 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Αποτυχία ρύθμισης εισαγωγής %d στην συσκευή %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Αδυναμία θέσης σε σειρά των buffer στη συσκευή '%s'."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Αποτυχία ανάγνωσης πλαισίων βίντεο από την συσκευή '%s'."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Αποτυχία έπειτα από %d προσπάθειες. συσκευή %s. σφάλμα συστήματος: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Δεν ήταν δυνατή η ανάγνωση των παραμέτρων στην συσκευή '%s'"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "Η συσκευή εισόδου βίντεο δεν αποδέχθηκε τη νέα ρύθμιση ταχύτητας καρέ."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Αδυναμία χαρτογράφησης buffer για τη συσκευή '%s'"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr "Ο οδηγός της συσκευής '%s' δεν υποστηρίζει κάποια γνωστή μέθοδο λήψης."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 "Η αλλαγή της ανάλυσης κατά τη διάρκεια λειτουργίας δεν υποστηρίζεται ακόμα."
@@ -679,6 +709,18 @@ msgstr ""
 msgid "Cannot operate without a clock"
 msgstr "Δεν είναι δυνατή η λειτουργία χωρίς ρολόι "
 
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Σφάλμα κατά την ανάγνωση %d bytes στην συσκευή '%s'."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Αδυναμία θέσης σε σειρά των buffer στη συσκευή '%s'."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Δεν ήταν δυνατή η σύνδεση με τον διακομιστή ήχου"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Αποτυχία αναζήτησης των δυνατοτήτων του διακομιστή ήχου"
+
 #~ msgid "Describes the selected input element."
 #~ msgstr "Περιγράφει το επιλεγμένο στοιχείο εισαγωγής."
 
index 2568d35..ee12a7a 100644 (file)
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins 0.8.1\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2004-04-26 10:41-0400\n"
 "Last-Translator: Gareth Owen <gowen72@yahoo.com>\n"
 "Language-Team: English (British) <en_gb@li.org>\n"
@@ -15,12 +15,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr ""
-
-msgid "Failed to query sound server capabilities"
-msgstr ""
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -548,13 +542,79 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Could not get buffers from device \"%s\"."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Could not get buffers from device \"%s\"."
+
+#, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+
+#, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Device \"%s\" is not a capture device."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Device \"%s\" is not a capture device."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Device \"%s\" is not a capture device."
+
+#, fuzzy, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Could not get buffers from device \"%s\"."
+
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Could not get enough buffers from device \"%s\"."
+
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed after %d tries. device %s. system error: %s"
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Could not get enough buffers from device \"%s\"."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Could not get buffers from device \"%s\"."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Device \"%s\" is not a capture device."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Could not close audio device \"%s\"."
+
+#, fuzzy, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Could not close audio device \"%s\"."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Could not get buffers from device \"%s\"."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -626,10 +686,6 @@ msgid "Failed to get current input on device '%s'. May be it is a radio device"
 msgstr ""
 
 #, fuzzy, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Could not close audio device \"%s\"."
-
-#, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr "Could not get enough buffers from device \"%s\"."
@@ -638,39 +694,16 @@ msgstr "Could not get enough buffers from device \"%s\"."
 msgid "Failed to set output %d on device %s."
 msgstr "Could not close audio device \"%s\"."
 
-#, fuzzy, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Could not get buffers from device \"%s\"."
-
-#, fuzzy, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Could not get enough buffers from device \"%s\"."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Could not get buffers from device \"%s\"."
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Could not get buffers from device \"%s\"."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 
 msgid "Cannot operate without a clock"
 msgstr ""
 
+#, fuzzy
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Could not get buffers from device \"%s\"."
+
 #~ msgid "Could not open file \"%s\" for writing."
 #~ msgstr "Could not open file \"%s\" for writing."
 
index 2a66fc9..ababb98 100644 (file)
--- a/po/es.po
+++ b/po/es.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.26.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-02-12 18:30+0100\n"
 "Last-Translator: Jorge González González <aloriel@gmail.com>\n"
 "Language-Team: Spanish <es@li.org>\n"
@@ -18,12 +18,6 @@ msgstr ""
 "X-Generator: KBabel 1.11.4\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "No se pudo establecer la conexión con el servidor de sonido"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Falló al preguntar al servidor de sonido sus capacidades"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -548,13 +542,89 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Error al leer %d bytes del dispositivo «%s»."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+"Falló al enumerar los posibles formatos de vídeo con los que el dispositivo "
+"«%s» puede trabajar"
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "No se pudieron mapear los búferes del dispositivo «%s»"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"El controlador del dispositivo «%s» no soporta ningún método de captura "
+"conocido."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"El controlador del dispositivo «%s» no soporta ningún método de captura "
+"conocido."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "El dispositivo «%s» no es un dispositivo de salida."
+
+#, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "El dispositivo «%s» no puede capturar a %dx%d"
+
+#, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "El dispositivo «%s» no puede capturar en el formato especificado"
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "No se pudieron obtener los parámetros para el dispositivo «%s»"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"El dispositivo de entrada de vídeo no aceptó el ajuste de la nueva tasa de "
+"fotogramas."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Se obtuvo un tamaño de cuadro inesperado %u en lugar de %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Falló al intentar obtener cuadros de vídeo del dispositivo «%s»."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Falló después de %d intentos. Dispositivo %s. Error del sistema: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr ""
+"Falló al obtener la posición del sintonizador %d en el dispositivo «%s»."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Error al leer %d bytes del dispositivo «%s»."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "El dispositivo «%s» no es un dispositivo de salida."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Falló al establecer la entrada %d en el dispositivo %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Falló al establecer la entrada %d en el dispositivo %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Falló al obtener la potencia de la señal para el dispositivo «%s»."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -636,10 +706,6 @@ msgstr ""
 "dispositivo de radio."
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Falló al establecer la entrada %d en el dispositivo %s."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -650,47 +716,23 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Falló al establecer la salida %d en el dispositivo %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "No se pueden encolar los búferes en el dispositivo «%s»."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Falló al intentar obtener cuadros de vídeo del dispositivo «%s»."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Falló después de %d intentos. Dispositivo %s. Error del sistema: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "No se pudieron obtener los parámetros para el dispositivo «%s»"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"El dispositivo de entrada de vídeo no aceptó el ajuste de la nueva tasa de "
-"fotogramas."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "No se pudieron mapear los búferes del dispositivo «%s»"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"El controlador del dispositivo «%s» no soporta ningún método de captura "
-"conocido."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "El cambio de resolución durante la reproducción aún no está soportado."
 
 msgid "Cannot operate without a clock"
 msgstr "No se puede operar sin reloj"
 
-#~ msgid "Failed to enumerate possible video formats device '%s' can work with"
-#~ msgstr ""
-#~ "Falló al enumerar los posibles formatos de vídeo con los que el "
-#~ "dispositivo «%s» puede trabajar"
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Error al leer %d bytes del dispositivo «%s»."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "No se pueden encolar los búferes en el dispositivo «%s»."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "No se pudo establecer la conexión con el servidor de sonido"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Falló al preguntar al servidor de sonido sus capacidades"
 
 #~ msgid ""
 #~ "The buffer type is not supported, or the index is out of bounds, or no "
@@ -715,12 +757,6 @@ msgstr "No se puede operar sin reloj"
 #~ msgid "No free buffers found in the pool at index %d."
 #~ msgstr "No se encontraron búferes libres en el índice %d del «pool»."
 
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "El dispositivo «%s» no puede capturar a %dx%d"
-
-#~ msgid "Device '%s' cannot capture in the specified format"
-#~ msgstr "El dispositivo «%s» no puede capturar en el formato especificado"
-
 #~ msgid "Could not get buffers from device '%s'."
 #~ msgstr "No se pudieron obtener búferes del dispositivo «%s»."
 
index 710d817..7f9569e 100644 (file)
--- a/po/eu.po
+++ b/po/eu.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good-0.10.18.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2010-03-25 12:37+0100\n"
 "Last-Translator: Mikel Olasagasti Uranga <hey_neken@mundurat.net>\n"
 "Language-Team: Basque <translation-team-eu@lists.sourceforge.net>\n"
@@ -19,12 +19,6 @@ msgstr ""
 "X-Generator: KBabel 1.11.4\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Ezin izan da konexioa ezarri soinu-zerbitzariarekin"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Huts egin du soinu-zerbitzariaren ahalmena kontsultatzean"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -547,13 +541,85 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Errorea gertatu da '%2$s' gailuan %1$d byte irakurtzean."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Ezin izan dira '%s' gailuaren bufferrak mapatu."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"'%s' gailuaren kontrolatzaileak ez du onartzen kaptura-metodo ezagunik."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"'%s' gailuaren kontrolatzaileak ez du onartzen kaptura-metodo ezagunik."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "'%s' gailua ez da irteerako gailu bat."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "'%s' gailua ez da kaptura-gailu bat."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "'%s' gailua ez da kaptura-gailu bat."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Ezin izan dira '%s' gailuaren parametroak eskuratu"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Bideoaren sarrerako gailuak ez du fotograma-tamainaren ezarpen berria "
+"onartzen."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Ustekabeko fotograma-tamaina jaso da (%u), %u ordez."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Huts egin du '%s' gailutik bideo-fotogramak eskuratzen saiatzean."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Huts egin du %d saio eta gero. %s gailua. Sistema-errorea: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr ""
+"Huts egin du '%2$s' gailuko %1$d. sintonizadorearen ezarpenak eskuratzean."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Errorea gertatu da '%2$s' gailuan %1$d byte irakurtzean."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "'%s' gailua ez da irteerako gailu bat."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Huts egin du '%2$s' gailuko %1$d. sarrera ezartzean."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Huts egin du '%2$s' gailuko %1$d. sarrera ezartzean."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Huts egin du '%s' gailuaren seinalearen indarra eskuratzean."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -633,10 +699,6 @@ msgstr ""
 "Huts egin du '%s' gailuko uneko sarrera eskuratzean. Litekeena da irrati-"
 "gailu bat izatea."
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Huts egin du '%2$s' gailuko %1$d. sarrera ezartzean."
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -648,42 +710,24 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Huts egin du '%2$s' gailuko %1$d. sarrera ezartzean."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Ezin izan dira bufferrak ilaran jarri '%s' gailuan."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Huts egin du '%s' gailutik bideo-fotogramak eskuratzen saiatzean."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Huts egin du %d saio eta gero. %s gailua. Sistema-errorea: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Ezin izan dira '%s' gailuaren parametroak eskuratu"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Bideoaren sarrerako gailuak ez du fotograma-tamainaren ezarpen berria "
-"onartzen."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Ezin izan dira '%s' gailuaren bufferrak mapatu."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"'%s' gailuaren kontrolatzaileak ez du onartzen kaptura-metodo ezagunik."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Oraindik ez dago onartua exekutatu bitartean bereizmena aldatzea."
 
 msgid "Cannot operate without a clock"
 msgstr "Ezin du funtzionatu erlojurik gabe"
 
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Errorea gertatu da '%2$s' gailuan %1$d byte irakurtzean."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Ezin izan dira bufferrak ilaran jarri '%s' gailuan."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Ezin izan da konexioa ezarri soinu-zerbitzariarekin"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Huts egin du soinu-zerbitzariaren ahalmena kontsultatzean"
+
 #~ msgid "Describes the selected input element."
 #~ msgstr "Sarrerako elementu hautatua deskribatzen du."
 
index ff809c5..b52c34c 100644 (file)
--- a/po/fi.po
+++ b/po/fi.po
@@ -11,7 +11,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.25.3\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2010-11-17 23:03+0200\n"
 "Last-Translator: Tommi Vainikainen <Tommi.Vainikainen@iki.fi>\n"
 "Language-Team: Finnish <translation-team-fi@lists.sourceforge.net>\n"
@@ -21,12 +21,6 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Yhteyttä äänipalvelimeen ei voitu avata"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Äänipalvelimen ominaisuuksia ei voitu selvittää"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -546,13 +540,80 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Virhe luettaessa %d tavua laitteelta ”%s”."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Puskereita laitteelta ”%s” ei voitu kartoittaa"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr "Laitteen ”%s” ajuri ei tue mitään tunnettua kaappaustapaa."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr "Laitteen ”%s” ajuri ei tue mitään tunnettua kaappaustapaa."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Laite ”%s” ei ole ulostulolaite."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Laitteelta ”%s” ei voi kaapata."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Laitteelta ”%s” ei voi kaapata."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Laitteelta ”%s” ei voitu saada parametreja"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "Videosyötelaite ei hyväksy uutta kehysnopeusasetusta."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Saatiin odottamaton kehys kooltaan %u odotetun %u sijaan."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Videoruutujen noutaminen laitteelta ”%s” epäonnistui."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Epäonnistui %d yrityksen jälkeen: laite %s, järjestelmävirhe: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Virittimen %d asetuksia ei voitu lukea laitteelta ”%s”."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Virhe luettaessa %d tavua laitteelta ”%s”."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Laite ”%s” ei ole ulostulolaite."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Sisääntuloa %d ei voitu asettaa laitteelle %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Sisääntuloa %d ei voitu asettaa laitteelle %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Laitteelta ”%s” ei saatu signaalinvoimakkuutta."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -627,10 +688,6 @@ msgstr ""
 "Laitteen ”%s” tämänhetkistä sisääntuloa ei voitu lukea, se ei ehkä ole "
 "radiolaite"
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Sisääntuloa %d ei voitu asettaa laitteelle %s."
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -642,39 +699,24 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Sisääntuloa %d ei voitu asettaa laitteelle %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Puskureita ei voitu laittaa jonoon laitteella ”%s”."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Videoruutujen noutaminen laitteelta ”%s” epäonnistui."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Epäonnistui %d yrityksen jälkeen: laite %s, järjestelmävirhe: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Laitteelta ”%s” ei voitu saada parametreja"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "Videosyötelaite ei hyväksy uutta kehysnopeusasetusta."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Puskereita laitteelta ”%s” ei voitu kartoittaa"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr "Laitteen ”%s” ajuri ei tue mitään tunnettua kaappaustapaa."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Resoluution vaihto käytön aikana ei ole vielä mahdollista."
 
 msgid "Cannot operate without a clock"
 msgstr "Ei voitu toimia ilman kelloa"
 
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Virhe luettaessa %d tavua laitteelta ”%s”."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Puskureita ei voitu laittaa jonoon laitteella ”%s”."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Yhteyttä äänipalvelimeen ei voitu avata"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Äänipalvelimen ominaisuuksia ei voitu selvittää"
+
 #~ msgid ""
 #~ "The buffer type is not supported, or the index is out of bounds, or no "
 #~ "buffers have been allocated yet, or the userptr or length are invalid. "
index c3a6013..4c025d6 100644 (file)
--- a/po/fr.po
+++ b/po/fr.po
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.28.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-04-28 09:22+0200\n"
 "Last-Translator: Claude Paroz <claude@2xlibre.net>\n"
 "Language-Team: French <traduc@traduc.org>\n"
@@ -18,13 +18,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Impossible d'établir une connexion vers le serveur de son"
-
-msgid "Failed to query sound server capabilities"
-msgstr ""
-"Échec lors de l'interrogation du serveur de son au sujet de ses capacités"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -549,13 +542,87 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Erreur de lecture de %d octets sur le périphérique « %s »."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Impossible de mapper les tampons du périphérique « %s »."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Le pilote du périphérique « %s » ne prend en charge aucune méthode "
+"d'enregistrement connue."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Le pilote du périphérique « %s » ne prend en charge aucune méthode "
+"d'enregistrement connue."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Le périphérique « %s » n'est pas un périphérique de sortie."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Le périphérique « %s » n'est pas un périphérique d'enregistrement."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Le périphérique « %s » n'est pas un périphérique d'enregistrement."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Impossible d'obtenir les paramètres du périphérique « %s »"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Le périphérique d'entrée vidéo n'a pas accepté le nouveau paramètre de "
+"fréquence d'image."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Taille de trame imprévue de %u à la place de %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "L'obtention de trames vidéo du périphérique « %s » a échoué."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Échec après %d tentatives. périphérique %s. erreur système : %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr ""
+"Impossible d'obtenir les paramètres du syntoniseur %d du périphérique « %s »."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Erreur de lecture de %d octets sur le périphérique « %s »."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Le périphérique « %s » n'est pas un périphérique de sortie."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Impossible de définir l'entrée %d du périphérique %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Impossible de définir l'entrée %d du périphérique %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Impossible d'obtenir la force du signal du périphérique « %s »."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -637,10 +704,6 @@ msgstr ""
 "être un périphérique radio"
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Impossible de définir l'entrée %d du périphérique %s."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -651,39 +714,6 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Impossible de définir la sortie %d du périphérique %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr ""
-"Impossible de mettre les tampons en file d'attente sur le périphérique "
-"« %s »."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "L'obtention de trames vidéo du périphérique « %s » a échoué."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Échec après %d tentatives. périphérique %s. erreur système : %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Impossible d'obtenir les paramètres du périphérique « %s »"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Le périphérique d'entrée vidéo n'a pas accepté le nouveau paramètre de "
-"fréquence d'image."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Impossible de mapper les tampons du périphérique « %s »."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Le pilote du périphérique « %s » ne prend en charge aucune méthode "
-"d'enregistrement connue."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 "La modification de résolution en cours d'exécution n'est pas encore prise en "
@@ -691,3 +721,18 @@ msgstr ""
 
 msgid "Cannot operate without a clock"
 msgstr "Impossible de fonctionner sans horloge"
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Erreur de lecture de %d octets sur le périphérique « %s »."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr ""
+#~ "Impossible de mettre les tampons en file d'attente sur le périphérique "
+#~ "« %s »."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Impossible d'établir une connexion vers le serveur de son"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr ""
+#~ "Échec lors de l'interrogation du serveur de son au sujet de ses capacités"
index c8f52a6..4884096 100644 (file)
--- a/po/gl.po
+++ b/po/gl.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.26.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-01-09 21:20+0100\n"
 "Last-Translator: Fran Diéguez <frandieguez@ubuntu.com>\n"
 "Language-Team: Galician <proxecto@trasno.net>\n"
@@ -17,12 +17,6 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n!=1);\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Non foi posíbel estabelecer a conexión co servidor de son"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Produciuse un erro ao consultar as capacidades do servidor de son"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -545,12 +539,90 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Produciuse un erro ao ler %d bytes desde o dispositivo «%s»."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Non foi posíbel mapear os búferes do dispositivo «%s»"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"O controlador do dispositivo «%s» non admite ningún método de captura "
+"coñecido."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"O controlador do dispositivo «%s» non admite ningún método de captura "
+"coñecido."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "O dispositivo «%s» non é un dispositivo de captura."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "O dispositivo «%s» non é un dispositivo de captura."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "O dispositivo «%s» non é un dispositivo de captura."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Non foi posíbel obter os parámetros para o dispositivo «%s»"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"O dispositivo de entrada de vídeo non aceptou o axuste da nova taxa de "
+"fotogramas."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Obtívose un tamaño de marco de %u non esperado no lugar de %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Produciuse un erro ao ler %d bytes do dispositivo «%s»."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr ""
+"Produciuse un fallo ao tentar obter cadros de vídeo do dispositivo «%s»."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr ""
+"Prouciuse un fallo despois de %d intentos. Dispositivo %s. Error do sistema: "
+"%s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr ""
+"Produciuse un erro ao configurar o sintonizador %d no dispositivo «%s»."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Produciuse un erro ao ler %d bytes desde o dispositivo «%s»."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "O dispositivo «%s» non é un dispositivo de captura."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Produciuse un fallo ao estabelecer a entrada %d no dispositivo %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Produciuse un fallo ao estabelecer a entrada %d no dispositivo %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr ""
+"Produciuse un erro ao obter a potencia do sinal para o dispositivo «%s»."
 
 #, c-format
 msgid ""
@@ -638,10 +710,6 @@ msgstr ""
 "sexa un dispositivo de radio."
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Produciuse un fallo ao estabelecer a entrada %d no dispositivo %s."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -652,46 +720,24 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Produciuse un fallo ao estabelecer a saída %d no dispositivo %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Non é posíbel meter na cola os búferes no dispositivo «%s»."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr ""
-"Produciuse un fallo ao tentar obter cadros de vídeo do dispositivo «%s»."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr ""
-"Prouciuse un fallo despois de %d intentos. Dispositivo %s. Error do sistema: "
-"%s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Non foi posíbel obter os parámetros para o dispositivo «%s»"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"O dispositivo de entrada de vídeo non aceptou o axuste da nova taxa de "
-"fotogramas."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Non foi posíbel mapear os búferes do dispositivo «%s»"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"O controlador do dispositivo «%s» non admite ningún método de captura "
-"coñecido."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Aínda non se admite o cambio de resolución durante a reprodución."
 
 msgid "Cannot operate without a clock"
 msgstr "Non é posíbel operar sen reloxo"
 
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Produciuse un erro ao ler %d bytes do dispositivo «%s»."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Non é posíbel meter na cola os búferes no dispositivo «%s»."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Non foi posíbel estabelecer a conexión co servidor de son"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Produciuse un erro ao consultar as capacidades do servidor de son"
+
 #~ msgid "Describes the selected input element."
 #~ msgstr "Describe o elemento de entrada seleccionado."
 
index 10ca581..de8764b 100644 (file)
--- a/po/hu.po
+++ b/po/hu.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.25.3\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2010-11-04 01:21+0100\n"
 "Last-Translator: Gabor Kelemen <kelemeng@gnome.hu>\n"
 "Language-Team: Hungarian <translation-team-hu@lists.sourceforge.net>\n"
@@ -21,12 +21,6 @@ msgstr ""
 "X-Rosetta-Export-Date: 2007-07-27 19:18:15+0000\n"
 "Plural-Forms:  nplurals=2; plural=(n != 1);\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Nem hozható létre kapcsolat a hangkiszolgálóhoz"
-
-msgid "Failed to query sound server capabilities"
-msgstr "A hangkiszolgáló képességeinek lekérdezése meghiúsult"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -545,13 +539,85 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Hiba %d bájt olvasásakor a következő eszközről: „%s”."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Nem képezhetők le a(z) „%s” eszköz pufferei"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"A(z) „%s” eszköz illesztőprogramja nem támogat egyetlen ismert felvételi "
+"módot sem."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"A(z) „%s” eszköz illesztőprogramja nem támogat egyetlen ismert felvételi "
+"módot sem."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "A(z) „%s” eszköz nem kimeneti eszköz."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "A(z) „%s” eszköz nem rögzítőeszköz."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "A(z) „%s” eszköz nem rögzítőeszköz."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Nem kérhetők le a(z) „%s” eszköz paraméterei"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"A videobemeneti eszköz nem fogadta el az új képkockasebesség-beállítást."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Váratlan keretméret (%u) érkezett %u helyett."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Nem sikerült videokockákat lekérni a(z) „%s” eszköztől."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Hiba %d próbálkozás után. Eszköz: %s. Rendszerhiba: %s."
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "A(z) %d. tuner beállításának lekérése a(z) „%s” eszközön meghiúsult."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Hiba %d bájt olvasásakor a következő eszközről: „%s”."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "A(z) „%s” eszköz nem kimeneti eszköz."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "A(z) %d. bemenet beállítása meghiúsult a(z) „%s” eszközön."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "A(z) %d. bemenet beállítása meghiúsult a(z) „%s” eszközön."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "A jelerősség lekérdezése meghiúsult a(z) „%s” eszközön."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -630,10 +696,6 @@ msgstr ""
 "Az aktuális bemenet lekérése meghiúsult a(z) „%s” eszközről. Lehet, hogy ez "
 "egy rádióeszköz."
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "A(z) %d. bemenet beállítása meghiúsult a(z) „%s” eszközön."
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -645,38 +707,20 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "A(z) %d. bemenet beállítása meghiúsult a(z) „%s” eszközön."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Nem állíthatók sorba a pufferek a(z) „%s” eszközben."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Nem sikerült videokockákat lekérni a(z) „%s” eszköztől."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Hiba %d próbálkozás után. Eszköz: %s. Rendszerhiba: %s."
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Nem kérhetők le a(z) „%s” eszköz paraméterei"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"A videobemeneti eszköz nem fogadta el az új képkockasebesség-beállítást."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Nem képezhetők le a(z) „%s” eszköz pufferei"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"A(z) „%s” eszköz illesztőprogramja nem támogat egyetlen ismert felvételi "
-"módot sem."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "A felbontás módosítása futás közben még nem támogatott."
 
 msgid "Cannot operate without a clock"
 msgstr "Óra nélkül lehetetlen a működés"
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Hiba %d bájt olvasásakor a következő eszközről: „%s”."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Nem állíthatók sorba a pufferek a(z) „%s” eszközben."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Nem hozható létre kapcsolat a hangkiszolgálóhoz"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "A hangkiszolgáló képességeinek lekérdezése meghiúsult"
index 194804b..677eb92 100644 (file)
--- a/po/id.po
+++ b/po/id.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.26.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-02-26 18:09+0700\n"
 "Last-Translator: Andhika Padmawan <andhika.padmawan@gmail.com>\n"
 "Language-Team: Indonesian <translation-team-id@lists.sourceforge.net>\n"
@@ -16,12 +16,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Tak dapat membangun koneksi ke server suara"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Gagal untuk kueri kemampuan server suara"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -540,12 +534,83 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Galat membaca %d bita dari divais '%s'."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+"Gagal menyebutkan kemungkinan format video yang dapat bekerja dengan divais "
+"'%s'."
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Tak dapat memetakan penyangga dari divais '%s'"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Driver dari divais '%s' tak mendukung metode penangkap apapun yang dikenal."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Driver dari divais '%s' tak mendukung metode penangkap apapun yang dikenal."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Divais '%s' bukan divais keluaran."
+
+#, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Divais '%s' tak dapat menangkap di %dx%d"
+
+#, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Divais '%s' tak dapat menangkap dalam format yang ditentukan"
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Tak bisa mendapatkan parameter di divais '%s'"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "Divais masukan video tak menerima pengaturan rasio bingkai baru."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Mendapatkan ukuran bingkai %u ketimbang %u yang tak diharapkan."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Galat membaca %d bita pada divais '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Gagal mencoba untuk mendapatkan bingkai video dari divais '%s'."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Gagal setelah %d percobaan. divais %s. galat sistem: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Gagal mendapatkan pengaturan tuner %d di divais '%s'."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Galat membaca %d bita dari divais '%s'."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Divais '%s' bukan divais keluaran."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Gagal mengatur masukan %d di divais %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Gagal mengatur masukan %d di divais %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Gagal mendapatkan kekuatan sinyal untuk divais '%s'."
 
 #, c-format
 msgid ""
@@ -621,10 +686,6 @@ msgstr ""
 "Gagal mendapatkan masukan terkini di divais '%s'. Mungkin itu divais radio"
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Gagal mengatur masukan %d di divais %s."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -634,44 +695,23 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Gagal mengatur keluaran %d di divais %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Tak dapat mengantrekan penyangga di divais '%s'."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Gagal mencoba untuk mendapatkan bingkai video dari divais '%s'."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Gagal setelah %d percobaan. divais %s. galat sistem: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Tak bisa mendapatkan parameter di divais '%s'"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "Divais masukan video tak menerima pengaturan rasio bingkai baru."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Tak dapat memetakan penyangga dari divais '%s'"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Driver dari divais '%s' tak mendukung metode penangkap apapun yang dikenal."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Mengubah resolusi saat waktu berjalan belum didukung."
 
 msgid "Cannot operate without a clock"
 msgstr "Tak dapat beroperasi tanpa jam"
 
-#~ msgid "Failed to enumerate possible video formats device '%s' can work with"
-#~ msgstr ""
-#~ "Gagal menyebutkan kemungkinan format video yang dapat bekerja dengan "
-#~ "divais '%s'."
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Galat membaca %d bita pada divais '%s'."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Tak dapat mengantrekan penyangga di divais '%s'."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Tak dapat membangun koneksi ke server suara"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Gagal untuk kueri kemampuan server suara"
 
 #~ msgid ""
 #~ "The buffer type is not supported, or the index is out of bounds, or no "
@@ -696,12 +736,6 @@ msgstr "Tak dapat beroperasi tanpa jam"
 #~ msgid "No free buffers found in the pool at index %d."
 #~ msgstr "Tak ada penyangga bebas ditemukan di lubuk pada indeks %d."
 
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "Divais '%s' tak dapat menangkap di %dx%d"
-
-#~ msgid "Device '%s' cannot capture in the specified format"
-#~ msgstr "Divais '%s' tak dapat menangkap dalam format yang ditentukan"
-
 #~ msgid "Could not get buffers from device '%s'."
 #~ msgstr "Tak bisa mendapatkan penyangga dari divais '%s'."
 
index 7b5c907..b8bb2ba 100644 (file)
--- a/po/it.po
+++ b/po/it.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.25.3\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2010-10-25 10:11+0200\n"
 "Last-Translator: Luca Ferretti <elle.uca@infinito.it>\n"
 "Language-Team: Italian <tp@lists.linux.it>\n"
@@ -16,12 +16,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Impossibile stabilire la connessione al server audio"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Interrogazione delle funzionalità del server audio non riuscita"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -549,12 +543,82 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Errore nel leggere %d byte dal device «%s»."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Impossibile mappare dei buffer dal device «%s»."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr "Il driver del device «%s» non supporta alcun metodo di cattura noto."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr "Il driver del device «%s» non supporta alcun metodo di cattura noto."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Il device «%s» non è un dispositivo di uscita."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Il device «%s» non è un dispositivo di cattura."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Il device «%s» non è un dispositivo di cattura."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Impossibile ottenere i parametri sul device «%s»"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Il device di ingresso video non accetta la nuova impostazione sul frame rate."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Ottenuta dimensione inattesa del fotogramma: %u invece di %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Errore nel leggere %d byte sul device «%s»."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Tentativo di ottenere fotogrammi video dal device «%s» non riuscito."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Fallito dopo %d tentativi. Device %s. Errore di sistema: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr ""
+"Recupero delle impostazioni del sintonizzatore %d sul device «%s» non "
+"riuscito."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Errore nel leggere %d byte dal device «%s»."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Il device «%s» non è un dispositivo di uscita."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Impostazione dell'ingresso %d sul device «%s» non riuscita."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Impostazione dell'ingresso %d sul device «%s» non riuscita."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Recupero dell'intensità del segnale per il device «%s» non riuscito."
 
 #, c-format
 msgid ""
@@ -644,10 +708,6 @@ msgstr ""
 "Recupero dell'attuale ingresso sul device «%s» non riuscito. Forse è un "
 "dispositivo radio"
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Impostazione dell'ingresso %d sul device «%s» non riuscita."
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -659,37 +719,21 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Impostazione dell'ingresso %d sul device «%s» non riuscita."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Impossibile accodare i buffer nel device «%s»."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Tentativo di ottenere fotogrammi video dal device «%s» non riuscito."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Fallito dopo %d tentativi. Device %s. Errore di sistema: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Impossibile ottenere i parametri sul device «%s»"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Il device di ingresso video non accetta la nuova impostazione sul frame rate."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Impossibile mappare dei buffer dal device «%s»."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr "Il driver del device «%s» non supporta alcun metodo di cattura noto."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 "Il cambio della risoluzione durante l'esecuzione non è ancora supportato."
 
 msgid "Cannot operate without a clock"
 msgstr "Impossibile operare senza un clock"
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Errore nel leggere %d byte sul device «%s»."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Impossibile accodare i buffer nel device «%s»."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Impossibile stabilire la connessione al server audio"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Interrogazione delle funzionalità del server audio non riuscita"
index 18c09ad..cda9197 100644 (file)
--- a/po/ja.po
+++ b/po/ja.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.28.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-04-26 20:15+0900\n"
 "Last-Translator: Makoto Kato <makoto.kt@gmail.com>\n"
 "Language-Team: Japanese <translation-team-ja@lists.sourceforge.net>\n"
@@ -18,12 +18,6 @@ msgstr ""
 "X-Generator: Lokalize 0.3\n"
 "Plural-Forms: nplurals=1; plural=0;\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "サウンドサーバーへの接続に失敗しました"
-
-msgid "Failed to query sound server capabilities"
-msgstr "サウンドサーバーのケイパビリティのクエリーに失敗しました"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -574,12 +568,84 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "デバイス %2$s から %1$d バイト読み込み時にエラーが発生しました。"
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "デバイス '%s' からバッファをマップできません。"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"デバイス '%s' のドライバーはよく知られたキャプチャーメソッドをサポートしてい"
+"ません"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"デバイス '%s' のドライバーはよく知られたキャプチャーメソッドをサポートしてい"
+"ません"
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "デバイス '%s' は出力デバイスではありません"
+
+#, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "デバイス '%s' は %dx%d でキャプチャできません"
+
+#, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "デバイス '%s' は指定されたフォーマットでキャプチャできません"
+
+# SUN REVIEWED
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "デバイス '%s' 上のパラメータを取得できません。"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "ビデオ入力デバイスは新しいフレームレート設定にすることができません"
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "予期しないフレームサイズ (%2$u ではなく %1$u) を取得しました。"
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "デバイス '%2$s' 上で %1$d バイトの読み込み時ににエラーが発生しました。"
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "デバイス '%s' からビデオフレームの取得に失敗しました。"
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "%d 回リトライしましたが失敗しました。デバイス %s。システムエラー: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "デバイス '%2$s' 上のチューナー %1$d の設定の取得に失敗しました。"
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "デバイス %2$s から %1$d バイト読み込み時にエラーが発生しました。"
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "デバイス '%s' は出力デバイスではありません"
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "デバイス '%2$s' 上のチューナー %1$d の設定の取得に失敗しました。"
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "デバイス '%s' の現在のチューナーの周波数の取得に失敗しました"
 
 #, c-format
 msgid ""
@@ -658,10 +724,6 @@ msgstr ""
 "デバイス '%s' 上の現在の入力の取得に失敗しました。ラジオデバイスかもしれませ"
 "ん"
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr ""
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -673,42 +735,22 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "デバイス '%2$s' 上のチューナー %1$d の設定の取得に失敗しました。"
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr ""
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "デバイス '%s' からビデオフレームの取得に失敗しました。"
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "%d 回リトライしましたが失敗しました。デバイス %s。システムエラー: %s"
-
-# SUN REVIEWED
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "デバイス '%s' 上のパラメータを取得できません。"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "ビデオ入力デバイスは新しいフレームレート設定にすることができません"
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "デバイス '%s' からバッファをマップできません。"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"デバイス '%s' のドライバーはよく知られたキャプチャーメソッドをサポートしてい"
-"ません"
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 
 msgid "Cannot operate without a clock"
 msgstr ""
 
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr ""
+#~ "デバイス '%2$s' 上で %1$d バイトの読み込み時ににエラーが発生しました。"
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "サウンドサーバーへの接続に失敗しました"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "サウンドサーバーのケイパビリティのクエリーに失敗しました"
+
 #~ msgid ""
 #~ "Failed trying to get video frames from device '%s'. Not enough memory."
 #~ msgstr ""
@@ -718,12 +760,6 @@ msgstr ""
 #~ msgid "No free buffers found in the pool at index %d."
 #~ msgstr "インデックス %d でプール内に空きバッファがありません。"
 
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "デバイス '%s' は %dx%d でキャプチャできません"
-
-#~ msgid "Device '%s' cannot capture in the specified format"
-#~ msgstr "デバイス '%s' は指定されたフォーマットでキャプチャできません"
-
 #~ msgid "Could not get buffers from device '%s'."
 #~ msgstr "デバイス '%s' からバッファを取得できませんでした。"
 
index 78e5013..14cfb84 100644 (file)
--- a/po/lt.po
+++ b/po/lt.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.23.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2010-07-16 19:34+0300\n"
 "Last-Translator: Žygimantas Beručka <uid0@akl.lt>\n"
 "Language-Team: Lithuanian <komp_lt@konferencijos.lt>\n"
@@ -19,12 +19,6 @@ msgstr ""
 "%100<10 || n%100>=20) ? 1 : 2);\n"
 "X-Generator: Virtaal 0.6.1\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Nepavyko prisijungti prie garso serverio"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Nepavyko užklausti garso serverio galimybių"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -542,12 +536,79 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Klaida skaitant %d baitus (-ų) iš įrenginio „%s“."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Nepavyko išdėstyti buferių iš įrenginio „%s“"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr "Įrenginio „%s“ tvarkyklė nepalaiko jokių žinomų įrašymo būdų."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr "Įrenginio „%s“ tvarkyklė nepalaiko jokių žinomų įrašymo būdų."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Įrenginys „%s“ nėra išvesties įrenginys."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Įrenginys „%s“ nėra įrašymo įrenginys."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Įrenginys „%s“ nėra įrašymo įrenginys."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Nepavyko įrenginio „%s“ parametrų"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "Vaizdo įvesties įrenginys nepriėmė naujų kadrų dažnio nustatymų."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Gautas netikėtas kadro dydis %u vietoje %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Klaida skaitant %d baitus (-ų) įrenginyje „%s“."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Nepavyko gauti vaizdo kadrų iš įrenginio „%s“."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Nepavyko po %d bandymų. Įrenginys %s. Sistemos klaida: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Nepavyko gauti derintuvo %d įrenginyje „%s“ parametrų."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Klaida skaitant %d baitus (-ų) iš įrenginio „%s“."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Įrenginys „%s“ nėra išvesties įrenginys."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Nepavyko nustatyti įvesties %d įrenginyje %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Nepavyko nustatyti įvesties %d įrenginyje %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Nepavyko gauti įrenginio „%s“ signalo stiprumo."
 
 #, c-format
 msgid ""
@@ -623,10 +684,6 @@ msgstr ""
 "Nepavyko gauti dabartinės įvesties įrenginyje „%s“. Galbūt tai radijo "
 "įrenginys"
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Nepavyko nustatyti įvesties %d įrenginyje %s."
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -638,39 +695,24 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Nepavyko nustatyti įvesties %d įrenginyje %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Nepavyko sustatyti į eilė buferių įrenginyje „%s“."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Nepavyko gauti vaizdo kadrų iš įrenginio „%s“."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Nepavyko po %d bandymų. Įrenginys %s. Sistemos klaida: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Nepavyko įrenginio „%s“ parametrų"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "Vaizdo įvesties įrenginys nepriėmė naujų kadrų dažnio nustatymų."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Nepavyko išdėstyti buferių iš įrenginio „%s“"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr "Įrenginio „%s“ tvarkyklė nepalaiko jokių žinomų įrašymo būdų."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Galimybės keisti skiriamąją gebą operacijos vykdymo metu dar nėra."
 
 msgid "Cannot operate without a clock"
 msgstr "Negali veikti be laikrodžio"
 
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Klaida skaitant %d baitus (-ų) įrenginyje „%s“."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Nepavyko sustatyti į eilė buferių įrenginyje „%s“."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Nepavyko prisijungti prie garso serverio"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Nepavyko užklausti garso serverio galimybių"
+
 #~ msgid "Describes the selected input element."
 #~ msgstr "Aprašo pasirinktą įvesties elementą."
 
index ef270e4..15dd796 100644 (file)
--- a/po/lv.po
+++ b/po/lv.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.23.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2010-07-07 11:53+0100\n"
 "Last-Translator: Rihards Priedītis <rprieditis@gmail.com>\n"
 "Language-Team: Latvian <translation-team-lv@lists.sourceforge.net>\n"
@@ -19,12 +19,6 @@ msgstr ""
 "2);\n"
 "X-Generator: Lokalize 1.0\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Nevar izveidot savienojumu ar skaņas serveri"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Neizdevās noskaidrot skaņas servera iespējas"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -543,13 +537,82 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Radās kļūda nolasot %d baitus no ierīces \"%s\"."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Nevar izvietot buferus no ierīces \"%s\""
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Ierīces \"%s\" draiveris neatbalsta nevienu zināmo ierakstīšanas metodi."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Ierīces \"%s\" draiveris neatbalsta nevienu zināmo ierakstīšanas metodi."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Ierīce \"%s\" nav izvades ierīce."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Ierīce \"%s\" nav ierakstīšanas ierīce."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Ierīce \"%s\" nav ierakstīšanas ierīce."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Nevar nolasīt parametrus no ierīces \"%s\""
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "Video ievades ierīce nepieņem jaunos kadra frekvences uzstādījumus."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Saņēmu negaidītu kadra izmēru %u, nevis %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Neizdevās saņemt video kadrus no ierīces \"%s\"."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Neveiksme pēc %d mēģinājumiem. ierīce %s. sistēmas kļūda: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Neizdevās saņemt skaņotāja %d uzstādījumus no ierīces \"%s\"."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Radās kļūda nolasot %d baitus no ierīces \"%s\"."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Ierīce \"%s\" nav izvades ierīce."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Neizdevās uzstādīt ievadi %d uz ierīces %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Neizdevās uzstādīt ievadi %d uz ierīces %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Neizdevās saņemt signāla stiprumu no ierīces \"%s\"."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -625,10 +688,6 @@ msgstr ""
 "Neizdevās saņemt pašreizējo ievadi no ierīces \"%s\". Iespējams tā ir radio "
 "ierīce"
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Neizdevās uzstādīt ievadi %d uz ierīces %s."
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -640,36 +699,20 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Neizdevās uzstādīt ievadi %d uz ierīces %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Nevar ierindod buferus ierīcē \"%s\"."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Neizdevās saņemt video kadrus no ierīces \"%s\"."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Neveiksme pēc %d mēģinājumiem. ierīce %s. sistēmas kļūda: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Nevar nolasīt parametrus no ierīces \"%s\""
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "Video ievades ierīce nepieņem jaunos kadra frekvences uzstādījumus."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Nevar izvietot buferus no ierīces \"%s\""
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Ierīces \"%s\" draiveris neatbalsta nevienu zināmo ierakstīšanas metodi."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Izšķirtspējas mainīšana izpildlaikā pašalik netiek atbalstīta."
 
 msgid "Cannot operate without a clock"
 msgstr "Nevar veikt darbības bez pulksteņa"
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Radās kļūda nolasot %d baitus no ierīces \"%s\"."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Nevar ierindod buferus ierīcē \"%s\"."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Nevar izveidot savienojumu ar skaņas serveri"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Neizdevās noskaidrot skaņas servera iespējas"
index 96935f1..ef98c6f 100644 (file)
--- a/po/mt.po
+++ b/po/mt.po
@@ -5,7 +5,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good-0.10.10.3\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2008-10-26 19:09+0100\n"
 "Last-Translator: Michel Bugeja <michelbugeja@rabatmalta.com>\n"
 "Language-Team: Maltese <translation-team-mt@lists.sourceforge.net>\n"
@@ -16,12 +16,6 @@ msgstr ""
 "X-Poedit-Language: Maltese\n"
 "X-Poedit-Country: MALTA\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Kuntatt mas-sound server ma ġiex stabbilit"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Mhux possibli t-tfittxija għall-kapaċita tas-sound server"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -574,13 +568,83 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Problema fil-qar()i %d bytes fid-device '%s'."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr "Failed to enumerate possible video formats device '%s' can work with"
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Ma nistax nqabbel buffers mill-apparat '%s'."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Id-driver tal-apparat '%s' ma jissapportja l-ebda capture method mifhum."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Id-driver tal-apparat '%s' ma jissapportja l-ebda capture method mifhum."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Device '%s' mhux capture device."
+
+#, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Appart '%s' ma jistax jagħmel capture bi %dx%d"
+
+#, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Appart '%s' ma jistax jagħmel capture f'dan il-format"
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Mhux possibli nġib parametri tal-apparat '%s'"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Apparat li jaqra video input ma aċċettax is-settings ġodda tal-frame rate."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Irċivejt frame size ta' %u minflok kif kien mistenni ta' %u."
 
+#, c-format
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Problema biex inġib video frames mill-apparat '%s'."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Problema wara li pruvajt %d drabi. apparat %s. żball fis-sistema: %s"
+
 #, fuzzy, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Problema biex inġib settings tat-tuner %d fuq l-appart '%s'"
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Problema fil-qar()i %d bytes fid-device '%s'."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Device '%s' mhux capture device."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Problema biex nissettja input %d fuq apparat %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Problema biex nissettja input %d fuq apparat %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Problema biex inġib signal strength fuq l-apparat '%s'."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -657,10 +721,6 @@ msgstr ""
 "Problema biex inġib current input fuq apparat '%s'. Jista jkun li huwa "
 "apparat tar-radju."
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Problema biex nissettja input %d fuq apparat %s."
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -672,41 +732,25 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Problema biex nissettja input %d fuq apparat %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Could not enqueue buffers in device '%s'."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Problema biex inġib video frames mill-apparat '%s'."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Problema wara li pruvajt %d drabi. apparat %s. żball fis-sistema: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Mhux possibli nġib parametri tal-apparat '%s'"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Apparat li jaqra video input ma aċċettax is-settings ġodda tal-frame rate."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Ma nistax nqabbel buffers mill-apparat '%s'."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Id-driver tal-apparat '%s' ma jissapportja l-ebda capture method mifhum."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Ma tistax tibdel ir-resolution waqt runtime."
 
 msgid "Cannot operate without a clock"
 msgstr "Ma nistax nħaddem mingħajr arloġġ"
 
+#, fuzzy
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Problema fil-qar()i %d bytes fid-device '%s'."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Could not enqueue buffers in device '%s'."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Kuntatt mas-sound server ma ġiex stabbilit"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Mhux possibli t-tfittxija għall-kapaċita tas-sound server"
+
 #~ msgid "Error stopping streaming capture from device '%s'."
 #~ msgstr "Problem biex inwaqqaf streaming capture mill-apparat '%s'."
 
@@ -719,12 +763,6 @@ msgstr "Ma nistax nħaddem mingħajr arloġġ"
 #~ msgid "Could not get buffers from device '%s'."
 #~ msgstr "Ma nistax nirċievi buffers mill-apparat '%s'."
 
-#~ msgid "Device '%s' cannot capture in the specified format"
-#~ msgstr "Appart '%s' ma jistax jagħmel capture f'dan il-format"
-
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "Appart '%s' ma jistax jagħmel capture bi %dx%d"
-
 #~ msgid "No free buffers found in the pool at index %d."
 #~ msgstr "Ma nstab l-ebda buffer free fl-indiċi %d tal-pool."
 
@@ -746,9 +784,5 @@ msgstr "Ma nistax nħaddem mingħajr arloġġ"
 #~ "buffers have been allocated yet, or the userptr or length are invalid. "
 #~ "device %s"
 
-#~ msgid "Failed to enumerate possible video formats device '%s' can work with"
-#~ msgstr ""
-#~ "Failed to enumerate possible video formats device '%s' can work with"
-
 #~ msgid "Failed getting controls attributes on device '%s.'"
 #~ msgstr "L-attributi ta' kontroll ta' device '%s' ma nqrawx."
index 595d485..433a4d9 100644 (file)
--- a/po/nb.po
+++ b/po/nb.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.25.3\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2010-10-24 21:53+0200\n"
 "Last-Translator: Kjartan Maraas <kmaraas@gnome.org>\n"
 "Language-Team: Norwegian Bokmaal <i18n-nb@lister.ping.uio.no>\n"
@@ -15,12 +15,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Kunne ikke etablere tilkobling til lydtjener"
-
-msgid "Failed to query sound server capabilities"
-msgstr ""
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -524,11 +518,77 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Kunne ikke lukke VFS-fil «%s»."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Kunne ikke lukke VFS-fil «%s»."
+
+#, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+
+#, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Enhet «%s» kan ikke fange data."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Enhet «%s» kan ikke fange data."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Enhet «%s» kan ikke fange data."
+
+#, fuzzy, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Kunne ikke lukke VFS-fil «%s»."
+
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr ""
 
+#, c-format
+msgid "Failed trying to get video frames from device '%s'."
+msgstr ""
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Kunne ikke lukke VFS-fil «%s»."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Kunne ikke lukke VFS-fil «%s»."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Enhet «%s» kan ikke fange data."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Kunne ikke lukke VFS-fil «%s»."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr ""
+
 #, fuzzy, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed to change mute state for device '%s'."
 msgstr "Kunne ikke lukke VFS-fil «%s»."
 
 #, c-format
@@ -602,10 +662,6 @@ msgid "Failed to get current input on device '%s'. May be it is a radio device"
 msgstr ""
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr ""
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -614,38 +670,22 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Kunne ikke lukke VFS-fil «%s»."
 
-#, fuzzy, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Kunne ikke lukke VFS-fil «%s»."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr ""
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Kunne ikke lukke VFS-fil «%s»."
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Kunne ikke lukke VFS-fil «%s»."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 
 msgid "Cannot operate without a clock"
 msgstr "Kan ikke operere uten en klokke"
 
+#, fuzzy
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Kunne ikke lukke VFS-fil «%s»."
+
+#, fuzzy
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Kunne ikke lukke VFS-fil «%s»."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Kunne ikke etablere tilkobling til lydtjener"
+
 #~ msgid "Describes the selected input element."
 #~ msgstr "Beskriver valgt inndataelement."
index 778380e..dccaea2 100644 (file)
--- a/po/nl.po
+++ b/po/nl.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.28.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-04-27 00:05+0200\n"
 "Last-Translator: Freek de Kruijf <f.de.kruijf@gmail.com>\n"
 "Language-Team: Dutch <vertaling@vrijschrift.org>\n"
@@ -17,12 +17,6 @@ msgstr ""
 "X-Generator: Lokalize 1.1\n"
 "Plural-Forms: nplurals=2; plural=n != 1;\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Kan geen verbinding maken met de geluidsserver"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Kan de eigenschappen van de geluidsserver niet opvragen"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -543,13 +537,83 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Fout bij het lezen van %d bytes van apparaat '%s'."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Kan de buffers van apparaat '%s' niet vinden"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Het stuurprogramma van apparaat '%s' ondersteunt geen  bekende opnamemethode."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Het stuurprogramma van apparaat '%s' ondersteunt geen  bekende opnamemethode."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Apparaat '%s' is geen uitvoerapparaat."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Apparaat '%s' is geen opnameapparaat."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Apparaat '%s' is geen opnameapparaat."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Kan de parameters op apparaat '%s' niet verkrijgen"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Invoerapparaat voor video heeft de nieuwe frame-snelheid niet geaccepteerd."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Onverwachte framegrootte, %u in plaats van %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Kan geen videoframes verkrijgen van apparaat '%s'."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Fout na %d pogingen. Apparaat %s. Systeemfout: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Kan de instelling van tuner %d op apparaat '%s' niet verkrijgen."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Fout bij het lezen van %d bytes van apparaat '%s'."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Apparaat '%s' is geen uitvoerapparaat."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Kan invoer %d op apparaat '%s' niet instellen."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Kan invoer %d op apparaat '%s' niet instellen."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Kan de signaalsterkte van apparaat '%s' niet verkrijgen."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -626,10 +690,6 @@ msgstr ""
 "mogelijk een radio"
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Kan invoer %d op apparaat '%s' niet instellen."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -640,37 +700,20 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Kan uitvoer %d op apparaat %s niet instellen."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Kan geen buffers toekennen in apparaat '%s'."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Kan geen videoframes verkrijgen van apparaat '%s'."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Fout na %d pogingen. Apparaat %s. Systeemfout: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Kan de parameters op apparaat '%s' niet verkrijgen"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Invoerapparaat voor video heeft de nieuwe frame-snelheid niet geaccepteerd."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Kan de buffers van apparaat '%s' niet vinden"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Het stuurprogramma van apparaat '%s' ondersteunt geen  bekende opnamemethode."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Tijdens het draaien kan de resolutie nog niet gewijzigd worden."
 
 msgid "Cannot operate without a clock"
 msgstr "Kan niet werken zonder een klok."
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Fout bij het lezen van %d bytes van apparaat '%s'."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Kan geen buffers toekennen in apparaat '%s'."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Kan geen verbinding maken met de geluidsserver"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Kan de eigenschappen van de geluidsserver niet opvragen"
index 6528dea..ebac9a9 100644 (file)
--- a/po/or.po
+++ b/po/or.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-0.8.3\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2004-09-27 13:32+0530\n"
 "Last-Translator: Gora Mohanty <gora_mohanty@yahoo.co.in>\n"
 "Language-Team: Oriya <gora_mohanty@yahoo.co.in>\n"
@@ -17,12 +17,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr ""
-
-msgid "Failed to query sound server capabilities"
-msgstr ""
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -550,13 +544,79 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
+
+#, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+
+#, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "\"%s\" ଯନ୍ତ୍ର ଗୋଟିଏ ଅନୁଲିପିକାର ନୁହେଁ."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "\"%s\" ଯନ୍ତ୍ର ଗୋଟିଏ ଅନୁଲିପିକାର ନୁହେଁ."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "\"%s\" ଯନ୍ତ୍ର ଗୋଟିଏ ଅନୁଲିପିକାର ନୁହେଁ."
+
+#, fuzzy, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
+
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ପର୍ଯ୍ଯାପ୍ତ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
+
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed after %d tries. device %s. system error: %s"
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ପର୍ଯ୍ଯାପ୍ତ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "\"%s\" ଯନ୍ତ୍ର ଗୋଟିଏ ଅନୁଲିପିକାର ନୁହେଁ."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "\"%s\" ଧ୍ବନି ଯନ୍ତ୍ର ବନ୍ଦ କରିହେଲା ନାହିଁ."
+
+#, fuzzy, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "\"%s\" ଧ୍ବନି ଯନ୍ତ୍ର ବନ୍ଦ କରିହେଲା ନାହିଁ."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -628,10 +688,6 @@ msgid "Failed to get current input on device '%s'. May be it is a radio device"
 msgstr ""
 
 #, fuzzy, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "\"%s\" ଧ୍ବନି ଯନ୍ତ୍ର ବନ୍ଦ କରିହେଲା ନାହିଁ."
-
-#, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ପର୍ଯ୍ଯାପ୍ତ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
@@ -640,33 +696,6 @@ msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ପର୍ଯ୍ଯାପ୍ତ ଅସ୍
 msgid "Failed to set output %d on device %s."
 msgstr "\"%s\" ଧ୍ବନି ଯନ୍ତ୍ର ବନ୍ଦ କରିହେଲା ନାହିଁ."
 
-#, fuzzy, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
-
-#, fuzzy, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ପର୍ଯ୍ଯାପ୍ତ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 
@@ -674,8 +703,8 @@ msgid "Cannot operate without a clock"
 msgstr ""
 
 #, fuzzy
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "\"%s\" ଯନ୍ତ୍ର ଗୋଟିଏ ଅନୁଲିପିକାର ନୁହେଁ."
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "\"%s\" ଯନ୍ତ୍ରରୁ ଅସ୍ଥାୟୀ ସଞ୍ଚୟ ସ୍ଥାନ ଆଣିହେଲା ନାହିଁ."
 
 #, fuzzy
 #~ msgid "Could not get buffers from device '%s'."
index 64a7f36..087b3cd 100644 (file)
--- a/po/pl.po
+++ b/po/pl.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.26.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-01-07 21:53+0100\n"
 "Last-Translator: Jakub Bogusz <qboosh@pld-linux.org>\n"
 "Language-Team: Polish <translation-team-pl@lists.sourceforge.net>\n"
@@ -15,12 +15,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Nie udało się nawiązać połączenia z serwerem dźwięku"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Nie udało się odpytać o możliwości serwera dźwięku"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -538,13 +532,84 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Błąd odczytu %d bajtów z urządzenia '%s'."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Nie udało się odwzorować buforów z urządzenia '%s'"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Sterownik urządzenia '%s' nie obsługuje żadnej znanej metody przechwytywania."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Sterownik urządzenia '%s' nie obsługuje żadnej znanej metody przechwytywania."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Urządzenie '%s' nie jest urządzeniem wyjściowym."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Urządzenie '%s' nie jest urządzeniem przechwytującym."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Urządzenie '%s' nie jest urządzeniem przechwytującym."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Nie udało się uzyskać parametrów urządzenia '%s'"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Urządzenie wejściowe obrazu nie przyjęło nowego ustawienia częstotliwości "
+"klatek."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Otrzymano nieoczekiwany rozmiar klatki %u zamiast %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Nie udało się uzyskać klatek obrazu z urządzenia '%s'."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Niepowodzenie po %d próbach. Urządzenie %s. Błąd systemowy: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Nie udało się uzyskać ustawień tunera %d urządzenia '%s'."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Błąd odczytu %d bajtów z urządzenia '%s'."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Urządzenie '%s' nie jest urządzeniem wyjściowym."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Nie udało się ustawić wejścia %d urządzenia %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Nie udało się ustawić wejścia %d urządzenia %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Nie udało się uzyskać siły sygnału dla urządzenia '%s'."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -622,10 +687,6 @@ msgstr ""
 "Nie udało się uzyskać aktualnego wejścia urządzenia '%s'. Może to radio"
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Nie udało się ustawić wejścia %d urządzenia %s."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -635,38 +696,20 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Nie udało się ustawić wyjścia %d urządzenia %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Nie udało się skolejkować buforów urządzenia '%s'."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Nie udało się uzyskać klatek obrazu z urządzenia '%s'."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Niepowodzenie po %d próbach. Urządzenie %s. Błąd systemowy: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Nie udało się uzyskać parametrów urządzenia '%s'"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Urządzenie wejściowe obrazu nie przyjęło nowego ustawienia częstotliwości "
-"klatek."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Nie udało się odwzorować buforów z urządzenia '%s'"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Sterownik urządzenia '%s' nie obsługuje żadnej znanej metody przechwytywania."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Zmiana rozdzielczości w czasie działania nie jest jeszcze obsługiwana."
 
 msgid "Cannot operate without a clock"
 msgstr "Nie można pracować bez zegara"
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Błąd odczytu %d bajtów z urządzenia '%s'."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Nie udało się skolejkować buforów urządzenia '%s'."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Nie udało się nawiązać połączenia z serwerem dźwięku"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Nie udało się odpytać o możliwości serwera dźwięku"
index 534a4fb..ade2d54 100644 (file)
@@ -11,7 +11,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.26.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-01-08 01:28-0300\n"
 "Last-Translator: Fabrício Godoy <skarllot@gmail.com>\n"
 "Language-Team: Brazilian Portuguese <ldp-br@bazar.conectiva.com.br>\n"
@@ -21,12 +21,6 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Não foi possível estabelecer uma conexão com servidor de som"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Falha ao examinar os recursos do servidor de som"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -548,12 +542,85 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Erro ao ler %d bytes do dispositivo \"%s\"."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Não foi possível mapear buffers do dispositivo \"%s\""
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"O driver do dispositivo \"%s\" não tem suporte a nenhum método conhecido de "
+"captura."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"O driver do dispositivo \"%s\" não tem suporte a nenhum método conhecido de "
+"captura."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "O dispositivo \"%s\" não é um dispositivo de saída."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "O dispositivo \"%s\" não é um dispositivo de captura."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "O dispositivo \"%s\" não é um dispositivo de captura."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Não foi possível obter os parâmetros no dispositivo \"%s\""
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"A entrada do dispositivo de vídeo não aceita definir uma nova taxa de "
+"quadros."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Foi obtido um tamanho de quadro inesperado de %u, ao invés de %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Erro ao ler %d bytes no dispositivo \"%s\"."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Falha ao tentar obter os quadros de vídeo do dispositivo \"%s\"."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Falha após %d tentativas. Dispositivo %s. Erro do sistema: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Falha ao obter configurações do sintonizador %d no dispositivo \"%s\"."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Erro ao ler %d bytes do dispositivo \"%s\"."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "O dispositivo \"%s\" não é um dispositivo de saída."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Falha ao definir a entrada %d no dispositivo %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Falha ao definir a entrada %d no dispositivo %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Falha ao obter a força do sinal para o dispositivo \"%s\"."
 
 #, c-format
 msgid ""
@@ -632,10 +699,6 @@ msgstr ""
 "dispositivo de rádio"
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Falha ao definir a entrada %d no dispositivo %s."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -646,39 +709,20 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Falha ao definir a saída %d no dispositivo %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Não possível adicionar buffers à fila no dispositivo \"%s\"."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Falha ao tentar obter os quadros de vídeo do dispositivo \"%s\"."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Falha após %d tentativas. Dispositivo %s. Erro do sistema: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Não foi possível obter os parâmetros no dispositivo \"%s\""
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"A entrada do dispositivo de vídeo não aceita definir uma nova taxa de "
-"quadros."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Não foi possível mapear buffers do dispositivo \"%s\""
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"O driver do dispositivo \"%s\" não tem suporte a nenhum método conhecido de "
-"captura."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Ainda não há suporte a mudança de resolução enquanto está executando."
 
 msgid "Cannot operate without a clock"
 msgstr "Não é possível operar sem um temporizador"
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Erro ao ler %d bytes no dispositivo \"%s\"."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Não possível adicionar buffers à fila no dispositivo \"%s\"."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Não foi possível estabelecer uma conexão com servidor de som"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Falha ao examinar os recursos do servidor de som"
index dc0db8c..a6584cd 100644 (file)
--- a/po/ro.po
+++ b/po/ro.po
@@ -5,7 +5,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.23.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2010-08-16 03:22+0300\n"
 "Last-Translator: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>\n"
 "Language-Team: Romanian <translation-team-ro@lists.sourceforge.net>\n"
@@ -18,12 +18,6 @@ msgstr ""
 "X-Generator: Virtaal 0.6.1\n"
 "X-Launchpad-Export-Date: 2010-08-16 00:08+0000\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Nu se poate stabili o conexiune la serverul de sunet"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Interogarea capabilităților serverului de sunet a eșuat"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -547,12 +541,85 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Eroare citire %d octeți de la dispozitivul „%s”."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Nu s-a putut mapa memoria tampon din dispozitivul „%s”"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Driverul pentru dispozitivul „%s” nu suport nici o metodă de captură "
+"cunoscută."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Driverul pentru dispozitivul „%s” nu suport nici o metodă de captură "
+"cunoscută."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Dispozitivul „%s” nu este un dispozitiv de ieșire."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Dispozitivul „%s” nu este un dispozitiv de captură."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Dispozitivul „%s” nu este un dispozitiv de captură."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Nu s-au putut obține parametrii pentru dispozitivul „%s”"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Dispozitivul de intrare video nu a acceptat noua configurare de rate cadre."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "S-a obținut o dimensiune neașteptată pentru cadru, %u în loc de %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Eroare citire %d octeți pe dispozitivul „%s”."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Obținerea cadrelor video pentru dispozitivul „%s” a eșuat."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "A eșuat după %d încercări. dispozitiv %s. eroare sistem: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr ""
+"A eșuat obținerea configurării receptorului %d pentru dispozitivul „%s”."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Eroare citire %d octeți de la dispozitivul „%s”."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Dispozitivul „%s” nu este un dispozitiv de ieșire."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Definirea valorii %d pentru dispozitivul „%s” a eșuat."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Definirea valorii %d pentru dispozitivul „%s” a eșuat."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Obținerea nivelului semnalului pentru dispozitivul „%s” a eșuat."
 
 #, c-format
 msgid ""
@@ -632,10 +699,6 @@ msgstr ""
 "Obținerea intrări curente pentru dispozitivul „%s” a eșuat. Posibil să fie "
 "un dispozitiv radio."
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Definirea valorii %d pentru dispozitivul „%s” a eșuat."
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -647,38 +710,20 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Definirea valorii %d pentru dispozitivul „%s” a eșuat."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Nu s-a putut programa memoria tampon în dispozitivul „%s”."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Obținerea cadrelor video pentru dispozitivul „%s” a eșuat."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "A eșuat după %d încercări. dispozitiv %s. eroare sistem: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Nu s-au putut obține parametrii pentru dispozitivul „%s”"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Dispozitivul de intrare video nu a acceptat noua configurare de rate cadre."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Nu s-a putut mapa memoria tampon din dispozitivul „%s”"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Driverul pentru dispozitivul „%s” nu suport nici o metodă de captură "
-"cunoscută."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Schimbarea rezoluției pe durata rulării nu este incă suportată."
 
 msgid "Cannot operate without a clock"
 msgstr "Nu se poate opera fără un ceas"
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Eroare citire %d octeți pe dispozitivul „%s”."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Nu s-a putut programa memoria tampon în dispozitivul „%s”."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Nu se poate stabili o conexiune la serverul de sunet"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Interogarea capabilităților serverului de sunet a eșuat"
index 83f867a..7dd6d47 100644 (file)
--- a/po/ru.po
+++ b/po/ru.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.28.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-04-26 21:13+0400\n"
 "Last-Translator: Yuri Kozlov <yuray@komyakino.ru>\n"
 "Language-Team: Russian <gnu@mx.ru>\n"
@@ -20,12 +20,6 @@ msgstr ""
 "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
 "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Не удалось установить соединение с сервером звука"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Ошибка при запросе возможностей сервера звука"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -545,13 +539,84 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Ошибка чтения %d байт из устройства «%s»."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+"Не удалось создать список видео-форматов, с которыми может работать "
+"устройство «%s»"
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Не удалось распределить буферы устройства «%s»"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Драйвер устройства «%s» не поддерживает ни один из известных методов захвата."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Драйвер устройства «%s» не поддерживает ни один из известных методов захвата."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Устройство «%s» не является устройством вывода."
+
+#, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Устройство «%s» не может осуществлять захват в разрешении %dx%d"
+
+#, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Устройство «%s» не может осуществлять захват в указанном формате"
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Не удалось получить параметры устройства «%s»"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "Устройство видео-захвата не приняло новый параметр кадровой частоты."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Получен неожиданный размер кадра: %u вместо %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Ошибка при попытке получения кадров видео с устройства «%s»."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Ошибка после %d попыток. Устройство: %s. Системная ошибка: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Ошибка получения установок тюнера %d устройства «%s»."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Ошибка чтения %d байт из устройства «%s»."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Устройство «%s» не является устройством вывода."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Не удалось выбрать вход %d для устройства %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Не удалось выбрать вход %d для устройства %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Ошибка получения мощности сигнала для устройства «%s»."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -628,10 +693,6 @@ msgstr ""
 "устройство"
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Не удалось выбрать вход %d для устройства %s."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -642,34 +703,6 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Не удалось выбрать выход %d для устройства %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Не удалось добавить в очередь буферы устройства «%s»"
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Ошибка при попытке получения кадров видео с устройства «%s»."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Ошибка после %d попыток. Устройство: %s. Системная ошибка: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Не удалось получить параметры устройства «%s»"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "Устройство видео-захвата не приняло новый параметр кадровой частоты."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Не удалось распределить буферы устройства «%s»"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Драйвер устройства «%s» не поддерживает ни один из известных методов захвата."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 "Изменение разрешения видео во время выполнения не поддерживается в настоящий "
@@ -678,10 +711,17 @@ msgstr ""
 msgid "Cannot operate without a clock"
 msgstr "Операция невозможна без часов"
 
-#~ msgid "Failed to enumerate possible video formats device '%s' can work with"
-#~ msgstr ""
-#~ "Не удалось создать список видео-форматов, с которыми может работать "
-#~ "устройство «%s»"
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Ошибка чтения %d байт из устройства «%s»."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Не удалось добавить в очередь буферы устройства «%s»"
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Не удалось установить соединение с сервером звука"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Ошибка при запросе возможностей сервера звука"
 
 #~ msgid ""
 #~ "The buffer type is not supported, or the index is out of bounds, or no "
@@ -706,12 +746,6 @@ msgstr "Операция невозможна без часов"
 #~ msgid "No free buffers found in the pool at index %d."
 #~ msgstr "В пуле не найдено свободных буферов для индекса %d."
 
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "Устройство «%s» не может осуществлять захват в разрешении %dx%d"
-
-#~ msgid "Device '%s' cannot capture in the specified format"
-#~ msgstr "Устройство «%s» не может осуществлять захват в указанном формате"
-
 #~ msgid "Could not get buffers from device '%s'."
 #~ msgstr "Не удалось получить буферы устройства «%s»"
 
index d04bc76..70917f3 100644 (file)
--- a/po/sk.po
+++ b/po/sk.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.25.3\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2010-11-08 15:48+0100\n"
 "Last-Translator: Peter Tuhársky <tuharsky@misbb.sk>\n"
 "Language-Team: Slovak <sk-i18n@lists.linux.sk>\n"
@@ -18,12 +18,6 @@ msgstr ""
 "X-Generator: KBabel 1.11.4\n"
 "X-Poedit-Country: SLOVAKIA\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Nepodarilo sa nadviazať spojenie so zvukovým serverom"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Nepodarilo sa zistiť schopnosti zvukového servera"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -541,13 +535,85 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Chyba pri čítaní %d bajtov na zariadení '%s'."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+"Nepodarilo sa zistiť možné video formáty, '%s' s ktorými vie zariadenie "
+"pracovať"
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Nepodarilo sa namapovať vyrovnávaciu pamäť zariadenia '%s'"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Tento ovládač zariadenia '%s' nepodporuje žiadnu známu metódu nahrávania."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Tento ovládač zariadenia '%s' nepodporuje žiadnu známu metódu nahrávania."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Zariadenie '%s' nie je určené pre výstup."
+
+#, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Zariadenie '%s' nevie zachytávať na %dx%d"
+
+#, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Zariadenie '%s' nedokáže zachytávať v uvedenom formáte"
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Nepodarilo sa získať parametre zariadenia '%s'"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Zariadenie video vstupu neakceptovalo nové nastavenie frekvencie snímok."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Nastala neočakávaná veľkosť snímky %u namiesto %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Nepodarilo sa získať videosnímky zo zariadenia '%s'."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Nepodarilo sa po %d pokusoch. Zariadenie %s. Systémová chyba: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Nepodarilo sa získať nastavenie prijímača %d od zariadenia '%s'."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
 msgstr "Chyba pri čítaní %d bajtov na zariadení '%s'."
 
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Zariadenie '%s' nie je určené pre výstup."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Nepodarilo sa nastaviť vstup %d na zariadení %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Nepodarilo sa nastaviť vstup %d na zariadení %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Nepodarilo sa zistiť silu signálu pre zariadenie '%s'."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -625,10 +691,6 @@ msgid "Failed to get current input on device '%s'. May be it is a radio device"
 msgstr ""
 "Nepodarilo sa zistiť súčasný vstup na zariadení '%s'. Možno je to rádio."
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Nepodarilo sa nastaviť vstup %d na zariadení %s."
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -639,49 +701,27 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Nepodarilo sa nastaviť vstup %d na zariadení %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Nepodarilo sa zaradiť vyrovnávaciu pamäť na zariadení '%s'."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Nepodarilo sa získať videosnímky zo zariadenia '%s'."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Nepodarilo sa po %d pokusoch. Zariadenie %s. Systémová chyba: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Nepodarilo sa získať parametre zariadenia '%s'"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Zariadenie video vstupu neakceptovalo nové nastavenie frekvencie snímok."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Nepodarilo sa namapovať vyrovnávaciu pamäť zariadenia '%s'"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Tento ovládač zariadenia '%s' nepodporuje žiadnu známu metódu nahrávania."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Zmena rozlíšenia za chodu nie je zatiaľ podporovaná."
 
 msgid "Cannot operate without a clock"
 msgstr "Nemôžem fungovať bez hodín"
 
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Chyba pri čítaní %d bajtov na zariadení '%s'."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Nepodarilo sa zaradiť vyrovnávaciu pamäť na zariadení '%s'."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Nepodarilo sa nadviazať spojenie so zvukovým serverom"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Nepodarilo sa zistiť schopnosti zvukového servera"
+
 #~ msgid "Failed getting controls attributes on device '%s.'"
 #~ msgstr "Nepodarilo sa získať atribúty ovládacích prvkov na zariadení '%s.'"
 
-#~ msgid "Failed to enumerate possible video formats device '%s' can work with"
-#~ msgstr ""
-#~ "Nepodarilo sa zistiť možné video formáty, '%s' s ktorými vie zariadenie "
-#~ "pracovať"
-
 #~ msgid ""
 #~ "The buffer type is not supported, or the index is out of bounds, or no "
 #~ "buffers have been allocated yet, or the userptr or length are invalid. "
@@ -705,12 +745,6 @@ msgstr "Nemôžem fungovať bez hodín"
 #~ msgstr ""
 #~ "Nenašli sa žiadne voľné oblasti vyrovnávacei pamäte v bloku na indexe %d."
 
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "Zariadenie '%s' nevie zachytávať na %dx%d"
-
-#~ msgid "Device '%s' cannot capture in the specified format"
-#~ msgstr "Zariadenie '%s' nedokáže zachytávať v uvedenom formáte"
-
 #~ msgid "Could not get buffers from device '%s'."
 #~ msgstr "Nepodarilo sa získať vyrovnávaciu pamäť od zariadenia '%s'."
 
index 414796f..b3a554b 100644 (file)
--- a/po/sl.po
+++ b/po/sl.po
@@ -9,7 +9,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.26.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-03-12 18:35+0100\n"
 "Last-Translator: Klemen Košir <klemen.kosir@gmx.com>\n"
 "Language-Team: Slovenian <translation-team-sl@lists.sourceforge.net>\n"
@@ -23,12 +23,6 @@ msgstr ""
 "X-Poedit-Country: SLOVENIA\n"
 "X-Poedit-SourceCharset: utf-8\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Povezave z zvočnim strežnikom ni mogoče vzpostaviti"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Poizvedba o zmogljivosti zvočnega strežnika je spodletela"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -546,13 +540,82 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Napaka med branjem %d bajtov iz naprave '%s'."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Medpomnilnika naprave '%s' ni mogoče preslikati"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr "Gonilnik naprave '%s' ne podpira nobenega znanega načina zajemanja."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr "Gonilnik naprave '%s' ne podpira nobenega znanega načina zajemanja."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Naprava '%s' ni izhodna naprava."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Naprava '%s' ni naprava za zajemanje."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Naprava '%s' ni naprava za zajemanje."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Parametrov na napravi '%s' ni mogoče pridobiti."
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Vhodni video napravi ni mogoče določiti novih nastavitev hitrosti sličic."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr ""
 "Nepričakovana vrednost velikosti okvirja (%u). Pričakovana vrednost je %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Napaka med branjem %d bajtov na napravi '%s'."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Napaka med poskusom pridobivanja video sličic z naprave '%s'."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr ""
+"Neuspešen zagon po %d poskusih na napravi %s. Sporočilo sistemske napake: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Napaka med pridobivanjem nastavitev uglaševalnika %d naprave '%s'."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Napaka med branjem %d bajtov iz naprave '%s'."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Naprava '%s' ni izhodna naprava."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Napaka med nastavljanjem vhoda %d na napravi %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Napaka med nastavljanjem vhoda %d na napravi %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Napaka med pridobivanjem moči signala za napravo '%s'."
 
 #, c-format
 msgid ""
@@ -631,10 +694,6 @@ msgstr ""
 "naprava."
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Napaka med nastavljanjem vhoda %d na napravi %s."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -645,41 +704,24 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Napaka med nastavljanjem izhoda %d na napravi %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Medpomnilnika na napravi '%s' ni mogoče uvrstiti."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Napaka med poskusom pridobivanja video sličic z naprave '%s'."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr ""
-"Neuspešen zagon po %d poskusih na napravi %s. Sporočilo sistemske napake: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Parametrov na napravi '%s' ni mogoče pridobiti."
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Vhodni video napravi ni mogoče določiti novih nastavitev hitrosti sličic."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Medpomnilnika naprave '%s' ni mogoče preslikati"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr "Gonilnik naprave '%s' ne podpira nobenega znanega načina zajemanja."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Spreminjanje ločljivosti med delovanjem še ni podprto."
 
 msgid "Cannot operate without a clock"
 msgstr "Delovanje brez ure ni mogoče"
 
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Napaka med branjem %d bajtov na napravi '%s'."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Medpomnilnika na napravi '%s' ni mogoče uvrstiti."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Povezave z zvočnim strežnikom ni mogoče vzpostaviti"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Poizvedba o zmogljivosti zvočnega strežnika je spodletela"
+
 #~ msgid "Describes the selected input element."
 #~ msgstr "Opisuje izbran vnosni predmet."
 
index 309b072..2be4423 100644 (file)
--- a/po/sq.po
+++ b/po/sq.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins 0.8.3\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2004-08-07 20:29+0200\n"
 "Last-Translator: Laurent Dhima <laurenti@alblinux.net>\n"
 "Language-Team: Albanian <begraj@hotmail.com>\n"
@@ -15,12 +15,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr ""
-
-msgid "Failed to query sound server capabilities"
-msgstr ""
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -548,13 +542,79 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "E pamundur marrja e buffers nga dispozitivi \"%s\"."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "E pamundur marrja e buffers nga dispozitivi \"%s\"."
+
+#, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+
+#, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Dispozitivi \"%s\" nuk është një dispozitiv marrje."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Dispozitivi \"%s\" nuk është një dispozitiv marrje."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Dispozitivi \"%s\" nuk është një dispozitiv marrje."
+
+#, fuzzy, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "E pamundur marrja e buffers nga dispozitivi \"%s\"."
+
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "E pamundur marrja e buffers të mjaftueshëm nga dispozitivi \"%s\"."
+
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed after %d tries. device %s. system error: %s"
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "E pamundur marrja e buffers të mjaftueshëm nga dispozitivi \"%s\"."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "E pamundur marrja e buffers nga dispozitivi \"%s\"."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Dispozitivi \"%s\" nuk është një dispozitiv marrje."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "E pamundur mbyllja e dispozitivit audio \"%s\"."
+
+#, fuzzy, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "E pamundur mbyllja e dispozitivit audio \"%s\"."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "E pamundur marrja e buffers nga dispozitivi \"%s\"."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -626,10 +686,6 @@ msgid "Failed to get current input on device '%s'. May be it is a radio device"
 msgstr ""
 
 #, fuzzy, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "E pamundur mbyllja e dispozitivit audio \"%s\"."
-
-#, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr "E pamundur marrja e buffers të mjaftueshëm nga dispozitivi \"%s\"."
@@ -638,39 +694,16 @@ msgstr "E pamundur marrja e buffers të mjaftueshëm nga dispozitivi \"%s\"."
 msgid "Failed to set output %d on device %s."
 msgstr "E pamundur mbyllja e dispozitivit audio \"%s\"."
 
-#, fuzzy, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "E pamundur marrja e buffers nga dispozitivi \"%s\"."
-
-#, fuzzy, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "E pamundur marrja e buffers të mjaftueshëm nga dispozitivi \"%s\"."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "E pamundur marrja e buffers nga dispozitivi \"%s\"."
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "E pamundur marrja e buffers nga dispozitivi \"%s\"."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 
 msgid "Cannot operate without a clock"
 msgstr ""
 
+#, fuzzy
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "E pamundur marrja e buffers nga dispozitivi \"%s\"."
+
 #~ msgid ""
 #~ "No usable colorspace element could be found.\n"
 #~ "Please install one and restart."
index 2aec60b..b08b0cd 100644 (file)
--- a/po/sr.po
+++ b/po/sr.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins 0.7.6\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2004-03-13 00:18+0100\n"
 "Last-Translator: Danilo Segan <dsegan@gmx.net>\n"
 "Language-Team: Serbian <gnu@prevod.org>\n"
@@ -17,12 +17,6 @@ msgstr ""
 "Plural-Forms: nplurals=3;    plural=n%10==1 && n%100!=11 ? 0 :  (n%10>=2 && n"
 "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
 
-msgid "Could not establish connection to sound server"
-msgstr ""
-
-msgid "Failed to query sound server capabilities"
-msgstr ""
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -549,13 +543,79 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Не могу да примим бафере са уређаја „%s“."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Не могу да примим бафере са уређаја „%s“."
+
+#, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+
+#, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Уређај „%s“ не представља уређај за снимање."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Уређај „%s“ не представља уређај за снимање."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Уређај „%s“ не представља уређај за снимање."
+
+#, fuzzy, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Не могу да примим бафере са уређаја „%s“."
+
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Не могу да примим довољно бафера са уређаја „%s“."
+
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Failed after %d tries. device %s. system error: %s"
 msgstr ""
 
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Не могу да примим довољно бафера са уређаја „%s“."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Не могу да примим бафере са уређаја „%s“."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Уређај „%s“ не представља уређај за снимање."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Не могу да отворим радио уређај '%s'"
+
+#, fuzzy, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Не могу да отворим радио уређај '%s'"
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Не могу да примим бафере са уређаја „%s“."
+
 #, c-format
 msgid ""
 "Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
@@ -627,10 +687,6 @@ msgid "Failed to get current input on device '%s'. May be it is a radio device"
 msgstr ""
 
 #, fuzzy, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Не могу да отворим радио уређај '%s'"
-
-#, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr "Не могу да примим довољно бафера са уређаја „%s“."
@@ -639,39 +695,16 @@ msgstr "Не могу да примим довољно бафера са уре
 msgid "Failed to set output %d on device %s."
 msgstr "Не могу да отворим радио уређај '%s'"
 
-#, fuzzy, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Не могу да примим бафере са уређаја „%s“."
-
-#, fuzzy, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Не могу да примим довољно бафера са уређаја „%s“."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Не могу да примим бафере са уређаја „%s“."
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-
-#, fuzzy, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Не могу да примим бафере са уређаја „%s“."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr ""
 
 msgid "Cannot operate without a clock"
 msgstr ""
 
+#, fuzzy
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Не могу да примим бафере са уређаја „%s“."
+
 #~ msgid "Could not open file \"%s\" for writing."
 #~ msgstr "Не могу да отворим датотеку „%s“ ради уписа."
 
index 1eca391..92aa17a 100644 (file)
--- a/po/sv.po
+++ b/po/sv.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.26.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-01-09 19:36+0100\n"
 "Last-Translator: Daniel Nylander <po@danielnylander.se>\n"
 "Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
@@ -17,12 +17,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Kunde inte etablera en anslutning till ljudservern"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Misslyckades med att fråga efter ljudserverförmågor"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -542,12 +536,83 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Fel vid läsning av %d byte från enheten \"%s\"."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+"Misslyckades med att räkna upp möjliga videoformat som enheten \"%s\" kan "
+"arbeta med"
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Kunde inte mappa buffertar från enheten \"%s\"."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr "Drivrutinen för enheten \"%s\" saknar stöd för någon känd fångstmetod."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr "Drivrutinen för enheten \"%s\" saknar stöd för någon känd fångstmetod."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Enheten \"%s\" är ingen utgångsenhet."
+
+#, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Enheten \"%s\" kan inte fånga i %dx%d"
+
+#, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Enheten \"%s\" kan inte fånga i det angivna formatet"
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Kunde inte få tag i parametrar på enheten \"%s\""
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "Videoingångsenheten accepterade inte ny inställning för bildfrekvens."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Fick oväntade bildrutstorleken %u istället för %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Fel vid läsning av %d byte på enheten \"%s\"."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Misslyckades med att få videobildrutor från enheten \"%s\"."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Misslyckades efter %d försök. enhet %s. systemfel: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr ""
+"Misslyckades med att få tag i inställningen för mottagare %d på enheten \"%s"
+"\"."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Fel vid läsning av %d byte från enheten \"%s\"."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Enheten \"%s\" är ingen utgångsenhet."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Kunde inte ställa in ingång %d på enheten %s."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Kunde inte ställa in ingång %d på enheten %s."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Misslyckades med att få tag på signalstyrka för enheten \"%s\"."
 
 #, c-format
 msgid ""
@@ -630,10 +695,6 @@ msgstr ""
 "radioenhet"
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Kunde inte ställa in ingång %d på enheten %s."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -644,43 +705,23 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Misslyckades med att ställa in utgång %d på enheten %s."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Kunde inte kölägga buffertar i enheten \"%s\"."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Misslyckades med att få videobildrutor från enheten \"%s\"."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Misslyckades efter %d försök. enhet %s. systemfel: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Kunde inte få tag i parametrar på enheten \"%s\""
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "Videoingångsenheten accepterade inte ny inställning för bildfrekvens."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Kunde inte mappa buffertar från enheten \"%s\"."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr "Drivrutinen för enheten \"%s\" saknar stöd för någon känd fångstmetod."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Ändring av upplösning vid körtid stöds inte än."
 
 msgid "Cannot operate without a clock"
 msgstr "Kan inte fungera utan en klocka"
 
-#~ msgid "Failed to enumerate possible video formats device '%s' can work with"
-#~ msgstr ""
-#~ "Misslyckades med att räkna upp möjliga videoformat som enheten \"%s\" kan "
-#~ "arbeta med"
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Fel vid läsning av %d byte på enheten \"%s\"."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Kunde inte kölägga buffertar i enheten \"%s\"."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Kunde inte etablera en anslutning till ljudservern"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Misslyckades med att fråga efter ljudserverförmågor"
 
 #~ msgid ""
 #~ "The buffer type is not supported, or the index is out of bounds, or no "
@@ -703,12 +744,6 @@ msgstr "Kan inte fungera utan en klocka"
 #~ msgid "No free buffers found in the pool at index %d."
 #~ msgstr "Inga lediga buffertar hittades i poolen på index %d."
 
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "Enheten \"%s\" kan inte fånga i %dx%d"
-
-#~ msgid "Device '%s' cannot capture in the specified format"
-#~ msgstr "Enheten \"%s\" kan inte fånga i det angivna formatet"
-
 #~ msgid "Could not get buffers from device '%s'."
 #~ msgstr "Kunde inte få tag i buffertar från enheten \"%s\"."
 
index 747b3e4..bfc92b6 100644 (file)
--- a/po/tr.po
+++ b/po/tr.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.26.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-01-08 00:03+0200\n"
 "Last-Translator: Server Acim <serveracim@gmail.com>\n"
 "Language-Team: Turkish <gnu-tr-u12a@lists.sourceforge.net>\n"
@@ -15,12 +15,6 @@ msgstr ""
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Ses sunucusuyla bağlantı kurulumayor"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Ses sunucusu olanakları sorgulanamadı"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -535,12 +529,83 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "%d bayt bilgili '%s' aygıtından okumada hata."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr "Aygıtın '%s' birlikte çalışabileceği vidyo kiplerini sıralamada hata"
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Aygıttan '%s' bellekler eşlenemiyor"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Bu aygıtın sürücüsü '%s' bilinen görüntü yakalama yöntemlerinden herhangi "
+"birisi desteklemiyor."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Bu aygıtın sürücüsü '%s' bilinen görüntü yakalama yöntemlerinden herhangi "
+"birisi desteklemiyor."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Aygıt '%s' bir çıkış aygıtı değil."
+
+#, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Aygıt '%s' görüntü yakalayamadı%dx%d"
+
+#, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Aygıt '%s' belirtilen kipte görüntü yakalayamadı"
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Değiştirgeler aygıttan '%s' alınamıyor"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "Vidyo giriş aygıtı yeni çerçeve oranı ayarlarını kabul etmedi."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Beklenmeyen bir çerçevece boyutu %u bunun yerine %u görüntülendi."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "%d baytı şu aygıtta '%s' okumada hata."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Aygıttan device '%s' vidyo çerçeveleri alınamadı."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Şu denemeden sonra %d başarılamadı. aygıt %s. sistem hatası: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Radyo istasyonu ayarlarını bulma %d şu aygıtta '%s' başarılamadı."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "%d bayt bilgili '%s' aygıtından okumada hata."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Aygıt '%s' bir çıkış aygıtı değil."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Giriş değeri olarak bu %d şu aygıtta %s ayarlanamadı."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Giriş değeri olarak bu %d şu aygıtta %s ayarlanamadı."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Aygıt için '%s' güçlü sinyal alımı gerçekleşemedi."
 
 #, c-format
 msgid ""
@@ -616,10 +681,6 @@ msgstr ""
 "Şu aygıtta '%s' geçerli giriş elde edilemedi. O bir radyo aygıtı olabilir."
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Giriş değeri olarak bu %d şu aygıtta %s ayarlanamadı."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -629,44 +690,23 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Çıkış değeri olarak %d şu aygıtta %s elde edilemedi."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Aygıtta '%s' arabellek kuyruğa sokulamıyor."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Aygıttan device '%s' vidyo çerçeveleri alınamadı."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Şu denemeden sonra %d başarılamadı. aygıt %s. sistem hatası: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Değiştirgeler aygıttan '%s' alınamıyor"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "Vidyo giriş aygıtı yeni çerçeve oranı ayarlarını kabul etmedi."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Aygıttan '%s' bellekler eşlenemiyor"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Bu aygıtın sürücüsü '%s' bilinen görüntü yakalama yöntemlerinden herhangi "
-"birisi desteklemiyor."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Çalışırken çözünürlüğü değiştirmek henüz desteklenmiyor."
 
 msgid "Cannot operate without a clock"
 msgstr "Saat olmadan çalışamaz"
 
-#~ msgid "Failed to enumerate possible video formats device '%s' can work with"
-#~ msgstr ""
-#~ "Aygıtın '%s' birlikte çalışabileceği vidyo kiplerini sıralamada hata"
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "%d baytı şu aygıtta '%s' okumada hata."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Aygıtta '%s' arabellek kuyruğa sokulamıyor."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Ses sunucusuyla bağlantı kurulumayor"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Ses sunucusu olanakları sorgulanamadı"
 
 #~ msgid ""
 #~ "The buffer type is not supported, or the index is out of bounds, or no "
@@ -688,12 +728,6 @@ msgstr "Saat olmadan çalışamaz"
 #~ msgid "No free buffers found in the pool at index %d."
 #~ msgstr "Dizindeki %d havuzda boş bellek bulunamadı."
 
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "Aygıt '%s' görüntü yakalayamadı%dx%d"
-
-#~ msgid "Device '%s' cannot capture in the specified format"
-#~ msgstr "Aygıt '%s' belirtilen kipte görüntü yakalayamadı"
-
 #~ msgid "Could not get buffers from device '%s'."
 #~ msgstr "Arabellek aygıttan '%s' alınamıyor."
 
index 3bc721d..07c6868 100644 (file)
--- a/po/uk.po
+++ b/po/uk.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.28.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2011-05-01 11:55+0300\n"
 "Last-Translator: Yuri Chornoivan <yurchor@ukr.net>\n"
 "Language-Team: Ukrainian <translation-team-uk@lists.sourceforge.net>\n"
@@ -19,12 +19,6 @@ msgstr ""
 "X-Generator: Lokalize 1.2\n"
 "Plural-Forms: nplurals=1; plural=0;\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Не вдалося встановити з'єднання із звуковим сервером."
-
-msgid "Failed to query sound server capabilities"
-msgstr "Помилка при запиті можливостей звукового сервера"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -546,12 +540,82 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Помилка під час спроби читання %d байтів з пристрою «%s»."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+"Не вдається отримати список усіх можливих відеоформатів, які підтримує "
+"пристрій \"%s\""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Не вдалося пов’язати буфери з пристрою «%s»."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr "Драйвер пристрою «%s» не підтримує жоден відомий метод захоплення."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr "Драйвер пристрою «%s» не підтримує жоден відомий метод захоплення."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Пристрій «%s» не є пристроєм виведення даних."
+
+#, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Пристрій \"%s\" не здатний захоплювати відео у форматі %dx%d"
+
+#, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Пристрій \"%s\" не здатний захоплювати відео у вказаному форматі"
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Не вдалося отримати параметри пристрою «%s»."
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+"Пристроєм відеовходу не підтримується нове значення параметра частоти кадрів."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Отримано неочікуваний розмір блоку %u замість %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Помилка під час спроби читання %d байтів на пристрої «%s»."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Не вдалося отримати відеокадри з пристрою «%s»."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Помилка після %d спроб. Пристрій %s. Системна помилка: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Помилка при встановленні приймача %d пристрою «%s»."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Помилка під час спроби читання %d байтів з пристрою «%s»."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Пристрій «%s» не є пристроєм виведення даних."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Не вдалося встановити ввід %d пристрою «%s»."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Не вдалося встановити ввід %d пристрою «%s»."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Помилка при отриманні сили сигналу пристрою «%s»."
 
 #, c-format
 msgid ""
@@ -629,10 +693,6 @@ msgstr ""
 "радіо."
 
 #, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Не вдалося встановити ввід %d пристрою «%s»."
-
-#, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
 msgstr ""
@@ -643,40 +703,24 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Не вдалося встановити вихід %d пристрою «%s»."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Не вдалося опитати буфери від пристрою «%s»."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Не вдалося отримати відеокадри з пристрою «%s»."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Помилка після %d спроб. Пристрій %s. Системна помилка: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Не вдалося отримати параметри пристрою «%s»."
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr ""
-"Пристроєм відеовходу не підтримується нове значення параметра частоти кадрів."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Не вдалося пов’язати буфери з пристрою «%s»."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr "Драйвер пристрою «%s» не підтримує жоден відомий метод захоплення."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Зміна роздільної здатності при відтворенні ще не підтримується."
 
 msgid "Cannot operate without a clock"
 msgstr "Робота без годинника неможлива"
 
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Помилка під час спроби читання %d байтів на пристрої «%s»."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Не вдалося опитати буфери від пристрою «%s»."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Не вдалося встановити з'єднання із звуковим сервером."
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Помилка при запиті можливостей звукового сервера"
+
 #~ msgid "Could not read from CD."
 #~ msgstr "Не вдається прочитати з компакт-диску."
 
@@ -689,11 +733,6 @@ msgstr "Робота без годинника неможлива"
 #~ msgid "Failed getting controls attributes on device '%s.'"
 #~ msgstr "Не вдається отримати атрибути органів керування пристрою \"%s\"."
 
-#~ msgid "Failed to enumerate possible video formats device '%s' can work with"
-#~ msgstr ""
-#~ "Не вдається отримати список усіх можливих відеоформатів, які підтримує "
-#~ "пристрій \"%s\""
-
 #~ msgid ""
 #~ "The buffer type is not supported, or the index is out of bounds, or no "
 #~ "buffers have been allocated yet, or the userptr or length are invalid. "
@@ -716,12 +755,6 @@ msgstr "Робота без годинника неможлива"
 #~ msgid "Could not exchange data with device '%s'."
 #~ msgstr "Помилка при обміні даними з пристроєм \"%s\"."
 
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "Пристрій \"%s\" не здатний захоплювати відео у форматі %dx%d"
-
-#~ msgid "Device '%s' cannot capture in the specified format"
-#~ msgstr "Пристрій \"%s\" не здатний захоплювати відео у вказаному форматі"
-
 #~ msgid "Could not set parameters on device '%s'"
 #~ msgstr "Не вдається встановити параметри пристрою \"%s\"."
 
index 1bce35d..dfc985d 100644 (file)
--- a/po/vi.po
+++ b/po/vi.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.23.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2010-10-03 18:48+1030\n"
 "Last-Translator: Clytie Siddall <clytie@riverland.net.au>\n"
 "Language-Team: Vietnamese <vi-VN@googlegroups.com>\n"
@@ -18,12 +18,6 @@ msgstr ""
 "Plural-Forms: nplurals=1; plural=0;\n"
 "X-Generator: LocFactoryEditor 1.8\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "Không thể thiết lập sự kết nối tới máy phục vụ âm thanh"
-
-msgid "Failed to query sound server capabilities"
-msgstr "Lỗi truy vấn khả năng của máy phục vụ âm thanh"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -543,12 +537,83 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "Gặp lỗi khi đọc %d byte từ thiết bị « %s »."
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr ""
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "Không thể ánh xạ các bộ đệm từ thiết bị « %s »."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr ""
+"Trình điều khiển của thiết bị « %s » không hỗ trợ phương pháp bắt đã biết "
+"nào."
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr ""
+"Trình điều khiển của thiết bị « %s » không hỗ trợ phương pháp bắt đã biết "
+"nào."
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "Thiết bị « %s » không phải là thiết bị xuất ra."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "Thiết bị « %s » không phải là thiết bị bắt gì."
+
+#, fuzzy, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "Thiết bị « %s » không phải là thiết bị bắt gì."
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "Không thể lấy các tham số về thiết bị « %s »."
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "Thiết bị nhập ảnh động vào không chấp nhận thiết lập tốc độ khung mới."
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "Nhận được kích cỡ khung bất thường %u, thay cho %u."
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "Gặp lỗi khi đọc %d byte trên thiết bị « %s »."
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "Lỗi khi thử lấy các khung ảnh động từ thiết bị « %s »."
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "Lỗi sau %d lần thử. Thiết bị %s. Lỗi hệ thống: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "Lỗi lấy thiết lập của thiết bị điều hưởng %d trên thiết bị « %s »."
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "Gặp lỗi khi đọc %d byte từ thiết bị « %s »."
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "Thiết bị « %s » không phải là thiết bị xuất ra."
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "Lỗi đặt dữ liệu nhập %d vào thiết bị « %s »."
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "Lỗi đặt dữ liệu nhập %d vào thiết bị « %s »."
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "Lỗi lấy biên độ tín hiệu cho thiết bị « %s »."
 
 #, c-format
 msgid ""
@@ -625,10 +690,6 @@ msgid "Failed to get current input on device '%s'. May be it is a radio device"
 msgstr ""
 "Lỗi lấy kết nhập hiện thời vào thiết bị « %s ». Có thể là thiết bị thu thanh."
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "Lỗi đặt dữ liệu nhập %d vào thiết bị « %s »."
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -639,37 +700,20 @@ msgstr ""
 msgid "Failed to set output %d on device %s."
 msgstr "Lỗi đặt dữ liệu nhập %d vào thiết bị « %s »."
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "Không thể phụ thêm các bộ đệm vào hàng đợi trên thiết bị « %s »."
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "Lỗi khi thử lấy các khung ảnh động từ thiết bị « %s »."
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "Lỗi sau %d lần thử. Thiết bị %s. Lỗi hệ thống: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "Không thể lấy các tham số về thiết bị « %s »."
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "Thiết bị nhập ảnh động vào không chấp nhận thiết lập tốc độ khung mới."
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "Không thể ánh xạ các bộ đệm từ thiết bị « %s »."
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr ""
-"Trình điều khiển của thiết bị « %s » không hỗ trợ phương pháp bắt đã biết "
-"nào."
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "Chưa hỗ trợ khả năng thay đổi độ phân giải trong khi chạy."
 
 msgid "Cannot operate without a clock"
 msgstr "Không thể thao tác khi không có đồng hồ."
+
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "Gặp lỗi khi đọc %d byte trên thiết bị « %s »."
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "Không thể phụ thêm các bộ đệm vào hàng đợi trên thiết bị « %s »."
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "Không thể thiết lập sự kết nối tới máy phục vụ âm thanh"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "Lỗi truy vấn khả năng của máy phục vụ âm thanh"
index 4c053e9..78f5b8a 100644 (file)
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good 0.10.16.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2009-11-13 22:20+0800\n"
 "Last-Translator: Ji ZhengYu <zhengyuji@gmail.com>\n"
 "Language-Team: Chinese (simplified) <i18n-zh@googlegroups.com>\n"
@@ -16,12 +16,6 @@ msgstr ""
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr "无法建立与音频服务器的连接"
-
-msgid "Failed to query sound server capabilities"
-msgstr "查寻音频服务器的服务失败"
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -555,12 +549,79 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr "从设备‘%2$s’中读取 %1$d 个字节时出错。"
 
 #, c-format
+msgid "Failed to enumerate possible video formats device '%s' can work with"
+msgstr "枚举设备‘%s’可能支持的视频格式时出错"
+
+#, c-format
+msgid "Could not map buffers from device '%s'"
+msgstr "无法从设备‘%s’中映射出缓冲区"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support the IO method %d"
+msgstr "设备‘%s’的驱动不支持任何已知的捕获方式。"
+
+#, fuzzy, c-format
+msgid "The driver of device '%s' does not support any known IO method."
+msgstr "设备‘%s’的驱动不支持任何已知的捕获方式。"
+
+#, fuzzy, c-format
+msgid "Device '%s' does not support video capture"
+msgstr "‘%s’不是输出设备。"
+
+#, c-format
+msgid "Device '%s' cannot capture at %dx%d"
+msgstr "设备‘%s’不能在 %dx%d 处捕获"
+
+#, c-format
+msgid "Device '%s' cannot capture in the specified format"
+msgstr "设备‘%s’无法以指定格式捕获"
+
+#, c-format
+msgid "Could not get parameters on device '%s'"
+msgstr "无法获取设备‘%s’的参数"
+
+#, fuzzy
+msgid "Video device did not accept new frame rate setting."
+msgstr "视频输入设备不接受新的帧率设置。"
+
+msgid "Video device could not create buffer pool."
+msgstr ""
+
+#, c-format
 msgid "Got unexpected frame size of %u instead of %u."
 msgstr "取得了 %u 的不需要的帧大小,而不是 %u。"
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
-msgstr "读取设备‘%2$s’中的 %1$d 字节时出错。"
+msgid "Failed trying to get video frames from device '%s'."
+msgstr "从设备‘%s’上获取视频的尝试失败了。"
+
+#, c-format
+msgid "Failed after %d tries. device %s. system error: %s"
+msgstr "在 %d 次尝试后失败。设备 %s。系统错误: %s"
+
+#, fuzzy, c-format
+msgid "Failed to get settings of tuner %d on device '%s'."
+msgstr "获取设备 %2$s 上的微调钮 %1$d 的设置时出错"
+
+#, fuzzy, c-format
+msgid "Error getting capabilities for device '%s'."
+msgstr "从设备‘%2$s’中读取 %1$d 个字节时出错。"
+
+#, fuzzy, c-format
+msgid "Device '%s' is not a tuner."
+msgstr "‘%s’不是输出设备。"
+
+#, fuzzy, c-format
+msgid "Failed to get radio input on device '%s'. "
+msgstr "设置设备 %2$s 上的输入 %1$d 时出错。"
+
+#, c-format
+msgid "Failed to set input %d on device %s."
+msgstr "设置设备 %2$s 上的输入 %1$d 时出错。"
+
+#, fuzzy, c-format
+msgid "Failed to change mute state for device '%s'."
+msgstr "获取设备‘%s’的信号长度时出错。"
 
 #, c-format
 msgid ""
@@ -632,10 +693,6 @@ msgstr "设置设备‘%3$s’的控制器 %2$d 的值为 %1$d 时出错。"
 msgid "Failed to get current input on device '%s'. May be it is a radio device"
 msgstr "获取设备‘%s’上的当前输入出错。也许它是一个广播设备"
 
-#, c-format
-msgid "Failed to set input %d on device %s."
-msgstr "设置设备 %2$s 上的输入 %1$d 时出错。"
-
 #, fuzzy, c-format
 msgid ""
 "Failed to get current output on device '%s'. May be it is a radio device"
@@ -645,41 +702,23 @@ msgstr "获取设备‘%s’上的当前输入出错。也许它是一个广播
 msgid "Failed to set output %d on device %s."
 msgstr "设置设备 %2$s 上的输入 %1$d 时出错。"
 
-#, c-format
-msgid "Could not enqueue buffers in device '%s'."
-msgstr "无法对设备‘%s’中的缓冲区进行排序。"
-
-#, c-format
-msgid "Failed trying to get video frames from device '%s'."
-msgstr "从设备‘%s’上获取视频的尝试失败了。"
-
-#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
-msgstr "在 %d 次尝试后失败。设备 %s。系统错误: %s"
-
-#, c-format
-msgid "Could not get parameters on device '%s'"
-msgstr "无法获取设备‘%s’的参数"
-
-msgid "Video input device did not accept new frame rate setting."
-msgstr "视频输入设备不接受新的帧率设置。"
-
-#, c-format
-msgid "Could not map buffers from device '%s'"
-msgstr "无法从设备‘%s’中映射出缓冲区"
-
-#, c-format
-msgid "The driver of device '%s' does not support any known capture method."
-msgstr "设备‘%s’的驱动不支持任何已知的捕获方式。"
-
 msgid "Changing resolution at runtime is not yet supported."
 msgstr "尚不支持在运行时更改分辨率。"
 
 msgid "Cannot operate without a clock"
 msgstr "没有时钟的话无法操作"
 
-#~ msgid "Failed to enumerate possible video formats device '%s' can work with"
-#~ msgstr "枚举设备‘%s’可能支持的视频格式时出错"
+#~ msgid "Error reading %d bytes on device '%s'."
+#~ msgstr "读取设备‘%2$s’中的 %1$d 字节时出错。"
+
+#~ msgid "Could not enqueue buffers in device '%s'."
+#~ msgstr "无法对设备‘%s’中的缓冲区进行排序。"
+
+#~ msgid "Could not establish connection to sound server"
+#~ msgstr "无法建立与音频服务器的连接"
+
+#~ msgid "Failed to query sound server capabilities"
+#~ msgstr "查寻音频服务器的服务失败"
 
 #~ msgid ""
 #~ "The buffer type is not supported, or the index is out of bounds, or no "
@@ -699,12 +738,6 @@ msgstr "没有时钟的话无法操作"
 #~ msgid "No free buffers found in the pool at index %d."
 #~ msgstr "在内存池中 %d 处没有可分配的缓冲区。"
 
-#~ msgid "Device '%s' cannot capture at %dx%d"
-#~ msgstr "设备‘%s’不能在 %dx%d 处捕获"
-
-#~ msgid "Device '%s' cannot capture in the specified format"
-#~ msgstr "设备‘%s’无法以指定格式捕获"
-
 #~ msgid "Could not get buffers from device '%s'."
 #~ msgstr "无法从设备‘%s’中获取缓冲区。"
 
index 78913ad..bff5b7f 100644 (file)
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good-0.10.2 0.10.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2006-08-29 01:08+0800\n"
 "Last-Translator: Abel Cheung <abelcheung@gmail.com>\n"
 "Language-Team: Chinese (Hong Kong) <community@linuxhall.org>\n"
@@ -15,12 +15,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr ""
-
-msgid "Failed to query sound server capabilities"
-msgstr ""
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -545,121 +539,156 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Got unexpected frame size of %u instead of %u."
+msgid "Failed to enumerate possible video formats device '%s' can work with"
 msgstr ""
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Could not map buffers from device '%s'"
 msgstr ""
 
 #, c-format
-msgid ""
-"Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
-"it is a v4l1 driver."
+msgid "The driver of device '%s' does not support the IO method %d"
 msgstr ""
 
 #, c-format
-msgid "Failed to query attributes of input %d in device %s"
+msgid "The driver of device '%s' does not support any known IO method."
 msgstr ""
 
 #, c-format
-msgid "Failed to get setting of tuner %d on device '%s'."
+msgid "Device '%s' does not support video capture"
 msgstr ""
 
 #, c-format
-msgid "Failed to query norm on device '%s'."
+msgid "Device '%s' cannot capture at %dx%d"
 msgstr ""
 
 #, c-format
-msgid "Failed getting controls attributes on device '%s'."
+msgid "Device '%s' cannot capture in the specified format"
 msgstr ""
 
 #, c-format
-msgid "Cannot identify device '%s'."
+msgid "Could not get parameters on device '%s'"
+msgstr ""
+
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+
+msgid "Video device could not create buffer pool."
 msgstr ""
 
 #, c-format
-msgid "This isn't a device '%s'."
+msgid "Got unexpected frame size of %u instead of %u."
 msgstr ""
 
 #, c-format
-msgid "Could not open device '%s' for reading and writing."
+msgid "Failed trying to get video frames from device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Device '%s' is not a capture device."
+msgid "Failed after %d tries. device %s. system error: %s"
 msgstr ""
 
 #, c-format
-msgid "Device '%s' is not a output device."
+msgid "Failed to get settings of tuner %d on device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to set norm for device '%s'."
+msgid "Error getting capabilities for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to get current tuner frequency for device '%s'."
+msgid "Device '%s' is not a tuner."
 msgstr ""
 
 #, c-format
-msgid "Failed to set current tuner frequency for device '%s' to %lu Hz."
+msgid "Failed to get radio input on device '%s'. "
 msgstr ""
 
 #, c-format
-msgid "Failed to get signal strength for device '%s'."
+msgid "Failed to set input %d on device %s."
 msgstr ""
 
 #, c-format
-msgid "Failed to get value for control %d on device '%s'."
+msgid "Failed to change mute state for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to set value %d for control %d on device '%s'."
+msgid ""
+"Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
+"it is a v4l1 driver."
 msgstr ""
 
 #, c-format
-msgid "Failed to get current input on device '%s'. May be it is a radio device"
+msgid "Failed to query attributes of input %d in device %s"
 msgstr ""
 
 #, c-format
-msgid "Failed to set input %d on device %s."
+msgid "Failed to get setting of tuner %d on device '%s'."
 msgstr ""
 
 #, c-format
-msgid ""
-"Failed to get current output on device '%s'. May be it is a radio device"
+msgid "Failed to query norm on device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to set output %d on device %s."
+msgid "Failed getting controls attributes on device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Could not enqueue buffers in device '%s'."
+msgid "Cannot identify device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed trying to get video frames from device '%s'."
+msgid "This isn't a device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
+msgid "Could not open device '%s' for reading and writing."
 msgstr ""
 
 #, c-format
-msgid "Could not get parameters on device '%s'"
+msgid "Device '%s' is not a capture device."
+msgstr ""
+
+#, c-format
+msgid "Device '%s' is not a output device."
 msgstr ""
 
-msgid "Video input device did not accept new frame rate setting."
+#, c-format
+msgid "Failed to set norm for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Could not map buffers from device '%s'"
+msgid "Failed to get current tuner frequency for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "The driver of device '%s' does not support any known capture method."
+msgid "Failed to set current tuner frequency for device '%s' to %lu Hz."
+msgstr ""
+
+#, c-format
+msgid "Failed to get signal strength for device '%s'."
+msgstr ""
+
+#, c-format
+msgid "Failed to get value for control %d on device '%s'."
+msgstr ""
+
+#, c-format
+msgid "Failed to set value %d for control %d on device '%s'."
+msgstr ""
+
+#, c-format
+msgid "Failed to get current input on device '%s'. May be it is a radio device"
+msgstr ""
+
+#, c-format
+msgid ""
+"Failed to get current output on device '%s'. May be it is a radio device"
+msgstr ""
+
+#, c-format
+msgid "Failed to set output %d on device %s."
 msgstr ""
 
 msgid "Changing resolution at runtime is not yet supported."
index f87df80..dac5bb3 100644 (file)
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gst-plugins-good-0.10.2 0.10.2\n"
 "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/\n"
-"POT-Creation-Date: 2011-05-10 09:38+0100\n"
+"POT-Creation-Date: 2011-08-08 15:23+0100\n"
 "PO-Revision-Date: 2006-08-29 01:08+0800\n"
 "Last-Translator: Abel Cheung <abelcheung@gmail.com>\n"
 "Language-Team: Chinese (traditional) <zh-l10n@linux.org.tw>\n"
@@ -15,12 +15,6 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Could not establish connection to sound server"
-msgstr ""
-
-msgid "Failed to query sound server capabilities"
-msgstr ""
-
 #. TRANSLATORS: 'song title' by 'artist name'
 #, c-format
 msgid "'%s' by '%s'"
@@ -545,121 +539,156 @@ msgid "Error reading %d bytes from device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Got unexpected frame size of %u instead of %u."
+msgid "Failed to enumerate possible video formats device '%s' can work with"
 msgstr ""
 
 #, c-format
-msgid "Error reading %d bytes on device '%s'."
+msgid "Could not map buffers from device '%s'"
 msgstr ""
 
 #, c-format
-msgid ""
-"Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
-"it is a v4l1 driver."
+msgid "The driver of device '%s' does not support the IO method %d"
 msgstr ""
 
 #, c-format
-msgid "Failed to query attributes of input %d in device %s"
+msgid "The driver of device '%s' does not support any known IO method."
 msgstr ""
 
 #, c-format
-msgid "Failed to get setting of tuner %d on device '%s'."
+msgid "Device '%s' does not support video capture"
 msgstr ""
 
 #, c-format
-msgid "Failed to query norm on device '%s'."
+msgid "Device '%s' cannot capture at %dx%d"
 msgstr ""
 
 #, c-format
-msgid "Failed getting controls attributes on device '%s'."
+msgid "Device '%s' cannot capture in the specified format"
 msgstr ""
 
 #, c-format
-msgid "Cannot identify device '%s'."
+msgid "Could not get parameters on device '%s'"
+msgstr ""
+
+msgid "Video device did not accept new frame rate setting."
+msgstr ""
+
+msgid "Video device could not create buffer pool."
 msgstr ""
 
 #, c-format
-msgid "This isn't a device '%s'."
+msgid "Got unexpected frame size of %u instead of %u."
 msgstr ""
 
 #, c-format
-msgid "Could not open device '%s' for reading and writing."
+msgid "Failed trying to get video frames from device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Device '%s' is not a capture device."
+msgid "Failed after %d tries. device %s. system error: %s"
 msgstr ""
 
 #, c-format
-msgid "Device '%s' is not a output device."
+msgid "Failed to get settings of tuner %d on device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to set norm for device '%s'."
+msgid "Error getting capabilities for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to get current tuner frequency for device '%s'."
+msgid "Device '%s' is not a tuner."
 msgstr ""
 
 #, c-format
-msgid "Failed to set current tuner frequency for device '%s' to %lu Hz."
+msgid "Failed to get radio input on device '%s'. "
 msgstr ""
 
 #, c-format
-msgid "Failed to get signal strength for device '%s'."
+msgid "Failed to set input %d on device %s."
 msgstr ""
 
 #, c-format
-msgid "Failed to get value for control %d on device '%s'."
+msgid "Failed to change mute state for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to set value %d for control %d on device '%s'."
+msgid ""
+"Error getting capabilities for device '%s': It isn't a v4l2 driver. Check if "
+"it is a v4l1 driver."
 msgstr ""
 
 #, c-format
-msgid "Failed to get current input on device '%s'. May be it is a radio device"
+msgid "Failed to query attributes of input %d in device %s"
 msgstr ""
 
 #, c-format
-msgid "Failed to set input %d on device %s."
+msgid "Failed to get setting of tuner %d on device '%s'."
 msgstr ""
 
 #, c-format
-msgid ""
-"Failed to get current output on device '%s'. May be it is a radio device"
+msgid "Failed to query norm on device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed to set output %d on device %s."
+msgid "Failed getting controls attributes on device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Could not enqueue buffers in device '%s'."
+msgid "Cannot identify device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed trying to get video frames from device '%s'."
+msgid "This isn't a device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
+msgid "Could not open device '%s' for reading and writing."
 msgstr ""
 
 #, c-format
-msgid "Could not get parameters on device '%s'"
+msgid "Device '%s' is not a capture device."
+msgstr ""
+
+#, c-format
+msgid "Device '%s' is not a output device."
 msgstr ""
 
-msgid "Video input device did not accept new frame rate setting."
+#, c-format
+msgid "Failed to set norm for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "Could not map buffers from device '%s'"
+msgid "Failed to get current tuner frequency for device '%s'."
 msgstr ""
 
 #, c-format
-msgid "The driver of device '%s' does not support any known capture method."
+msgid "Failed to set current tuner frequency for device '%s' to %lu Hz."
+msgstr ""
+
+#, c-format
+msgid "Failed to get signal strength for device '%s'."
+msgstr ""
+
+#, c-format
+msgid "Failed to get value for control %d on device '%s'."
+msgstr ""
+
+#, c-format
+msgid "Failed to set value %d for control %d on device '%s'."
+msgstr ""
+
+#, c-format
+msgid "Failed to get current input on device '%s'. May be it is a radio device"
+msgstr ""
+
+#, c-format
+msgid ""
+"Failed to get current output on device '%s'. May be it is a radio device"
+msgstr ""
+
+#, c-format
+msgid "Failed to set output %d on device %s."
 msgstr ""
 
 msgid "Changing resolution at runtime is not yet supported."
index 6d7e6bd..639ee9d 100644 (file)
@@ -169,53 +169,34 @@ static GstStructure *
 gst_oss_helper_get_format_structure (unsigned int format_bit)
 {
   GstStructure *structure;
-  int endianness;
-  gboolean sign;
-  int width;
+  const gchar *format;
 
   switch (format_bit) {
     case AFMT_U8:
-      endianness = 0;
-      sign = FALSE;
-      width = 8;
+      format = "U8";
       break;
     case AFMT_S16_LE:
-      endianness = G_LITTLE_ENDIAN;
-      sign = TRUE;
-      width = 16;
+      format = "S16_LE";
       break;
     case AFMT_S16_BE:
-      endianness = G_BIG_ENDIAN;
-      sign = TRUE;
-      width = 16;
+      format = "S16_BE";
       break;
     case AFMT_S8:
-      endianness = 0;
-      sign = TRUE;
-      width = 8;
+      format = "S8";
       break;
     case AFMT_U16_LE:
-      endianness = G_LITTLE_ENDIAN;
-      sign = FALSE;
-      width = 16;
+      format = "U16_LE";
       break;
     case AFMT_U16_BE:
-      endianness = G_BIG_ENDIAN;
-      sign = FALSE;
-      width = 16;
+      format = "U16_BE";
       break;
     default:
       g_assert_not_reached ();
       return NULL;
   }
 
-  structure = gst_structure_new ("audio/x-raw-int",
-      "width", G_TYPE_INT, width,
-      "depth", G_TYPE_INT, width, "signed", G_TYPE_BOOLEAN, sign, NULL);
-
-  if (endianness) {
-    gst_structure_set (structure, "endianness", G_TYPE_INT, endianness, NULL);
-  }
+  structure = gst_structure_new ("audio/x-raw",
+      "format", G_TYPE_STRING, format, NULL);
 
   return structure;
 }
index 9f9b137..6a8046d 100644 (file)
@@ -110,20 +110,14 @@ enum
   PROP_DEVICE,
 };
 
+#define FORMATS "{" GST_AUDIO_NE(S16)","GST_AUDIO_NE(U16)", S8, U8 }"
+
 static GstStaticPadTemplate osssink_sink_factory =
-    GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "endianness = (int) { " G_STRINGIFY (G_BYTE_ORDER) " }, "
-        "signed = (boolean) { TRUE, FALSE }, "
-        "width = (int) 16, "
-        "depth = (int) 16, "
-        "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]; "
-        "audio/x-raw-int, "
-        "signed = (boolean) { TRUE, FALSE }, "
-        "width = (int) 8, "
-        "depth = (int) 8, "
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " FORMATS ", "
         "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
     );
 
index 33f585d..bdadbbc 100644 (file)
@@ -101,25 +101,16 @@ static guint gst_oss_src_read (GstAudioSrc * asrc, gpointer data, guint length);
 static guint gst_oss_src_delay (GstAudioSrc * asrc);
 static void gst_oss_src_reset (GstAudioSrc * asrc);
 
-
+#define FORMATS "{" GST_AUDIO_NE(S16)","GST_AUDIO_NE(U16)", S8, U8 }"
 
 static GstStaticPadTemplate osssrc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "endianness = (int) { " G_STRINGIFY (G_BYTE_ORDER) " }, "
-        "signed = (boolean) { TRUE, FALSE }, "
-        "width = (int) 16, "
-        "depth = (int) 16, "
-        "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]; "
-        "audio/x-raw-int, "
-        "signed = (boolean) { TRUE, FALSE }, "
-        "width = (int) 8, "
-        "depth = (int) 8, "
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " FORMATS ", "
         "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
     );
 
-
 static void
 gst_oss_src_dispose (GObject * object)
 {
index ea2bc8c..e71d134 100644 (file)
@@ -219,7 +219,7 @@ gst_oss4_mixer_slider_set_mute (GstOss4MixerSlider * s, gboolean mute)
     }
     ret = gst_oss4_mixer_set_control_val (s->mixer, s->mc, volume);
   } else {
-    ret = gst_oss4_mixer_set_control_val (s->mixer, s->mc->mute, ! !mute);
+    ret = gst_oss4_mixer_set_control_val (s->mixer, s->mc->mute, !!mute);
   }
 
   if (mute) {
@@ -286,7 +286,7 @@ gst_oss4_mixer_slider_process_change_unlocked (GstMixerTrack * track)
 
   if (s->mc->mute != NULL && s->mc->mute->changed) {
     gst_mixer_mute_toggled (GST_MIXER (s->mixer), track,
-        ! !s->mc->mute->last_val);
+        !!s->mc->mute->last_val);
   } else {
     /* nothing to do here, since we don't/can't easily implement the record
      * flag */
index a7a99de..b4431c1 100644 (file)
@@ -1,7 +1,7 @@
 plugin_LTLIBRARIES = libgstvideo4linux2.la
 
 if USE_XVIDEO
-xv_source = gstv4l2xoverlay.c
+xv_source = gstv4l2videooverlay.c
 xv_libs = $(X_LIBS) $(XVIDEO_LIBS)
 else
 xv_source =
@@ -17,12 +17,8 @@ libgstvideo4linux2_la_SOURCES = gstv4l2.c \
                                gstv4l2tuner.c \
                                gstv4l2vidorient.c \
                                v4l2_calls.c \
-                               v4l2src_calls.c \
                                $(xv_source)
-
-if BUILD_EXPERIMENTAL
 libgstvideo4linux2_la_SOURCES += gstv4l2sink.c
-endif
 
 libgstvideo4linux2_la_CFLAGS =   $(GST_PLUGINS_BASE_CFLAGS) \
                                 $(GST_BASE_CFLAGS) \
@@ -55,6 +51,5 @@ noinst_HEADERS = \
        gstv4l2radio.h \
        gstv4l2tuner.h \
        gstv4l2vidorient.h \
-       gstv4l2xoverlay.h \
-       v4l2_calls.h \
-       v4l2src_calls.h
+       gstv4l2videooverlay.h \
+       v4l2_calls.h
index 95f64db..061adcb 100644 (file)
@@ -32,9 +32,7 @@
 
 #include "gstv4l2object.h"
 #include "gstv4l2src.h"
-#ifdef HAVE_EXPERIMENTAL
 #include "gstv4l2sink.h"
-#endif
 #include "gstv4l2radio.h"
 /* #include "gstv4l2jpegsrc.h" */
 /* #include "gstv4l2mjpegsrc.h" */
@@ -55,10 +53,8 @@ plugin_init (GstPlugin * plugin)
 
   if (!gst_element_register (plugin, "v4l2src", GST_RANK_PRIMARY,
           GST_TYPE_V4L2SRC) ||
-#ifdef HAVE_EXPERIMENTAL
       !gst_element_register (plugin, "v4l2sink", GST_RANK_NONE,
           GST_TYPE_V4L2SINK) ||
-#endif
       !gst_element_register (plugin, "v4l2radio", GST_RANK_NONE,
           GST_TYPE_V4L2RADIO) ||
       /*       !gst_element_register (plugin, "v4l2jpegsrc", */
index e976ec5..b38541d 100644 (file)
 #include <unistd.h>
 
 #include "gst/video/video.h"
+#include "gst/video/gstmetavideo.h"
+#include "gst/video/gstvideopool.h"
 
 #include <gstv4l2bufferpool.h>
+
 #include "gstv4l2src.h"
-#ifdef HAVE_EXPERIMENTAL
 #include "gstv4l2sink.h"
-#endif
 #include "v4l2_calls.h"
 #include "gst/gst-i18n-plugin.h"
 
 GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
 #define GST_CAT_DEFAULT v4l2_debug
 
-
 /*
  * GstV4l2Buffer:
  */
-
-static GstBufferClass *v4l2buffer_parent_class = NULL;
-
-static void
-gst_v4l2_buffer_finalize (GstV4l2Buffer * buffer)
+const GstMetaInfo *
+gst_meta_v4l2_get_info (void)
 {
-  GstV4l2BufferPool *pool;
-  gboolean resuscitated = FALSE;
-  gint index;
-
-  pool = buffer->pool;
-
-  index = buffer->vbuffer.index;
-
-  GST_LOG_OBJECT (pool->v4l2elem, "finalizing buffer %p %d", buffer, index);
-
-  GST_V4L2_BUFFER_POOL_LOCK (pool);
-  if (pool->running) {
-    if (pool->requeuebuf) {
-      if (!gst_v4l2_buffer_pool_qbuf (pool, buffer)) {
-        GST_WARNING ("could not requeue buffer %p %d", buffer, index);
-      } else {
-        resuscitated = TRUE;
-      }
-    } else {
-      resuscitated = TRUE;
-      /* XXX double check this... I think it is ok to not synchronize this
-       * w.r.t. destruction of the pool, since the buffer is still live and
-       * the buffer holds a ref to the pool..
-       */
-      g_async_queue_push (pool->avail_buffers, buffer);
-    }
-  } else {
-    GST_LOG_OBJECT (pool->v4l2elem, "the pool is shutting down");
-  }
-
-  if (resuscitated) {
-    /* FIXME: check that the caps didn't change */
-    GST_LOG_OBJECT (pool->v4l2elem, "reviving buffer %p, %d", buffer, index);
-    gst_buffer_ref (GST_BUFFER (buffer));
-    GST_BUFFER_SIZE (buffer) = 0;
-    pool->buffers[index] = buffer;
-  }
-
-  GST_V4L2_BUFFER_POOL_UNLOCK (pool);
-
-  if (!resuscitated) {
-    GST_LOG_OBJECT (pool->v4l2elem,
-        "buffer %p (data %p, len %u) not recovered, unmapping",
-        buffer, GST_BUFFER_DATA (buffer), buffer->vbuffer.length);
-    gst_mini_object_unref (GST_MINI_OBJECT (pool));
-    v4l2_munmap ((void *) GST_BUFFER_DATA (buffer), buffer->vbuffer.length);
-
-    GST_MINI_OBJECT_CLASS (v4l2buffer_parent_class)->finalize (GST_MINI_OBJECT
-        (buffer));
+  static const GstMetaInfo *meta_info = NULL;
+
+  if (meta_info == NULL) {
+    meta_info =
+        gst_meta_register ("GstMetaV4l2", "GstMetaV4l2",
+        sizeof (GstMetaV4l2), (GstMetaInitFunction) NULL,
+        (GstMetaFreeFunction) NULL, (GstMetaCopyFunction) NULL,
+        (GstMetaTransformFunction) NULL);
   }
+  return meta_info;
 }
 
-static void
-gst_v4l2_buffer_class_init (gpointer g_class, gpointer class_data)
-{
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
-
-  v4l2buffer_parent_class = g_type_class_peek_parent (g_class);
-
-  mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
-      gst_v4l2_buffer_finalize;
-}
+/*
+ * GstV4l2BufferPool:
+ */
+#define gst_v4l2_buffer_pool_parent_class parent_class
+G_DEFINE_TYPE (GstV4l2BufferPool, gst_v4l2_buffer_pool, GST_TYPE_BUFFER_POOL);
 
-GType
-gst_v4l2_buffer_get_type (void)
-{
-  static GType _gst_v4l2_buffer_type;
-
-  if (G_UNLIKELY (_gst_v4l2_buffer_type == 0)) {
-    static const GTypeInfo v4l2_buffer_info = {
-      sizeof (GstBufferClass),
-      NULL,
-      NULL,
-      gst_v4l2_buffer_class_init,
-      NULL,
-      NULL,
-      sizeof (GstV4l2Buffer),
-      0,
-      NULL,
-      NULL
-    };
-    _gst_v4l2_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
-        "GstV4l2Buffer", &v4l2_buffer_info, 0);
-  }
-  return _gst_v4l2_buffer_type;
-}
+static void gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool,
+    GstBuffer * buffer);
 
-static GstV4l2Buffer *
-gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
+static void
+gst_v4l2_buffer_pool_free_buffer (GstBufferPool * bpool, GstBuffer * buffer)
 {
-  GstV4l2Buffer *ret;
-  guint8 *data;
-
-  ret = (GstV4l2Buffer *) gst_mini_object_new (GST_TYPE_V4L2_BUFFER);
-
-  GST_LOG_OBJECT (pool->v4l2elem, "creating buffer %u, %p in pool %p", index,
-      ret, pool);
-
-  ret->pool =
-      (GstV4l2BufferPool *) gst_mini_object_ref (GST_MINI_OBJECT (pool));
+  GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
+  GstV4l2Object *obj;
 
-  ret->vbuffer.index = index;
-  ret->vbuffer.type = pool->type;
-  ret->vbuffer.memory = V4L2_MEMORY_MMAP;
+  obj = pool->obj;
 
-  if (v4l2_ioctl (pool->video_fd, VIDIOC_QUERYBUF, &ret->vbuffer) < 0)
-    goto querybuf_failed;
+  switch (obj->mode) {
+    case GST_V4L2_IO_RW:
+      break;
+    case GST_V4L2_IO_MMAP:
+    {
+      GstMetaV4l2 *meta;
+      gint index;
 
-  GST_LOG_OBJECT (pool->v4l2elem, "  index:     %u", ret->vbuffer.index);
-  GST_LOG_OBJECT (pool->v4l2elem, "  type:      %d", ret->vbuffer.type);
-  GST_LOG_OBJECT (pool->v4l2elem, "  bytesused: %u", ret->vbuffer.bytesused);
-  GST_LOG_OBJECT (pool->v4l2elem, "  flags:     %08x", ret->vbuffer.flags);
-  GST_LOG_OBJECT (pool->v4l2elem, "  field:     %d", ret->vbuffer.field);
-  GST_LOG_OBJECT (pool->v4l2elem, "  memory:    %d", ret->vbuffer.memory);
-  if (ret->vbuffer.memory == V4L2_MEMORY_MMAP)
-    GST_LOG_OBJECT (pool->v4l2elem, "  MMAP offset:  %u",
-        ret->vbuffer.m.offset);
-  GST_LOG_OBJECT (pool->v4l2elem, "  length:    %u", ret->vbuffer.length);
-  GST_LOG_OBJECT (pool->v4l2elem, "  input:     %u", ret->vbuffer.input);
+      meta = GST_META_V4L2_GET (buffer);
+      g_assert (meta != NULL);
 
-  data = (guint8 *) v4l2_mmap (0, ret->vbuffer.length,
-      PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd,
-      ret->vbuffer.m.offset);
+      index = meta->vbuffer.index;
+      GST_LOG_OBJECT (pool,
+          "mmap buffer %p idx %d (data %p, len %u) freed, unmapping", buffer,
+          index, meta->mem, meta->vbuffer.length);
 
-  if (data == MAP_FAILED)
-    goto mmap_failed;
+      v4l2_munmap (meta->mem, meta->vbuffer.length);
+      pool->buffers[index] = NULL;
+      break;
+    }
+    case GST_V4L2_IO_USERPTR:
+    default:
+      g_assert_not_reached ();
+      break;
+  }
+  gst_buffer_unref (buffer);
+}
 
-  GST_BUFFER_DATA (ret) = data;
-  GST_BUFFER_SIZE (ret) = ret->vbuffer.length;
+static GstFlowReturn
+gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
+    GstBufferPoolParams * params)
+{
+  GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
+  GstBuffer *newbuf;
+  GstMetaV4l2 *meta;
+  GstV4l2Object *obj;
+  GstVideoInfo *info;
+  guint index;
+
+  obj = pool->obj;
+  info = &obj->info;
+
+  switch (obj->mode) {
+    case GST_V4L2_IO_RW:
+    {
+      newbuf =
+          gst_buffer_new_allocate (pool->allocator, pool->size, pool->align);
+      break;
+    }
+    case GST_V4L2_IO_MMAP:
+    {
+      newbuf = gst_buffer_new ();
+      meta = GST_META_V4L2_ADD (newbuf);
+
+      index = pool->num_allocated;
+
+      GST_LOG_OBJECT (pool, "creating buffer %u, %p", index, newbuf, pool);
+
+      meta->vbuffer.index = index;
+      meta->vbuffer.type = obj->type;
+      meta->vbuffer.memory = V4L2_MEMORY_MMAP;
+
+      if (v4l2_ioctl (pool->video_fd, VIDIOC_QUERYBUF, &meta->vbuffer) < 0)
+        goto querybuf_failed;
+
+      GST_LOG_OBJECT (pool, "  index:     %u", meta->vbuffer.index);
+      GST_LOG_OBJECT (pool, "  type:      %d", meta->vbuffer.type);
+      GST_LOG_OBJECT (pool, "  bytesused: %u", meta->vbuffer.bytesused);
+      GST_LOG_OBJECT (pool, "  flags:     %08x", meta->vbuffer.flags);
+      GST_LOG_OBJECT (pool, "  field:     %d", meta->vbuffer.field);
+      GST_LOG_OBJECT (pool, "  memory:    %d", meta->vbuffer.memory);
+      if (meta->vbuffer.memory == V4L2_MEMORY_MMAP)
+        GST_LOG_OBJECT (pool, "  MMAP offset:  %u", meta->vbuffer.m.offset);
+      GST_LOG_OBJECT (pool, "  length:    %u", meta->vbuffer.length);
+      GST_LOG_OBJECT (pool, "  input:     %u", meta->vbuffer.input);
+
+      meta->mem = v4l2_mmap (0, meta->vbuffer.length,
+          PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd,
+          meta->vbuffer.m.offset);
+      if (meta->mem == MAP_FAILED)
+        goto mmap_failed;
+
+      gst_buffer_take_memory (newbuf, -1,
+          gst_memory_new_wrapped (0,
+              meta->mem, NULL, meta->vbuffer.length, 0, meta->vbuffer.length));
+
+      /* add metadata to raw video buffers */
+      if (pool->add_videometa && info->finfo) {
+        gsize offset[GST_VIDEO_MAX_PLANES];
+        gint stride[GST_VIDEO_MAX_PLANES];
+
+        offset[0] = 0;
+        stride[0] = obj->bytesperline;
+
+        GST_DEBUG_OBJECT (pool, "adding video meta, stride %d", stride[0]);
+        gst_buffer_add_meta_video_full (newbuf, info->flags,
+            GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
+            GST_VIDEO_INFO_HEIGHT (info), GST_VIDEO_INFO_N_PLANES (info),
+            offset, stride);
+      }
+      break;
+    }
+    case GST_V4L2_IO_USERPTR:
+    default:
+      g_assert_not_reached ();
+      break;
+  }
 
-  GST_BUFFER_FLAG_SET (ret, GST_BUFFER_FLAG_READONLY);
+  pool->num_allocated++;
 
-  gst_buffer_set_caps (GST_BUFFER (ret), caps);
+  *buffer = newbuf;
 
-  return ret;
+  return GST_FLOW_OK;
 
   /* ERRORS */
 querybuf_failed:
@@ -204,448 +208,898 @@ querybuf_failed:
     gint errnosave = errno;
 
     GST_WARNING ("Failed QUERYBUF: %s", g_strerror (errnosave));
-    gst_buffer_unref (GST_BUFFER (ret));
+    gst_buffer_unref (newbuf);
     errno = errnosave;
-    return NULL;
+    return GST_FLOW_ERROR;
   }
 mmap_failed:
   {
     gint errnosave = errno;
 
     GST_WARNING ("Failed to mmap: %s", g_strerror (errnosave));
-    gst_buffer_unref (GST_BUFFER (ret));
+    gst_buffer_unref (newbuf);
     errno = errnosave;
-    return NULL;
+    return GST_FLOW_ERROR;
   }
 }
 
+static gboolean
+gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
+{
+  GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
+  GstV4l2Object *obj = pool->obj;
+  const GstCaps *caps;
+  guint size, min_buffers, max_buffers;
+  guint prefix, align;
 
-/*
- * GstV4l2BufferPool:
- */
+  GST_DEBUG_OBJECT (pool, "set config");
 
-static GstMiniObjectClass *buffer_pool_parent_class = NULL;
+  pool->add_videometa =
+      gst_buffer_pool_config_has_option (config,
+      GST_BUFFER_POOL_OPTION_META_VIDEO);
 
-static void
-gst_v4l2_buffer_pool_finalize (GstV4l2BufferPool * pool)
-{
-  g_mutex_free (pool->lock);
-  pool->lock = NULL;
+  if (!pool->add_videometa) {
+    gint stride;
 
-  g_async_queue_unref (pool->avail_buffers);
-  pool->avail_buffers = NULL;
+    /* we don't have video metadata, see if the strides are compatible */
+    stride = GST_VIDEO_INFO_PLANE_STRIDE (&obj->info, 0);
 
-  if (pool->video_fd >= 0)
-    v4l2_close (pool->video_fd);
+    GST_DEBUG_OBJECT (pool, "no videometadata, checking strides %d and %u",
+        stride, obj->bytesperline);
 
-  if (pool->buffers) {
-    g_free (pool->buffers);
-    pool->buffers = NULL;
+    if (stride != obj->bytesperline)
+      goto missing_video_api;
   }
 
-  GST_MINI_OBJECT_CLASS (buffer_pool_parent_class)->finalize (GST_MINI_OBJECT
-      (pool));
-}
+  /* parse the config and keep around */
+  if (!gst_buffer_pool_config_get (config, &caps, &size, &min_buffers,
+          &max_buffers, &prefix, &align))
+    goto wrong_config;
 
-static void
-gst_v4l2_buffer_pool_init (GstV4l2BufferPool * pool, gpointer g_class)
-{
-  pool->lock = g_mutex_new ();
-  pool->running = FALSE;
-  pool->num_live_buffers = 0;
-}
+  GST_DEBUG_OBJECT (pool, "config %" GST_PTR_FORMAT, config);
 
-static void
-gst_v4l2_buffer_pool_class_init (gpointer g_class, gpointer class_data)
-{
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
+  pool->size = size;
+  pool->max_buffers = MAX (min_buffers, max_buffers);
+  pool->min_buffers = MIN (pool->max_buffers, min_buffers);
+  pool->prefix = prefix;
+  pool->align = align;
 
-  buffer_pool_parent_class = g_type_class_peek_parent (g_class);
+  gst_buffer_pool_config_set (config, caps, size, min_buffers,
+      max_buffers, prefix, align);
 
-  mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
-      gst_v4l2_buffer_pool_finalize;
-}
+  return GST_BUFFER_POOL_CLASS (parent_class)->set_config (bpool, config);
 
-GType
-gst_v4l2_buffer_pool_get_type (void)
-{
-  static GType _gst_v4l2_buffer_pool_type;
-
-  if (G_UNLIKELY (_gst_v4l2_buffer_pool_type == 0)) {
-    static const GTypeInfo v4l2_buffer_pool_info = {
-      sizeof (GstMiniObjectClass),
-      NULL,
-      NULL,
-      gst_v4l2_buffer_pool_class_init,
-      NULL,
-      NULL,
-      sizeof (GstV4l2BufferPool),
-      0,
-      (GInstanceInitFunc) gst_v4l2_buffer_pool_init,
-      NULL
-    };
-    _gst_v4l2_buffer_pool_type = g_type_register_static (GST_TYPE_MINI_OBJECT,
-        "GstV4l2BufferPool", &v4l2_buffer_pool_info, 0);
-  }
-  return _gst_v4l2_buffer_pool_type;
+  /* ERRORS */
+missing_video_api:
+  {
+    GST_ERROR_OBJECT (pool, "missing GstMetaVideo API in config, "
+        "default stride: %d, wanted stride %u",
+        GST_VIDEO_INFO_PLANE_STRIDE (&obj->info, 0), obj->bytesperline);
+    return FALSE;
+  }
+wrong_config:
+  {
+    GST_ERROR_OBJECT (pool, "invalid config %" GST_PTR_FORMAT, config);
+    return FALSE;
+  }
 }
 
-
-/* this is somewhat of a hack.. but better to keep the hack in
- * one place than copy/pasting it around..
- */
-static GstV4l2Object *
-get_v4l2_object (GstElement * v4l2elem)
+static gboolean
+start_streaming (GstV4l2BufferPool * pool)
 {
-  GstV4l2Object *v4l2object = NULL;
-  if (GST_IS_V4L2SRC (v4l2elem)) {
-    v4l2object = (GST_V4L2SRC (v4l2elem))->v4l2object;
-#ifdef HAVE_EXPERIMENTAL
-  } else if (GST_IS_V4L2SINK (v4l2elem)) {
-    v4l2object = (GST_V4L2SINK (v4l2elem))->v4l2object;
-#endif
-  } else {
-    GST_ERROR_OBJECT (v4l2elem, "unknown v4l2 element");
+  GstV4l2Object *obj = pool->obj;
+
+  switch (obj->mode) {
+    case GST_V4L2_IO_RW:
+      break;
+    case GST_V4L2_IO_MMAP:
+    case GST_V4L2_IO_USERPTR:
+      GST_DEBUG_OBJECT (pool, "STREAMON");
+      if (v4l2_ioctl (pool->video_fd, VIDIOC_STREAMON, &obj->type) < 0)
+        goto start_failed;
+      break;
+    default:
+      g_assert_not_reached ();
+      break;
   }
-  return v4l2object;
-}
 
+  pool->streaming = TRUE;
 
+  return TRUE;
 
-/**
- * gst_v4l2_buffer_pool_new:
- * @v4l2elem:  the v4l2 element (src or sink) that owns this pool
- * @fd:   the video device file descriptor
- * @num_buffers:  the requested number of buffers in the pool
- * @caps:  the caps to set on the buffer
- * @requeuebuf: if %TRUE, and if the pool is still in the running state, a
- *  buffer with no remaining references is immediately passed back to v4l2
- *  (VIDIOC_QBUF), otherwise it is returned to the pool of available buffers
- *  (which can be accessed via gst_v4l2_buffer_pool_get().
- *
- * Construct a new buffer pool.
- *
- * Returns: the new pool, use gst_v4l2_buffer_pool_destroy() to free resources
- */
-GstV4l2BufferPool *
-gst_v4l2_buffer_pool_new (GstElement * v4l2elem, gint fd, gint num_buffers,
-    GstCaps * caps, gboolean requeuebuf, enum v4l2_buf_type type)
+  /* ERRORS */
+start_failed:
+  {
+    GST_ERROR_OBJECT (pool, "error with STREAMON %d (%s)", errno,
+        g_strerror (errno));
+    return FALSE;
+  }
+}
+
+static gboolean
+gst_v4l2_buffer_pool_start (GstBufferPool * bpool)
 {
-  GstV4l2BufferPool *pool;
+  GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
+  GstV4l2Object *obj = pool->obj;
   gint n;
   struct v4l2_requestbuffers breq;
+  gint min_buffers, max_buffers;
 
-  pool = (GstV4l2BufferPool *) gst_mini_object_new (GST_TYPE_V4L2_BUFFER_POOL);
-
-  pool->video_fd = v4l2_dup (fd);
-  if (pool->video_fd < 0)
-    goto dup_failed;
+  min_buffers = pool->min_buffers;
+  max_buffers = pool->max_buffers;
 
+  switch (obj->mode) {
+    case GST_V4L2_IO_RW:
+    {
+      break;
+    }
+    case GST_V4L2_IO_MMAP:
+    {
+      /* first, lets request buffers, and see how many we can get: */
+      GST_DEBUG_OBJECT (pool, "starting, requesting %d MMAP buffers",
+          max_buffers);
 
-  /* first, lets request buffers, and see how many we can get: */
-  GST_DEBUG_OBJECT (v4l2elem, "STREAMING, requesting %d MMAP buffers",
-      num_buffers);
+      if (max_buffers == 0)
+        max_buffers = 4;
 
-  memset (&breq, 0, sizeof (struct v4l2_requestbuffers));
-  breq.type = type;
-  breq.count = num_buffers;
-  breq.memory = V4L2_MEMORY_MMAP;
+      memset (&breq, 0, sizeof (struct v4l2_requestbuffers));
+      breq.type = obj->type;
+      breq.count = max_buffers;
+      breq.memory = V4L2_MEMORY_MMAP;
 
-  if (v4l2_ioctl (fd, VIDIOC_REQBUFS, &breq) < 0)
-    goto reqbufs_failed;
+      if (v4l2_ioctl (pool->video_fd, VIDIOC_REQBUFS, &breq) < 0)
+        goto reqbufs_failed;
 
-  GST_LOG_OBJECT (v4l2elem, " count:  %u", breq.count);
-  GST_LOG_OBJECT (v4l2elem, " type:   %d", breq.type);
-  GST_LOG_OBJECT (v4l2elem, " memory: %d", breq.memory);
+      GST_LOG_OBJECT (pool, " count:  %u", breq.count);
+      GST_LOG_OBJECT (pool, " type:   %d", breq.type);
+      GST_LOG_OBJECT (pool, " memory: %d", breq.memory);
 
-  if (breq.count < GST_V4L2_MIN_BUFFERS)
-    goto no_buffers;
+      if (breq.count < GST_V4L2_MIN_BUFFERS)
+        goto no_buffers;
 
-  if (num_buffers != breq.count) {
-    GST_WARNING_OBJECT (v4l2elem, "using %u buffers instead", breq.count);
-    num_buffers = breq.count;
+      if (max_buffers != breq.count) {
+        GST_WARNING_OBJECT (pool, "using %u buffers instead", breq.count);
+        max_buffers = breq.count;
+      }
+      break;
+    }
+    case GST_V4L2_IO_USERPTR:
+    default:
+      g_assert_not_reached ();
+      break;
   }
 
-  pool->v4l2elem = v4l2elem;
-  pool->requeuebuf = requeuebuf;
-  pool->type = type;
-  pool->buffer_count = num_buffers;
-  pool->buffers = g_new0 (GstV4l2Buffer *, num_buffers);
-  pool->avail_buffers = g_async_queue_new ();
+  pool->obj = obj;
+  pool->max_buffers = max_buffers;
+  pool->buffers = g_new0 (GstBuffer *, max_buffers);
+  pool->num_allocated = 0;
+
+  /* now, allocate the buffers: */
+  for (n = 0; n < min_buffers; n++) {
+    GstBuffer *buffer;
 
-  /* now, map the buffers: */
-  for (n = 0; n < num_buffers; n++) {
-    pool->buffers[n] = gst_v4l2_buffer_new (pool, n, caps);
-    if (!pool->buffers[n])
+    if (gst_v4l2_buffer_pool_alloc_buffer (bpool, &buffer, NULL) != GST_FLOW_OK)
       goto buffer_new_failed;
-    pool->num_live_buffers++;
-    g_async_queue_push (pool->avail_buffers, pool->buffers[n]);
-  }
 
-  return pool;
+    gst_v4l2_buffer_pool_release_buffer (bpool, buffer);
+  }
 
-  /* ERRORS */
-dup_failed:
-  {
-    gint errnosave = errno;
+  /* we can start capturing now, we wait for the playback case until we queued
+   * the first buffer */
+  if (obj->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+    if (!start_streaming (pool))
+      goto start_failed;
 
-    gst_mini_object_unref (GST_MINI_OBJECT (pool));
+  gst_poll_set_flushing (obj->poll, FALSE);
 
-    errno = errnosave;
+  return TRUE;
 
-    return NULL;
-  }
+  /* ERRORS */
 reqbufs_failed:
   {
-    GstV4l2Object *v4l2object = get_v4l2_object (v4l2elem);
-    GST_ELEMENT_ERROR (v4l2elem, RESOURCE, READ,
-        (_("Could not get buffers from device '%s'."),
-            v4l2object->videodev),
-        ("error requesting %d buffers: %s", num_buffers, g_strerror (errno)));
-    return NULL;
+    GST_ERROR_OBJECT (pool,
+        "error requesting %d buffers: %s", max_buffers, g_strerror (errno));
+    return FALSE;
   }
 no_buffers:
   {
-    GstV4l2Object *v4l2object = get_v4l2_object (v4l2elem);
-    GST_ELEMENT_ERROR (v4l2elem, RESOURCE, READ,
-        (_("Could not get enough buffers from device '%s'."),
-            v4l2object->videodev),
-        ("we received %d from device '%s', we want at least %d",
-            breq.count, v4l2object->videodev, GST_V4L2_MIN_BUFFERS));
-    return NULL;
+    GST_ERROR_OBJECT (pool,
+        "we received %d from device '%s', we want at least %d",
+        breq.count, obj->videodev, GST_V4L2_MIN_BUFFERS);
+    return FALSE;
   }
 buffer_new_failed:
   {
-    gint errnosave = errno;
+    GST_ERROR_OBJECT (pool, "failed to create a buffer");
+    return FALSE;
+  }
+start_failed:
+  {
+    GST_ERROR_OBJECT (pool, "failed to start streaming");
+    return FALSE;
+  }
+}
 
-    gst_v4l2_buffer_pool_destroy (pool);
+static gboolean
+gst_v4l2_buffer_pool_stop (GstBufferPool * bpool)
+{
+  gboolean ret;
+  GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
+  GstV4l2Object *obj = pool->obj;
+  guint n;
+
+  GST_DEBUG_OBJECT (pool, "stopping pool");
+
+  gst_poll_set_flushing (obj->poll, TRUE);
+
+  if (pool->streaming) {
+    switch (obj->mode) {
+      case GST_V4L2_IO_RW:
+        break;
+      case GST_V4L2_IO_MMAP:
+      case GST_V4L2_IO_USERPTR:
+        /* we actually need to sync on all queued buffers but not
+         * on the non-queued ones */
+        GST_DEBUG_OBJECT (pool, "STREAMOFF");
+        if (v4l2_ioctl (pool->video_fd, VIDIOC_STREAMOFF, &obj->type) < 0)
+          goto stop_failed;
+        break;
+      default:
+        g_assert_not_reached ();
+        break;
+    }
+    pool->streaming = FALSE;
+  }
 
-    errno = errnosave;
+  /* first free the buffers in the queue */
+  ret = GST_BUFFER_POOL_CLASS (parent_class)->stop (bpool);
 
-    return NULL;
+  /* then free the remaining buffers */
+  for (n = 0; n < pool->num_allocated; n++) {
+    if (pool->buffers[n])
+      gst_v4l2_buffer_pool_free_buffer (bpool, pool->buffers[n]);
+  }
+  g_free (pool->buffers);
+  pool->buffers = NULL;
+
+  return ret;
+
+  /* ERRORS */
+stop_failed:
+  {
+    GST_ERROR_OBJECT (pool, "error with STREAMOFF %d (%s)", errno,
+        g_strerror (errno));
+    return FALSE;
   }
 }
 
-/**
- * gst_v4l2_buffer_pool_destroy:
- * @pool: the pool
- *
- * Free all resources in the pool and the pool itself.
- */
-void
-gst_v4l2_buffer_pool_destroy (GstV4l2BufferPool * pool)
+static GstFlowReturn
+gst_v4l2_object_poll (GstV4l2Object * v4l2object)
 {
-  gint n;
+  gint ret;
+
+  if (v4l2object->can_poll_device) {
+    GST_LOG_OBJECT (v4l2object->element, "polling device");
+    ret = gst_poll_wait (v4l2object->poll, GST_CLOCK_TIME_NONE);
+    if (G_UNLIKELY (ret < 0)) {
+      if (errno == EBUSY)
+        goto stopped;
+      if (errno == ENXIO) {
+        GST_WARNING_OBJECT (v4l2object->element,
+            "v4l2 device doesn't support polling. Disabling");
+        v4l2object->can_poll_device = FALSE;
+      } else {
+        if (errno != EAGAIN && errno != EINTR)
+          goto select_error;
+      }
+    }
+  }
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+stopped:
+  {
+    GST_DEBUG ("stop called");
+    return GST_FLOW_WRONG_STATE;
+  }
+select_error:
+  {
+    GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, READ, (NULL),
+        ("poll error %d: %s (%d)", ret, g_strerror (errno), errno));
+    return GST_FLOW_ERROR;
+  }
+}
+
+static GstFlowReturn
+gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool * pool, GstBuffer * buf)
+{
+  GstMetaV4l2 *meta;
+  gint index;
+
+  meta = GST_META_V4L2_GET (buf);
+  g_assert (meta != NULL);
 
-  GST_V4L2_BUFFER_POOL_LOCK (pool);
-  pool->running = FALSE;
-  GST_V4L2_BUFFER_POOL_UNLOCK (pool);
+  index = meta->vbuffer.index;
 
-  GST_DEBUG_OBJECT (pool->v4l2elem, "destroy pool");
+  GST_LOG_OBJECT (pool, "enqueue buffer %p, index:%d, queued:%d", buf,
+      index, pool->num_queued);
 
-  /* after this point, no more buffers will be queued or dequeued; no buffer
-   * from pool->buffers that is NULL will be set to a buffer, and no buffer that
-   * is not NULL will be pushed out. */
+  if (pool->buffers[index] != NULL)
+    goto already_queued;
 
-  /* miniobjects have no dispose, so they can't break ref-cycles, as buffers ref
-   * the pool, we need to unref the buffer to properly finalize te pool */
-  for (n = 0; n < pool->buffer_count; n++) {
-    GstBuffer *buf;
+  if (v4l2_ioctl (pool->video_fd, VIDIOC_QBUF, &meta->vbuffer) < 0)
+    goto queue_failed;
 
-    GST_V4L2_BUFFER_POOL_LOCK (pool);
-    buf = GST_BUFFER (pool->buffers[n]);
-    GST_V4L2_BUFFER_POOL_UNLOCK (pool);
+  pool->buffers[index] = buf;
+  pool->num_queued++;
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+already_queued:
+  {
+    GST_WARNING_OBJECT (pool, "the buffer was already queued");
+    return GST_FLOW_ERROR;
+  }
+queue_failed:
+  {
+    GST_WARNING_OBJECT (pool, "could not queue a buffer %d (%s)", errno,
+        g_strerror (errno));
+    return GST_FLOW_ERROR;
+  }
+}
 
-    if (buf)
-      /* we own the ref if the buffer is in pool->buffers; drop it. */
-      gst_buffer_unref (buf);
+static GstFlowReturn
+gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool * pool, GstBuffer ** buffer)
+{
+  GstFlowReturn res;
+  GstBuffer *outbuf;
+  struct v4l2_buffer vbuffer;
+  GstV4l2Object *obj = pool->obj;
+
+  if (obj->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+    /* select works for input devices when data is available. According to the
+     * specs we can also poll to find out when a frame has been displayed but
+     * that just seems to lock up here */
+    if ((res = gst_v4l2_object_poll (obj)) != GST_FLOW_OK)
+      goto poll_error;
   }
 
-  gst_mini_object_unref (GST_MINI_OBJECT (pool));
+  memset (&vbuffer, 0x00, sizeof (vbuffer));
+  vbuffer.type = obj->type;
+  vbuffer.memory = V4L2_MEMORY_MMAP;
+
+  GST_LOG_OBJECT (pool, "doing DQBUF");
+  if (v4l2_ioctl (pool->video_fd, VIDIOC_DQBUF, &vbuffer) < 0)
+    goto error;
+
+  /* get our GstBuffer with that index from the pool, if the buffer was
+   * outstanding we have a serious problem.
+   */
+  outbuf = pool->buffers[vbuffer.index];
+  if (outbuf == NULL)
+    goto no_buffer;
+
+  /* mark the buffer outstanding */
+  pool->buffers[vbuffer.index] = NULL;
+  pool->num_queued--;
+
+  GST_LOG_OBJECT (pool,
+      "dequeued buffer %p seq:%d (ix=%d), used %d, flags %08x, pool-queued=%d, buffer=%p",
+      outbuf, vbuffer.sequence, vbuffer.index, vbuffer.bytesused, vbuffer.flags,
+      pool->num_queued, outbuf);
+
+  /* set top/bottom field first if v4l2_buffer has the information */
+  if (vbuffer.field == V4L2_FIELD_INTERLACED_TB)
+    GST_BUFFER_FLAG_SET (outbuf, GST_VIDEO_BUFFER_FLAG_TFF);
+  if (vbuffer.field == V4L2_FIELD_INTERLACED_BT)
+    GST_BUFFER_FLAG_UNSET (outbuf, GST_VIDEO_BUFFER_FLAG_TFF);
+
+  /* this can change at every frame, esp. with jpeg */
+  if (obj->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+    gst_buffer_resize (outbuf, 0, vbuffer.bytesused);
+  else
+    gst_buffer_resize (outbuf, 0, vbuffer.length);
+
+  *buffer = outbuf;
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+poll_error:
+  {
+    GST_DEBUG_OBJECT (pool, "poll error %s", gst_flow_get_name (res));
+    return res;
+  }
+error:
+  {
+    GST_WARNING_OBJECT (pool,
+        "problem dequeuing frame %d (ix=%d), pool-ct=%d, buf.flags=%d",
+        vbuffer.sequence, vbuffer.index,
+        GST_MINI_OBJECT_REFCOUNT (pool), vbuffer.flags);
+
+    switch (errno) {
+      case EAGAIN:
+        GST_WARNING_OBJECT (pool,
+            "Non-blocking I/O has been selected using O_NONBLOCK and"
+            " no buffer was in the outgoing queue. device %s", obj->videodev);
+        break;
+      case EINVAL:
+        GST_ERROR_OBJECT (pool,
+            "The buffer type is not supported, or the index is out of bounds, "
+            "or no buffers have been allocated yet, or the userptr "
+            "or length are invalid. device %s", obj->videodev);
+        break;
+      case ENOMEM:
+        GST_ERROR_OBJECT (pool,
+            "insufficient memory to enqueue a user pointer buffer");
+        break;
+      case EIO:
+        GST_INFO_OBJECT (pool,
+            "VIDIOC_DQBUF failed due to an internal error."
+            " Can also indicate temporary problems like signal loss."
+            " Note the driver might dequeue an (empty) buffer despite"
+            " returning an error, or even stop capturing."
+            " device %s", obj->videodev);
+        /* have we de-queued a buffer ? */
+        if (!(vbuffer.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE))) {
+          GST_DEBUG_OBJECT (pool, "reenqueing buffer");
+          /* FIXME ... should we do something here? */
+        }
+        break;
+      case EINTR:
+        GST_WARNING_OBJECT (pool,
+            "could not sync on a buffer on device %s", obj->videodev);
+        break;
+      default:
+        GST_WARNING_OBJECT (pool,
+            "Grabbing frame got interrupted on %s unexpectedly. %d: %s.",
+            obj->videodev, errno, g_strerror (errno));
+        break;
+    }
+    return GST_FLOW_ERROR;
+  }
+no_buffer:
+  {
+    GST_ERROR_OBJECT (pool, "No free buffer found in the pool at index %d.",
+        vbuffer.index);
+    return GST_FLOW_ERROR;
+  }
 }
 
-/**
- * gst_v4l2_buffer_pool_get:
- * @pool:   the "this" object
- * @blocking:  should this call suspend until there is a buffer available
- *    in the buffer pool?
- *
- * Get an available buffer in the pool
- */
-GstV4l2Buffer *
-gst_v4l2_buffer_pool_get (GstV4l2BufferPool * pool, gboolean blocking)
+static GstFlowReturn
+gst_v4l2_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
+    GstBufferPoolParams * params)
 {
-  GstV4l2Buffer *buf;
+  GstFlowReturn ret;
+  GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
+  GstV4l2Object *obj = pool->obj;
+
+  GST_DEBUG_OBJECT (pool, "acquire");
+
+  if (GST_BUFFER_POOL_IS_FLUSHING (bpool))
+    goto flushing;
+
+  switch (obj->type) {
+    case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+      /* capture, This function should return a buffer with new captured data */
+      switch (obj->mode) {
+        case GST_V4L2_IO_RW:
+          /* take empty buffer from the pool */
+          ret = GST_BUFFER_POOL_CLASS (parent_class)->acquire_buffer (bpool,
+              buffer, params);
+          break;
+
+        case GST_V4L2_IO_MMAP:
+          /* just dequeue a buffer, we basically use the queue of v4l2 as the
+           * storage for our buffers. This function does poll first so we can
+           * interrupt it fine. */
+          ret = gst_v4l2_buffer_pool_dqbuf (pool, buffer);
+          break;
+
+        case GST_V4L2_IO_USERPTR:
+        default:
+          g_assert_not_reached ();
+          break;
+      }
+      break;
 
-  if (blocking) {
-    buf = g_async_queue_pop (pool->avail_buffers);
-  } else {
-    buf = g_async_queue_try_pop (pool->avail_buffers);
+    case V4L2_BUF_TYPE_VIDEO_OUTPUT:
+      /* playback, This function should return an empty buffer */
+      switch (obj->mode) {
+        case GST_V4L2_IO_RW:
+          /* get an empty buffer */
+          ret = GST_BUFFER_POOL_CLASS (parent_class)->acquire_buffer (bpool,
+              buffer, params);
+          break;
+
+        case GST_V4L2_IO_MMAP:
+          /* get a free unqueued buffer */
+          ret = GST_BUFFER_POOL_CLASS (parent_class)->acquire_buffer (bpool,
+              buffer, params);
+          break;
+
+        case GST_V4L2_IO_USERPTR:
+        default:
+          g_assert_not_reached ();
+          break;
+      }
+      break;
+
+    default:
+      g_assert_not_reached ();
+      break;
   }
+  return ret;
 
-  if (buf) {
-    GST_V4L2_BUFFER_POOL_LOCK (pool);
-    GST_BUFFER_SIZE (buf) = buf->vbuffer.length;
-    GST_BUFFER_FLAG_UNSET (buf, 0xffffffff);
-    GST_V4L2_BUFFER_POOL_UNLOCK (pool);
+  /* ERRORS */
+flushing:
+  {
+    GST_DEBUG_OBJECT (pool, "We are flushing");
+    return GST_FLOW_WRONG_STATE;
   }
+}
 
-  pool->running = TRUE;
+static void
+gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer)
+{
+  GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
+  GstV4l2Object *obj = pool->obj;
+
+  GST_DEBUG_OBJECT (pool, "release buffer %p", buffer);
+
+  switch (obj->type) {
+    case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+      /* capture, put the buffer back in the queue so that we can refill it
+       * later. */
+      switch (obj->mode) {
+        case GST_V4L2_IO_RW:
+          /* release back in the pool */
+          GST_BUFFER_POOL_CLASS (parent_class)->release_buffer (bpool, buffer);
+          break;
+
+        case GST_V4L2_IO_MMAP:
+          /* queue back in the device */
+          gst_v4l2_buffer_pool_qbuf (pool, buffer);
+          break;
+
+        case GST_V4L2_IO_USERPTR:
+        default:
+          g_assert_not_reached ();
+          break;
+      }
+      break;
 
-  return buf;
-}
+    case V4L2_BUF_TYPE_VIDEO_OUTPUT:
+      switch (obj->mode) {
+        case GST_V4L2_IO_RW:
+          /* release back in the pool */
+          GST_BUFFER_POOL_CLASS (parent_class)->release_buffer (bpool, buffer);
+          break;
+
+        case GST_V4L2_IO_MMAP:
+        {
+          GstMetaV4l2 *meta;
+
+          meta = GST_META_V4L2_GET (buffer);
+          g_assert (meta != NULL);
+
+          if (pool->buffers[meta->vbuffer.index] == NULL) {
+            GST_LOG_OBJECT (pool, "buffer not queued, putting on free list");
+            /* playback, put the buffer back in the queue to refill later. */
+            GST_BUFFER_POOL_CLASS (parent_class)->release_buffer (bpool,
+                buffer);
+          } else {
+            /* the buffer is queued in the device but maybe not played yet. We just
+             * leave it there and not make it available for future calls to acquire
+             * for now. The buffer will be dequeued and reused later. */
+            GST_LOG_OBJECT (pool, "buffer is queued");
+          }
+          break;
+        }
+
+        case GST_V4L2_IO_USERPTR:
+        default:
+          g_assert_not_reached ();
+          break;
+      }
+      break;
 
+    default:
+      g_assert_not_reached ();
+      break;
+  }
+}
 
-/**
- * gst_v4l2_buffer_pool_qbuf:
- * @pool: the pool
- * @buf: the buffer to queue
- *
- * Queue a buffer to the driver
- *
- * Returns: %TRUE for success
- */
-gboolean
-gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool * pool, GstV4l2Buffer * buf)
+static void
+gst_v4l2_buffer_pool_finalize (GObject * object)
 {
-  GST_LOG_OBJECT (pool->v4l2elem, "enqueue pool buffer %d", buf->vbuffer.index);
+  GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (object);
 
-  if (v4l2_ioctl (pool->video_fd, VIDIOC_QBUF, &buf->vbuffer) < 0)
-    return FALSE;
+  if (pool->video_fd >= 0)
+    v4l2_close (pool->video_fd);
 
-  pool->num_live_buffers--;
-  GST_DEBUG_OBJECT (pool->v4l2elem, "num_live_buffers--: %d",
-      pool->num_live_buffers);
+  g_free (pool->buffers);
 
-  return TRUE;
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gst_v4l2_buffer_pool_init (GstV4l2BufferPool * pool)
+{
+}
+
+static void
+gst_v4l2_buffer_pool_class_init (GstV4l2BufferPoolClass * klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GstBufferPoolClass *bufferpool_class = GST_BUFFER_POOL_CLASS (klass);
+
+  object_class->finalize = gst_v4l2_buffer_pool_finalize;
+
+  bufferpool_class->start = gst_v4l2_buffer_pool_start;
+  bufferpool_class->stop = gst_v4l2_buffer_pool_stop;
+  bufferpool_class->set_config = gst_v4l2_buffer_pool_set_config;
+  bufferpool_class->alloc_buffer = gst_v4l2_buffer_pool_alloc_buffer;
+  bufferpool_class->acquire_buffer = gst_v4l2_buffer_pool_acquire_buffer;
+  bufferpool_class->release_buffer = gst_v4l2_buffer_pool_release_buffer;
+  bufferpool_class->free_buffer = gst_v4l2_buffer_pool_free_buffer;
 }
 
 /**
- * gst_v4l2_buffer_pool_dqbuf:
- * @pool: the pool
+ * gst_v4l2_buffer_pool_new:
+ * @obj:  the v4l2 object owning the pool
  *
- * Dequeue a buffer from the driver.  Some generic error handling is done in
- * this function, but any error handling specific to v4l2src (capture) or
- * v4l2sink (output) can be done outside this function by checking 'errno'
+ * Construct a new buffer pool.
  *
- * Returns: a buffer
+ * Returns: the new pool, use gst_object_unref() to free resources
  */
-GstV4l2Buffer *
-gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool * pool)
+GstBufferPool *
+gst_v4l2_buffer_pool_new (GstV4l2Object * obj, GstCaps * caps)
 {
-  GstV4l2Object *v4l2object = get_v4l2_object (pool->v4l2elem);
-  GstV4l2Buffer *pool_buffer;
-  struct v4l2_buffer buffer;
+  GstV4l2BufferPool *pool;
+  gint fd;
 
-  memset (&buffer, 0x00, sizeof (buffer));
-  buffer.type = pool->type;
-  buffer.memory = V4L2_MEMORY_MMAP;
+  fd = v4l2_dup (obj->video_fd);
+  if (fd < 0)
+    goto dup_failed;
 
+  pool = (GstV4l2BufferPool *) g_object_new (GST_TYPE_V4L2_BUFFER_POOL, NULL);
+  pool->video_fd = fd;
+  pool->obj = obj;
 
-  if (v4l2_ioctl (pool->video_fd, VIDIOC_DQBUF, &buffer) >= 0) {
+  gst_buffer_pool_config_set (GST_BUFFER_POOL_CAST (pool)->config, caps,
+      obj->sizeimage, 2, 0, 0, 0);
 
-    GST_V4L2_BUFFER_POOL_LOCK (pool);
+  return GST_BUFFER_POOL (pool);
 
-    /* get our GstBuffer with that index from the pool, if the buffer was
-     * outstanding we have a serious problem.
-     */
-    pool_buffer = pool->buffers[buffer.index];
+  /* ERRORS */
+dup_failed:
+  {
+    GST_DEBUG ("failed to dup fd %d (%s)", errno, g_strerror (errno));
+    return NULL;
+  }
+}
 
-    if (pool_buffer == NULL) {
-      GST_ELEMENT_ERROR (pool->v4l2elem, RESOURCE, FAILED,
-          (_("Failed trying to get video frames from device '%s'."),
-              v4l2object->videodev),
-          (_("No free buffers found in the pool at index %d."), buffer.index));
-      GST_V4L2_BUFFER_POOL_UNLOCK (pool);
-      return NULL;
-    }
+static GstFlowReturn
+gst_v4l2_do_read (GstV4l2BufferPool * pool, GstBuffer * buf)
+{
+  GstFlowReturn res;
+  GstV4l2Object *obj = pool->obj;
+  gint amount;
+  gpointer data;
+  gint toread;
 
-    GST_LOG_OBJECT (pool->v4l2elem,
-        "grabbed frame %d (ix=%d), flags %08x, pool-ct=%d, buffer=%p",
-        buffer.sequence, buffer.index, buffer.flags, pool->num_live_buffers,
-        pool_buffer);
+  toread = obj->sizeimage;
 
-    pool->num_live_buffers++;
-    GST_DEBUG_OBJECT (pool->v4l2elem, "num_live_buffers++: %d",
-        pool->num_live_buffers);
+  GST_LOG_OBJECT (pool, "reading %d bytes into buffer %p", toread, buf);
 
-    /* set top/bottom field first if v4l2_buffer has the information */
-    if (buffer.field == V4L2_FIELD_INTERLACED_TB)
-      GST_BUFFER_FLAG_SET (pool_buffer, GST_VIDEO_BUFFER_TFF);
-    if (buffer.field == V4L2_FIELD_INTERLACED_BT)
-      GST_BUFFER_FLAG_UNSET (pool_buffer, GST_VIDEO_BUFFER_TFF);
+  data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
 
-    /* this can change at every frame, esp. with jpeg */
-    GST_BUFFER_SIZE (pool_buffer) = buffer.bytesused;
+  do {
+    if ((res = gst_v4l2_object_poll (obj)) != GST_FLOW_OK)
+      goto poll_error;
 
-    GST_V4L2_BUFFER_POOL_UNLOCK (pool);
+    amount = v4l2_read (obj->video_fd, data, toread);
 
-    return pool_buffer;
-  }
+    if (amount == toread) {
+      break;
+    } else if (amount == -1) {
+      if (errno == EAGAIN || errno == EINTR) {
+        continue;
+      } else
+        goto read_error;
+    } else {
+      /* short reads can happen if a signal interrupts the read */
+      continue;
+    }
+  } while (TRUE);
 
+  GST_LOG_OBJECT (pool, "read %d bytes", amount);
+  gst_buffer_unmap (buf, data, amount);
 
-  GST_WARNING_OBJECT (pool->v4l2elem,
-      "problem grabbing frame %d (ix=%d), pool-ct=%d, buf.flags=%d",
-      buffer.sequence, buffer.index,
-      GST_MINI_OBJECT_REFCOUNT (pool), buffer.flags);
+  return GST_FLOW_OK;
 
-  switch (errno) {
-    case EAGAIN:
-      GST_WARNING_OBJECT (pool->v4l2elem,
-          "Non-blocking I/O has been selected using O_NONBLOCK and"
-          " no buffer was in the outgoing queue. device %s",
-          v4l2object->videodev);
-      break;
-    case EINVAL:
-      GST_ELEMENT_ERROR (pool->v4l2elem, RESOURCE, FAILED,
-          (_("Failed trying to get video frames from device '%s'."),
-              v4l2object->videodev),
-          (_("The buffer type is not supported, or the index is out of bounds,"
-                  " or no buffers have been allocated yet, or the userptr"
-                  " or length are invalid. device %s"), v4l2object->videodev));
-      break;
-    case ENOMEM:
-      GST_ELEMENT_ERROR (pool->v4l2elem, RESOURCE, FAILED,
-          (_("Failed trying to get video frames from device '%s'. Not enough memory."), v4l2object->videodev), (_("insufficient memory to enqueue a user pointer buffer. device %s."), v4l2object->videodev));
-      break;
-    case EIO:
-      GST_INFO_OBJECT (pool->v4l2elem,
-          "VIDIOC_DQBUF failed due to an internal error."
-          " Can also indicate temporary problems like signal loss."
-          " Note the driver might dequeue an (empty) buffer despite"
-          " returning an error, or even stop capturing."
-          " device %s", v4l2object->videodev);
-      /* have we de-queued a buffer ? */
-      if (!(buffer.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE))) {
-        GST_DEBUG_OBJECT (pool->v4l2elem, "reenqueing buffer");
-        /* FIXME ... should we do something here? */
-      }
-      break;
-    case EINTR:
-      GST_WARNING_OBJECT (pool->v4l2elem,
-          "could not sync on a buffer on device %s", v4l2object->videodev);
-      break;
-    default:
-      GST_WARNING_OBJECT (pool->v4l2elem,
-          "Grabbing frame got interrupted on %s unexpectedly. %d: %s.",
-          v4l2object->videodev, errno, g_strerror (errno));
-      break;
+  /* ERRORS */
+poll_error:
+  {
+    GST_DEBUG ("poll error %s", gst_flow_get_name (res));
+    goto cleanup;
+  }
+read_error:
+  {
+    GST_ELEMENT_ERROR (obj->element, RESOURCE, READ,
+        (_("Error reading %d bytes from device '%s'."),
+            toread, obj->videodev), GST_ERROR_SYSTEM);
+    res = GST_FLOW_ERROR;
+    goto cleanup;
+  }
+cleanup:
+  {
+    gst_buffer_unmap (buf, data, 0);
+    return res;
   }
-
-  return NULL;
 }
 
 /**
- * gst_v4l2_buffer_pool_available_buffers:
- * @pool: the pool
+ * gst_v4l2_buffer_pool_process:
+ * @bpool: a #GstBufferPool
+ * @buf: a #GstBuffer
  *
- * Check the number of buffers available to the driver, ie. buffers that
- * have been QBUF'd but not yet DQBUF'd.
+ * Process @buf in @bpool. For capture devices, this functions fills @buf with
+ * data from the device. For output devices, this functions send the contents of
+ * @buf to the device for playback.
  *
- * Returns: the number of buffers available.
+ * Returns: %GST_FLOW_OK on success.
  */
-gint
-gst_v4l2_buffer_pool_available_buffers (GstV4l2BufferPool * pool)
+GstFlowReturn
+gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer * buf)
 {
-  return pool->buffer_count - pool->num_live_buffers;
+  GstFlowReturn ret = GST_FLOW_OK;
+  GstBufferPool *bpool = GST_BUFFER_POOL_CAST (pool);
+  GstV4l2Object *obj = pool->obj;
+
+  GST_DEBUG_OBJECT (pool, "process buffer %p", buf);
+
+  switch (obj->type) {
+    case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+      /* capture */
+      switch (obj->mode) {
+        case GST_V4L2_IO_RW:
+          /* capture into the buffer */
+          ret = gst_v4l2_do_read (pool, buf);
+          break;
+
+        case GST_V4L2_IO_MMAP:
+        {
+          GstBuffer *tmp;
+
+          if (buf->pool == bpool)
+            /* nothing, data was inside the buffer when we did _acquire() */
+            goto done;
+
+          /* buffer not from our pool, grab a frame and copy it into the target */
+          if ((ret = gst_v4l2_buffer_pool_dqbuf (pool, &tmp)) != GST_FLOW_OK)
+            goto done;
+
+          if (!gst_v4l2_object_copy (obj, buf, tmp))
+            goto copy_failed;
+
+          /* an queue the buffer again after the copy */
+          if ((ret = gst_v4l2_buffer_pool_qbuf (pool, tmp)) != GST_FLOW_OK)
+            goto done;
+          break;
+        }
+
+        case GST_V4L2_IO_USERPTR:
+        default:
+          g_assert_not_reached ();
+          break;
+      }
+      break;
+
+    case V4L2_BUF_TYPE_VIDEO_OUTPUT:
+      /* playback */
+      switch (obj->mode) {
+        case GST_V4L2_IO_RW:
+          /* FIXME, do write() */
+          GST_WARNING_OBJECT (pool, "implement write()");
+          break;
+
+        case GST_V4L2_IO_MMAP:
+        {
+          GstBuffer *to_queue;
+
+          if (buf->pool == bpool) {
+            /* nothing, we can queue directly */
+            to_queue = buf;
+            GST_LOG_OBJECT (pool, "processing buffer from our pool");
+          } else {
+            GST_LOG_OBJECT (pool, "alloc buffer from our pool");
+            if (!gst_buffer_pool_is_active (bpool)) {
+              GstStructure *config;
+
+              /* this pool was not activated, configure and activate */
+              GST_DEBUG_OBJECT (pool, "activating pool");
+
+              config = gst_buffer_pool_get_config (bpool);
+              gst_buffer_pool_config_add_option (config,
+                  GST_BUFFER_POOL_OPTION_META_VIDEO);
+              gst_buffer_pool_set_config (bpool, config);
+
+              if (!gst_buffer_pool_set_active (bpool, TRUE))
+                goto activate_failed;
+            }
+
+            /* this can block if all buffers are outstanding which would be
+             * strange because we would expect the upstream element to have
+             * allocated them and returned to us.. */
+            ret = GST_BUFFER_POOL_CLASS (parent_class)->acquire_buffer (bpool,
+                &to_queue, NULL);
+            if (ret != GST_FLOW_OK)
+              goto acquire_failed;
+
+            /* copy into it and queue */
+            if (!gst_v4l2_object_copy (obj, to_queue, buf))
+              goto copy_failed;
+          }
+
+          if ((ret = gst_v4l2_buffer_pool_qbuf (pool, to_queue)) != GST_FLOW_OK)
+            goto done;
+
+          /* if we are not streaming yet (this is the first buffer, start
+           * streaming now */
+          if (!pool->streaming)
+            if (!start_streaming (pool))
+              goto start_failed;
+
+          if (pool->num_queued == pool->num_allocated) {
+            /* all buffers are queued, try to dequeue one and release it back
+             * into the pool so that _acquire can get to it again. */
+            ret = gst_v4l2_buffer_pool_dqbuf (pool, &to_queue);
+            if (ret != GST_FLOW_OK)
+              goto done;
+
+            /* release the rendered buffer back into the pool. This wakes up any
+             * thread waiting for a buffer in _acquire() */
+            gst_v4l2_buffer_pool_release_buffer (bpool, to_queue);
+          }
+          break;
+        }
+
+        case GST_V4L2_IO_USERPTR:
+        default:
+          g_assert_not_reached ();
+          break;
+      }
+      break;
+    default:
+      g_assert_not_reached ();
+      break;
+  }
+done:
+  return ret;
+
+  /* ERRORS */
+activate_failed:
+  {
+    GST_ERROR_OBJECT (obj->element, "failed to activate pool");
+    return GST_FLOW_ERROR;
+  }
+acquire_failed:
+  {
+    GST_WARNING_OBJECT (obj->element, "failed to acquire a buffer: %s",
+        gst_flow_get_name (ret));
+    return ret;
+  }
+copy_failed:
+  {
+    GST_ERROR_OBJECT (obj->element, "failed to copy data");
+    return GST_FLOW_ERROR;
+  }
+start_failed:
+  {
+    GST_ERROR_OBJECT (obj->element, "failed to start streaming");
+    return GST_FLOW_ERROR;
+  }
 }
index caad9ac..17e04e3 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#ifndef __GSTV4L2BUFFER_H__
-#define __GSTV4L2BUFFER_H__
+#ifndef __GST_V4L2_BUFFER_POOL_H__
+#define __GST_V4L2_BUFFER_POOL_H__
 
 #include <gst/gst.h>
-#include "v4l2_calls.h"
+
+typedef struct _GstV4l2BufferPool GstV4l2BufferPool;
+typedef struct _GstV4l2BufferPoolClass GstV4l2BufferPoolClass;
+typedef struct _GstMetaV4l2 GstMetaV4l2;
+
+#include "gstv4l2object.h"
+//#include "v4l2_calls.h"
 
 GST_DEBUG_CATEGORY_EXTERN (v4l2buffer_debug);
 
 G_BEGIN_DECLS
 
 
-GType gst_v4l2_buffer_get_type (void);
-#define GST_TYPE_V4L2_BUFFER (gst_v4l2_buffer_get_type())
-#define GST_IS_V4L2_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_BUFFER))
-#define GST_V4L2_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_BUFFER, GstV4l2Buffer))
-
-GType gst_v4l2_buffer_pool_get_type (void);
-#define GST_TYPE_V4L2_BUFFER_POOL (gst_v4l2_buffer_pool_get_type())
-#define GST_IS_V4L2_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_BUFFER_POOL))
-#define GST_V4L2_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_BUFFER_POOL, GstV4l2BufferPool))
+#define GST_TYPE_V4L2_BUFFER_POOL      (gst_v4l2_buffer_pool_get_type())
+#define GST_IS_V4L2_BUFFER_POOL(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_BUFFER_POOL))
+#define GST_V4L2_BUFFER_POOL(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4L2_BUFFER_POOL, GstV4l2BufferPool))
+#define GST_V4L2_BUFFER_POOL_CAST(obj) ((GstV4l2BufferPool*)(obj))
 
+struct _GstV4l2BufferPool
+{
+  GstBufferPool parent;
 
+  GstV4l2Object *obj;        /* the v4l2 object */
+  gint video_fd;             /* a dup(2) of the v4l2object's video_fd */
 
-typedef struct _GstV4l2BufferPool GstV4l2BufferPool;
-typedef struct _GstV4l2Buffer GstV4l2Buffer;
+  GstAllocator *allocator;
+  guint size;
+  guint min_buffers;
+  guint max_buffers;
+  guint prefix;
+  guint align;
+  gboolean add_videometa;
 
+  guint num_allocated;       /* number of buffers allocated by the driver */
+  guint num_queued;          /* number of buffers queued in the driver */
 
-struct _GstV4l2BufferPool
-{
-  GstMiniObject parent;
+  gboolean streaming;
 
-  GstElement *v4l2elem;      /* the v4l2 src/sink that owns us.. maybe we should be owned by v4l2object? */
-  gboolean requeuebuf;       /* if true, unusued buffers are automatically re-QBUF'd */
-  enum v4l2_buf_type type;   /* V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_OUTPUT */
+  GstBuffer **buffers;
+};
 
-  GMutex *lock;
-  gboolean running;          /* with lock */
-  gint num_live_buffers;     /* number of buffers not with driver */
-  GAsyncQueue* avail_buffers;/* pool of available buffers, not with the driver and which aren't held outside the bufferpool */
-  gint video_fd;             /* a dup(2) of the v4l2object's video_fd */
-  guint buffer_count;
-  GstV4l2Buffer **buffers;
+struct _GstV4l2BufferPoolClass
+{
+  GstBufferPoolClass parent_class;
 };
 
-struct _GstV4l2Buffer {
-  GstBuffer   buffer;
+struct _GstMetaV4l2 {
+  GstMeta meta;
 
+  gpointer mem;
   struct v4l2_buffer vbuffer;
-
-  /* FIXME: have GstV4l2Src* instead, as this has GstV4l2BufferPool* */
-  /* FIXME: do we really want to fix this if GstV4l2Buffer/Pool is shared
-   * between v4l2src and v4l2sink??
-   */
-  GstV4l2BufferPool *pool;
 };
 
-void gst_v4l2_buffer_pool_destroy (GstV4l2BufferPool * pool);
-GstV4l2BufferPool *gst_v4l2_buffer_pool_new (GstElement *v4l2elem, gint fd, gint num_buffers, GstCaps * caps, gboolean requeuebuf, enum v4l2_buf_type type);
-
+const GstMetaInfo * gst_meta_v4l2_get_info (void);
+#define GST_META_V4L2_GET(buf) ((GstMetaV4l2 *)gst_buffer_get_meta(buf,gst_meta_v4l2_get_info()))
+#define GST_META_V4L2_ADD(buf) ((GstMetaV4l2 *)gst_buffer_add_meta(buf,gst_meta_v4l2_get_info(),NULL))
 
-GstV4l2Buffer *gst_v4l2_buffer_pool_get (GstV4l2BufferPool *pool, gboolean blocking);
-gboolean gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool *pool, GstV4l2Buffer *buf);
-GstV4l2Buffer *gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool *pool);
-
-gint gst_v4l2_buffer_pool_available_buffers (GstV4l2BufferPool *pool);
+GType gst_v4l2_buffer_pool_get_type (void);
 
+GstBufferPool *     gst_v4l2_buffer_pool_new     (GstV4l2Object *obj, GstCaps *caps);
 
-#define GST_V4L2_BUFFER_POOL_LOCK(pool)     g_mutex_lock ((pool)->lock)
-#define GST_V4L2_BUFFER_POOL_UNLOCK(pool)   g_mutex_unlock ((pool)->lock)
+GstFlowReturn       gst_v4l2_buffer_pool_process (GstV4l2BufferPool * bpool, GstBuffer * buf);
 
 G_END_DECLS
 
-#endif /* __GSTV4L2BUFFER_H__ */
+#endif /*__GST_V4L2_BUFFER_POOL_H__ */
index f5cde09..a07c9be 100644 (file)
 #include "gstv4l2colorbalance.h"
 #include "gstv4l2object.h"
 
-GST_BOILERPLATE (GstV4l2ColorBalanceChannel,
-    gst_v4l2_color_balance_channel,
-    GstColorBalanceChannel, GST_TYPE_COLOR_BALANCE_CHANNEL);
-
-static void
-gst_v4l2_color_balance_channel_base_init (gpointer g_class)
-{
-}
+#define gst_v4l2_color_balance_channel_parent_class parent_class
+G_DEFINE_TYPE (GstV4l2ColorBalanceChannel,
+    gst_v4l2_color_balance_channel, GST_TYPE_COLOR_BALANCE_CHANNEL);
 
 static void
 gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
@@ -45,8 +40,7 @@ gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
 }
 
 static void
-gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel * channel,
-    GstV4l2ColorBalanceChannelClass * klass)
+gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel * channel)
 {
   channel->id = (guint32) - 1;
 }
index 24a4123..7be11b8 100644 (file)
 #include "v4l2_calls.h"
 #include "gstv4l2tuner.h"
 #ifdef HAVE_XVIDEO
-#include "gstv4l2xoverlay.h"
+#include "gstv4l2videooverlay.h"
 #endif
 #include "gstv4l2colorbalance.h"
 
 #include "gst/gst-i18n-plugin.h"
 
+#include <gst/video/video.h>
+
 /* videodev2.h is not versioned and we can't easily check for the presence
  * of enum values at compile time, but the V4L2_CAP_VIDEO_OUTPUT_OVERLAY define
  * was added in the same commit as V4L2_FIELD_INTERLACED_{TB,BT} (b2787845) */
 #endif
 
 GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
+GST_DEBUG_CATEGORY_EXTERN (GST_CAT_PERFORMANCE);
 #define GST_CAT_DEFAULT v4l2_debug
 
-
 #define DEFAULT_PROP_DEVICE_NAME       NULL
 #define DEFAULT_PROP_DEVICE_FD          -1
 #define DEFAULT_PROP_FLAGS              0
 #define DEFAULT_PROP_TV_NORM            0
 #define DEFAULT_PROP_CHANNEL            NULL
 #define DEFAULT_PROP_FREQUENCY          0
+#define DEFAULT_PROP_IO_MODE            GST_V4L2_IO_AUTO
 
 enum
 {
@@ -66,21 +69,21 @@ enum
   V4L2_STD_OBJECT_PROPS,
 };
 
+G_LOCK_DEFINE_STATIC (probe_lock);
+
 const GList *
 gst_v4l2_probe_get_properties (GstPropertyProbe * probe)
 {
   GObjectClass *klass = G_OBJECT_GET_CLASS (probe);
   static GList *list = NULL;
 
-  /* well, not perfect, but better than no locking at all.
-   * In the worst case we leak a list node, so who cares? */
-  GST_CLASS_LOCK (GST_OBJECT_CLASS (klass));
+  G_LOCK (probe_lock);
 
   if (!list) {
     list = g_list_append (NULL, g_object_class_find_property (klass, "device"));
   }
 
-  GST_CLASS_UNLOCK (GST_OBJECT_CLASS (klass));
+  G_UNLOCK (probe_lock);
 
   return list;
 }
@@ -368,6 +371,26 @@ gst_v4l2_tv_norm_get_type (void)
   return v4l2_tv_norm;
 }
 
+#define GST_TYPE_V4L2_IO_MODE (gst_v4l2_io_mode_get_type ())
+static GType
+gst_v4l2_io_mode_get_type (void)
+{
+  static GType v4l2_io_mode = 0;
+
+  if (!v4l2_io_mode) {
+    static const GEnumValue io_modes[] = {
+      {GST_V4L2_IO_AUTO, "GST_V4L2_IO_AUTO", "auto"},
+      {GST_V4L2_IO_RW, "GST_V4L2_IO_RW", "rw"},
+      {GST_V4L2_IO_MMAP, "GST_V4L2_IO_MMAP", "mmap"},
+      {GST_V4L2_IO_USERPTR, "GST_V4L2_IO_USERPTR", "userptr"},
+
+      {0, NULL, NULL}
+    };
+    v4l2_io_mode = g_enum_register_static ("GstV4l2IOMode", io_modes);
+  }
+  return v4l2_io_mode;
+}
+
 void
 gst_v4l2_object_install_properties_helper (GObjectClass * gobject_class,
     const char *default_device)
@@ -449,6 +472,17 @@ gst_v4l2_object_install_properties_helper (GObjectClass * gobject_class,
           "video standard",
           GST_TYPE_V4L2_TV_NORM, DEFAULT_PROP_TV_NORM,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  /**
+   * GstV4l2Src:io-mode
+   *
+   * IO Mode
+   */
+  g_object_class_install_property (gobject_class, PROP_IO_MODE,
+      g_param_spec_enum ("io-mode", "IO mode",
+          "I/O mode",
+          GST_TYPE_V4L2_IO_MODE, DEFAULT_PROP_IO_MODE,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 }
 
 GstV4l2Object *
@@ -476,7 +510,7 @@ gst_v4l2_object_new (GstElement * element,
 
   v4l2object->video_fd = -1;
   v4l2object->poll = gst_poll_new (TRUE);
-  v4l2object->buffer = NULL;
+  v4l2object->active = FALSE;
   v4l2object->videodev = g_strdup (default_device);
 
   v4l2object->norms = NULL;
@@ -610,6 +644,9 @@ gst_v4l2_object_set_property_helper (GstV4l2Object * v4l2object,
       }
       break;
 #endif
+    case PROP_IO_MODE:
+      v4l2object->req_mode = g_value_get_enum (value);
+      break;
     default:
       return FALSE;
       break;
@@ -683,6 +720,9 @@ gst_v4l2_object_get_property_helper (GstV4l2Object * v4l2object,
     case PROP_TV_NORM:
       g_value_set_enum (value, v4l2object->tv_norm);
       break;
+    case PROP_IO_MODE:
+      g_value_set_enum (value, v4l2object->req_mode);
+      break;
     default:
       return FALSE;
       break;
@@ -749,7 +789,7 @@ gst_v4l2_set_defaults (GstV4l2Object * v4l2object)
 }
 
 gboolean
-gst_v4l2_object_start (GstV4l2Object * v4l2object)
+gst_v4l2_object_open (GstV4l2Object * v4l2object)
 {
   if (gst_v4l2_open (v4l2object))
     gst_v4l2_set_defaults (v4l2object);
@@ -757,17 +797,17 @@ gst_v4l2_object_start (GstV4l2Object * v4l2object)
     return FALSE;
 
 #ifdef HAVE_XVIDEO
-  gst_v4l2_xoverlay_start (v4l2object);
+  gst_v4l2_video_overlay_start (v4l2object);
 #endif
 
   return TRUE;
 }
 
 gboolean
-gst_v4l2_object_stop (GstV4l2Object * v4l2object)
+gst_v4l2_object_close (GstV4l2Object * v4l2object)
 {
 #ifdef HAVE_XVIDEO
-  gst_v4l2_xoverlay_stop (v4l2object);
+  gst_v4l2_video_overlay_stop (v4l2object);
 #endif
 
   if (!gst_v4l2_close (v4l2object))
@@ -1147,97 +1187,22 @@ gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc)
     case V4L2_PIX_FMT_JPEG:    /* JFIF JPEG */
       structure = gst_structure_new ("image/jpeg", NULL);
       break;
+    case V4L2_PIX_FMT_YYUV:    /* 16  YUV 4:2:2     */
+    case V4L2_PIX_FMT_HI240:   /*  8  8-bit color   */
+      /* FIXME: get correct fourccs here */
+      break;
     case V4L2_PIX_FMT_RGB332:
-    case V4L2_PIX_FMT_RGB555:
     case V4L2_PIX_FMT_RGB555X:
-    case V4L2_PIX_FMT_RGB565:
     case V4L2_PIX_FMT_RGB565X:
+      /* FIXME: get correct fourccs here */
+      break;
+    case V4L2_PIX_FMT_GREY:    /*  8  Greyscale     */
+    case V4L2_PIX_FMT_RGB555:
+    case V4L2_PIX_FMT_RGB565:
     case V4L2_PIX_FMT_RGB24:
     case V4L2_PIX_FMT_BGR24:
     case V4L2_PIX_FMT_RGB32:
-    case V4L2_PIX_FMT_BGR32:{
-      guint depth = 0, bpp = 0;
-
-      gint endianness = 0;
-
-      guint32 r_mask = 0, b_mask = 0, g_mask = 0;
-
-      switch (fourcc) {
-        case V4L2_PIX_FMT_RGB332:
-          bpp = depth = 8;
-          endianness = G_BYTE_ORDER;    /* 'like, whatever' */
-          r_mask = 0xe0;
-          g_mask = 0x1c;
-          b_mask = 0x03;
-          break;
-        case V4L2_PIX_FMT_RGB555:
-        case V4L2_PIX_FMT_RGB555X:
-          bpp = 16;
-          depth = 15;
-          endianness =
-              fourcc == V4L2_PIX_FMT_RGB555X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
-          r_mask = 0x7c00;
-          g_mask = 0x03e0;
-          b_mask = 0x001f;
-          break;
-        case V4L2_PIX_FMT_RGB565:
-        case V4L2_PIX_FMT_RGB565X:
-          bpp = depth = 16;
-          endianness =
-              fourcc == V4L2_PIX_FMT_RGB565X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
-          r_mask = 0xf800;
-          g_mask = 0x07e0;
-          b_mask = 0x001f;
-          break;
-        case V4L2_PIX_FMT_RGB24:
-          bpp = depth = 24;
-          endianness = G_BIG_ENDIAN;
-          r_mask = 0xff0000;
-          g_mask = 0x00ff00;
-          b_mask = 0x0000ff;
-          break;
-        case V4L2_PIX_FMT_BGR24:
-          bpp = depth = 24;
-          endianness = G_BIG_ENDIAN;
-          r_mask = 0x0000ff;
-          g_mask = 0x00ff00;
-          b_mask = 0xff0000;
-          break;
-        case V4L2_PIX_FMT_RGB32:
-          bpp = depth = 32;
-          endianness = G_BIG_ENDIAN;
-          r_mask = 0xff000000;
-          g_mask = 0x00ff0000;
-          b_mask = 0x0000ff00;
-          break;
-        case V4L2_PIX_FMT_BGR32:
-          bpp = depth = 32;
-          endianness = G_BIG_ENDIAN;
-          r_mask = 0x000000ff;
-          g_mask = 0x0000ff00;
-          b_mask = 0x00ff0000;
-          break;
-        default:
-          g_assert_not_reached ();
-          break;
-      }
-      structure = gst_structure_new ("video/x-raw-rgb",
-          "bpp", G_TYPE_INT, bpp,
-          "depth", G_TYPE_INT, depth,
-          "red_mask", G_TYPE_INT, r_mask,
-          "green_mask", G_TYPE_INT, g_mask,
-          "blue_mask", G_TYPE_INT, b_mask,
-          "endianness", G_TYPE_INT, endianness, NULL);
-      break;
-    }
-    case V4L2_PIX_FMT_GREY:    /*  8  Greyscale     */
-      structure = gst_structure_new ("video/x-raw-gray",
-          "bpp", G_TYPE_INT, 8, NULL);
-      break;
-    case V4L2_PIX_FMT_YYUV:    /* 16  YUV 4:2:2     */
-    case V4L2_PIX_FMT_HI240:   /*  8  8-bit color   */
-      /* FIXME: get correct fourccs here */
-      break;
+    case V4L2_PIX_FMT_BGR32:
     case V4L2_PIX_FMT_NV12:    /* 12  Y/CbCr 4:2:0  */
     case V4L2_PIX_FMT_NV21:    /* 12  Y/CrCb 4:2:0  */
     case V4L2_PIX_FMT_YVU410:
@@ -1246,59 +1211,84 @@ gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc)
     case V4L2_PIX_FMT_YUYV:
     case V4L2_PIX_FMT_YVU420:
     case V4L2_PIX_FMT_UYVY:
+#if 0
     case V4L2_PIX_FMT_Y41P:
+#endif
     case V4L2_PIX_FMT_YUV422P:
 #ifdef V4L2_PIX_FMT_YVYU
     case V4L2_PIX_FMT_YVYU:
 #endif
     case V4L2_PIX_FMT_YUV411P:{
-      guint32 fcc = 0;
+      GstVideoFormat format;
 
       switch (fourcc) {
+        case V4L2_PIX_FMT_GREY:        /*  8  Greyscale     */
+          format = GST_VIDEO_FORMAT_GRAY8;
+          break;
+        case V4L2_PIX_FMT_RGB555:
+          format = GST_VIDEO_FORMAT_RGB15;
+          break;
+        case V4L2_PIX_FMT_RGB565:
+          format = GST_VIDEO_FORMAT_RGB16;
+          break;
+        case V4L2_PIX_FMT_RGB24:
+          format = GST_VIDEO_FORMAT_RGB;
+          break;
+        case V4L2_PIX_FMT_BGR24:
+          format = GST_VIDEO_FORMAT_BGR;
+          break;
+        case V4L2_PIX_FMT_RGB32:
+          format = GST_VIDEO_FORMAT_RGBx;
+          break;
+        case V4L2_PIX_FMT_BGR32:
+          format = GST_VIDEO_FORMAT_BGRx;
+          break;
         case V4L2_PIX_FMT_NV12:
-          fcc = GST_MAKE_FOURCC ('N', 'V', '1', '2');
+          format = GST_VIDEO_FORMAT_NV12;
           break;
         case V4L2_PIX_FMT_NV21:
-          fcc = GST_MAKE_FOURCC ('N', 'V', '2', '1');
+          format = GST_VIDEO_FORMAT_NV21;
           break;
         case V4L2_PIX_FMT_YVU410:
-          fcc = GST_MAKE_FOURCC ('Y', 'V', 'U', '9');
+          format = GST_VIDEO_FORMAT_YVU9;
           break;
         case V4L2_PIX_FMT_YUV410:
-          fcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
+          format = GST_VIDEO_FORMAT_YUV9;
           break;
         case V4L2_PIX_FMT_YUV420:
-          fcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
+          format = GST_VIDEO_FORMAT_I420;
           break;
         case V4L2_PIX_FMT_YUYV:
-          fcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
+          format = GST_VIDEO_FORMAT_YUY2;
           break;
         case V4L2_PIX_FMT_YVU420:
-          fcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
+          format = GST_VIDEO_FORMAT_YV12;
           break;
         case V4L2_PIX_FMT_UYVY:
-          fcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
+          format = GST_VIDEO_FORMAT_UYVY;
           break;
+#if 0
         case V4L2_PIX_FMT_Y41P:
-          fcc = GST_MAKE_FOURCC ('Y', '4', '1', 'P');
+          format = GST_VIDEO_FORMAT_Y41P;
           break;
+#endif
         case V4L2_PIX_FMT_YUV411P:
-          fcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
+          format = GST_VIDEO_FORMAT_Y41B;
           break;
         case V4L2_PIX_FMT_YUV422P:
-          fcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
+          format = GST_VIDEO_FORMAT_Y42B;
           break;
 #ifdef V4L2_PIX_FMT_YVYU
         case V4L2_PIX_FMT_YVYU:
-          fcc = GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U');
+          format = GST_VIDEO_FORMAT_YVYU;
           break;
 #endif
         default:
           g_assert_not_reached ();
           break;
       }
-      structure = gst_structure_new ("video/x-raw-yuv",
-          "format", GST_TYPE_FOURCC, fcc, NULL);
+      structure = gst_structure_new ("video/x-raw",
+          "format", G_TYPE_STRING, gst_video_format_to_string (format), NULL);
       break;
     }
     case V4L2_PIX_FMT_DV:
@@ -1379,160 +1369,180 @@ gst_v4l2_object_get_all_caps (void)
  * @fps_n/@fps_d: location for framerate
  * @size: location for expected size of the frame or 0 if unknown
  */
-gboolean
+static gboolean
 gst_v4l2_object_get_caps_info (GstV4l2Object * v4l2object, GstCaps * caps,
-    struct v4l2_fmtdesc ** format, gint * w, gint * h,
-    gboolean * interlaced, guint * fps_n, guint * fps_d, guint * size)
+    struct v4l2_fmtdesc **format, GstVideoInfo * info)
 {
   GstStructure *structure;
-  const GValue *framerate;
   guint32 fourcc;
   const gchar *mimetype;
-  guint outsize;
+  struct v4l2_fmtdesc *fmt;
 
   /* default unknown values */
   fourcc = 0;
-  outsize = 0;
 
   structure = gst_caps_get_structure (caps, 0);
 
   mimetype = gst_structure_get_name (structure);
 
-  if (strcmp (mimetype, "video/mpegts") == 0) {
-    fourcc = V4L2_PIX_FMT_MPEG;
-    *fps_n = 0;
-    *fps_d = 1;
-    goto done;
-  }
-
-  if (!gst_structure_get_int (structure, "width", w))
-    return FALSE;
-
-  if (!gst_structure_get_int (structure, "height", h))
-    return FALSE;
-
-  if (!gst_structure_get_boolean (structure, "interlaced", interlaced))
-    *interlaced = FALSE;
+  if (g_str_equal (mimetype, "video/x-raw")) {
+    /* raw caps, parse into video info */
+    if (!gst_video_info_from_caps (info, caps))
+      goto invalid_format;
 
-  framerate = gst_structure_get_value (structure, "framerate");
-  if (!framerate)
-    return FALSE;
-
-  *fps_n = gst_value_get_fraction_numerator (framerate);
-  *fps_d = gst_value_get_fraction_denominator (framerate);
-
-  if (!strcmp (mimetype, "video/x-raw-yuv")) {
-    gst_structure_get_fourcc (structure, "format", &fourcc);
-
-    switch (fourcc) {
-      case GST_MAKE_FOURCC ('I', '4', '2', '0'):
-      case GST_MAKE_FOURCC ('I', 'Y', 'U', 'V'):
+    switch (GST_VIDEO_INFO_FORMAT (info)) {
+      case GST_VIDEO_FORMAT_I420:
         fourcc = V4L2_PIX_FMT_YUV420;
-        outsize = GST_ROUND_UP_4 (*w) * GST_ROUND_UP_2 (*h);
-        outsize += 2 * ((GST_ROUND_UP_8 (*w) / 2) * (GST_ROUND_UP_2 (*h) / 2));
         break;
-      case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+      case GST_VIDEO_FORMAT_YUY2:
         fourcc = V4L2_PIX_FMT_YUYV;
-        outsize = (GST_ROUND_UP_2 (*w) * 2) * *h;
         break;
-      case GST_MAKE_FOURCC ('Y', '4', '1', 'P'):
+#if 0
+      case GST_VIDEO_FORMAT_Y41P:
         fourcc = V4L2_PIX_FMT_Y41P;
-        outsize = (GST_ROUND_UP_2 (*w) * 2) * *h;
         break;
-      case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
+#endif
+      case GST_VIDEO_FORMAT_UYVY:
         fourcc = V4L2_PIX_FMT_UYVY;
-        outsize = (GST_ROUND_UP_2 (*w) * 2) * *h;
         break;
-      case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+      case GST_VIDEO_FORMAT_YV12:
         fourcc = V4L2_PIX_FMT_YVU420;
-        outsize = GST_ROUND_UP_4 (*w) * GST_ROUND_UP_2 (*h);
-        outsize += 2 * ((GST_ROUND_UP_8 (*w) / 2) * (GST_ROUND_UP_2 (*h) / 2));
         break;
-      case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
+      case GST_VIDEO_FORMAT_Y41B:
         fourcc = V4L2_PIX_FMT_YUV411P;
-        outsize = GST_ROUND_UP_4 (*w) * *h;
-        outsize += 2 * ((GST_ROUND_UP_8 (*w) / 4) * *h);
         break;
-      case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
+      case GST_VIDEO_FORMAT_Y42B:
         fourcc = V4L2_PIX_FMT_YUV422P;
-        outsize = GST_ROUND_UP_4 (*w) * *h;
-        outsize += 2 * ((GST_ROUND_UP_8 (*w) / 2) * *h);
         break;
-      case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
+      case GST_VIDEO_FORMAT_NV12:
         fourcc = V4L2_PIX_FMT_NV12;
-        outsize = GST_ROUND_UP_4 (*w) * GST_ROUND_UP_2 (*h);
-        outsize += (GST_ROUND_UP_4 (*w) * *h) / 2;
         break;
-      case GST_MAKE_FOURCC ('N', 'V', '2', '1'):
+      case GST_VIDEO_FORMAT_NV21:
         fourcc = V4L2_PIX_FMT_NV21;
-        outsize = GST_ROUND_UP_4 (*w) * GST_ROUND_UP_2 (*h);
-        outsize += (GST_ROUND_UP_4 (*w) * *h) / 2;
         break;
 #ifdef V4L2_PIX_FMT_YVYU
-      case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
+      case GST_VIDEO_FORMAT_YVYU:
         fourcc = V4L2_PIX_FMT_YVYU;
-        outsize = (GST_ROUND_UP_2 (*w) * 2) * *h;
         break;
 #endif
-    }
-  } else if (!strcmp (mimetype, "video/x-raw-rgb")) {
-    gint depth, endianness, r_mask;
-
-    gst_structure_get_int (structure, "depth", &depth);
-    gst_structure_get_int (structure, "endianness", &endianness);
-    gst_structure_get_int (structure, "red_mask", &r_mask);
-
-    switch (depth) {
-      case 8:
-        fourcc = V4L2_PIX_FMT_RGB332;
+      case GST_VIDEO_FORMAT_RGB15:
+        fourcc = V4L2_PIX_FMT_RGB555;
+        break;
+      case GST_VIDEO_FORMAT_RGB16:
+        fourcc = V4L2_PIX_FMT_RGB565;
         break;
-      case 15:
-        fourcc = (endianness == G_LITTLE_ENDIAN) ?
-            V4L2_PIX_FMT_RGB555 : V4L2_PIX_FMT_RGB555X;
+      case GST_VIDEO_FORMAT_RGB:
+        fourcc = V4L2_PIX_FMT_RGB24;
         break;
-      case 16:
-        fourcc = (endianness == G_LITTLE_ENDIAN) ?
-            V4L2_PIX_FMT_RGB565 : V4L2_PIX_FMT_RGB565X;
+      case GST_VIDEO_FORMAT_BGR:
+        fourcc = V4L2_PIX_FMT_BGR24;
         break;
-      case 24:
-        fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR24 : V4L2_PIX_FMT_RGB24;
+      case GST_VIDEO_FORMAT_RGBx:
+      case GST_VIDEO_FORMAT_RGBA:
+        fourcc = V4L2_PIX_FMT_RGB32;
         break;
-      case 32:
-        fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR32 : V4L2_PIX_FMT_RGB32;
+      case GST_VIDEO_FORMAT_BGRx:
+      case GST_VIDEO_FORMAT_BGRA:
+        fourcc = V4L2_PIX_FMT_BGR32;
+        break;
+      case GST_VIDEO_FORMAT_GRAY8:
+        fourcc = V4L2_PIX_FMT_GREY;
+      default:
         break;
     }
-  } else if (strcmp (mimetype, "video/x-dv") == 0) {
-    fourcc = V4L2_PIX_FMT_DV;
-  } else if (strcmp (mimetype, "image/jpeg") == 0) {
-    fourcc = V4L2_PIX_FMT_JPEG;
+  } else {
+    gboolean dimensions = TRUE;
+
+    /* no video caps, construct videoinfo ourselves */
+    gst_video_info_init (info);
+
+    if (g_str_equal (mimetype, "video/mpegts")) {
+      fourcc = V4L2_PIX_FMT_MPEG;
+      dimensions = FALSE;
+    } else if (g_str_equal (mimetype, "video/x-dv")) {
+      fourcc = V4L2_PIX_FMT_DV;
+    } else if (g_str_equal (mimetype, "image/jpeg")) {
+      fourcc = V4L2_PIX_FMT_JPEG;
 #ifdef V4L2_PIX_FMT_SBGGR8
-  } else if (strcmp (mimetype, "video/x-raw-bayer") == 0) {
-    fourcc = V4L2_PIX_FMT_SBGGR8;
+    } else if (g_str_equal (mimetype, "video/x-raw-bayer")) {
+      fourcc = V4L2_PIX_FMT_SBGGR8;
 #endif
 #ifdef V4L2_PIX_FMT_SN9C10X
-  } else if (strcmp (mimetype, "video/x-sonix") == 0) {
-    fourcc = V4L2_PIX_FMT_SN9C10X;
+    } else if (g_str_equal (mimetype, "video/x-sonix")) {
+      fourcc = V4L2_PIX_FMT_SN9C10X;
 #endif
 #ifdef V4L2_PIX_FMT_PWC1
-  } else if (strcmp (mimetype, "video/x-pwc1") == 0) {
-    fourcc = V4L2_PIX_FMT_PWC1;
+    } else if (g_str_equal (mimetype, "video/x-pwc1")) {
+      fourcc = V4L2_PIX_FMT_PWC1;
 #endif
 #ifdef V4L2_PIX_FMT_PWC2
-  } else if (strcmp (mimetype, "video/x-pwc2") == 0) {
-    fourcc = V4L2_PIX_FMT_PWC2;
+    } else if (g_str_equal (mimetype, "video/x-pwc2")) {
+      fourcc = V4L2_PIX_FMT_PWC2;
+    }
 #endif
-  } else if (strcmp (mimetype, "video/x-raw-gray") == 0) {
-    fourcc = V4L2_PIX_FMT_GREY;
+
+    if (dimensions) {
+      gboolean interlaced;
+
+      if (!gst_structure_get_int (structure, "width", &info->width))
+        goto no_width;
+
+      if (!gst_structure_get_int (structure, "height", &info->height))
+        goto no_height;
+
+      if (!gst_structure_get_boolean (structure, "interlaced", &interlaced))
+        interlaced = FALSE;
+      if (interlaced)
+        info->flags |= GST_VIDEO_FLAG_INTERLACED;
+
+      if (!gst_structure_get_fraction (structure, "framerate", &info->fps_n,
+              &info->fps_d))
+        goto no_framerate;
+    }
   }
 
   if (fourcc == 0)
-    return FALSE;
+    goto unhandled_format;
 
-done:
-  *format = gst_v4l2_object_get_format_from_fourcc (v4l2object, fourcc);
-  *size = outsize;
+  fmt = gst_v4l2_object_get_format_from_fourcc (v4l2object, fourcc);
+  if (fmt == NULL)
+    goto unsupported_format;
+
+  *format = fmt;
 
   return TRUE;
+
+  /* ERRORS */
+no_width:
+  {
+    GST_DEBUG_OBJECT (v4l2object, "no width");
+    return FALSE;
+  }
+no_height:
+  {
+    GST_DEBUG_OBJECT (v4l2object, "no height");
+    return FALSE;
+  }
+no_framerate:
+  {
+    GST_DEBUG_OBJECT (v4l2object, "no framerate");
+    return FALSE;
+  }
+invalid_format:
+  {
+    GST_DEBUG_OBJECT (v4l2object, "invalid format");
+    return FALSE;
+  }
+unhandled_format:
+  {
+    GST_DEBUG_OBJECT (v4l2object, "unhandled format");
+    return FALSE;
+  }
+unsupported_format:
+  {
+    GST_DEBUG_OBJECT (v4l2object, "unsupported format");
+    return FALSE;
+  }
 }
 
 
@@ -2092,16 +2102,102 @@ error:
   return FALSE;
 }
 
+static gboolean
+gst_v4l2_object_setup_pool (GstV4l2Object * v4l2object, GstCaps * caps)
+{
+  GstV4l2IOMode mode;
+
+  GST_DEBUG_OBJECT (v4l2object->element, "initializing the capture system");
+
+  GST_V4L2_CHECK_OPEN (v4l2object);
+  GST_V4L2_CHECK_NOT_ACTIVE (v4l2object);
+
+  /* find transport */
+  mode = v4l2object->req_mode;
+
+  if (v4l2object->vcap.capabilities & V4L2_CAP_READWRITE) {
+    if (v4l2object->req_mode == GST_V4L2_IO_AUTO)
+      mode = GST_V4L2_IO_RW;
+  } else if (v4l2object->req_mode == GST_V4L2_IO_RW)
+    goto method_not_supported;
+
+  if (v4l2object->vcap.capabilities & V4L2_CAP_STREAMING) {
+    if (v4l2object->req_mode == GST_V4L2_IO_AUTO)
+      mode = GST_V4L2_IO_MMAP;
+  } else if (v4l2object->req_mode == GST_V4L2_IO_MMAP)
+    goto method_not_supported;
+
+  /* if still no transport selected, error out */
+  if (mode == GST_V4L2_IO_AUTO)
+    goto no_supported_capture_method;
+
+  GST_INFO_OBJECT (v4l2object->element, "accessing buffers via mode %d", mode);
+  v4l2object->mode = mode;
+
+  /* Map the buffers */
+  GST_LOG_OBJECT (v4l2object->element, "initiating buffer pool");
+
+  if (!(v4l2object->pool = gst_v4l2_buffer_pool_new (v4l2object, caps)))
+    goto buffer_pool_new_failed;
+
+  GST_V4L2_SET_ACTIVE (v4l2object);
+
+  return TRUE;
+
+  /* ERRORS */
+buffer_pool_new_failed:
+  {
+    GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, READ,
+        (_("Could not map buffers from device '%s'"),
+            v4l2object->videodev),
+        ("Failed to create buffer pool: %s", g_strerror (errno)));
+    return FALSE;
+  }
+method_not_supported:
+  {
+    GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, READ,
+        (_("The driver of device '%s' does not support the IO method %d"),
+            v4l2object->videodev, mode), (NULL));
+    return FALSE;
+  }
+no_supported_capture_method:
+  {
+    GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, READ,
+        (_("The driver of device '%s' does not support any known IO "
+                "method."), v4l2object->videodev), (NULL));
+    return FALSE;
+  }
+}
+
+
+/* Note about fraction simplification
+ *  * n1/d1 == n2/d2  is also written as  n1 == ( n2 * d1 ) / d2
+ *   */
+#define fractions_are_equal(n1,d1,n2,d2) ((n1) == gst_util_uint64_scale_int((n2), (d1), (d2)))
 
 gboolean
-gst_v4l2_object_set_format (GstV4l2Object * v4l2object, guint32 pixelformat,
-    guint32 width, guint32 height, gboolean interlaced)
+gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
 {
   gint fd = v4l2object->video_fd;
   struct v4l2_format format;
+  struct v4l2_streamparm streamparm;
   enum v4l2_field field;
-
-  if (interlaced) {
+  guint32 pixelformat;
+  struct v4l2_fmtdesc *fmtdesc;
+  GstVideoInfo info;
+  gint width, height, fps_n, fps_d, stride;
+
+  if (!gst_v4l2_object_get_caps_info (v4l2object, caps, &fmtdesc, &info))
+    goto invalid_caps;
+
+  pixelformat = fmtdesc->pixelformat;
+  width = GST_VIDEO_INFO_WIDTH (&info);
+  height = GST_VIDEO_INFO_HEIGHT (&info);
+  fps_n = GST_VIDEO_INFO_FPS_N (&info);
+  fps_d = GST_VIDEO_INFO_FPS_D (&info);
+  stride = GST_VIDEO_INFO_PLANE_STRIDE (&info, 0);
+
+  if (info.flags & GST_VIDEO_FLAG_INTERLACED) {
     GST_DEBUG_OBJECT (v4l2object->element, "interlaced video");
     /* ideally we would differentiate between types of interlaced video
      * but there is not sufficient information in the caps..
@@ -2112,8 +2208,9 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, guint32 pixelformat,
     field = V4L2_FIELD_NONE;
   }
 
-  GST_DEBUG_OBJECT (v4l2object->element, "Setting format to %dx%d, format "
-      "%" GST_FOURCC_FORMAT, width, height, GST_FOURCC_ARGS (pixelformat));
+  GST_DEBUG_OBJECT (v4l2object->element, "Desired format %dx%d, format "
+      "%" GST_FOURCC_FORMAT " stride: %d", width, height,
+      GST_FOURCC_ARGS (pixelformat), stride);
 
   GST_V4L2_CHECK_OPEN (v4l2object);
   GST_V4L2_CHECK_NOT_ACTIVE (v4l2object);
@@ -2121,7 +2218,7 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, guint32 pixelformat,
   /* Only unconditionally accept mpegts for sources */
   if ((v4l2object->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
       (pixelformat == GST_MAKE_FOURCC ('M', 'P', 'E', 'G')))
-    return TRUE;
+    goto done;
 
   memset (&format, 0x00, sizeof (struct v4l2_format));
   format.type = v4l2object->type;
@@ -2129,42 +2226,128 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, guint32 pixelformat,
   if (v4l2_ioctl (fd, VIDIOC_G_FMT, &format) < 0)
     goto get_fmt_failed;
 
-  if (format.type == v4l2object->type &&
-      format.fmt.pix.width == width &&
-      format.fmt.pix.height == height &&
-      format.fmt.pix.pixelformat == pixelformat &&
-      format.fmt.pix.field == field) {
-    /* Nothing to do. We want to succeed immediately
-     * here because setting the same format back
-     * can still fail due to EBUSY. By short-circuiting
-     * here, we allow pausing and re-playing pipelines
-     * with changed caps, as long as the changed caps
-     * do not change the webcam's format. Otherwise,
-     * any caps change would require us to go to NULL
-     * state to close the device and set format.
-     */
-    return TRUE;
+  GST_DEBUG_OBJECT (v4l2object->element, "Got format to %dx%d, format "
+      "%" GST_FOURCC_FORMAT " bytesperline %d, colorspace %d",
+      format.fmt.pix.width, format.fmt.pix.height,
+      GST_FOURCC_ARGS (format.fmt.pix.pixelformat), format.fmt.pix.bytesperline,
+      format.fmt.pix.colorspace);
+
+  if (format.type != v4l2object->type ||
+      format.fmt.pix.width != width ||
+      format.fmt.pix.height != height ||
+      format.fmt.pix.pixelformat != pixelformat ||
+      format.fmt.pix.field != field || format.fmt.pix.bytesperline != stride) {
+    /* something different, set the format */
+    GST_DEBUG_OBJECT (v4l2object->element, "Setting format to %dx%d, format "
+        "%" GST_FOURCC_FORMAT " bytesperline %d", width, height,
+        GST_FOURCC_ARGS (pixelformat), stride);
+
+    format.type = v4l2object->type;
+    format.fmt.pix.width = width;
+    format.fmt.pix.height = height;
+    format.fmt.pix.pixelformat = pixelformat;
+    format.fmt.pix.field = field;
+    /* try to ask our prefered stride */
+    format.fmt.pix.bytesperline = stride;
+
+    if (v4l2_ioctl (fd, VIDIOC_S_FMT, &format) < 0)
+      goto set_fmt_failed;
+
+    GST_DEBUG_OBJECT (v4l2object->element, "Got format to %dx%d, format "
+        "%" GST_FOURCC_FORMAT " stride %d", format.fmt.pix.width,
+        format.fmt.pix.height, GST_FOURCC_ARGS (format.fmt.pix.pixelformat),
+        format.fmt.pix.bytesperline);
+
+    if (format.fmt.pix.width != width || format.fmt.pix.height != height)
+      goto invalid_dimensions;
+
+    if (format.fmt.pix.pixelformat != pixelformat)
+      goto invalid_pixelformat;
   }
 
-  format.type = v4l2object->type;
-  format.fmt.pix.width = width;
-  format.fmt.pix.height = height;
-  format.fmt.pix.pixelformat = pixelformat;
-  format.fmt.pix.field = field;
+  /* figure out the frame layout */
+  v4l2object->bytesperline = format.fmt.pix.bytesperline;
+  v4l2object->sizeimage = format.fmt.pix.sizeimage;
+
+  GST_DEBUG_OBJECT (v4l2object->element, "Got sizeimage %u",
+      v4l2object->sizeimage);
+
+  /* Is there a reason we require the caller to always specify a framerate? */
+  GST_DEBUG_OBJECT (v4l2object->element, "Desired framerate: %u/%u", fps_n,
+      fps_d);
+
+  memset (&streamparm, 0x00, sizeof (struct v4l2_streamparm));
+  streamparm.type = v4l2object->type;
+
+  if (v4l2_ioctl (fd, VIDIOC_G_PARM, &streamparm) < 0)
+    goto get_parm_failed;
+
+  GST_VIDEO_INFO_FPS_N (&info) =
+      streamparm.parm.capture.timeperframe.denominator;
+  GST_VIDEO_INFO_FPS_D (&info) = streamparm.parm.capture.timeperframe.numerator;
+
+  if (v4l2object->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+    GST_DEBUG_OBJECT (v4l2object->element, "Got framerate: %u/%u",
+        streamparm.parm.capture.timeperframe.denominator,
+        streamparm.parm.capture.timeperframe.numerator);
+
+    /* We used to skip frame rate setup if the camera was already setup
+     * with the requested frame rate. This breaks some cameras though,
+     * causing them to not output data (several models of Thinkpad cameras
+     * have this problem at least).
+     * So, don't skip. */
+    GST_LOG_OBJECT (v4l2object->element, "Setting framerate to %u/%u", fps_n,
+        fps_d);
+    /* We want to change the frame rate, so check whether we can. Some cheap USB
+     * cameras don't have the capability */
+    if ((streamparm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) == 0) {
+      GST_DEBUG_OBJECT (v4l2object->element,
+          "Not setting framerate (not supported)");
+      goto done;
+    }
+
+    /* Note: V4L2 wants the frame interval, we have the frame rate */
+    streamparm.parm.capture.timeperframe.numerator = fps_d;
+    streamparm.parm.capture.timeperframe.denominator = fps_n;
 
-  if (v4l2_ioctl (fd, VIDIOC_S_FMT, &format) < 0) {
-    goto set_fmt_failed;
+    /* some cheap USB cam's won't accept any change */
+    if (v4l2_ioctl (fd, VIDIOC_S_PARM, &streamparm) < 0)
+      goto set_parm_failed;
+
+    /* get new values */
+    fps_d = streamparm.parm.capture.timeperframe.numerator;
+    fps_n = streamparm.parm.capture.timeperframe.denominator;
+
+    GST_INFO_OBJECT (v4l2object->element, "Set framerate to %u/%u", fps_n,
+        fps_d);
+
+    GST_VIDEO_INFO_FPS_N (&info) = fps_n;
+    GST_VIDEO_INFO_FPS_D (&info) = fps_d;
   }
 
-  if (format.fmt.pix.width != width || format.fmt.pix.height != height)
-    goto invalid_dimensions;
+done:
+  /* if we have a framerate pre-calculate duration */
+  if (fps_n > 0 && fps_d > 0) {
+    v4l2object->duration = gst_util_uint64_scale_int (GST_SECOND, fps_d, fps_n);
+  } else {
+    v4l2object->duration = GST_CLOCK_TIME_NONE;
+  }
+  v4l2object->info = info;
+  v4l2object->fmtdesc = fmtdesc;
 
-  if (format.fmt.pix.pixelformat != pixelformat)
-    goto invalid_pixelformat;
+  /* now configure ther pools */
+  if (!gst_v4l2_object_setup_pool (v4l2object, caps))
+    goto pool_failed;
 
   return TRUE;
 
   /* ERRORS */
+invalid_caps:
+  {
+    GST_DEBUG_OBJECT (v4l2object->element, "can't parse caps %" GST_PTR_FORMAT,
+        caps);
+    return FALSE;
+  }
 get_fmt_failed:
   {
     GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
@@ -2202,30 +2385,220 @@ invalid_pixelformat:
             GST_FOURCC_ARGS (format.fmt.pix.pixelformat)));
     return FALSE;
   }
+get_parm_failed:
+  {
+    /* it's possible that this call is not supported */
+    if (errno != EINVAL) {
+      GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
+          (_("Could not get parameters on device '%s'"),
+              v4l2object->videodev), GST_ERROR_SYSTEM);
+    }
+    goto done;
+  }
+set_parm_failed:
+  {
+    GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
+        (_("Video device did not accept new frame rate setting.")),
+        GST_ERROR_SYSTEM);
+    goto done;
+  }
+pool_failed:
+  {
+    GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS,
+        (_("Video device could not create buffer pool.")), GST_ERROR_SYSTEM);
+    return FALSE;
+  }
 }
 
 gboolean
-gst_v4l2_object_start_streaming (GstV4l2Object * v4l2object)
+gst_v4l2_object_unlock (GstV4l2Object * v4l2object)
 {
-  if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_STREAMON,
-          &(v4l2object->type)) < 0) {
-    GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, OPEN_READ,
-        (_("Error starting streaming on device '%s'."), v4l2object->videodev),
-        GST_ERROR_SYSTEM);
-    return FALSE;
+  GST_LOG_OBJECT (v4l2object->element, "flush poll");
+  gst_poll_set_flushing (v4l2object->poll, TRUE);
+
+  return TRUE;
+}
+
+gboolean
+gst_v4l2_object_unlock_stop (GstV4l2Object * v4l2object)
+{
+  GST_LOG_OBJECT (v4l2object->element, "flush stop poll");
+  gst_poll_set_flushing (v4l2object->poll, FALSE);
+
+  return TRUE;
+}
+
+gboolean
+gst_v4l2_object_stop (GstV4l2Object * v4l2object)
+{
+  GST_DEBUG_OBJECT (v4l2object->element, "stopping");
+
+  if (!GST_V4L2_IS_OPEN (v4l2object))
+    goto done;
+  if (!GST_V4L2_IS_ACTIVE (v4l2object))
+    goto done;
+
+  if (v4l2object->pool) {
+    GST_DEBUG_OBJECT (v4l2object->element, "deactivating pool");
+    gst_buffer_pool_set_active (GST_BUFFER_POOL_CAST (v4l2object->pool), FALSE);
+    gst_object_unref (v4l2object->pool);
+    v4l2object->pool = NULL;
   }
+
+  GST_V4L2_SET_INACTIVE (v4l2object);
+
+done:
   return TRUE;
 }
 
+#if 0
+static GstFlowReturn
+gst_v4l2_object_get_mmap (GstV4l2Object * v4l2object, GstBuffer ** buf)
+{
+  GstFlowReturn res;
+#define NUM_TRIALS 50
+  GstBufferPool *pool;
+  gint32 trials = NUM_TRIALS;
+  GstBuffer *pool_buffer;
+  gboolean need_copy;
+
+  pool = v4l2object->pool;
+  if (!pool)
+    goto no_buffer_pool;
+
+  GST_DEBUG_OBJECT (v4l2object->element, "grab frame");
+
+  for (;;) {
+    if ((res = gst_v4l2_object_poll (v4l2object)) != GST_FLOW_OK)
+      goto poll_error;
+
+    res = gst_buffer_pool_acquire_buffer (pool, &pool_buffer, NULL);
+    if (res != GST_FLOW_OK)
+      goto no_buffer;
+
+    if (v4l2object->size > 0) {
+      gsize size = gst_buffer_get_size (pool_buffer);
+
+      /* if size does not match what we expected, try again */
+      if (size != v4l2object->size) {
+        GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, READ,
+            (_("Got unexpected frame size of %u instead of %u."),
+                size, v4l2object->size), (NULL));
+        gst_buffer_unref (pool_buffer);
+        goto no_buffer;
+      }
+    }
+    /* when we get here all is fine */
+    break;
+
+  no_buffer:
+    GST_WARNING_OBJECT (v4l2object->element, "trials=%d", trials);
+
+    /* if the sync() got interrupted, we can retry */
+    switch (errno) {
+      case EINVAL:
+      case ENOMEM:
+        /* fatal */
+        return GST_FLOW_ERROR;
+
+      case EAGAIN:
+      case EIO:
+      case EINTR:
+      default:
+        /* try again, until too many trials */
+        break;
+    }
+
+    /* check nr. of attempts to capture */
+    if (--trials == -1) {
+      goto too_many_trials;
+    }
+  }
+
+
+  /* if we are handing out the last buffer in the pool, we need to make a
+   * copy and bring the buffer back in the pool. */
+  need_copy = v4l2object->always_copy
+      || !gst_v4l2_buffer_pool_available_buffers (pool);
+
+  if (G_UNLIKELY (need_copy)) {
+    if (!v4l2object->always_copy) {
+      GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, v4l2object->element,
+          "running out of buffers, making a copy to reuse current one");
+    }
+    *buf = gst_buffer_copy (pool_buffer);
+    /* this will requeue */
+    gst_buffer_unref (pool_buffer);
+  } else {
+    *buf = pool_buffer;
+  }
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+no_buffer_pool:
+  {
+    GST_DEBUG_OBJECT (v4l2object->element, "no buffer pool");
+    return GST_FLOW_WRONG_STATE;
+  }
+poll_error:
+  {
+    return res;
+  }
+too_many_trials:
+  {
+    GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, FAILED,
+        (_("Failed trying to get video frames from device '%s'."),
+            v4l2object->videodev),
+        (_("Failed after %d tries. device %s. system error: %s"),
+            NUM_TRIALS, v4l2object->videodev, g_strerror (errno)));
+    return GST_FLOW_ERROR;
+  }
+}
+#endif
+
 gboolean
-gst_v4l2_object_stop_streaming (GstV4l2Object * v4l2object)
+gst_v4l2_object_copy (GstV4l2Object * v4l2object, GstBuffer * dest,
+    GstBuffer * src)
 {
-  if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_STREAMOFF,
-          &(v4l2object->type)) < 0) {
-    GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, OPEN_READ,
-        (_("Error stopping streaming on device '%s'."), v4l2object->videodev),
-        GST_ERROR_SYSTEM);
-    return FALSE;
+  guint8 *data;
+  gsize size;
+
+  if (v4l2object->info.finfo) {
+    GstVideoFrame src_frame, dest_frame;
+
+    GST_DEBUG_OBJECT (v4l2object->element, "copy video frame");
+
+    /* we have raw video, use videoframe copy to get strides right */
+    if (!gst_video_frame_map (&src_frame, &v4l2object->info, src, GST_MAP_READ))
+      goto invalid_buffer;
+
+    if (!gst_video_frame_map (&dest_frame, &v4l2object->info, dest,
+            GST_MAP_WRITE)) {
+      gst_video_frame_unmap (&src_frame);
+      goto invalid_buffer;
+    }
+
+    gst_video_frame_copy (&dest_frame, &src_frame);
+
+    gst_video_frame_unmap (&src_frame);
+    gst_video_frame_unmap (&dest_frame);
+  } else {
+    GST_DEBUG_OBJECT (v4l2object->element, "copy raw bytes");
+    data = gst_buffer_map (src, &size, NULL, GST_MAP_READ);
+    gst_buffer_fill (dest, 0, data, size);
+    gst_buffer_unmap (src, data, size);
   }
+  GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, v4l2object->element,
+      "slow copy into buffer %p", dest);
+
   return TRUE;
+
+  /* ERRORS */
+invalid_buffer:
+  {
+    /* No Window available to put our image into */
+    GST_WARNING_OBJECT (v4l2object->element, "could not map image");
+    return FALSE;
+  }
 }
index a7b590d..aae6a8d 100644 (file)
 #include <gst/base/gstpushsrc.h>
 #include <gst/controller/gstcontroller.h>
 
+#include <gst/video/video.h>
 #include <gst/interfaces/propertyprobe.h>
 
+typedef struct _GstV4l2Object GstV4l2Object;
+typedef struct _GstV4l2ObjectClassHelper GstV4l2ObjectClassHelper;
+typedef struct _GstV4l2Xv GstV4l2Xv;
+
+#include <gstv4l2bufferpool.h>
 
 /* size of v4l2 buffer pool in streaming case */
 #define GST_V4L2_MAX_BUFFERS 16
 /* max frame width/height */
 #define GST_V4L2_MAX_SIZE (1<<15) /* 2^15 == 32768 */
 
-
-
 G_BEGIN_DECLS
 
 #define GST_V4L2_OBJECT(obj) (GstV4l2Object *)(obj)
 
-typedef struct _GstV4l2Object GstV4l2Object;
-typedef struct _GstV4l2ObjectClassHelper GstV4l2ObjectClassHelper;
-typedef struct _GstV4l2Xv GstV4l2Xv;
+typedef enum {
+  GST_V4L2_IO_AUTO    = 0,
+  GST_V4L2_IO_RW      = 1,
+  GST_V4L2_IO_MMAP    = 2,
+  GST_V4L2_IO_USERPTR = 3
+} GstV4l2IOMode;
 
 typedef gboolean  (*GstV4l2GetInOutFunction)  (GstV4l2Object * v4l2object, gint * input);
 typedef gboolean  (*GstV4l2SetInOutFunction)  (GstV4l2Object * v4l2object, gint input);
 typedef gboolean  (*GstV4l2UpdateFpsFunction) (GstV4l2Object * v4l2object);
 
+#define GST_V4L2_WIDTH(o)        (GST_VIDEO_INFO_WIDTH (&(o)->info))
+#define GST_V4L2_HEIGHT(o)       (GST_VIDEO_INFO_HEIGHT (&(o)->info))
+#define GST_V4L2_PIXELFORMAT(o)  ((o)->fmtdesc->pixelformat)
+#define GST_V4L2_FPS_N(o)        (GST_VIDEO_INFO_FPS_N (&(o)->info))
+#define GST_V4L2_FPS_D(o)        (GST_VIDEO_INFO_FPS_D (&(o)->info))
+
+/* simple check whether the device is open */
+#define GST_V4L2_IS_OPEN(o)      ((o)->video_fd > 0)
+
+/* check whether the device is 'active' */
+#define GST_V4L2_IS_ACTIVE(o)    ((o)->active)
+#define GST_V4L2_SET_ACTIVE(o)   ((o)->active = TRUE)
+#define GST_V4L2_SET_INACTIVE(o) ((o)->active = FALSE)
+
 struct _GstV4l2Object {
   GstElement * element;
 
+  enum v4l2_buf_type type;   /* V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_OUTPUT */
+
   /* the video device */
   char *videodev;
 
   /* the video-device's file descriptor */
   gint video_fd;
+  GstV4l2IOMode mode;
   GstPoll * poll;
   gboolean can_poll_device;
 
-  /* the video buffer (mmap()'ed) */
-  guint8 **buffer;
+  gboolean active;
+  gboolean streaming;
 
-  enum v4l2_buf_type type;   /* V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_OUTPUT */
+  /* the current format */
+  struct v4l2_fmtdesc *fmtdesc;
+  GstVideoInfo info;
+
+  guint32 bytesperline;
+  guint32 sizeimage;
+  GstClockTime duration;
+
+  /* wanted mode */
+  GstV4l2IOMode req_mode;
+
+  /* optional pool */
+  gboolean always_copy;
+  GstBufferPool *pool;
 
   /* the video device's capabilities */
   struct v4l2_capability vcap;
@@ -138,7 +175,8 @@ GType gst_v4l2_object_get_type (void);
     PROP_CONTRAST,                     \
     PROP_SATURATION,                   \
     PROP_HUE,                           \
-    PROP_TV_NORM
+    PROP_TV_NORM,                       \
+    PROP_IO_MODE
 
 /* create/destroy */
 GstV4l2Object *        gst_v4l2_object_new              (GstElement * element,
@@ -159,9 +197,9 @@ gboolean  gst_v4l2_object_set_property_helper       (GstV4l2Object *v4l2object,
 gboolean  gst_v4l2_object_get_property_helper       (GstV4l2Object *v4l2object,
                                                     guint prop_id, GValue * value,
                                                     GParamSpec * pspec);
-/* starting/stopping */
-gboolean  gst_v4l2_object_start             (GstV4l2Object *v4l2object);
-gboolean  gst_v4l2_object_stop              (GstV4l2Object *v4l2object);
+/* open/close */
+gboolean  gst_v4l2_object_open               (GstV4l2Object *v4l2object);
+gboolean  gst_v4l2_object_close              (GstV4l2Object *v4l2object);
 
 /* probing */
 const GList* gst_v4l2_probe_get_properties  (GstPropertyProbe * probe);
@@ -179,21 +217,22 @@ GValueArray* gst_v4l2_probe_get_values      (GstPropertyProbe * probe, guint pro
 GstCaps*      gst_v4l2_object_probe_caps_for_format (GstV4l2Object *v4l2object, guint32 pixelformat,
                                              const GstStructure * template);
 
-gboolean      gst_v4l2_object_get_caps_info (GstV4l2Object *v4l2object, GstCaps *caps,
-                                             struct v4l2_fmtdesc **format, gint *w, gint *h,
-                                             gboolean * interlaced, guint *fps_n, guint *fps_d, guint *size);
-
-
 GSList*       gst_v4l2_object_get_format_list  (GstV4l2Object *v4l2object);
 
 GstCaps*      gst_v4l2_object_get_all_caps (void);
 
 GstStructure* gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc);
 
-gboolean      gst_v4l2_object_set_format (GstV4l2Object *v4l2object, guint32 pixelformat, guint32 width, guint32 height, gboolean interlaced);
+gboolean      gst_v4l2_object_set_format (GstV4l2Object *v4l2object, GstCaps * caps);
+
+gboolean      gst_v4l2_object_unlock      (GstV4l2Object *v4l2object);
+gboolean      gst_v4l2_object_unlock_stop (GstV4l2Object *v4l2object);
+
+gboolean      gst_v4l2_object_stop        (GstV4l2Object *v4l2object);
+
 
-gboolean      gst_v4l2_object_start_streaming (GstV4l2Object *v4l2object);
-gboolean      gst_v4l2_object_stop_streaming (GstV4l2Object *v4l2object);
+gboolean      gst_v4l2_object_copy        (GstV4l2Object * v4l2object,
+                                           GstBuffer * dest, GstBuffer *src);
 
 
 #define GST_IMPLEMENT_V4L2_PROBE_METHODS(Type_Class, interface_as_function)                 \
index 63a2fed..66aa043 100644 (file)
@@ -257,67 +257,20 @@ GST_IMPLEMENT_V4L2_TUNER_METHODS (GstV4l2Radio, gst_v4l2radio);
 static void gst_v4l2radio_uri_handler_init (gpointer g_iface,
     gpointer iface_data);
 
-static gboolean
-gst_v4l2radio_interface_supported (GstImplementsInterface * iface,
-    GType iface_type)
-{
-  if (iface_type == GST_TYPE_TUNER)
-    return TRUE;
-  else
-    return FALSE;
-}
-
-static void
-gst_v4l2radio_implements_interface_init (GstImplementsInterfaceClass * iface)
-{
-  iface->supported = gst_v4l2radio_interface_supported;
-}
-
 static void
 gst_v4l2radio_tuner_interface_reinit (GstTunerClass * iface)
 {
   gst_v4l2radio_tuner_interface_init (iface);
 }
 
-static void
-gst_v4l2radio_interfaces (GType type)
-{
-  static const GInterfaceInfo urihandler_info = {
-    (GInterfaceInitFunc) gst_v4l2radio_uri_handler_init,
-    NULL,
-    NULL
-  };
-
-  static const GInterfaceInfo implements_interface_info = {
-    (GInterfaceInitFunc) gst_v4l2radio_implements_interface_init,
-    NULL,
-    NULL,
-  };
-
-  static const GInterfaceInfo propertyprobe_info = {
-    (GInterfaceInitFunc) gst_v4l2radio_property_probe_interface_init,
-    NULL,
-    NULL,
-  };
-
-  static const GInterfaceInfo tuner_interface_info = {
-    (GInterfaceInitFunc) gst_v4l2radio_tuner_interface_reinit,
-    NULL,
-    NULL,
-  };
-
-  g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
-  g_type_add_interface_static (type,
-      GST_TYPE_IMPLEMENTS_INTERFACE, &implements_interface_info);
-
-  g_type_add_interface_static (type, GST_TYPE_TUNER, &tuner_interface_info);
-
-  g_type_add_interface_static (type,
-      GST_TYPE_PROPERTY_PROBE, &propertyprobe_info);
-}
-
-GST_BOILERPLATE_FULL (GstV4l2Radio, gst_v4l2radio, GstElement, GST_TYPE_ELEMENT,
-    gst_v4l2radio_interfaces);
+#define gst_v4l2radio_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstV4l2Radio, gst_v4l2radio, GST_TYPE_ELEMENT,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
+        gst_v4l2radio_uri_handler_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_TUNER,
+        gst_v4l2radio_tuner_interface_reinit);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_PROPERTY_PROBE,
+        gst_v4l2radio_property_probe_interface_init));
 
 static void gst_v4l2radio_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -329,24 +282,6 @@ static GstStateChangeReturn gst_v4l2radio_change_state (GstElement * element,
     GstStateChange transition);
 
 static void
-gst_v4l2radio_base_init (gpointer gclass)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (gclass);
-  GstV4l2RadioClass *gstv4l2radio_class = GST_V4L2RADIO_CLASS (gclass);
-
-  GST_DEBUG_CATEGORY_INIT (v4l2radio_debug, "v4l2radio", 0,
-      "V4l2 radio element");
-
-  gstv4l2radio_class->v4l2_class_devices = NULL;
-
-  gst_element_class_set_details_simple (gstelement_class,
-      "Radio (video4linux2) Tuner",
-      "Tuner",
-      "Controls a Video4Linux2 radio device",
-      "Alexey Chernov <4ernov@gmail.com>");
-}
-
-static void
 gst_v4l2radio_class_init (GstV4l2RadioClass * klass)
 {
   GObjectClass *gobject_class;
@@ -355,6 +290,8 @@ gst_v4l2radio_class_init (GstV4l2RadioClass * klass)
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
 
+  gobject_class->dispose = gst_v4l2radio_dispose;
+  gobject_class->finalize = (GObjectFinalizeFunc) gst_v4l2radio_finalize;
   gobject_class->set_property = gst_v4l2radio_set_property;
   gobject_class->get_property = gst_v4l2radio_get_property;
 
@@ -368,16 +305,23 @@ gst_v4l2radio_class_init (GstV4l2RadioClass * klass)
           "Station frequency in Hz",
           MIN_FREQUENCY, MAX_FREQUENCY, DEFAULT_FREQUENCY, G_PARAM_READWRITE));
 
-  gobject_class->dispose = gst_v4l2radio_dispose;
-  gobject_class->finalize = (GObjectFinalizeFunc) gst_v4l2radio_finalize;
-
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_v4l2radio_change_state);
 
+  gst_element_class_set_details_simple (gstelement_class,
+      "Radio (video4linux2) Tuner",
+      "Tuner",
+      "Controls a Video4Linux2 radio device",
+      "Alexey Chernov <4ernov@gmail.com>");
+
+  klass->v4l2_class_devices = NULL;
+
+  GST_DEBUG_CATEGORY_INIT (v4l2radio_debug, "v4l2radio", 0,
+      "V4l2 radio element");
 }
 
 static void
-gst_v4l2radio_init (GstV4l2Radio * filter, GstV4l2RadioClass * gclass)
+gst_v4l2radio_init (GstV4l2Radio * filter)
 {
   filter->v4l2object = gst_v4l2_object_new (GST_ELEMENT (filter),
       V4L2_BUF_TYPE_VIDEO_CAPTURE, DEFAULT_PROP_DEVICE,
@@ -473,7 +417,7 @@ gst_v4l2radio_start (GstV4l2Radio * radio)
 static gboolean
 gst_v4l2radio_stop (GstV4l2Radio * radio)
 {
-  if (!gst_v4l2_object_stop (radio->v4l2object))
+  if (!gst_v4l2_object_close (radio->v4l2object))
     return FALSE;
 
   return TRUE;
@@ -563,13 +507,13 @@ gst_v4l2radio_get_property (GObject * object, guint prop_id,
 
 /* GstURIHandler interface */
 static GstURIType
-gst_v4l2radio_uri_get_type (void)
+gst_v4l2radio_uri_get_type (GType type)
 {
   return GST_URI_SRC;
 }
 
 static gchar **
-gst_v4l2radio_uri_get_protocols (void)
+gst_v4l2radio_uri_get_protocols (GType type)
 {
   static gchar *protocols[] = { (char *) "radio", NULL };
   return protocols;
index 8672a1d..5ad4a18 100644 (file)
 #include <config.h>
 #endif
 
+#include "gst/video/gstmetavideo.h"
 
 #include "gstv4l2colorbalance.h"
 #include "gstv4l2tuner.h"
 #ifdef HAVE_XVIDEO
-#include "gstv4l2xoverlay.h"
+#include "gstv4l2videooverlay.h"
 #endif
 #include "gstv4l2vidorient.h"
 
 GST_DEBUG_CATEGORY (v4l2sink_debug);
 #define GST_CAT_DEFAULT v4l2sink_debug
 
-#define PROP_DEF_QUEUE_SIZE         12
-#define PROP_DEF_MIN_QUEUED_BUFS    1
 #define DEFAULT_PROP_DEVICE   "/dev/video1"
 
 enum
 {
   PROP_0,
   V4L2_STD_OBJECT_PROPS,
-  PROP_QUEUE_SIZE,
-  PROP_MIN_QUEUED_BUFS,
   PROP_OVERLAY_TOP,
   PROP_OVERLAY_LEFT,
   PROP_OVERLAY_WIDTH,
@@ -94,49 +91,10 @@ GST_IMPLEMENT_V4L2_PROBE_METHODS (GstV4l2SinkClass, gst_v4l2sink);
 GST_IMPLEMENT_V4L2_COLOR_BALANCE_METHODS (GstV4l2Sink, gst_v4l2sink);
 GST_IMPLEMENT_V4L2_TUNER_METHODS (GstV4l2Sink, gst_v4l2sink);
 #ifdef HAVE_XVIDEO
-GST_IMPLEMENT_V4L2_XOVERLAY_METHODS (GstV4l2Sink, gst_v4l2sink);
+GST_IMPLEMENT_V4L2_VIDEO_OVERLAY_METHODS (GstV4l2Sink, gst_v4l2sink);
 #endif
 GST_IMPLEMENT_V4L2_VIDORIENT_METHODS (GstV4l2Sink, gst_v4l2sink);
 
-static gboolean
-gst_v4l2sink_iface_supported (GstImplementsInterface * iface, GType iface_type)
-{
-  GstV4l2Object *v4l2object = GST_V4L2SINK (iface)->v4l2object;
-
-#ifdef HAVE_XVIDEO
-  g_assert (iface_type == GST_TYPE_X_OVERLAY ||
-      iface_type == GST_TYPE_NAVIGATION ||
-      iface_type == GST_TYPE_COLOR_BALANCE ||
-      iface_type == GST_TYPE_VIDEO_ORIENTATION ||
-      iface_type == GST_TYPE_TUNER);
-#else
-  g_assert (iface_type == GST_TYPE_COLOR_BALANCE ||
-      iface_type == GST_TYPE_VIDEO_ORIENTATION ||
-      iface_type == GST_TYPE_TUNER);
-#endif
-
-  if (v4l2object->video_fd == -1)
-    return FALSE;
-
-#ifdef HAVE_XVIDEO
-  if (!GST_V4L2_IS_OVERLAY (v4l2object)) {
-    if (iface_type == GST_TYPE_X_OVERLAY || iface_type == GST_TYPE_NAVIGATION)
-      return FALSE;
-  }
-#endif
-
-  return TRUE;
-}
-
-static void
-gst_v4l2sink_interface_init (GstImplementsInterfaceClass * klass)
-{
-  /*
-   * default virtual functions
-   */
-  klass->supported = gst_v4l2sink_iface_supported;
-}
-
 #ifdef HAVE_XVIDEO
 static void gst_v4l2sink_navigation_send_event (GstNavigation * navigation,
     GstStructure * structure);
@@ -147,66 +105,20 @@ gst_v4l2sink_navigation_init (GstNavigationInterface * iface)
 }
 #endif
 
-static void
-gst_v4l2sink_init_interfaces (GType type)
-{
-  static const GInterfaceInfo v4l2iface_info = {
-    (GInterfaceInitFunc) gst_v4l2sink_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo v4l2_tuner_info = {
-    (GInterfaceInitFunc) gst_v4l2sink_tuner_interface_init,
-    NULL,
-    NULL,
-  };
+#define gst_v4l2sink_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstV4l2Sink, gst_v4l2sink, GST_TYPE_VIDEO_SINK,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_TUNER, gst_v4l2sink_tuner_interface_init);
 #ifdef HAVE_XVIDEO
-  static const GInterfaceInfo v4l2_xoverlay_info = {
-    (GInterfaceInitFunc) gst_v4l2sink_xoverlay_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo v4l2_navigation_info = {
-    (GInterfaceInitFunc) gst_v4l2sink_navigation_init,
-    NULL,
-    NULL,
-  };
+    G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_OVERLAY,
+        gst_v4l2sink_video_overlay_interface_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_NAVIGATION, gst_v4l2sink_navigation_init);
 #endif
-  static const GInterfaceInfo v4l2_colorbalance_info = {
-    (GInterfaceInitFunc) gst_v4l2sink_color_balance_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo v4l2_videoorientation_info = {
-    (GInterfaceInitFunc) gst_v4l2sink_video_orientation_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo v4l2_propertyprobe_info = {
-    (GInterfaceInitFunc) gst_v4l2sink_property_probe_interface_init,
-    NULL,
-    NULL,
-  };
-
-  g_type_add_interface_static (type,
-      GST_TYPE_IMPLEMENTS_INTERFACE, &v4l2iface_info);
-  g_type_add_interface_static (type, GST_TYPE_TUNER, &v4l2_tuner_info);
-#ifdef HAVE_XVIDEO
-  g_type_add_interface_static (type, GST_TYPE_X_OVERLAY, &v4l2_xoverlay_info);
-  g_type_add_interface_static (type,
-      GST_TYPE_NAVIGATION, &v4l2_navigation_info);
-#endif
-  g_type_add_interface_static (type,
-      GST_TYPE_COLOR_BALANCE, &v4l2_colorbalance_info);
-  g_type_add_interface_static (type,
-      GST_TYPE_VIDEO_ORIENTATION, &v4l2_videoorientation_info);
-  g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE,
-      &v4l2_propertyprobe_info);
-}
-
-
-GST_BOILERPLATE_FULL (GstV4l2Sink, gst_v4l2sink, GstVideoSink,
-    GST_TYPE_VIDEO_SINK, gst_v4l2sink_init_interfaces);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_COLOR_BALANCE,
+        gst_v4l2sink_color_balance_interface_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_ORIENTATION,
+        gst_v4l2sink_video_orientation_interface_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_PROPERTY_PROBE,
+        gst_v4l2sink_property_probe_interface_init));
 
 
 static void gst_v4l2sink_dispose (GObject * object);
@@ -218,40 +130,23 @@ static void gst_v4l2sink_set_property (GObject * object, guint prop_id,
 static void gst_v4l2sink_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-
 /* GstElement methods: */
 static GstStateChangeReturn gst_v4l2sink_change_state (GstElement * element,
     GstStateChange transition);
 
 /* GstBaseSink methods: */
-static GstCaps *gst_v4l2sink_get_caps (GstBaseSink * bsink);
+static gboolean gst_v4l2sink_propose_allocation (GstBaseSink * bsink,
+    GstQuery * query);
+static GstCaps *gst_v4l2sink_get_caps (GstBaseSink * bsink, GstCaps * filter);
 static gboolean gst_v4l2sink_set_caps (GstBaseSink * bsink, GstCaps * caps);
+#if 0
 static GstFlowReturn gst_v4l2sink_buffer_alloc (GstBaseSink * bsink,
     guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
+#endif
 static GstFlowReturn gst_v4l2sink_show_frame (GstBaseSink * bsink,
     GstBuffer * buf);
 
 static void
-gst_v4l2sink_base_init (gpointer g_class)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-  GstV4l2SinkClass *gstv4l2sink_class = GST_V4L2SINK_CLASS (g_class);
-
-  gstv4l2sink_class->v4l2_class_devices = NULL;
-
-  GST_DEBUG_CATEGORY_INIT (v4l2sink_debug, "v4l2sink", 0, "V4L2 sink element");
-
-  gst_element_class_set_details_simple (gstelement_class,
-      "Video (video4linux2) Sink", "Sink/Video",
-      "Displays frames on a video4linux2 device", "Rob Clark <rob@ti.com>,");
-
-  gst_element_class_add_pad_template
-      (gstelement_class,
-      gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
-          gst_v4l2_object_get_all_caps ()));
-}
-
-static void
 gst_v4l2sink_class_init (GstV4l2SinkClass * klass)
 {
   GObjectClass *gobject_class;
@@ -271,17 +166,7 @@ gst_v4l2sink_class_init (GstV4l2SinkClass * klass)
 
   gst_v4l2_object_install_properties_helper (gobject_class,
       DEFAULT_PROP_DEVICE);
-  g_object_class_install_property (gobject_class, PROP_QUEUE_SIZE,
-      g_param_spec_uint ("queue-size", "Queue size",
-          "Number of buffers to be enqueud in the driver in streaming mode",
-          GST_V4L2_MIN_BUFFERS, GST_V4L2_MAX_BUFFERS, PROP_DEF_QUEUE_SIZE,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (gobject_class, PROP_MIN_QUEUED_BUFS,
-      g_param_spec_uint ("min-queued-bufs", "Minimum queued bufs",
-          "Minimum number of queued bufs; v4l2sink won't dqbuf if the driver "
-          "doesn't have more than this number (which normally you shouldn't change)",
-          0, GST_V4L2_MAX_BUFFERS, PROP_DEF_MIN_QUEUED_BUFS,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
   g_object_class_install_property (gobject_class, PROP_OVERLAY_TOP,
       g_param_spec_int ("overlay-top", "Overlay top",
           "The topmost (y) coordinate of the video overlay; top left corner of screen is 0,0",
@@ -316,14 +201,28 @@ gst_v4l2sink_class_init (GstV4l2SinkClass * klass)
           "The height of the video crop; default is equal to negotiated image height",
           0, 0xffffffff, 0, G_PARAM_READWRITE));
 
+  gst_element_class_set_details_simple (element_class,
+      "Video (video4linux2) Sink", "Sink/Video",
+      "Displays frames on a video4linux2 device", "Rob Clark <rob@ti.com>,");
+
+  gst_element_class_add_pad_template (element_class,
+      gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
+          gst_v4l2_object_get_all_caps ()));
+
   basesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_v4l2sink_get_caps);
   basesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_v4l2sink_set_caps);
-  basesink_class->buffer_alloc = GST_DEBUG_FUNCPTR (gst_v4l2sink_buffer_alloc);
+  basesink_class->propose_allocation =
+      GST_DEBUG_FUNCPTR (gst_v4l2sink_propose_allocation);
   basesink_class->render = GST_DEBUG_FUNCPTR (gst_v4l2sink_show_frame);
+
+  klass->v4l2_class_devices = NULL;
+
+  GST_DEBUG_CATEGORY_INIT (v4l2sink_debug, "v4l2sink", 0, "V4L2 sink element");
+
 }
 
 static void
-gst_v4l2sink_init (GstV4l2Sink * v4l2sink, GstV4l2SinkClass * klass)
+gst_v4l2sink_init (GstV4l2Sink * v4l2sink)
 {
   v4l2sink->v4l2object = gst_v4l2_object_new (GST_ELEMENT (v4l2sink),
       V4L2_BUF_TYPE_VIDEO_OUTPUT, DEFAULT_PROP_DEVICE,
@@ -336,16 +235,10 @@ gst_v4l2sink_init (GstV4l2Sink * v4l2sink, GstV4l2SinkClass * klass)
    */
   g_object_set (v4l2sink, "device", "/dev/video1", NULL);
 
-  /* number of buffers requested */
-  v4l2sink->num_buffers = PROP_DEF_QUEUE_SIZE;
-  v4l2sink->min_queued_bufs = PROP_DEF_MIN_QUEUED_BUFS;
-
   v4l2sink->probed_caps = NULL;
-  v4l2sink->current_caps = NULL;
 
   v4l2sink->overlay_fields_set = 0;
   v4l2sink->crop_fields_set = 0;
-  v4l2sink->state = 0;
 }
 
 
@@ -358,10 +251,6 @@ gst_v4l2sink_dispose (GObject * object)
     gst_caps_unref (v4l2sink->probed_caps);
   }
 
-  if (v4l2sink->current_caps) {
-    gst_caps_unref (v4l2sink->current_caps);
-  }
-
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
@@ -376,16 +265,6 @@ gst_v4l2sink_finalize (GstV4l2Sink * v4l2sink)
 
 
 /*
- * State values
- */
-enum
-{
-  STATE_OFF = 0,
-  STATE_PENDING_STREAMON,
-  STATE_STREAMING
-};
-
-/*
  * flags to indicate which overlay/crop properties the user has set (and
  * therefore which ones should override the defaults from the driver)
  */
@@ -495,12 +374,6 @@ gst_v4l2sink_set_property (GObject * object,
   if (!gst_v4l2_object_set_property_helper (v4l2sink->v4l2object,
           prop_id, value, pspec)) {
     switch (prop_id) {
-      case PROP_QUEUE_SIZE:
-        v4l2sink->num_buffers = g_value_get_uint (value);
-        break;
-      case PROP_MIN_QUEUED_BUFS:
-        v4l2sink->min_queued_bufs = g_value_get_uint (value);
-        break;
       case PROP_OVERLAY_TOP:
         v4l2sink->overlay.top = g_value_get_int (value);
         v4l2sink->overlay_fields_set |= RECT_TOP_SET;
@@ -558,12 +431,6 @@ gst_v4l2sink_get_property (GObject * object,
   if (!gst_v4l2_object_get_property_helper (v4l2sink->v4l2object,
           prop_id, value, pspec)) {
     switch (prop_id) {
-      case PROP_QUEUE_SIZE:
-        g_value_set_uint (value, v4l2sink->num_buffers);
-        break;
-      case PROP_MIN_QUEUED_BUFS:
-        g_value_set_uint (value, v4l2sink->min_queued_bufs);
-        break;
       case PROP_OVERLAY_TOP:
         g_value_set_int (value, v4l2sink->overlay.top);
         break;
@@ -608,7 +475,7 @@ gst_v4l2sink_change_state (GstElement * element, GstStateChange transition)
   switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
       /* open the device */
-      if (!gst_v4l2_object_start (v4l2sink->v4l2object))
+      if (!gst_v4l2_object_open (v4l2sink->v4l2object))
         return GST_STATE_CHANGE_FAILURE;
       break;
     default:
@@ -619,21 +486,16 @@ gst_v4l2sink_change_state (GstElement * element, GstStateChange transition)
 
   switch (transition) {
     case GST_STATE_CHANGE_PAUSED_TO_READY:
-      if (v4l2sink->state == STATE_STREAMING) {
-        if (!gst_v4l2_object_stop_streaming (v4l2sink->v4l2object)) {
-          return GST_STATE_CHANGE_FAILURE;
-        }
-        v4l2sink->state = STATE_PENDING_STREAMON;
-      }
+      if (!gst_v4l2_object_stop (v4l2sink->v4l2object))
+        return GST_STATE_CHANGE_FAILURE;
       break;
     case GST_STATE_CHANGE_READY_TO_NULL:
-      if (NULL != v4l2sink->pool)
-        gst_v4l2_buffer_pool_destroy (v4l2sink->pool);
-      v4l2sink->pool = NULL;
-      /* close the device */
+      /* we need to call stop here too */
       if (!gst_v4l2_object_stop (v4l2sink->v4l2object))
         return GST_STATE_CHANGE_FAILURE;
-      v4l2sink->state = STATE_OFF;
+      /* close the device */
+      if (!gst_v4l2_object_close (v4l2sink->v4l2object))
+        return GST_STATE_CHANGE_FAILURE;
       break;
     default:
       break;
@@ -644,7 +506,7 @@ gst_v4l2sink_change_state (GstElement * element, GstStateChange transition)
 
 
 static GstCaps *
-gst_v4l2sink_get_caps (GstBaseSink * bsink)
+gst_v4l2sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
 {
   GstV4l2Sink *v4l2sink = GST_V4L2SINK (bsink);
   GstCaps *ret;
@@ -659,40 +521,44 @@ gst_v4l2sink_get_caps (GstBaseSink * bsink)
             (v4l2sink)));
   }
 
-  if (v4l2sink->probed_caps) {
-    LOG_CAPS (v4l2sink, v4l2sink->probed_caps);
-    return gst_caps_ref (v4l2sink->probed_caps);
-  }
+  if (v4l2sink->probed_caps == NULL) {
+    formats = gst_v4l2_object_get_format_list (v4l2sink->v4l2object);
 
-  formats = gst_v4l2_object_get_format_list (v4l2sink->v4l2object);
+    ret = gst_caps_new_empty ();
 
-  ret = gst_caps_new_empty ();
+    for (walk = formats; walk; walk = walk->next) {
+      struct v4l2_fmtdesc *format;
 
-  for (walk = formats; walk; walk = walk->next) {
-    struct v4l2_fmtdesc *format;
+      GstStructure *template;
 
-    GstStructure *template;
+      format = (struct v4l2_fmtdesc *) walk->data;
 
-    format = (struct v4l2_fmtdesc *) walk->data;
+      template = gst_v4l2_object_v4l2fourcc_to_structure (format->pixelformat);
 
-    template = gst_v4l2_object_v4l2fourcc_to_structure (format->pixelformat);
+      if (template) {
+        GstCaps *tmp;
 
-    if (template) {
-      GstCaps *tmp;
+        tmp =
+            gst_v4l2_object_probe_caps_for_format (v4l2sink->v4l2object,
+            format->pixelformat, template);
+        if (tmp)
+          gst_caps_append (ret, tmp);
 
-      tmp =
-          gst_v4l2_object_probe_caps_for_format (v4l2sink->v4l2object,
-          format->pixelformat, template);
-      if (tmp)
-        gst_caps_append (ret, tmp);
-
-      gst_structure_free (template);
-    } else {
-      GST_DEBUG_OBJECT (v4l2sink, "unknown format %u", format->pixelformat);
+        gst_structure_free (template);
+      } else {
+        GST_DEBUG_OBJECT (v4l2sink, "unknown format %u", format->pixelformat);
+      }
     }
+    v4l2sink->probed_caps = ret;
   }
 
-  v4l2sink->probed_caps = gst_caps_ref (ret);
+  if (filter) {
+    ret =
+        gst_caps_intersect_full (filter, v4l2sink->probed_caps,
+        GST_CAPS_INTERSECT_FIRST);
+  } else {
+    ret = gst_caps_ref (v4l2sink->probed_caps);
+  }
 
   GST_INFO_OBJECT (v4l2sink, "probed caps: %p", ret);
   LOG_CAPS (v4l2sink, ret);
@@ -704,11 +570,7 @@ static gboolean
 gst_v4l2sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
 {
   GstV4l2Sink *v4l2sink = GST_V4L2SINK (bsink);
-  gint w = 0, h = 0;
-  gboolean interlaced;
-  struct v4l2_fmtdesc *format;
-  guint fps_n, fps_d;
-  guint size;
+  GstV4l2Object *obj = v4l2sink->v4l2object;
 
   LOG_CAPS (v4l2sink, caps);
 
@@ -717,118 +579,102 @@ gst_v4l2sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
     return FALSE;
   }
 
-  if (v4l2sink->current_caps) {
-    GST_DEBUG_OBJECT (v4l2sink, "already have caps set.. are they equal?");
-    LOG_CAPS (v4l2sink, v4l2sink->current_caps);
-    if (gst_caps_is_equal (v4l2sink->current_caps, caps)) {
-      GST_DEBUG_OBJECT (v4l2sink, "yes they are!");
-      return TRUE;
-    }
-    GST_DEBUG_OBJECT (v4l2sink, "no they aren't!");
-  }
+  if (!gst_v4l2_object_stop (obj))
+    goto stop_failed;
 
-  if (v4l2sink->pool) {
-    /* TODO: if we've already allocated buffers, we probably need to
-     * do something here to free and reallocate....
-     *
-     *   gst_v4l2_object_stop_streaming()
-     *   gst_v4l2_buffer_pool_destroy()
-     *
-     */
-    GST_DEBUG_OBJECT (v4l2sink, "warning, changing caps not supported yet");
-    return FALSE;
-  }
+  if (!gst_v4l2_object_set_format (v4l2sink->v4l2object, caps))
+    goto invalid_format;
 
-  /* we want our own v4l2 type of fourcc codes */
-  if (!gst_v4l2_object_get_caps_info (v4l2sink->v4l2object, caps,
-          &format, &w, &h, &interlaced, &fps_n, &fps_d, &size)) {
-    GST_DEBUG_OBJECT (v4l2sink, "can't get capture format from caps %p", caps);
-    return FALSE;
-  }
+  gst_v4l2sink_sync_overlay_fields (v4l2sink);
+  gst_v4l2sink_sync_crop_fields (v4l2sink);
 
-  if (!format) {
-    GST_DEBUG_OBJECT (v4l2sink, "unrecognized caps!!");
-    return FALSE;
-  }
+#ifdef HAVE_XVIDEO
+  gst_v4l2_video_overlay_prepare_window_handle (v4l2sink->v4l2object, TRUE);
+#endif
 
-  if (!gst_v4l2_object_set_format (v4l2sink->v4l2object, format->pixelformat,
-          w, h, interlaced)) {
-    /* error already posted */
-    return FALSE;
-  }
+  GST_INFO_OBJECT (v4l2sink, "outputting buffers via mmap()");
 
-  v4l2sink->video_width = w;
-  v4l2sink->video_height = h;
+  v4l2sink->video_width = GST_V4L2_WIDTH (v4l2sink->v4l2object);
+  v4l2sink->video_height = GST_V4L2_HEIGHT (v4l2sink->v4l2object);
 
   /* TODO: videosink width/height should be scaled according to
    * pixel-aspect-ratio
    */
-  GST_VIDEO_SINK_WIDTH (v4l2sink) = w;
-  GST_VIDEO_SINK_HEIGHT (v4l2sink) = h;
-
-  v4l2sink->current_caps = gst_caps_ref (caps);
+  GST_VIDEO_SINK_WIDTH (v4l2sink) = v4l2sink->video_width;
+  GST_VIDEO_SINK_HEIGHT (v4l2sink) = v4l2sink->video_height;
 
   return TRUE;
+
+  /* ERRORS */
+stop_failed:
+  {
+    GST_DEBUG_OBJECT (v4l2sink, "failed to stop streaming");
+    return FALSE;
+  }
+invalid_format:
+  {
+    /* error already posted */
+    GST_DEBUG_OBJECT (v4l2sink, "can't set format");
+    return FALSE;
+  }
 }
 
-/* buffer alloc function to implement pad_alloc for upstream element */
-static GstFlowReturn
-gst_v4l2sink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
-    GstCaps * caps, GstBuffer ** buf)
+static gboolean
+gst_v4l2sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
 {
   GstV4l2Sink *v4l2sink = GST_V4L2SINK (bsink);
-  GstV4l2Buffer *v4l2buf;
-
-  if (v4l2sink->v4l2object->vcap.capabilities & V4L2_CAP_STREAMING) {
+  GstV4l2Object *obj = v4l2sink->v4l2object;
+  GstBufferPool *pool;
+  guint size = 0;
+  GstCaps *caps;
+  gboolean need_pool;
 
-    /* initialize the buffer pool if not initialized yet (first buffer): */
-    if (G_UNLIKELY (!v4l2sink->pool)) {
+  gst_query_parse_allocation (query, &caps, &need_pool);
 
-      /* set_caps() might not be called yet.. so just to make sure: */
-      if (!gst_v4l2sink_set_caps (bsink, caps)) {
-        return GST_FLOW_ERROR;
-      }
+  if (caps == NULL)
+    goto no_caps;
 
-      GST_V4L2_CHECK_OPEN (v4l2sink->v4l2object);
+  if ((pool = obj->pool))
+    gst_object_ref (pool);
 
-      if (!(v4l2sink->pool = gst_v4l2_buffer_pool_new (GST_ELEMENT (v4l2sink),
-                  v4l2sink->v4l2object->video_fd,
-                  v4l2sink->num_buffers, caps, FALSE,
-                  V4L2_BUF_TYPE_VIDEO_OUTPUT))) {
-        return GST_FLOW_ERROR;
-      }
+  if (pool != NULL) {
+    const GstCaps *pcaps;
+    GstStructure *config;
 
-      gst_v4l2sink_sync_overlay_fields (v4l2sink);
-      gst_v4l2sink_sync_crop_fields (v4l2sink);
+    /* we had a pool, check caps */
+    config = gst_buffer_pool_get_config (pool);
+    gst_buffer_pool_config_get (config, &pcaps, &size, NULL, NULL, NULL, NULL);
 
-#ifdef HAVE_XVIDEO
-      gst_v4l2_xoverlay_prepare_xwindow_id (v4l2sink->v4l2object, TRUE);
-#endif
-
-      v4l2sink->state = STATE_PENDING_STREAMON;
-
-      GST_INFO_OBJECT (v4l2sink, "outputting buffers via mmap()");
-
-      if (v4l2sink->num_buffers != v4l2sink->pool->buffer_count) {
-        v4l2sink->num_buffers = v4l2sink->pool->buffer_count;
-        g_object_notify (G_OBJECT (v4l2sink), "queue-size");
-      }
+    GST_DEBUG_OBJECT (v4l2sink,
+        "we had a pool with caps %" GST_PTR_FORMAT, pcaps);
+    if (!gst_caps_is_equal (caps, pcaps)) {
+      gst_object_unref (pool);
+      goto different_caps;
     }
+  }
+  /* we need at least 2 buffers to operate */
+  gst_query_set_allocation_params (query, size, 2, 0, 0, 0, pool);
 
-    v4l2buf = gst_v4l2_buffer_pool_get (v4l2sink->pool, TRUE);
+  /* we also support various metadata */
+  gst_query_add_allocation_meta (query, GST_META_API_VIDEO);
+  gst_query_add_allocation_meta (query, GST_META_API_VIDEO_CROP);
 
-    if (G_LIKELY (v4l2buf)) {
-      GST_DEBUG_OBJECT (v4l2sink, "allocated buffer: %p", v4l2buf);
-      *buf = GST_BUFFER (v4l2buf);
-      return GST_FLOW_OK;
-    } else {
-      GST_DEBUG_OBJECT (v4l2sink, "failed to allocate buffer");
-      return GST_FLOW_ERROR;
-    }
+  if (pool)
+    gst_object_unref (pool);
 
-  } else {
-    GST_ERROR_OBJECT (v4l2sink, "only supporting streaming mode for now...");
-    return GST_FLOW_ERROR;
+  return TRUE;
+
+  /* ERRORS */
+no_caps:
+  {
+    GST_DEBUG_OBJECT (v4l2sink, "no caps specified");
+    return FALSE;
+  }
+different_caps:
+  {
+    /* different caps, we can't use this pool */
+    GST_DEBUG_OBJECT (v4l2sink, "pool has different caps");
+    return FALSE;
   }
 }
 
@@ -836,92 +682,26 @@ gst_v4l2sink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
 static GstFlowReturn
 gst_v4l2sink_show_frame (GstBaseSink * bsink, GstBuffer * buf)
 {
+  GstFlowReturn ret;
   GstV4l2Sink *v4l2sink = GST_V4L2SINK (bsink);
-  GstBuffer *newbuf = NULL;
+  GstV4l2Object *obj = v4l2sink->v4l2object;
 
   GST_DEBUG_OBJECT (v4l2sink, "render buffer: %p", buf);
 
-  if (!GST_IS_V4L2_BUFFER (buf)) {
-    GstFlowReturn ret;
-
-    /* special case check for sub-buffers:  In certain cases, places like
-     * GstBaseTransform, which might check that the buffer is writable
-     * before copying metadata, timestamp, and such, will find that the
-     * buffer has more than one reference to it.  In these cases, they
-     * will create a sub-buffer with an offset=0 and length equal to the
-     * original buffer size.
-     *
-     * This could happen in two scenarios: (1) a tee in the pipeline, and
-     * (2) because the refcnt is incremented in gst_mini_object_free()
-     * before the finalize function is called, and decremented after it
-     * returns..  but returning this buffer to the buffer pool in the
-     * finalize function, could wake up a thread blocked in _buffer_alloc()
-     * which could run and get a buffer w/ refcnt==2 before the thread
-     * originally unref'ing the buffer returns from finalize function and
-     * decrements the refcnt back to 1!
-     */
-    if (buf->parent &&
-        (GST_BUFFER_DATA (buf) == GST_BUFFER_DATA (buf->parent)) &&
-        (GST_BUFFER_SIZE (buf) == GST_BUFFER_SIZE (buf->parent))) {
-      GST_DEBUG_OBJECT (v4l2sink, "I have a sub-buffer!");
-      return gst_v4l2sink_show_frame (bsink, buf->parent);
-    }
-
-    GST_DEBUG_OBJECT (v4l2sink, "slow-path.. I got a %s so I need to memcpy",
-        g_type_name (G_OBJECT_TYPE (buf)));
-
-    ret = gst_v4l2sink_buffer_alloc (bsink,
-        GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf), GST_BUFFER_CAPS (buf),
-        &newbuf);
-
-    if (GST_FLOW_OK != ret) {
-      GST_DEBUG_OBJECT (v4l2sink,
-          "dropping frame!  Consider increasing 'queue-size' property!");
-      return GST_FLOW_OK;
-    }
-
-    memcpy (GST_BUFFER_DATA (newbuf),
-        GST_BUFFER_DATA (buf),
-        MIN (GST_BUFFER_SIZE (newbuf), GST_BUFFER_SIZE (buf)));
+  if (G_UNLIKELY (obj->pool == NULL))
+    goto not_negotiated;
 
-    GST_DEBUG_OBJECT (v4l2sink, "render copied buffer: %p", newbuf);
+  ret =
+      gst_v4l2_buffer_pool_process (GST_V4L2_BUFFER_POOL_CAST (obj->pool), buf);
 
-    buf = newbuf;
-  }
-
-  if (!gst_v4l2_buffer_pool_qbuf (v4l2sink->pool, GST_V4L2_BUFFER (buf))) {
-    return GST_FLOW_ERROR;
-  }
-  if (v4l2sink->state == STATE_PENDING_STREAMON) {
-    if (!gst_v4l2_object_start_streaming (v4l2sink->v4l2object)) {
-      return GST_FLOW_ERROR;
-    }
-    v4l2sink->state = STATE_STREAMING;
-  }
-
-  if (!newbuf) {
-    gst_buffer_ref (buf);
-  }
+  return ret;
 
-  /* if the driver has more than one buffer, ie. more than just the one we
-   * just queued, then dequeue one immediately to make it available via
-   * _buffer_alloc():
-   */
-  if (gst_v4l2_buffer_pool_available_buffers (v4l2sink->pool) >
-      v4l2sink->min_queued_bufs) {
-    GstV4l2Buffer *v4l2buf = gst_v4l2_buffer_pool_dqbuf (v4l2sink->pool);
-
-    /* note: if we get a buf, we don't want to use it directly (because
-     * someone else could still hold a ref).. but instead we release our
-     * reference to it, and if no one else holds a ref it will be returned
-     * to the pool of available buffers..  and if not, we keep looping.
-     */
-    if (v4l2buf) {
-      gst_buffer_unref (GST_BUFFER (v4l2buf));
-    }
+  /* ERRORS */
+not_negotiated:
+  {
+    GST_ERROR_OBJECT (bsink, "not negotiated");
+    return GST_FLOW_NOT_NEGOTIATED;
   }
-
-  return GST_FLOW_OK;
 }
 
 #ifdef HAVE_XVIDEO
@@ -940,7 +720,7 @@ gst_v4l2sink_navigation_send_event (GstNavigation * navigation,
     GstVideoRectangle rect;
     gdouble x, y, xscale = 1.0, yscale = 1.0;
 
-    gst_v4l2_xoverlay_get_render_rect (v4l2sink->v4l2object, &rect);
+    gst_v4l2_video_overlay_get_render_rect (v4l2sink->v4l2object, &rect);
 
     /* We calculate scaling using the original video frames geometry to
      * include pixel aspect ratio scaling.
index 8fe8222..b461e2c 100644 (file)
@@ -55,10 +55,6 @@ struct _GstV4l2Sink {
   /*< private >*/
   GstV4l2Object * v4l2object;
   GstCaps *probed_caps;         /* all supported caps of underlying v4l2 device */
-  GstCaps *current_caps;        /* the current negotiated caps */
-  GstV4l2BufferPool *pool;
-  guint32 num_buffers;
-  guint32 min_queued_bufs;
 
   gint video_width, video_height;      /* original (unscaled) video w/h */
 
@@ -73,8 +69,6 @@ struct _GstV4l2Sink {
    * setting properties:
    */
   guint8 overlay_fields_set, crop_fields_set;
-
-  guint8 state;
 };
 
 struct _GstV4l2SinkClass {
index df11dd4..4e01c62 100644 (file)
 
 #include <string.h>
 #include <sys/time.h>
-#include "v4l2src_calls.h"
 #include <unistd.h>
 
+#include "gst/video/gstmetavideo.h"
+#include "gst/video/gstvideopool.h"
+
+#include "gstv4l2src.h"
+
 #include "gstv4l2colorbalance.h"
 #include "gstv4l2tuner.h"
 #ifdef HAVE_XVIDEO
@@ -63,7 +67,6 @@
 GST_DEBUG_CATEGORY (v4l2src_debug);
 #define GST_CAT_DEFAULT v4l2src_debug
 
-#define PROP_DEF_QUEUE_SIZE         2
 #define PROP_DEF_ALWAYS_COPY        TRUE
 #define PROP_DEF_DECIMATE           1
 
@@ -73,7 +76,6 @@ enum
 {
   PROP_0,
   V4L2_STD_OBJECT_PROPS,
-  PROP_QUEUE_SIZE,
   PROP_ALWAYS_COPY,
   PROP_DECIMATE
 };
@@ -89,102 +91,21 @@ GST_IMPLEMENT_V4L2_VIDORIENT_METHODS (GstV4l2Src, gst_v4l2src);
 static void gst_v4l2src_uri_handler_init (gpointer g_iface,
     gpointer iface_data);
 
-static gboolean
-gst_v4l2src_iface_supported (GstImplementsInterface * iface, GType iface_type)
-{
-  GstV4l2Object *v4l2object = GST_V4L2SRC (iface)->v4l2object;
-
-#ifdef HAVE_XVIDEO
-  g_assert (iface_type == GST_TYPE_TUNER ||
-      iface_type == GST_TYPE_X_OVERLAY ||
-      iface_type == GST_TYPE_COLOR_BALANCE ||
-      iface_type == GST_TYPE_VIDEO_ORIENTATION);
-#else
-  g_assert (iface_type == GST_TYPE_TUNER ||
-      iface_type == GST_TYPE_COLOR_BALANCE ||
-      iface_type == GST_TYPE_VIDEO_ORIENTATION);
-#endif
-
-  if (v4l2object->video_fd == -1)
-    return FALSE;
-
+#define gst_v4l2src_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstV4l2Src, gst_v4l2src, GST_TYPE_PUSH_SRC,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_v4l2src_uri_handler_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_TUNER, gst_v4l2src_tuner_interface_init);
 #ifdef HAVE_XVIDEO
-  if (iface_type == GST_TYPE_X_OVERLAY && !GST_V4L2_IS_OVERLAY (v4l2object))
-    return FALSE;
+    /* FIXME: does GstXOverlay for v4l2src make sense in a GStreamer context? */
+    G_IMPLEMENT_INTERFACE (GST_TYPE_X_OVERLAY,
+        gst_v4l2src_xoverlay_interface_init);
 #endif
-
-  return TRUE;
-}
-
-static void
-gst_v4l2src_interface_init (GstImplementsInterfaceClass * klass)
-{
-  /*
-   * default virtual functions 
-   */
-  klass->supported = gst_v4l2src_iface_supported;
-}
-
-static void
-gst_v4l2src_init_interfaces (GType type)
-{
-  static const GInterfaceInfo urihandler_info = {
-    gst_v4l2src_uri_handler_init,
-    NULL,
-    NULL
-  };
-
-  static const GInterfaceInfo v4l2iface_info = {
-    (GInterfaceInitFunc) gst_v4l2src_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo v4l2_tuner_info = {
-    (GInterfaceInitFunc) gst_v4l2src_tuner_interface_init,
-    NULL,
-    NULL,
-  };
-#ifdef HAVE_XVIDEO
-  /* FIXME: does GstXOverlay for v4l2src make sense in a GStreamer context? */
-  static const GInterfaceInfo v4l2_xoverlay_info = {
-    (GInterfaceInitFunc) gst_v4l2src_xoverlay_interface_init,
-    NULL,
-    NULL,
-  };
-#endif
-  static const GInterfaceInfo v4l2_colorbalance_info = {
-    (GInterfaceInitFunc) gst_v4l2src_color_balance_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo v4l2_videoorientation_info = {
-    (GInterfaceInitFunc) gst_v4l2src_video_orientation_interface_init,
-    NULL,
-    NULL,
-  };
-  static const GInterfaceInfo v4l2_propertyprobe_info = {
-    (GInterfaceInitFunc) gst_v4l2src_property_probe_interface_init,
-    NULL,
-    NULL,
-  };
-
-  g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
-  g_type_add_interface_static (type,
-      GST_TYPE_IMPLEMENTS_INTERFACE, &v4l2iface_info);
-  g_type_add_interface_static (type, GST_TYPE_TUNER, &v4l2_tuner_info);
-#ifdef HAVE_XVIDEO
-  g_type_add_interface_static (type, GST_TYPE_X_OVERLAY, &v4l2_xoverlay_info);
-#endif
-  g_type_add_interface_static (type,
-      GST_TYPE_COLOR_BALANCE, &v4l2_colorbalance_info);
-  g_type_add_interface_static (type,
-      GST_TYPE_VIDEO_ORIENTATION, &v4l2_videoorientation_info);
-  g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE,
-      &v4l2_propertyprobe_info);
-}
-
-GST_BOILERPLATE_FULL (GstV4l2Src, gst_v4l2src, GstPushSrc, GST_TYPE_PUSH_SRC,
-    gst_v4l2src_init_interfaces);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_COLOR_BALANCE,
+        gst_v4l2src_color_balance_interface_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_ORIENTATION,
+        gst_v4l2src_video_orientation_interface_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_PROPERTY_PROBE,
+        gst_v4l2src_property_probe_interface_init));
 
 static void gst_v4l2src_dispose (GObject * object);
 static void gst_v4l2src_finalize (GstV4l2Src * v4l2src);
@@ -199,9 +120,11 @@ static gboolean gst_v4l2src_unlock (GstBaseSrc * src);
 static gboolean gst_v4l2src_unlock_stop (GstBaseSrc * src);
 static gboolean gst_v4l2src_stop (GstBaseSrc * src);
 static gboolean gst_v4l2src_set_caps (GstBaseSrc * src, GstCaps * caps);
-static GstCaps *gst_v4l2src_get_caps (GstBaseSrc * src);
+static GstCaps *gst_v4l2src_get_caps (GstBaseSrc * src, GstCaps * filter);
 static gboolean gst_v4l2src_query (GstBaseSrc * bsrc, GstQuery * query);
-static GstFlowReturn gst_v4l2src_create (GstPushSrc * src, GstBuffer ** out);
+static gboolean gst_v4l2src_decide_allocation (GstBaseSrc * src,
+    GstQuery * query);
+static GstFlowReturn gst_v4l2src_fill (GstPushSrc * src, GstBuffer * out);
 static void gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps);
 static gboolean gst_v4l2src_negotiate (GstBaseSrc * basesrc);
 
@@ -210,34 +133,6 @@ static void gst_v4l2src_set_property (GObject * object, guint prop_id,
 static void gst_v4l2src_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-/* get_frame io methods */
-static GstFlowReturn
-gst_v4l2src_get_read (GstV4l2Src * v4l2src, GstBuffer ** buf);
-static GstFlowReturn
-gst_v4l2src_get_mmap (GstV4l2Src * v4l2src, GstBuffer ** buf);
-
-static void
-gst_v4l2src_base_init (gpointer g_class)
-{
-  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-  GstV4l2SrcClass *gstv4l2src_class = GST_V4L2SRC_CLASS (g_class);
-
-  gstv4l2src_class->v4l2_class_devices = NULL;
-
-  GST_DEBUG_CATEGORY_INIT (v4l2src_debug, "v4l2src", 0, "V4L2 source element");
-
-  gst_element_class_set_details_simple (gstelement_class,
-      "Video (video4linux2) Source", "Source/Video",
-      "Reads frames from a Video4Linux2 device",
-      "Edgard Lima <edgard.lima@indt.org.br>,"
-      " Stefan Kost <ensonic@users.sf.net>");
-
-  gst_element_class_add_pad_template
-      (gstelement_class,
-      gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
-          gst_v4l2_object_get_all_caps ()));
-}
-
 static void
 gst_v4l2src_class_init (GstV4l2SrcClass * klass)
 {
@@ -260,11 +155,6 @@ gst_v4l2src_class_init (GstV4l2SrcClass * klass)
 
   gst_v4l2_object_install_properties_helper (gobject_class,
       DEFAULT_PROP_DEVICE);
-  g_object_class_install_property (gobject_class, PROP_QUEUE_SIZE,
-      g_param_spec_uint ("queue-size", "Queue size",
-          "Number of buffers to be enqueud in the driver in streaming mode",
-          GST_V4L2_MIN_BUFFERS, GST_V4L2_MAX_BUFFERS, PROP_DEF_QUEUE_SIZE,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (gobject_class, PROP_ALWAYS_COPY,
       g_param_spec_boolean ("always-copy", "Always Copy",
           "If the buffer will or not be used directly from mmap",
@@ -281,6 +171,17 @@ gst_v4l2src_class_init (GstV4l2SrcClass * klass)
           "Only use every nth frame", 1, G_MAXINT,
           PROP_DEF_DECIMATE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  gst_element_class_set_details_simple (element_class,
+      "Video (video4linux2) Source", "Source/Video",
+      "Reads frames from a Video4Linux2 device",
+      "Edgard Lima <edgard.lima@indt.org.br>, "
+      "Stefan Kost <ensonic@users.sf.net>");
+
+  gst_element_class_add_pad_template
+      (element_class,
+      gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
+          gst_v4l2_object_get_all_caps ()));
+
   basesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_v4l2src_get_caps);
   basesrc_class->set_caps = GST_DEBUG_FUNCPTR (gst_v4l2src_set_caps);
   basesrc_class->start = GST_DEBUG_FUNCPTR (gst_v4l2src_start);
@@ -290,34 +191,31 @@ gst_v4l2src_class_init (GstV4l2SrcClass * klass)
   basesrc_class->query = GST_DEBUG_FUNCPTR (gst_v4l2src_query);
   basesrc_class->fixate = GST_DEBUG_FUNCPTR (gst_v4l2src_fixate);
   basesrc_class->negotiate = GST_DEBUG_FUNCPTR (gst_v4l2src_negotiate);
+  basesrc_class->decide_allocation =
+      GST_DEBUG_FUNCPTR (gst_v4l2src_decide_allocation);
+
+  pushsrc_class->fill = GST_DEBUG_FUNCPTR (gst_v4l2src_fill);
+
+  klass->v4l2_class_devices = NULL;
 
-  pushsrc_class->create = GST_DEBUG_FUNCPTR (gst_v4l2src_create);
+  GST_DEBUG_CATEGORY_INIT (v4l2src_debug, "v4l2src", 0, "V4L2 source element");
 }
 
 static void
-gst_v4l2src_init (GstV4l2Src * v4l2src, GstV4l2SrcClass * klass)
+gst_v4l2src_init (GstV4l2Src * v4l2src)
 {
   /* fixme: give an update_fps_function */
   v4l2src->v4l2object = gst_v4l2_object_new (GST_ELEMENT (v4l2src),
       V4L2_BUF_TYPE_VIDEO_CAPTURE, DEFAULT_PROP_DEVICE,
       gst_v4l2_get_input, gst_v4l2_set_input, NULL);
 
-  /* number of buffers requested */
-  v4l2src->num_buffers = PROP_DEF_QUEUE_SIZE;
-
-  v4l2src->always_copy = PROP_DEF_ALWAYS_COPY;
+  v4l2src->v4l2object->always_copy = PROP_DEF_ALWAYS_COPY;
   v4l2src->decimate = PROP_DEF_DECIMATE;
 
-  v4l2src->is_capturing = FALSE;
-
   gst_base_src_set_format (GST_BASE_SRC (v4l2src), GST_FORMAT_TIME);
   gst_base_src_set_live (GST_BASE_SRC (v4l2src), TRUE);
-
-  v4l2src->fps_d = 0;
-  v4l2src->fps_n = 0;
 }
 
-
 static void
 gst_v4l2src_dispose (GObject * object)
 {
@@ -349,11 +247,8 @@ gst_v4l2src_set_property (GObject * object,
   if (!gst_v4l2_object_set_property_helper (v4l2src->v4l2object,
           prop_id, value, pspec)) {
     switch (prop_id) {
-      case PROP_QUEUE_SIZE:
-        v4l2src->num_buffers = g_value_get_uint (value);
-        break;
       case PROP_ALWAYS_COPY:
-        v4l2src->always_copy = g_value_get_boolean (value);
+        v4l2src->v4l2object->always_copy = g_value_get_boolean (value);
         break;
       case PROP_DECIMATE:
         v4l2src->decimate = g_value_get_int (value);
@@ -365,7 +260,6 @@ gst_v4l2src_set_property (GObject * object,
   }
 }
 
-
 static void
 gst_v4l2src_get_property (GObject * object,
     guint prop_id, GValue * value, GParamSpec * pspec)
@@ -375,11 +269,8 @@ gst_v4l2src_get_property (GObject * object,
   if (!gst_v4l2_object_get_property_helper (v4l2src->v4l2object,
           prop_id, value, pspec)) {
     switch (prop_id) {
-      case PROP_QUEUE_SIZE:
-        g_value_set_uint (value, v4l2src->num_buffers);
-        break;
       case PROP_ALWAYS_COPY:
-        g_value_set_boolean (value, v4l2src->always_copy);
+        g_value_set_boolean (value, v4l2src->v4l2object->always_copy);
         break;
       case PROP_DECIMATE:
         g_value_set_int (value, v4l2src->decimate);
@@ -391,7 +282,6 @@ gst_v4l2src_get_property (GObject * object,
   }
 }
 
-
 /* this function is a bit of a last resort */
 static void
 gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps)
@@ -402,33 +292,20 @@ gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps)
   GST_DEBUG_OBJECT (basesrc, "fixating caps %" GST_PTR_FORMAT, caps);
 
   for (i = 0; i < gst_caps_get_size (caps); ++i) {
-    const GValue *v;
-
     structure = gst_caps_get_structure (caps, i);
 
-    /* FIXME such sizes? we usually fixate to something in the 320x200
-     * range... */
-    /* We are fixating to greater possble size (limited to GST_V4L2_MAX_SIZE)
+    /* We are fixating to a resonable 320x200 resolution
        and the maximum framerate resolution for that size */
-    gst_structure_fixate_field_nearest_int (structure, "width",
-        GST_V4L2_MAX_SIZE);
-    gst_structure_fixate_field_nearest_int (structure, "height",
-        GST_V4L2_MAX_SIZE);
+    gst_structure_fixate_field_nearest_int (structure, "width", 320);
+    gst_structure_fixate_field_nearest_int (structure, "height", 200);
     gst_structure_fixate_field_nearest_fraction (structure, "framerate",
         G_MAXINT, 1);
-
-    v = gst_structure_get_value (structure, "format");
-    if (v && G_VALUE_TYPE (v) != GST_TYPE_FOURCC) {
-      guint32 fourcc;
-
-      g_return_if_fail (G_VALUE_TYPE (v) == GST_TYPE_LIST);
-
-      fourcc = gst_value_get_fourcc (gst_value_list_get_value (v, 0));
-      gst_structure_set (structure, "format", GST_TYPE_FOURCC, fourcc, NULL);
-    }
+    gst_structure_fixate_field (structure, "format");
   }
 
   GST_DEBUG_OBJECT (basesrc, "fixated caps %" GST_PTR_FORMAT, caps);
+
+  GST_BASE_SRC_CLASS (parent_class)->fixate (basesrc, caps);
 }
 
 
@@ -441,7 +318,7 @@ gst_v4l2src_negotiate (GstBaseSrc * basesrc)
   gboolean result = FALSE;
 
   /* first see what is possible on our source pad */
-  thiscaps = gst_pad_get_caps (GST_BASE_SRC_PAD (basesrc));
+  thiscaps = gst_pad_get_caps (GST_BASE_SRC_PAD (basesrc), NULL);
   GST_DEBUG_OBJECT (basesrc, "caps of src: %" GST_PTR_FORMAT, thiscaps);
   LOG_CAPS (basesrc, thiscaps);
 
@@ -450,7 +327,7 @@ gst_v4l2src_negotiate (GstBaseSrc * basesrc)
     goto no_nego_needed;
 
   /* get the peer caps */
-  peercaps = gst_pad_peer_get_caps (GST_BASE_SRC_PAD (basesrc));
+  peercaps = gst_pad_peer_get_caps (GST_BASE_SRC_PAD (basesrc), thiscaps);
   GST_DEBUG_OBJECT (basesrc, "caps of peer: %" GST_PTR_FORMAT, peercaps);
   LOG_CAPS (basesrc, peercaps);
   if (peercaps && !gst_caps_is_any (peercaps)) {
@@ -482,11 +359,8 @@ gst_v4l2src_negotiate (GstBaseSrc * basesrc)
        * resolution strictly bigger then the first peer caps */
       if (gst_caps_get_size (icaps) > 1) {
         GstStructure *s = gst_caps_get_structure (peercaps, 0);
-
         int best = 0;
-
         int twidth, theight;
-
         int width = G_MAXINT, height = G_MAXINT;
 
         if (gst_structure_get_int (s, "width", &twidth)
@@ -497,7 +371,6 @@ gst_v4l2src_negotiate (GstBaseSrc * basesrc)
            */
           for (i = gst_caps_get_size (icaps) - 1; i >= 0; i--) {
             GstStructure *is = gst_caps_get_structure (icaps, i);
-
             int w, h;
 
             if (gst_structure_get_int (is, "width", &w)
@@ -539,8 +412,7 @@ gst_v4l2src_negotiate (GstBaseSrc * basesrc)
         result = TRUE;
       } else if (gst_caps_is_fixed (caps)) {
         /* yay, fixed caps, use those then */
-        if (gst_pad_set_caps (GST_BASE_SRC_PAD (basesrc), caps))
-          result = TRUE;
+        result = gst_base_src_set_caps (basesrc, caps);
       }
     }
     gst_caps_unref (caps);
@@ -557,14 +429,18 @@ no_nego_needed:
 }
 
 static GstCaps *
-gst_v4l2src_get_caps (GstBaseSrc * src)
+gst_v4l2src_get_caps (GstBaseSrc * src, GstCaps * filter)
 {
-  GstV4l2Src *v4l2src = GST_V4L2SRC (src);
+  GstV4l2Src *v4l2src;
+  GstV4l2Object *obj;
   GstCaps *ret;
   GSList *walk;
   GSList *formats;
 
-  if (!GST_V4L2_IS_OPEN (v4l2src->v4l2object)) {
+  v4l2src = GST_V4L2SRC (src);
+  obj = v4l2src->v4l2object;
+
+  if (!GST_V4L2_IS_OPEN (obj)) {
     /* FIXME: copy? */
     return
         gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD
@@ -574,13 +450,12 @@ gst_v4l2src_get_caps (GstBaseSrc * src)
   if (v4l2src->probed_caps)
     return gst_caps_ref (v4l2src->probed_caps);
 
-  formats = gst_v4l2_object_get_format_list (v4l2src->v4l2object);
+  formats = gst_v4l2_object_get_format_list (obj);
 
   ret = gst_caps_new_empty ();
 
   for (walk = formats; walk; walk = walk->next) {
     struct v4l2_fmtdesc *format;
-
     GstStructure *template;
 
     format = (struct v4l2_fmtdesc *) walk->data;
@@ -591,7 +466,7 @@ gst_v4l2src_get_caps (GstBaseSrc * src)
       GstCaps *tmp;
 
       tmp =
-          gst_v4l2_object_probe_caps_for_format (v4l2src->v4l2object,
+          gst_v4l2_object_probe_caps_for_format (obj,
           format->pixelformat, template);
       if (tmp)
         gst_caps_append (ret, tmp);
@@ -613,57 +488,100 @@ static gboolean
 gst_v4l2src_set_caps (GstBaseSrc * src, GstCaps * caps)
 {
   GstV4l2Src *v4l2src;
-  gint w = 0, h = 0;
-  gboolean interlaced;
-  struct v4l2_fmtdesc *format;
-  guint fps_n, fps_d;
-  guint size;
+  GstV4l2Object *obj;
 
   v4l2src = GST_V4L2SRC (src);
-
-  /* if we're not open, punt -- we'll get setcaps'd later via negotiate */
-  if (!GST_V4L2_IS_OPEN (v4l2src->v4l2object))
-    return FALSE;
+  obj = v4l2src->v4l2object;
 
   /* make sure we stop capturing and dealloc buffers */
-  if (GST_V4L2_IS_ACTIVE (v4l2src->v4l2object)) {
-    /* both will throw an element-error on failure */
-    if (!gst_v4l2src_capture_stop (v4l2src))
-      return FALSE;
-    if (!gst_v4l2src_capture_deinit (v4l2src))
-      return FALSE;
-  }
-
-  /* we want our own v4l2 type of fourcc codes */
-  if (!gst_v4l2_object_get_caps_info (v4l2src->v4l2object, caps, &format, &w,
-          &h, &interlaced, &fps_n, &fps_d, &size)) {
-    GST_INFO_OBJECT (v4l2src,
-        "can't get capture format from caps %" GST_PTR_FORMAT, caps);
+  if (!gst_v4l2_object_stop (obj))
     return FALSE;
-  }
 
-  GST_DEBUG_OBJECT (v4l2src, "trying to set_capture %dx%d at %d/%d fps, "
-      "format %s", w, h, fps_n, fps_d, format->description);
-
-  if (!gst_v4l2src_set_capture (v4l2src, format->pixelformat, w, h,
-          interlaced, fps_n, fps_d))
+  if (!gst_v4l2_object_set_format (obj, caps))
     /* error already posted */
     return FALSE;
 
-  if (!gst_v4l2src_capture_init (v4l2src, caps))
-    return FALSE;
+  return TRUE;
+}
+
+static gboolean
+gst_v4l2src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
+{
+  GstV4l2Src *src;
+  GstV4l2Object *obj;
+  GstBufferPool *pool;
+  guint size, min, max, prefix, alignment;
+
+  src = GST_V4L2SRC (bsrc);
+  obj = src->v4l2object;
+
+  gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
+      &alignment, &pool);
 
-  if (v4l2src->use_mmap) {
-    v4l2src->get_frame = gst_v4l2src_get_mmap;
+  GST_DEBUG_OBJECT (src, "allocation: size:%u min:%u max:%u prefix:%u "
+      "align:%u pool:%" GST_PTR_FORMAT, size, min, max, prefix, alignment,
+      pool);
+
+  if (min != 0) {
+    /* if there is a min-buffers suggestion, use it. We add 1 because we need 1
+     * buffer extra to capture while the other two buffers are downstream */
+    min += 1;
   } else {
-    v4l2src->get_frame = gst_v4l2src_get_read;
+    min = 2;
   }
 
-  if (!gst_v4l2src_capture_start (v4l2src))
-    return FALSE;
+  /* select a pool */
+  switch (obj->mode) {
+    case GST_V4L2_IO_RW:
+      if (pool == NULL) {
+        /* no downstream pool, use our own then */
+        GST_DEBUG_OBJECT (src,
+            "read/write mode: no downstream pool, using our own");
+        pool = GST_BUFFER_POOL_CAST (obj->pool);
+        size = obj->sizeimage;
+      } else {
+        /* in READ/WRITE mode, prefer a downstream pool because our own pool
+         * doesn't help much, we have to write to it as well */
+        GST_DEBUG_OBJECT (src, "read/write mode: using downstream pool");
+        /* use the bigest size, when we use our own pool we can't really do any
+         * other size than what the hardware gives us but for downstream pools
+         * we can try */
+        size = MAX (size, obj->sizeimage);
+      }
+      break;
+    case GST_V4L2_IO_MMAP:
+    case GST_V4L2_IO_USERPTR:
+      /* in streaming mode, prefer our own pool */
+      pool = GST_BUFFER_POOL_CAST (obj->pool);
+      size = obj->sizeimage;
+      GST_DEBUG_OBJECT (src,
+          "streaming mode: using our own pool %" GST_PTR_FORMAT, pool);
+      break;
+    case GST_V4L2_IO_AUTO:
+    default:
+      GST_WARNING_OBJECT (src, "unhandled mode");
+      break;
+  }
 
-  /* now store the expected output size */
-  v4l2src->frame_byte_size = size;
+  if (pool) {
+    GstStructure *config;
+    const GstCaps *caps;
+
+    config = gst_buffer_pool_get_config (pool);
+    gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL, NULL);
+    gst_buffer_pool_config_set (config, caps, size, min, max, prefix,
+        alignment);
+
+    /* if downstream supports video metadata, add this to the pool config */
+    if (gst_query_has_allocation_meta (query, GST_META_API_VIDEO))
+      gst_buffer_pool_config_add_option (config,
+          GST_BUFFER_POOL_OPTION_META_VIDEO);
+
+    gst_buffer_pool_set_config (pool, config);
+  }
+
+  gst_query_set_allocation_params (query, size, min, max, prefix,
+      alignment, pool);
 
   return TRUE;
 }
@@ -672,35 +590,40 @@ static gboolean
 gst_v4l2src_query (GstBaseSrc * bsrc, GstQuery * query)
 {
   GstV4l2Src *src;
-
+  GstV4l2Object *obj;
   gboolean res = FALSE;
 
   src = GST_V4L2SRC (bsrc);
+  obj = src->v4l2object;
 
   switch (GST_QUERY_TYPE (query)) {
     case GST_QUERY_LATENCY:{
       GstClockTime min_latency, max_latency;
+      guint32 fps_n, fps_d;
 
       /* device must be open */
-      if (!GST_V4L2_IS_OPEN (src->v4l2object)) {
+      if (!GST_V4L2_IS_OPEN (obj)) {
         GST_WARNING_OBJECT (src,
             "Can't give latency since device isn't open !");
         goto done;
       }
 
+      fps_n = GST_V4L2_FPS_N (obj);
+      fps_d = GST_V4L2_FPS_D (obj);
+
       /* we must have a framerate */
-      if (src->fps_n <= 0 || src->fps_d <= 0) {
+      if (fps_n <= 0 || fps_d <= 0) {
         GST_WARNING_OBJECT (src,
             "Can't give latency since framerate isn't fixated !");
         goto done;
       }
 
       /* min latency is the time to capture one frame */
-      min_latency =
-          gst_util_uint64_scale_int (GST_SECOND, src->fps_d, src->fps_n);
+      min_latency = gst_util_uint64_scale_int (GST_SECOND, fps_d, fps_n);
 
       /* max latency is total duration of the frame buffer */
-      max_latency = src->num_buffers * min_latency;
+      max_latency =
+          GST_V4L2_BUFFER_POOL_CAST (obj->pool)->max_buffers * min_latency;
 
       GST_DEBUG_OBJECT (bsrc,
           "report latency min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
@@ -745,41 +668,26 @@ static gboolean
 gst_v4l2src_unlock (GstBaseSrc * src)
 {
   GstV4l2Src *v4l2src = GST_V4L2SRC (src);
-
-  GST_LOG_OBJECT (src, "Flushing");
-  gst_poll_set_flushing (v4l2src->v4l2object->poll, TRUE);
-
-  return TRUE;
+  return gst_v4l2_object_unlock (v4l2src->v4l2object);
 }
 
 static gboolean
 gst_v4l2src_unlock_stop (GstBaseSrc * src)
 {
   GstV4l2Src *v4l2src = GST_V4L2SRC (src);
-
-  GST_LOG_OBJECT (src, "No longer flushing");
-  gst_poll_set_flushing (v4l2src->v4l2object->poll, FALSE);
-
-  return TRUE;
+  return gst_v4l2_object_unlock_stop (v4l2src->v4l2object);
 }
 
 static gboolean
 gst_v4l2src_stop (GstBaseSrc * src)
 {
   GstV4l2Src *v4l2src = GST_V4L2SRC (src);
+  GstV4l2Object *obj = v4l2src->v4l2object;
 
-  if (GST_V4L2_IS_ACTIVE (v4l2src->v4l2object)
-      && !gst_v4l2src_capture_stop (v4l2src))
-    return FALSE;
-
-  if (v4l2src->v4l2object->buffer != NULL) {
-    if (!gst_v4l2src_capture_deinit (v4l2src))
+  if (GST_V4L2_IS_ACTIVE (obj)) {
+    if (!gst_v4l2_object_stop (obj))
       return FALSE;
   }
-
-  v4l2src->fps_d = 0;
-  v4l2src->fps_n = 0;
-
   return TRUE;
 }
 
@@ -788,11 +696,12 @@ gst_v4l2src_change_state (GstElement * element, GstStateChange transition)
 {
   GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
   GstV4l2Src *v4l2src = GST_V4L2SRC (element);
+  GstV4l2Object *obj = v4l2src->v4l2object;
 
   switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
       /* open the device */
-      if (!gst_v4l2_object_start (v4l2src->v4l2object))
+      if (!gst_v4l2_object_open (obj))
         return GST_STATE_CHANGE_FAILURE;
       break;
     default:
@@ -804,7 +713,7 @@ gst_v4l2src_change_state (GstElement * element, GstStateChange transition)
   switch (transition) {
     case GST_STATE_CHANGE_READY_TO_NULL:
       /* close the device */
-      if (!gst_v4l2_object_stop (v4l2src->v4l2object))
+      if (!gst_v4l2_object_close (obj))
         return GST_STATE_CHANGE_FAILURE;
 
       if (v4l2src->probed_caps) {
@@ -820,202 +729,102 @@ gst_v4l2src_change_state (GstElement * element, GstStateChange transition)
 }
 
 static GstFlowReturn
-gst_v4l2src_get_read (GstV4l2Src * v4l2src, GstBuffer ** buf)
+gst_v4l2src_fill (GstPushSrc * src, GstBuffer * buf)
 {
-  gint amount;
-  gint ret;
-
-  gint buffersize;
-
-  buffersize = v4l2src->frame_byte_size;
-  /* In case the size per frame is unknown assume it's a streaming format (e.g.
-   * mpegts) and grab a reasonable default size instead */
-  if (buffersize == 0)
-    buffersize = GST_BASE_SRC (v4l2src)->blocksize;
-
-  *buf = gst_buffer_new_and_alloc (buffersize);
-
-  do {
-    ret = gst_poll_wait (v4l2src->v4l2object->poll, GST_CLOCK_TIME_NONE);
-    if (G_UNLIKELY (ret < 0)) {
-      if (errno == EBUSY)
-        goto stopped;
-      if (errno == ENXIO) {
-        GST_DEBUG_OBJECT (v4l2src,
-            "v4l2 device doesn't support polling. Disabling");
-        v4l2src->v4l2object->can_poll_device = FALSE;
-      } else {
-        if (errno != EAGAIN && errno != EINTR)
-          goto select_error;
-      }
-    }
-    amount =
-        v4l2_read (v4l2src->v4l2object->video_fd, GST_BUFFER_DATA (*buf),
-        buffersize);
-    if (amount == buffersize) {
-      break;
-    } else if (amount == -1) {
-      if (errno == EAGAIN || errno == EINTR) {
-        continue;
-      } else
-        goto read_error;
-    } else {
-      /* short reads can happen if a signal interrupts the read */
-      continue;
-    }
-  } while (TRUE);
-
-  /* we set the buffer metadata in gst_v4l2src_create() */
-
-  return GST_FLOW_OK;
+  GstV4l2Src *v4l2src = GST_V4L2SRC (src);
+  GstV4l2Object *obj = v4l2src->v4l2object;
+  GstFlowReturn ret;
+  GstClock *clock;
+  GstClockTime timestamp, duration;
 
-  /* ERRORS */
-select_error:
-  {
-    GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
-        ("select error %d: %s (%d)", ret, g_strerror (errno), errno));
-    return GST_FLOW_ERROR;
-  }
-stopped:
-  {
-    GST_DEBUG ("stop called");
-    return GST_FLOW_WRONG_STATE;
-  }
-read_error:
-  {
-    GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
-        (_("Error reading %d bytes from device '%s'."),
-            buffersize, v4l2src->v4l2object->videodev), GST_ERROR_SYSTEM);
+#if 0
+  int i;
+  /* decimate, just capture and throw away frames */
+  for (i = 0; i < v4l2src->decimate - 1; i++) {
+    ret = gst_v4l2_buffer_pool_process (obj, buf);
+    if (ret != GST_FLOW_OK) {
+      return ret;
+    }
     gst_buffer_unref (*buf);
-    return GST_FLOW_ERROR;
   }
-}
+#endif
 
-static GstFlowReturn
-gst_v4l2src_get_mmap (GstV4l2Src * v4l2src, GstBuffer ** buf)
-{
-  GstBuffer *temp;
-  GstFlowReturn ret;
-  guint size;
-  guint count = 0;
+  ret =
+      gst_v4l2_buffer_pool_process (GST_V4L2_BUFFER_POOL_CAST (obj->pool), buf);
 
-again:
-  ret = gst_v4l2src_grab_frame (v4l2src, &temp);
   if (G_UNLIKELY (ret != GST_FLOW_OK))
-    goto done;
+    goto error;
 
-  if (v4l2src->frame_byte_size > 0) {
-    size = GST_BUFFER_SIZE (temp);
-
-    /* if size does not match what we expected, try again */
-    if (size != v4l2src->frame_byte_size) {
-      GST_ELEMENT_WARNING (v4l2src, RESOURCE, READ,
-          (_("Got unexpected frame size of %u instead of %u."),
-              size, v4l2src->frame_byte_size), (NULL));
-      gst_buffer_unref (temp);
-      if (count++ > 50)
-        goto size_error;
-
-      goto again;
-    }
+  /* set buffer metadata */
+  GST_BUFFER_OFFSET (buf) = v4l2src->offset++;
+  GST_BUFFER_OFFSET_END (buf) = v4l2src->offset;
+
+  /* timestamps, LOCK to get clock and base time. */
+  /* FIXME: element clock and base_time is rarely changing */
+  GST_OBJECT_LOCK (v4l2src);
+  if ((clock = GST_ELEMENT_CLOCK (v4l2src))) {
+    /* we have a clock, get base time and ref clock */
+    timestamp = GST_ELEMENT (v4l2src)->base_time;
+    gst_object_ref (clock);
+  } else {
+    /* no clock, can't set timestamps */
+    timestamp = GST_CLOCK_TIME_NONE;
   }
+  GST_OBJECT_UNLOCK (v4l2src);
 
-  *buf = temp;
-done:
-  return ret;
+  duration = obj->duration;
 
-  /* ERRORS */
-size_error:
-  {
-    GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
-        (_("Error reading %d bytes on device '%s'."),
-            v4l2src->frame_byte_size, v4l2src->v4l2object->videodev), (NULL));
-    return GST_FLOW_ERROR;
-  }
-}
+  if (G_LIKELY (clock)) {
+    /* the time now is the time of the clock minus the base time */
+    timestamp = gst_clock_get_time (clock) - timestamp;
+    gst_object_unref (clock);
 
-static GstFlowReturn
-gst_v4l2src_create (GstPushSrc * src, GstBuffer ** buf)
-{
-  GstV4l2Src *v4l2src = GST_V4L2SRC (src);
-  int i;
-  GstFlowReturn ret;
-
-  for (i = 0; i < v4l2src->decimate - 1; i++) {
-    ret = v4l2src->get_frame (v4l2src, buf);
-    if (ret != GST_FLOW_OK) {
-      return ret;
+    /* if we have a framerate adjust timestamp for frame latency */
+    if (GST_CLOCK_TIME_IS_VALID (duration)) {
+      if (timestamp > duration)
+        timestamp -= duration;
+      else
+        timestamp = 0;
     }
-    gst_buffer_unref (*buf);
   }
 
-  ret = v4l2src->get_frame (v4l2src, buf);
+  /* activate settings for next frame */
+  if (GST_CLOCK_TIME_IS_VALID (duration)) {
+    v4l2src->ctrl_time += duration;
+  } else {
+    /* this is not very good (as it should be the next timestamp),
+     * still good enough for linear fades (as long as it is not -1)
+     */
+    v4l2src->ctrl_time = timestamp;
+  }
+  gst_object_sync_values (G_OBJECT (src), v4l2src->ctrl_time);
+  GST_INFO_OBJECT (src, "sync to %" GST_TIME_FORMAT,
+      GST_TIME_ARGS (v4l2src->ctrl_time));
 
-  /* set buffer metadata */
-  if (G_LIKELY (ret == GST_FLOW_OK && *buf)) {
-    GstClock *clock;
-    GstClockTime timestamp;
-
-    GST_BUFFER_OFFSET (*buf) = v4l2src->offset++;
-    GST_BUFFER_OFFSET_END (*buf) = v4l2src->offset;
-
-    /* timestamps, LOCK to get clock and base time. */
-    /* FIXME: element clock and base_time is rarely changing */
-    GST_OBJECT_LOCK (v4l2src);
-    if ((clock = GST_ELEMENT_CLOCK (v4l2src))) {
-      /* we have a clock, get base time and ref clock */
-      timestamp = GST_ELEMENT (v4l2src)->base_time;
-      gst_object_ref (clock);
-    } else {
-      /* no clock, can't set timestamps */
-      timestamp = GST_CLOCK_TIME_NONE;
-    }
-    GST_OBJECT_UNLOCK (v4l2src);
-
-    if (G_LIKELY (clock)) {
-      /* the time now is the time of the clock minus the base time */
-      timestamp = gst_clock_get_time (clock) - timestamp;
-      gst_object_unref (clock);
-
-      /* if we have a framerate adjust timestamp for frame latency */
-      if (GST_CLOCK_TIME_IS_VALID (v4l2src->duration)) {
-        if (timestamp > v4l2src->duration)
-          timestamp -= v4l2src->duration;
-        else
-          timestamp = 0;
-      }
-    }
+  /* FIXME: use the timestamp from the buffer itself! */
+  GST_BUFFER_TIMESTAMP (buf) = timestamp;
+  GST_BUFFER_DURATION (buf) = duration;
 
-    /* activate settings for next frame */
-    if (GST_CLOCK_TIME_IS_VALID (v4l2src->duration)) {
-      v4l2src->ctrl_time += v4l2src->duration;
-    } else {
-      /* this is not very good (as it should be the next timestamp),
-       * still good enough for linear fades (as long as it is not -1) 
-       */
-      v4l2src->ctrl_time = timestamp;
-    }
-    gst_object_sync_values (G_OBJECT (src), v4l2src->ctrl_time);
-    GST_INFO_OBJECT (src, "sync to %" GST_TIME_FORMAT,
-        GST_TIME_ARGS (v4l2src->ctrl_time));
+  return ret;
 
-    /* FIXME: use the timestamp from the buffer itself! */
-    GST_BUFFER_TIMESTAMP (*buf) = timestamp;
-    GST_BUFFER_DURATION (*buf) = v4l2src->duration;
+  /* ERROR */
+error:
+  {
+    GST_ERROR_OBJECT (src, "error processing buffer");
+    return ret;
   }
-  return ret;
 }
 
 
 /* GstURIHandler interface */
 static GstURIType
-gst_v4l2src_uri_get_type (void)
+gst_v4l2src_uri_get_type (GType type)
 {
   return GST_URI_SRC;
 }
 
 static gchar **
-gst_v4l2src_uri_get_protocols (void)
+gst_v4l2src_uri_get_protocols (GType type)
 {
   static gchar *protocols[] = { (char *) "v4l2", NULL };
 
index 0dd794a..8ebaa57 100644 (file)
@@ -45,8 +45,6 @@ G_BEGIN_DECLS
 typedef struct _GstV4l2Src GstV4l2Src;
 typedef struct _GstV4l2SrcClass GstV4l2SrcClass;
 
-typedef GstFlowReturn (*GstV4l2SrcGetFunc)(GstV4l2Src * v4l2src, GstBuffer ** buf);
-
 /**
  * GstV4l2Src:
  *
@@ -62,30 +60,11 @@ struct _GstV4l2Src
   /* pads */
   GstCaps *probed_caps;
 
-  /* buffer handling */
-  GstV4l2BufferPool *pool;
-
-  guint32 num_buffers;
-  gboolean use_mmap;
-  guint32 frame_byte_size;
-
-  /* if the buffer will be or not used from directly mmap */
-  gboolean always_copy;
-
   int decimate;
 
-  /* True if we want to stop */
-  gboolean quit;
-  gboolean is_capturing;
-
   guint64 offset;
 
-  gint     fps_d, fps_n;       /* framerate if device is open */
-  GstClockTime duration;       /* duration of one frame */
-
   GstClockTime ctrl_time;
-
-  GstV4l2SrcGetFunc get_frame;
 };
 
 struct _GstV4l2SrcClass
index a805396..c885dc6 100644 (file)
@@ -30,7 +30,6 @@
 #include "gstv4l2tuner.h"
 #include "gstv4l2object.h"
 #include "v4l2_calls.h"
-#include "v4l2src_calls.h"
 
 static void gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass *
     klass);
similarity index 90%
rename from sys/v4l2/gstv4l2xoverlay.c
rename to sys/v4l2/gstv4l2videooverlay.c
index 80f114d..6c2fd68 100644 (file)
@@ -1,9 +1,8 @@
 /* GStreamer
- *
  * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
  *               2006 Edgard Lima <edgard.lima@indt.org.br>
  *
- * gstv4l2xoverlay.c: X-based overlay interface implementation for V4L2
+ * gstv4l2video_overlay.c: X-based overlay interface implementation for V4L2
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -35,7 +34,7 @@
 
 #include <gst/interfaces/navigation.h>
 
-#include "gstv4l2xoverlay.h"
+#include "gstv4l2videooverlay.h"
 #include "gstv4l2object.h"
 #include "v4l2_calls.h"
 
@@ -52,14 +51,14 @@ GST_DEBUG_CATEGORY_STATIC (v4l2xv_debug);
 #define GST_CAT_DEFAULT v4l2xv_debug
 
 void
-gst_v4l2_xoverlay_interface_init (GstXOverlayClass * klass)
+gst_v4l2_video_overlay_interface_init (GstVideoOverlayIface * klass)
 {
   GST_DEBUG_CATEGORY_INIT (v4l2xv_debug, "v4l2xv", 0,
-      "V4L2 XOverlay interface debugging");
+      "V4L2 GstVideoOverlay interface debugging");
 }
 
 static void
-gst_v4l2_xoverlay_open (GstV4l2Object * v4l2object)
+gst_v4l2_video_overlay_open (GstV4l2Object * v4l2object)
 {
   struct stat s;
   GstV4l2Xv *v4l2xv;
@@ -137,12 +136,13 @@ gst_v4l2_xoverlay_open (GstV4l2Object * v4l2object)
   v4l2object->xv = v4l2xv;
 
   if (v4l2object->xwindow_id) {
-    gst_v4l2_xoverlay_set_window_handle (v4l2object, v4l2object->xwindow_id);
+    gst_v4l2_video_overlay_set_window_handle (v4l2object,
+        v4l2object->xwindow_id);
   }
 }
 
 static void
-gst_v4l2_xoverlay_close (GstV4l2Object * v4l2object)
+gst_v4l2_video_overlay_close (GstV4l2Object * v4l2object)
 {
   GstV4l2Xv *v4l2xv = v4l2object->xv;
 
@@ -150,7 +150,7 @@ gst_v4l2_xoverlay_close (GstV4l2Object * v4l2object)
     return;
 
   if (v4l2object->xwindow_id) {
-    gst_v4l2_xoverlay_set_window_handle (v4l2object, 0);
+    gst_v4l2_video_overlay_set_window_handle (v4l2object, 0);
   }
 
   XCloseDisplay (v4l2xv->dpy);
@@ -164,17 +164,17 @@ gst_v4l2_xoverlay_close (GstV4l2Object * v4l2object)
 }
 
 void
-gst_v4l2_xoverlay_start (GstV4l2Object * v4l2object)
+gst_v4l2_video_overlay_start (GstV4l2Object * v4l2object)
 {
   if (v4l2object->xwindow_id) {
-    gst_v4l2_xoverlay_open (v4l2object);
+    gst_v4l2_video_overlay_open (v4l2object);
   }
 }
 
 void
-gst_v4l2_xoverlay_stop (GstV4l2Object * v4l2object)
+gst_v4l2_video_overlay_stop (GstV4l2Object * v4l2object)
 {
-  gst_v4l2_xoverlay_close (v4l2object);
+  gst_v4l2_video_overlay_close (v4l2object);
 }
 
 /* should be called with mutex held */
@@ -197,7 +197,7 @@ get_render_rect (GstV4l2Object * v4l2object, GstVideoRectangle * rect)
 }
 
 gboolean
-gst_v4l2_xoverlay_get_render_rect (GstV4l2Object * v4l2object,
+gst_v4l2_video_overlay_get_render_rect (GstV4l2Object * v4l2object,
     GstVideoRectangle * rect)
 {
   GstV4l2Xv *v4l2xv = v4l2object->xv;
@@ -363,7 +363,8 @@ event_refresh (gpointer data)
 }
 
 void
-gst_v4l2_xoverlay_set_window_handle (GstV4l2Object * v4l2object, guintptr id)
+gst_v4l2_video_overlay_set_window_handle (GstV4l2Object * v4l2object,
+    guintptr id)
 {
   GstV4l2Xv *v4l2xv;
   XID xwindow_id = id;
@@ -373,7 +374,7 @@ gst_v4l2_xoverlay_set_window_handle (GstV4l2Object * v4l2object, guintptr id)
       (gulong) xwindow_id);
 
   if (!v4l2object->xv && GST_V4L2_IS_OPEN (v4l2object))
-    gst_v4l2_xoverlay_open (v4l2object);
+    gst_v4l2_video_overlay_open (v4l2object);
 
   v4l2xv = v4l2object->xv;
 
@@ -417,7 +418,7 @@ gst_v4l2_xoverlay_set_window_handle (GstV4l2Object * v4l2object, guintptr id)
 }
 
 /**
- * gst_v4l2_xoverlay_prepare_xwindow_id:
+ * gst_v4l2_video_overlay_prepare_window_handle:
  * @v4l2object: the v4l2object
  * @required: %TRUE if display is required (ie. TRUE for v4l2sink, but
  *   FALSE for any other element with optional overlay capabilities)
@@ -425,13 +426,16 @@ gst_v4l2_xoverlay_set_window_handle (GstV4l2Object * v4l2object, guintptr id)
  * Helper function to create a windo if none is set from the application.
  */
 void
-gst_v4l2_xoverlay_prepare_xwindow_id (GstV4l2Object * v4l2object,
+gst_v4l2_video_overlay_prepare_window_handle (GstV4l2Object * v4l2object,
     gboolean required)
 {
+  GstVideoOverlay *overlay;
+
   if (!GST_V4L2_IS_OVERLAY (v4l2object))
     return;
 
-  gst_x_overlay_prepare_xwindow_id (GST_X_OVERLAY (v4l2object->element));
+  overlay = GST_VIDEO_OVERLAY (v4l2object->element);
+  gst_video_overlay_prepare_window_handle (overlay);
 
   if (required && !v4l2object->xwindow_id) {
     GstV4l2Xv *v4l2xv;
@@ -440,15 +444,15 @@ gst_v4l2_xoverlay_prepare_xwindow_id (GstV4l2Object * v4l2object,
     long event_mask;
 
     if (!v4l2object->xv && GST_V4L2_IS_OPEN (v4l2object))
-      gst_v4l2_xoverlay_open (v4l2object);
+      gst_v4l2_video_overlay_open (v4l2object);
 
     v4l2xv = v4l2object->xv;
 
-    /* if xoverlay is not supported, just bail */
+    /* if video_overlay is not supported, just bail */
     if (!v4l2xv)
       return;
 
-    /* xoverlay is supported, but we don't have a window.. so create one */
+    /* video_overlay is supported, but we don't have a window.. so create one */
     GST_DEBUG_OBJECT (v4l2object->element, "creating window");
 
     g_mutex_lock (v4l2xv->mutex);
@@ -480,6 +484,6 @@ gst_v4l2_xoverlay_prepare_xwindow_id (GstV4l2Object * v4l2object,
 
     GST_DEBUG_OBJECT (v4l2object->element, "got window");
 
-    gst_v4l2_xoverlay_set_window_handle (v4l2object, win);
+    gst_v4l2_video_overlay_set_window_handle (v4l2object, win);
   }
 }
similarity index 60%
rename from sys/v4l2/gstv4l2xoverlay.h
rename to sys/v4l2/gstv4l2videooverlay.h
index 1a09306..6013666 100644 (file)
@@ -1,9 +1,8 @@
 /* GStreamer
- *
  * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
  *               2006 Edgard Lima <edgard.lima@indt.org.br>
  *
- * gstv4l2xoverlay.h: tv mixer interface implementation for V4L2
+ * gstv4l2videooverlay.h: tv mixer interface implementation for V4L2
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * Boston, MA 02111-1307, USA.
  */
 
-#ifndef __GST_V4L2_X_OVERLAY_H__
-#define __GST_V4L2_X_OVERLAY_H__
+#ifndef __GST_V4L2_VIDEO_OVERLAY_H__
+#define __GST_V4L2_VIDEO_OVERLAY_H__
 
 #include <X11/X.h>
 
 #include <gst/gst.h>
-#include <gst/interfaces/xoverlay.h>
+#include <gst/interfaces/videooverlay.h>
 #include <gst/interfaces/navigation.h>
 #include <gst/video/gstvideosink.h>  /* for GstVideoRectange */
 
 
 G_BEGIN_DECLS
 
-void gst_v4l2_xoverlay_start (GstV4l2Object  *v4l2object);
-void gst_v4l2_xoverlay_stop  (GstV4l2Object  *v4l2object);
-gboolean gst_v4l2_xoverlay_get_render_rect (GstV4l2Object *v4l2object,
+void gst_v4l2_video_overlay_start (GstV4l2Object  *v4l2object);
+void gst_v4l2_video_overlay_stop  (GstV4l2Object  *v4l2object);
+gboolean gst_v4l2_video_overlay_get_render_rect (GstV4l2Object *v4l2object,
     GstVideoRectangle *rect);
 
-void gst_v4l2_xoverlay_interface_init (GstXOverlayClass * klass);
-void gst_v4l2_xoverlay_set_window_handle (GstV4l2Object * v4l2object,
+void gst_v4l2_video_overlay_interface_init (GstVideoOverlayIface * iface);
+void gst_v4l2_video_overlay_set_window_handle (GstV4l2Object * v4l2object,
     guintptr id);
-void gst_v4l2_xoverlay_prepare_xwindow_id (GstV4l2Object * v4l2object,
+void gst_v4l2_video_overlay_prepare_window_handle (GstV4l2Object * v4l2object,
     gboolean required);
 
 
-#define GST_IMPLEMENT_V4L2_XOVERLAY_METHODS(Type, interface_as_function)      \
+#define GST_IMPLEMENT_V4L2_VIDEO_OVERLAY_METHODS(Type, interface_as_function) \
                                                                               \
 static void                                                                   \
-interface_as_function ## _xoverlay_set_window_handle (GstXOverlay * xoverlay, \
-                                                   guintptr id)               \
+interface_as_function ## _video_overlay_set_window_handle (GstVideoOverlay * overlay, \
+                                                           guintptr id)       \
 {                                                                             \
-  Type *this = (Type*) xoverlay;                                              \
-  gst_v4l2_xoverlay_set_window_handle (this->v4l2object, id);                 \
+  Type *this = (Type*) overlay;                                              \
+  gst_v4l2_video_overlay_set_window_handle (this->v4l2object, id);                 \
 }                                                                             \
                                                                               \
 static void                                                                   \
-interface_as_function ## _xoverlay_interface_init (GstXOverlayClass * klass)  \
+interface_as_function ## _video_overlay_interface_init (GstVideoOverlayIface * iface)  \
 {                                                                             \
   /* default virtual functions */                                             \
-  klass->set_window_handle = interface_as_function ## _xoverlay_set_window_handle;  \
+  iface->set_window_handle = interface_as_function ## _video_overlay_set_window_handle;  \
                                                                               \
-  gst_v4l2_xoverlay_interface_init(klass);                                    \
+  gst_v4l2_video_overlay_interface_init (iface);                              \
 }                                                                             \
 
 
-#endif /* __GST_V4L2_X_OVERLAY_H__ */
+#endif /* __GST_V4L2_VIDEO_OVERLAY_H__ */
index 1fa47e7..ee765b6 100644 (file)
@@ -29,7 +29,6 @@
 #include "gstv4l2vidorient.h"
 #include "gstv4l2object.h"
 #include "v4l2_calls.h"
-#include "v4l2src_calls.h"
 
 GST_DEBUG_CATEGORY_STATIC (v4l2vo_debug);
 #define GST_CAT_DEFAULT v4l2vo_debug
index 3808d8e..74b2e0a 100644 (file)
 #include "gstv4l2colorbalance.h"
 
 #include "gstv4l2src.h"
-
-#ifdef HAVE_EXPERIMENTAL
 #include "gstv4l2sink.h"
-#endif
 
 #include "gst/gst-i18n-plugin.h"
 
@@ -468,11 +465,9 @@ gst_v4l2_open (GstV4l2Object * v4l2object)
       !(v4l2object->vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE))
     goto not_capture;
 
-#ifdef HAVE_EXPERIMENTAL
   if (GST_IS_V4L2SINK (v4l2object->element) &&
       !(v4l2object->vcap.capabilities & V4L2_CAP_VIDEO_OUTPUT))
     goto not_output;
-#endif
 
   /* create enumerations, posts errors. */
   if (!gst_v4l2_fill_lists (v4l2object))
@@ -518,7 +513,6 @@ not_capture:
         ("Capabilities: 0x%x", v4l2object->vcap.capabilities));
     goto error;
   }
-#ifdef HAVE_EXPERIMENTAL
 not_output:
   {
     GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, NOT_FOUND,
@@ -527,7 +521,6 @@ not_output:
         ("Capabilities: 0x%x", v4l2object->vcap.capabilities));
     goto error;
   }
-#endif
 error:
   {
     if (GST_V4L2_IS_OPEN (v4l2object)) {
index d2e2c72..36cf0f3 100644 (file)
 #  define v4l2_munmap   munmap
 #endif
 
-/* simple check whether the device is open */
-#define GST_V4L2_IS_OPEN(v4l2object) \
-  (v4l2object->video_fd > 0)
-
-/* check whether the device is 'active' */
-#define GST_V4L2_IS_ACTIVE(v4l2object) \
-  (v4l2object->buffer != NULL)
-
 #define GST_V4L2_IS_OVERLAY(v4l2object) \
   (v4l2object->vcap.capabilities & V4L2_CAP_VIDEO_OVERLAY)
 
diff --git a/sys/v4l2/v4l2src_calls.c b/sys/v4l2/v4l2src_calls.c
deleted file mode 100644 (file)
index bfa5589..0000000
+++ /dev/null
@@ -1,434 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
- *               2006 Edgard Lima <edgard.lima@indt.org.br>
- *
- * v4l2src.c - system calls
- *
- * 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 <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <string.h>
-#include <errno.h>
-#include "v4l2src_calls.h"
-#include <sys/time.h>
-#include <unistd.h>
-#ifdef __sun
-/* Needed on older Solaris Nevada builds (72 at least) */
-#include <stropts.h>
-#include <sys/ioccom.h>
-#endif
-
-#include "gstv4l2tuner.h"
-#include "gstv4l2bufferpool.h"
-
-#include "gst/gst-i18n-plugin.h"
-
-#define GST_CAT_DEFAULT v4l2src_debug
-GST_DEBUG_CATEGORY_EXTERN (GST_CAT_PERFORMANCE);
-
-/* lalala... */
-#define GST_V4L2_SET_ACTIVE(element) (element)->buffer = GINT_TO_POINTER (-1)
-#define GST_V4L2_SET_INACTIVE(element) (element)->buffer = NULL
-
-/* On some systems MAP_FAILED seems to be missing */
-#ifndef MAP_FAILED
-#define MAP_FAILED ((caddr_t) -1)
-#endif
-
-
-/* Local functions */
-
-static gboolean
-gst_v4l2src_buffer_pool_activate (GstV4l2BufferPool * pool,
-    GstV4l2Src * v4l2src)
-{
-  GstV4l2Buffer *buf;
-
-  while ((buf = gst_v4l2_buffer_pool_get (pool, FALSE)) != NULL)
-    if (!gst_v4l2_buffer_pool_qbuf (pool, buf))
-      goto queue_failed;
-
-  return TRUE;
-
-  /* ERRORS */
-queue_failed:
-  {
-    GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
-        (_("Could not enqueue buffers in device '%s'."),
-            v4l2src->v4l2object->videodev),
-        ("enqueing buffer %d/%d failed: %s",
-            buf->vbuffer.index, v4l2src->num_buffers, g_strerror (errno)));
-    return FALSE;
-  }
-}
-
-/******************************************************
- * gst_v4l2src_grab_frame ():
- *   grab a frame for capturing
- * return value: GST_FLOW_OK, GST_FLOW_WRONG_STATE or GST_FLOW_ERROR
- ******************************************************/
-GstFlowReturn
-gst_v4l2src_grab_frame (GstV4l2Src * v4l2src, GstBuffer ** buf)
-{
-#define NUM_TRIALS 50
-  GstV4l2Object *v4l2object;
-  GstV4l2BufferPool *pool;
-  gint32 trials = NUM_TRIALS;
-  GstBuffer *pool_buffer;
-  gboolean need_copy;
-  gint ret;
-
-  v4l2object = v4l2src->v4l2object;
-  pool = v4l2src->pool;
-  if (!pool)
-    goto no_buffer_pool;
-
-  GST_DEBUG_OBJECT (v4l2src, "grab frame");
-
-  for (;;) {
-    if (v4l2object->can_poll_device) {
-      ret = gst_poll_wait (v4l2object->poll, GST_CLOCK_TIME_NONE);
-      if (G_UNLIKELY (ret < 0)) {
-        if (errno == EBUSY)
-          goto stopped;
-        if (errno == ENXIO) {
-          GST_DEBUG_OBJECT (v4l2src,
-              "v4l2 device doesn't support polling. Disabling");
-          v4l2object->can_poll_device = FALSE;
-        } else {
-          if (errno != EAGAIN && errno != EINTR)
-            goto select_error;
-        }
-      }
-    }
-
-    pool_buffer = GST_BUFFER (gst_v4l2_buffer_pool_dqbuf (pool));
-    if (pool_buffer)
-      break;
-
-    GST_WARNING_OBJECT (pool->v4l2elem, "trials=%d", trials);
-
-    /* if the sync() got interrupted, we can retry */
-    switch (errno) {
-      case EINVAL:
-      case ENOMEM:
-        /* fatal */
-        return GST_FLOW_ERROR;
-
-      case EAGAIN:
-      case EIO:
-      case EINTR:
-      default:
-        /* try again, until too many trials */
-        break;
-    }
-
-    /* check nr. of attempts to capture */
-    if (--trials == -1) {
-      goto too_many_trials;
-    }
-  }
-
-  /* if we are handing out the last buffer in the pool, we need to make a
-   * copy and bring the buffer back in the pool. */
-  need_copy = v4l2src->always_copy
-      || !gst_v4l2_buffer_pool_available_buffers (pool);
-
-  if (G_UNLIKELY (need_copy)) {
-    if (!v4l2src->always_copy) {
-      GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, v4l2src,
-          "running out of buffers, making a copy to reuse current one");
-    }
-    *buf = gst_buffer_copy (pool_buffer);
-    GST_BUFFER_FLAG_UNSET (*buf, GST_BUFFER_FLAG_READONLY);
-    /* this will requeue */
-    gst_buffer_unref (pool_buffer);
-  } else {
-    *buf = pool_buffer;
-  }
-  /* we set the buffer metadata in gst_v4l2src_create() */
-
-  return GST_FLOW_OK;
-
-  /* ERRORS */
-no_buffer_pool:
-  {
-    GST_DEBUG ("no buffer pool");
-    return GST_FLOW_WRONG_STATE;
-  }
-select_error:
-  {
-    GST_ELEMENT_ERROR (pool->v4l2elem, RESOURCE, READ, (NULL),
-        ("select error %d: %s (%d)", ret, g_strerror (errno), errno));
-    return GST_FLOW_ERROR;
-  }
-stopped:
-  {
-    GST_DEBUG ("stop called");
-    return GST_FLOW_WRONG_STATE;
-  }
-too_many_trials:
-  {
-    GST_ELEMENT_ERROR (pool->v4l2elem, RESOURCE, FAILED,
-        (_("Failed trying to get video frames from device '%s'."),
-            v4l2object->videodev),
-        (_("Failed after %d tries. device %s. system error: %s"),
-            NUM_TRIALS, v4l2object->videodev, g_strerror (errno)));
-    return GST_FLOW_ERROR;
-  }
-}
-
-/******************************************************
- * gst_v4l2src_set_capture():
- *   set capture parameters
- * return value: TRUE on success, FALSE on error
- ******************************************************/
-gboolean
-gst_v4l2src_set_capture (GstV4l2Src * v4l2src, guint32 pixelformat,
-    guint32 width, guint32 height, gboolean interlaced,
-    guint fps_n, guint fps_d)
-{
-  gint fd = v4l2src->v4l2object->video_fd;
-  struct v4l2_streamparm stream;
-
-  if (pixelformat == GST_MAKE_FOURCC ('M', 'P', 'E', 'G'))
-    return TRUE;
-
-  if (!gst_v4l2_object_set_format (v4l2src->v4l2object, pixelformat, width,
-          height, interlaced)) {
-    /* error already reported */
-    return FALSE;
-  }
-
-  /* Is there a reason we require the caller to always specify a framerate? */
-  GST_DEBUG_OBJECT (v4l2src, "Desired framerate: %u/%u", fps_n, fps_d);
-
-  memset (&stream, 0x00, sizeof (struct v4l2_streamparm));
-  stream.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-  if (v4l2_ioctl (fd, VIDIOC_G_PARM, &stream) < 0) {
-    GST_ELEMENT_WARNING (v4l2src, RESOURCE, SETTINGS,
-        (_("Could not get parameters on device '%s'"),
-            v4l2src->v4l2object->videodev), GST_ERROR_SYSTEM);
-    goto done;
-  }
-
-  /* We used to skip frame rate setup if the camera was already setup
-     with the requested frame rate. This breaks some cameras though,
-     causing them to not output data (several models of Thinkpad cameras
-     have this problem at least).
-     So, don't skip. */
-
-  /* We want to change the frame rate, so check whether we can. Some cheap USB
-   * cameras don't have the capability */
-  if ((stream.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) == 0) {
-    GST_DEBUG_OBJECT (v4l2src, "Not setting framerate (not supported)");
-    goto done;
-  }
-
-  GST_LOG_OBJECT (v4l2src, "Setting framerate to %u/%u", fps_n, fps_d);
-
-  /* Note: V4L2 wants the frame interval, we have the frame rate */
-  stream.parm.capture.timeperframe.numerator = fps_d;
-  stream.parm.capture.timeperframe.denominator = fps_n;
-
-  /* some cheap USB cam's won't accept any change */
-  if (v4l2_ioctl (fd, VIDIOC_S_PARM, &stream) < 0) {
-    GST_ELEMENT_WARNING (v4l2src, RESOURCE, SETTINGS,
-        (_("Video input device did not accept new frame rate setting.")),
-        GST_ERROR_SYSTEM);
-    goto done;
-  }
-
-  v4l2src->fps_n = fps_n;
-  v4l2src->fps_d = fps_d;
-
-  /* if we have a framerate pre-calculate duration */
-  if (fps_n > 0 && fps_d > 0) {
-    v4l2src->duration = gst_util_uint64_scale_int (GST_SECOND, fps_d, fps_n);
-  } else {
-    v4l2src->duration = GST_CLOCK_TIME_NONE;
-  }
-
-  GST_INFO_OBJECT (v4l2src,
-      "Set framerate to %u/%u and duration to %" GST_TIME_FORMAT, fps_n, fps_d,
-      GST_TIME_ARGS (v4l2src->duration));
-done:
-
-  return TRUE;
-}
-
-/******************************************************
- * gst_v4l2src_capture_init():
- *   initialize the capture system
- * return value: TRUE on success, FALSE on error
- ******************************************************/
-gboolean
-gst_v4l2src_capture_init (GstV4l2Src * v4l2src, GstCaps * caps)
-{
-  GST_DEBUG_OBJECT (v4l2src, "initializing the capture system");
-
-  GST_V4L2_CHECK_OPEN (v4l2src->v4l2object);
-  GST_V4L2_CHECK_NOT_ACTIVE (v4l2src->v4l2object);
-
-  if (v4l2src->v4l2object->vcap.capabilities & V4L2_CAP_STREAMING) {
-
-    /* Map the buffers */
-    GST_LOG_OBJECT (v4l2src, "initiating buffer pool");
-
-    if (!(v4l2src->pool = gst_v4l2_buffer_pool_new (GST_ELEMENT (v4l2src),
-                v4l2src->v4l2object->video_fd,
-                v4l2src->num_buffers, caps, TRUE, V4L2_BUF_TYPE_VIDEO_CAPTURE)))
-      goto buffer_pool_new_failed;
-
-    GST_INFO_OBJECT (v4l2src, "capturing buffers via mmap()");
-    v4l2src->use_mmap = TRUE;
-
-    if (v4l2src->num_buffers != v4l2src->pool->buffer_count) {
-      v4l2src->num_buffers = v4l2src->pool->buffer_count;
-      g_object_notify (G_OBJECT (v4l2src), "queue-size");
-    }
-
-  } else if (v4l2src->v4l2object->vcap.capabilities & V4L2_CAP_READWRITE) {
-    GST_INFO_OBJECT (v4l2src, "capturing buffers via read()");
-    v4l2src->use_mmap = FALSE;
-    v4l2src->pool = NULL;
-  } else {
-    goto no_supported_capture_method;
-  }
-
-  GST_V4L2_SET_ACTIVE (v4l2src->v4l2object);
-
-  return TRUE;
-
-  /* ERRORS */
-buffer_pool_new_failed:
-  {
-    GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
-        (_("Could not map buffers from device '%s'"),
-            v4l2src->v4l2object->videodev),
-        ("Failed to create buffer pool: %s", g_strerror (errno)));
-    return FALSE;
-  }
-no_supported_capture_method:
-  {
-    GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
-        (_("The driver of device '%s' does not support any known capture "
-                "method."), v4l2src->v4l2object->videodev), (NULL));
-    return FALSE;
-  }
-}
-
-
-/******************************************************
- * gst_v4l2src_capture_start():
- *   start streaming capture
- * return value: TRUE on success, FALSE on error
- ******************************************************/
-gboolean
-gst_v4l2src_capture_start (GstV4l2Src * v4l2src)
-{
-  GST_DEBUG_OBJECT (v4l2src, "starting the capturing");
-  //GST_V4L2_CHECK_OPEN (v4l2src->v4l2object);
-  GST_V4L2_CHECK_ACTIVE (v4l2src->v4l2object);
-
-  v4l2src->quit = FALSE;
-
-  if (v4l2src->use_mmap) {
-    if (!gst_v4l2src_buffer_pool_activate (v4l2src->pool, v4l2src)) {
-      return FALSE;
-    }
-
-    if (!gst_v4l2_object_start_streaming (v4l2src->v4l2object)) {
-      return FALSE;
-    }
-  }
-
-  v4l2src->is_capturing = TRUE;
-
-  return TRUE;
-}
-
-/******************************************************
- * gst_v4l2src_capture_stop():
- *   stop streaming capture
- * return value: TRUE on success, FALSE on error
- ******************************************************/
-gboolean
-gst_v4l2src_capture_stop (GstV4l2Src * v4l2src)
-{
-  GST_DEBUG_OBJECT (v4l2src, "stopping capturing");
-
-  if (!GST_V4L2_IS_OPEN (v4l2src->v4l2object)) {
-    goto done;
-  }
-  if (!GST_V4L2_IS_ACTIVE (v4l2src->v4l2object)) {
-    goto done;
-  }
-
-  if (v4l2src->use_mmap) {
-    /* we actually need to sync on all queued buffers but not
-     * on the non-queued ones */
-    if (!gst_v4l2_object_stop_streaming (v4l2src->v4l2object)) {
-      return FALSE;
-    }
-  }
-
-done:
-
-  /* make an optional pending wait stop */
-  v4l2src->quit = TRUE;
-  v4l2src->is_capturing = FALSE;
-
-  return TRUE;
-}
-
-/******************************************************
- * gst_v4l2src_capture_deinit():
- *   deinitialize the capture system
- * return value: TRUE on success, FALSE on error
- ******************************************************/
-gboolean
-gst_v4l2src_capture_deinit (GstV4l2Src * v4l2src)
-{
-  GST_DEBUG_OBJECT (v4l2src, "deinitting capture system");
-
-  if (!GST_V4L2_IS_OPEN (v4l2src->v4l2object)) {
-    return TRUE;
-  }
-  if (!GST_V4L2_IS_ACTIVE (v4l2src->v4l2object)) {
-    return TRUE;
-  }
-
-  if (v4l2src->pool) {
-    gst_v4l2_buffer_pool_destroy (v4l2src->pool);
-    v4l2src->pool = NULL;
-  }
-
-  GST_V4L2_SET_INACTIVE (v4l2src->v4l2object);
-
-  return TRUE;
-}
diff --git a/sys/v4l2/v4l2src_calls.h b/sys/v4l2/v4l2src_calls.h
deleted file mode 100644 (file)
index 7091918..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
- *               2006 Edgard Lima <edgard.lima@indt.org.br>
- *
- * v4l2src.h - system calls
- *
- * 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 __V4L2SRC_CALLS_H__
-#define __V4L2SRC_CALLS_H__
-
-#include "gstv4l2src.h"
-#include "v4l2_calls.h"
-
-gboolean   gst_v4l2src_get_capture       (GstV4l2Src * v4l2src);
-gboolean   gst_v4l2src_set_capture       (GstV4l2Src * v4l2src,
-                                          guint32 pixelformat,
-                                          guint32 width, guint32 height,
-                                          gboolean interlaced,
-                                          guint32 fps_n, guint32 fps_d);
-
-gboolean   gst_v4l2src_capture_init      (GstV4l2Src * v4l2src, GstCaps *caps);
-gboolean   gst_v4l2src_capture_start     (GstV4l2Src * v4l2src);
-
-GstFlowReturn gst_v4l2src_grab_frame     (GstV4l2Src * v4l2src, GstBuffer **buf);
-
-gboolean   gst_v4l2src_capture_stop      (GstV4l2Src * v4l2src);
-gboolean   gst_v4l2src_capture_deinit    (GstV4l2Src * v4l2src);
-
-
-#endif /* __V4L2SRC_CALLS_H__ */
index 94d4bcd..60d8e8c 100644 (file)
@@ -73,23 +73,23 @@ enum
   PROP_REMOTE,
 };
 
-GST_BOILERPLATE (GstXImageSrc, gst_ximage_src, GstPushSrc, GST_TYPE_PUSH_SRC);
+#define gst_ximage_src_parent_class parent_class
+G_DEFINE_TYPE (GstXImageSrc, gst_ximage_src, GST_TYPE_PUSH_SRC);
 
 static void gst_ximage_src_fixate (GstPad * pad, GstCaps * caps);
 static void gst_ximage_src_clear_bufpool (GstXImageSrc * ximagesrc);
 
 /* Called when a buffer is returned from the pipeline */
 static void
-gst_ximage_src_return_buf (GstXImageSrc * ximagesrc,
-    GstXImageSrcBuffer * ximage)
+gst_ximage_src_return_buf (GstXImageSrc * ximagesrc, GstBuffer * ximage)
 {
+  GstMetaXImage *meta = GST_META_XIMAGE_GET (ximage);
+
   /* If our geometry changed we can't reuse that image. */
-  if ((ximage->width != ximagesrc->width) ||
-      (ximage->height != ximagesrc->height)) {
+  if ((meta->width != ximagesrc->width) || (meta->height != ximagesrc->height)) {
     GST_DEBUG_OBJECT (ximagesrc,
         "destroy image %p as its size changed %dx%d vs current %dx%d",
-        ximage, ximage->width, ximage->height,
-        ximagesrc->width, ximagesrc->height);
+        ximage, meta->width, meta->height, ximagesrc->width, ximagesrc->height);
     g_mutex_lock (ximagesrc->x_lock);
     gst_ximageutil_ximage_destroy (ximagesrc->xcontext, ximage);
     g_mutex_unlock (ximagesrc->x_lock);
@@ -97,7 +97,7 @@ gst_ximage_src_return_buf (GstXImageSrc * ximagesrc,
     /* In that case we can reuse the image and add it to our image pool. */
     GST_LOG_OBJECT (ximagesrc, "recycling image %p in pool", ximage);
     /* need to increment the refcount again to recycle */
-    gst_buffer_ref (GST_BUFFER (ximage));
+    gst_buffer_ref (ximage);
     g_mutex_lock (ximagesrc->pool_lock);
     GST_BUFFER_FLAGS (GST_BUFFER (ximage)) = 0; /* clear out any flags from the previous use */
     ximagesrc->buffer_pool = g_slist_prepend (ximagesrc->buffer_pool, ximage);
@@ -357,19 +357,33 @@ composite_pixel (GstXContext * xcontext, guchar * dest, guchar * src)
 }
 #endif
 
+static void
+copy_buffer (GstBuffer * dest, GstBuffer * src)
+{
+  guint8 *data;
+  gsize size;
+
+  data = gst_buffer_map (src, &size, NULL, GST_MAP_READ);
+  gst_buffer_fill (dest, 0, data, size);
+  gst_buffer_unmap (src, data, size);
+}
+
 /* Retrieve an XImageSrcBuffer, preferably from our
  * pool of existing images and populate it from the window */
-static GstXImageSrcBuffer *
+static GstBuffer *
 gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
 {
-  GstXImageSrcBuffer *ximage = NULL;
+  GstBuffer *ximage = NULL;
+  GstMetaXImage *meta;
 
   g_mutex_lock (ximagesrc->pool_lock);
   while (ximagesrc->buffer_pool != NULL) {
     ximage = ximagesrc->buffer_pool->data;
 
-    if ((ximage->width != ximagesrc->width) ||
-        (ximage->height != ximagesrc->height)) {
+    meta = GST_META_XIMAGE_GET (ximage);
+
+    if ((meta->width != ximagesrc->width) ||
+        (meta->height != ximagesrc->height)) {
       gst_ximage_buffer_free (ximage);
     }
 
@@ -399,7 +413,6 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
 
     xcontext = ximagesrc->xcontext;
 
-
     caps = gst_caps_new_simple ("video/x-raw-rgb",
         "bpp", G_TYPE_INT, xcontext->bpp,
         "depth", G_TYPE_INT, xcontext->depth,
@@ -414,13 +427,15 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
         gst_value_get_fraction_numerator (xcontext->par),
         gst_value_get_fraction_denominator (xcontext->par), NULL);
 
-    gst_buffer_set_caps (GST_BUFFER (ximage), caps);
     g_mutex_unlock (ximagesrc->x_lock);
 
     gst_caps_unref (caps);
   }
 
   g_return_val_if_fail (GST_IS_XIMAGE_SRC (ximagesrc), NULL);
+
+  meta = GST_META_XIMAGE_GET (ximage);
+
 #ifdef HAVE_XDAMAGE
   if (ximagesrc->have_xdamage && ximagesrc->use_damage &&
       ximagesrc->last_ximage != NULL) {
@@ -451,10 +466,8 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
           if (!have_frame) {
             GST_LOG_OBJECT (ximagesrc,
                 "Copying from last frame ximage->size: %d",
-                GST_BUFFER_SIZE (GST_BUFFER (ximage)));
-            memcpy (GST_BUFFER_DATA (GST_BUFFER (ximage)),
-                GST_BUFFER_DATA (GST_BUFFER (ximagesrc->last_ximage)),
-                GST_BUFFER_SIZE (GST_BUFFER (ximage)));
+                gst_buffer_get_size (ximage));
+            copy_buffer (ximage, ximagesrc->last_ximage);
             have_frame = TRUE;
           }
           for (i = 0; i < nrects; i++) {
@@ -493,7 +506,7 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
                     startx, starty, width, height);
                 XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
                     startx, starty, width, height, AllPlanes, ZPixmap,
-                    ximage->ximage, startx - ximagesrc->startx,
+                    meta->ximage, startx - ximagesrc->startx,
                     starty - ximagesrc->starty);
               }
             } else {
@@ -505,7 +518,7 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
               XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
                   rects[i].x, rects[i].y,
                   rects[i].width, rects[i].height,
-                  AllPlanes, ZPixmap, ximage->ximage, rects[i].x, rects[i].y);
+                  AllPlanes, ZPixmap, meta->ximage, rects[i].x, rects[i].y);
             }
           }
           free (rects);
@@ -515,10 +528,8 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
     if (!have_frame) {
       GST_LOG_OBJECT (ximagesrc,
           "Copying from last frame ximage->size: %d",
-          GST_BUFFER_SIZE (GST_BUFFER (ximage)));
-      memcpy (GST_BUFFER_DATA (GST_BUFFER (ximage)),
-          GST_BUFFER_DATA (GST_BUFFER (ximagesrc->last_ximage)),
-          GST_BUFFER_SIZE (GST_BUFFER (ximage)));
+          gst_buffer_get_size (ximage));
+      copy_buffer (ximage, ximagesrc->last_ximage);
     }
 #ifdef HAVE_XFIXES
     /* re-get area where last mouse pointer was  but only if in our clipping
@@ -567,14 +578,14 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
           GST_DEBUG_OBJECT (ximagesrc, "Removing cursor from %d,%d", x, y);
           XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
               startx, starty, iwidth, iheight, AllPlanes, ZPixmap,
-              ximage->ximage, startx - ximagesrc->startx,
+              meta->ximage, startx - ximagesrc->startx,
               starty - ximagesrc->starty);
         }
       } else {
 
         GST_DEBUG_OBJECT (ximagesrc, "Removing cursor from %d,%d", x, y);
         XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
-            x, y, width, height, AllPlanes, ZPixmap, ximage->ximage, x, y);
+            x, y, width, height, AllPlanes, ZPixmap, meta->ximage, x, y);
       }
     }
 #endif
@@ -587,7 +598,7 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
     if (ximagesrc->xcontext->use_xshm) {
       GST_DEBUG_OBJECT (ximagesrc, "Retrieving screen using XShm");
       XShmGetImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
-          ximage->ximage, ximagesrc->startx, ximagesrc->starty, AllPlanes);
+          meta->ximage, ximagesrc->startx, ximagesrc->starty, AllPlanes);
 
     } else
 #endif /* HAVE_XSHM */
@@ -596,9 +607,9 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
       if (ximagesrc->remote) {
         XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
             ximagesrc->startx, ximagesrc->starty, ximagesrc->width,
-            ximagesrc->height, AllPlanes, ZPixmap, ximage->ximage, 0, 0);
+            ximagesrc->height, AllPlanes, ZPixmap, meta->ximage, 0, 0);
       } else {
-        ximage->ximage =
+        meta->ximage =
             XGetImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
             ximagesrc->startx, ximagesrc->starty, ximagesrc->width,
             ximagesrc->height, AllPlanes, ZPixmap);
@@ -678,7 +689,7 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
                 (guint8 *) & (ximagesrc->cursor_image->pixels[((j -
                             cy) * ximagesrc->cursor_image->width + (i - cx))]);
             dest =
-                (guint8 *) & (ximage->ximage->data[((j -
+                (guint8 *) & (meta->ximage->data[((j -
                             ximagesrc->starty) * ximagesrc->width + (i -
                             ximagesrc->startx)) * (ximagesrc->xcontext->bpp /
                         8)]);
@@ -694,9 +705,9 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
 #ifdef HAVE_XDAMAGE
   if (ximagesrc->have_xdamage && ximagesrc->use_damage) {
     /* need to ref ximage to put in last_ximage */
-    gst_buffer_ref (GST_BUFFER (ximage));
+    gst_buffer_ref (ximage);
     if (ximagesrc->last_ximage) {
-      gst_buffer_unref (GST_BUFFER (ximagesrc->last_ximage));
+      gst_buffer_unref (ximagesrc->last_ximage);
     }
     ximagesrc->last_ximage = ximage;
     GST_LOG_OBJECT (ximagesrc, "reffing current buffer for last_ximage");
@@ -709,7 +720,7 @@ static GstFlowReturn
 gst_ximage_src_create (GstPushSrc * bs, GstBuffer ** buf)
 {
   GstXImageSrc *s = GST_XIMAGE_SRC (bs);
-  GstXImageSrcBuffer *image;
+  GstBuffer *image;
   GstClockTime base_time;
   GstClockTime next_capture_ts;
   GstClockTime dur;
@@ -793,7 +804,7 @@ gst_ximage_src_create (GstPushSrc * bs, GstBuffer ** buf)
   if (!image)
     return GST_FLOW_ERROR;
 
-  *buf = GST_BUFFER (image);
+  *buf = image;
   GST_BUFFER_TIMESTAMP (*buf) = next_capture_ts;
   GST_BUFFER_DURATION (*buf) = dur;
 
@@ -890,7 +901,7 @@ gst_ximage_src_clear_bufpool (GstXImageSrc * ximagesrc)
 {
   g_mutex_lock (ximagesrc->pool_lock);
   while (ximagesrc->buffer_pool != NULL) {
-    GstXImageSrcBuffer *ximage = ximagesrc->buffer_pool->data;
+    GstBuffer *ximage = ximagesrc->buffer_pool->data;
 
     gst_ximage_buffer_free (ximage);
 
@@ -901,20 +912,6 @@ gst_ximage_src_clear_bufpool (GstXImageSrc * ximagesrc)
 }
 
 static void
-gst_ximage_src_base_init (gpointer g_class)
-{
-  GstElementClass *ec = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (ec, "Ximage video source",
-      "Source/Video",
-      "Creates a screenshot video stream",
-      "Lutz Mueller <lutz@users.sourceforge.net>, "
-      "Jan Schmidt <thaytan@mad.scientist.com>, "
-      "Zaheer Merali <zaheerabbas at merali dot org>");
-  gst_element_class_add_pad_template (ec, gst_static_pad_template_get (&t));
-}
-
-static void
 gst_ximage_src_dispose (GObject * object)
 {
   /* Drop references in the buffer_pool */
@@ -938,7 +935,7 @@ gst_ximage_src_finalize (GObject * object)
 }
 
 static GstCaps *
-gst_ximage_src_get_caps (GstBaseSrc * bs)
+gst_ximage_src_get_caps (GstBaseSrc * bs, GstCaps * filter)
 {
   GstXImageSrc *s = GST_XIMAGE_SRC (bs);
   GstXContext *xcontext;
@@ -1047,6 +1044,7 @@ static void
 gst_ximage_src_class_init (GstXImageSrcClass * klass)
 {
   GObjectClass *gc = G_OBJECT_CLASS (klass);
+  GstElementClass *ec = GST_ELEMENT_CLASS (klass);
   GstBaseSrcClass *bc = GST_BASE_SRC_CLASS (klass);
   GstPushSrcClass *push_class = GST_PUSH_SRC_CLASS (klass);
 
@@ -1138,7 +1136,13 @@ gst_ximage_src_class_init (GstXImageSrcClass * klass)
           "Whether the display is remote", FALSE,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
-  parent_class = g_type_class_peek_parent (klass);
+  gst_element_class_set_details_simple (ec, "Ximage video source",
+      "Source/Video",
+      "Creates a screenshot video stream",
+      "Lutz Mueller <lutz@users.sourceforge.net>, "
+      "Jan Schmidt <thaytan@mad.scientist.com>, "
+      "Zaheer Merali <zaheerabbas at merali dot org>");
+  gst_element_class_add_pad_template (ec, gst_static_pad_template_get (&t));
 
   push_class->create = gst_ximage_src_create;
   bc->get_caps = gst_ximage_src_get_caps;
@@ -1149,7 +1153,7 @@ gst_ximage_src_class_init (GstXImageSrcClass * klass)
 }
 
 static void
-gst_ximage_src_init (GstXImageSrc * ximagesrc, GstXImageSrcClass * klass)
+gst_ximage_src_init (GstXImageSrc * ximagesrc)
 {
   gst_base_src_set_format (GST_BASE_SRC (ximagesrc), GST_FORMAT_TIME);
   gst_base_src_set_live (GST_BASE_SRC (ximagesrc), TRUE);
index f436df6..732e7af 100644 (file)
@@ -95,7 +95,7 @@ struct _GstXImageSrc
   int damage_event_base;
   XserverRegion damage_region;
   GC damage_copy_gc;
-  GstXImageSrcBuffer *last_ximage;
+  GstBuffer *last_ximage;
 #endif
 };
 
index 2fac09a..d3dee2b 100644 (file)
 
 #include "ximageutil.h"
 
+const GstMetaInfo *
+gst_meta_ximage_get_info (void)
+{
+  static const GstMetaInfo *meta_ximage_info = NULL;
+
+  if (meta_ximage_info == NULL) {
+    meta_ximage_info =
+        gst_meta_register ("GstMetaXImageSrc", "GstMetaXImageSrc",
+        sizeof (GstMetaXImage), (GstMetaInitFunction) NULL,
+        (GstMetaFreeFunction) NULL, (GstMetaCopyFunction) NULL,
+        (GstMetaTransformFunction) NULL);
+  }
+  return meta_ximage_info;
+}
+
 #ifdef HAVE_XSHM
 static gboolean error_caught = FALSE;
 
@@ -296,108 +311,70 @@ ximageutil_calculate_pixel_aspect_ratio (GstXContext * xcontext)
       gst_value_get_fraction_denominator (xcontext->par));
 }
 
-static GstBufferClass *ximagesrc_buffer_parent_class = NULL;
-
 static void
-gst_ximagesrc_buffer_finalize (GstXImageSrcBuffer * ximage)
+gst_ximagesrc_buffer_dispose (GstBuffer * ximage)
 {
   GstElement *parent;
+  GstMetaXImage *meta;
 
   g_return_if_fail (ximage != NULL);
 
-  parent = ximage->parent;
+  meta = GST_META_XIMAGE_GET (ximage);
+
+  parent = meta->parent;
   if (parent == NULL) {
     g_warning ("XImageSrcBuffer->ximagesrc == NULL");
     goto beach;
   }
 
-  if (ximage->return_func)
-    ximage->return_func (parent, ximage);
+  if (meta->return_func)
+    meta->return_func (parent, ximage);
 
 beach:
-
-  GST_MINI_OBJECT_CLASS (ximagesrc_buffer_parent_class)->finalize
-      (GST_MINI_OBJECT (ximage));
-
   return;
 }
 
 void
-gst_ximage_buffer_free (GstXImageSrcBuffer * ximage)
+gst_ximage_buffer_free (GstBuffer * ximage)
 {
-  /* make sure it is not recycled */
-  ximage->width = -1;
-  ximage->height = -1;
-  gst_buffer_unref (GST_BUFFER (ximage));
-}
+  GstMetaXImage *meta;
 
-static void
-gst_ximagesrc_buffer_init (GstXImageSrcBuffer * ximage_buffer, gpointer g_class)
-{
-#ifdef HAVE_XSHM
-  ximage_buffer->SHMInfo.shmaddr = ((void *) -1);
-  ximage_buffer->SHMInfo.shmid = -1;
-#endif
-}
-
-static void
-gst_ximagesrc_buffer_class_init (gpointer g_class, gpointer class_data)
-{
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
-
-  ximagesrc_buffer_parent_class = g_type_class_peek_parent (g_class);
-
-  mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
-      gst_ximagesrc_buffer_finalize;
-}
+  meta = GST_META_XIMAGE_GET (ximage);
 
-static GType
-gst_ximagesrc_buffer_get_type (void)
-{
-  static GType _gst_ximagesrc_buffer_type;
-
-  if (G_UNLIKELY (_gst_ximagesrc_buffer_type == 0)) {
-    static const GTypeInfo ximagesrc_buffer_info = {
-      sizeof (GstBufferClass),
-      NULL,
-      NULL,
-      gst_ximagesrc_buffer_class_init,
-      NULL,
-      NULL,
-      sizeof (GstXImageSrcBuffer),
-      0,
-      (GInstanceInitFunc) gst_ximagesrc_buffer_init,
-      NULL
-    };
-    _gst_ximagesrc_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
-        "GstXImageSrcBuffer", &ximagesrc_buffer_info, 0);
-  }
-  return _gst_ximagesrc_buffer_type;
+  /* make sure it is not recycled */
+  meta->width = -1;
+  meta->height = -1;
+  gst_buffer_unref (ximage);
 }
 
 /* This function handles GstXImageSrcBuffer creation depending on XShm availability */
-GstXImageSrcBuffer *
+GstBuffer *
 gst_ximageutil_ximage_new (GstXContext * xcontext,
     GstElement * parent, int width, int height, BufferReturnFunc return_func)
 {
-  GstXImageSrcBuffer *ximage = NULL;
+  GstBuffer *ximage = NULL;
+  GstMetaXImage *meta;
   gboolean succeeded = FALSE;
 
-  ximage =
-      (GstXImageSrcBuffer *) gst_mini_object_new (GST_TYPE_XIMAGESRC_BUFFER);
+  ximage = gst_buffer_new ();
+  GST_MINI_OBJECT_CAST (ximage)->dispose =
+      (GstMiniObjectDisposeFunction) gst_ximagesrc_buffer_dispose;
 
-  ximage->width = width;
-  ximage->height = height;
+  meta = GST_META_XIMAGE_ADD (ximage);
+  meta->width = width;
+  meta->height = height;
 
 #ifdef HAVE_XSHM
+  meta->SHMInfo.shmaddr = ((void *) -1);
+  meta->SHMInfo.shmid = -1;
+
   if (xcontext->use_xshm) {
-    ximage->ximage = XShmCreateImage (xcontext->disp,
+    meta->ximage = XShmCreateImage (xcontext->disp,
         xcontext->visual, xcontext->depth,
-        ZPixmap, NULL, &ximage->SHMInfo, ximage->width, ximage->height);
-    if (!ximage->ximage) {
+        ZPixmap, NULL, &meta->SHMInfo, meta->width, meta->height);
+    if (!meta->ximage) {
       GST_WARNING_OBJECT (parent,
-          "could not XShmCreateImage a %dx%d image",
-          ximage->width, ximage->height);
+          "could not XShmCreateImage a %dx%d image", meta->width, meta->height);
 
       /* Retry without XShm */
       xcontext->use_xshm = FALSE;
@@ -405,24 +382,23 @@ gst_ximageutil_ximage_new (GstXContext * xcontext,
     }
 
     /* we have to use the returned bytes_per_line for our shm size */
-    ximage->size = ximage->ximage->bytes_per_line * ximage->ximage->height;
-    ximage->SHMInfo.shmid = shmget (IPC_PRIVATE, ximage->size,
-        IPC_CREAT | 0777);
-    if (ximage->SHMInfo.shmid == -1)
+    meta->size = meta->ximage->bytes_per_line * meta->ximage->height;
+    meta->SHMInfo.shmid = shmget (IPC_PRIVATE, meta->size, IPC_CREAT | 0777);
+    if (meta->SHMInfo.shmid == -1)
       goto beach;
 
-    ximage->SHMInfo.shmaddr = shmat (ximage->SHMInfo.shmid, 0, 0);
-    if (ximage->SHMInfo.shmaddr == ((void *) -1))
+    meta->SHMInfo.shmaddr = shmat (meta->SHMInfo.shmid, 0, 0);
+    if (meta->SHMInfo.shmaddr == ((void *) -1))
       goto beach;
 
     /* Delete the SHM segment. It will actually go away automatically
      * when we detach now */
-    shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
+    shmctl (meta->SHMInfo.shmid, IPC_RMID, 0);
 
-    ximage->ximage->data = ximage->SHMInfo.shmaddr;
-    ximage->SHMInfo.readOnly = FALSE;
+    meta->ximage->data = meta->SHMInfo.shmaddr;
+    meta->SHMInfo.readOnly = FALSE;
 
-    if (XShmAttach (xcontext->disp, &ximage->SHMInfo) == 0)
+    if (XShmAttach (xcontext->disp, &meta->SHMInfo) == 0)
       goto beach;
 
     XSync (xcontext->disp, FALSE);
@@ -430,27 +406,28 @@ gst_ximageutil_ximage_new (GstXContext * xcontext,
   no_xshm:
 #endif /* HAVE_XSHM */
   {
-    ximage->ximage = XCreateImage (xcontext->disp,
+    meta->ximage = XCreateImage (xcontext->disp,
         xcontext->visual,
         xcontext->depth,
-        ZPixmap, 0, NULL, ximage->width, ximage->height, xcontext->bpp, 0);
-    if (!ximage->ximage)
+        ZPixmap, 0, NULL, meta->width, meta->height, xcontext->bpp, 0);
+    if (!meta->ximage)
       goto beach;
 
     /* we have to use the returned bytes_per_line for our image size */
-    ximage->size = ximage->ximage->bytes_per_line * ximage->ximage->height;
-    ximage->ximage->data = g_malloc (ximage->size);
+    meta->size = meta->ximage->bytes_per_line * meta->ximage->height;
+    meta->ximage->data = g_malloc (meta->size);
 
     XSync (xcontext->disp, FALSE);
   }
   succeeded = TRUE;
 
-  GST_BUFFER_DATA (ximage) = (guchar *) ximage->ximage->data;
-  GST_BUFFER_SIZE (ximage) = ximage->size;
+  gst_buffer_take_memory (ximage, -1,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE, meta->ximage->data,
+          NULL, meta->size, 0, meta->size));
 
   /* Keep a ref to our src */
-  ximage->parent = gst_object_ref (parent);
-  ximage->return_func = return_func;
+  meta->parent = gst_object_ref (parent);
+  meta->return_func = return_func;
 beach:
   if (!succeeded) {
     gst_ximage_buffer_free (ximage);
@@ -462,9 +439,12 @@ beach:
 
 /* This function destroys a GstXImageBuffer handling XShm availability */
 void
-gst_ximageutil_ximage_destroy (GstXContext * xcontext,
-    GstXImageSrcBuffer * ximage)
+gst_ximageutil_ximage_destroy (GstXContext * xcontext, GstBuffer * ximage)
 {
+  GstMetaXImage *meta;
+
+  meta = GST_META_XIMAGE_GET (ximage);
+
   /* We might have some buffers destroyed after changing state to NULL */
   if (!xcontext)
     goto beach;
@@ -473,28 +453,28 @@ gst_ximageutil_ximage_destroy (GstXContext * xcontext,
 
 #ifdef HAVE_XSHM
   if (xcontext->use_xshm) {
-    if (ximage->SHMInfo.shmaddr != ((void *) -1)) {
-      XShmDetach (xcontext->disp, &ximage->SHMInfo);
+    if (meta->SHMInfo.shmaddr != ((void *) -1)) {
+      XShmDetach (xcontext->disp, &meta->SHMInfo);
       XSync (xcontext->disp, 0);
-      shmdt (ximage->SHMInfo.shmaddr);
+      shmdt (meta->SHMInfo.shmaddr);
     }
-    if (ximage->ximage)
-      XDestroyImage (ximage->ximage);
+    if (meta->ximage)
+      XDestroyImage (meta->ximage);
 
   } else
 #endif /* HAVE_XSHM */
   {
-    if (ximage->ximage) {
-      XDestroyImage (ximage->ximage);
+    if (meta->ximage) {
+      XDestroyImage (meta->ximage);
     }
   }
 
   XSync (xcontext->disp, FALSE);
 beach:
-  if (ximage->parent) {
+  if (meta->parent) {
     /* Release the ref to our parent */
-    gst_object_unref (ximage->parent);
-    ximage->parent = NULL;
+    gst_object_unref (meta->parent);
+    meta->parent = NULL;
   }
 
   return;
index 517fc8e..aa674de 100644 (file)
@@ -43,7 +43,7 @@ G_BEGIN_DECLS
 typedef struct _GstXContext GstXContext;
 typedef struct _GstXWindow GstXWindow;
 typedef struct _GstXImage GstXImage;
-typedef struct _GstXImageSrcBuffer GstXImageSrcBuffer;
+typedef struct _GstMetaXImage GstMetaXImage;
 
 /* Global X Context stuff */
 /**
@@ -130,20 +130,20 @@ void ximageutil_calculate_pixel_aspect_ratio (GstXContext * xcontext);
 /* custom ximagesrc buffer, copied from ximagesink */
 
 /* BufferReturnFunc is called when a buffer is finalised */
-typedef void (*BufferReturnFunc) (GstElement *parent, GstXImageSrcBuffer *buf);
+typedef void (*BufferReturnFunc) (GstElement *parent, GstBuffer *buf);
 
 /**
- * GstXImageSrcBuffer:
+ * GstMetaXImage:
  * @parent: a reference to the element we belong to
  * @ximage: the XImage of this buffer
  * @width: the width in pixels of XImage @ximage
  * @height: the height in pixels of XImage @ximage
  * @size: the size in bytes of XImage @ximage
  *
- * Subclass of #GstBuffer containing additional information about an XImage.
+ * Extra data attached to buffers containing additional information about an XImage.
  */
-struct _GstXImageSrcBuffer {
-  GstBuffer buffer;
+struct _GstMetaXImage {
+  GstMeta meta;
 
   /* Reference to the ximagesrc we belong to */
   GstElement *parent;
@@ -156,26 +156,22 @@ struct _GstXImageSrcBuffer {
 
   gint width, height;
   size_t size;
-  
+
   BufferReturnFunc return_func;
 };
 
+const GstMetaInfo * gst_meta_ximage_get_info (void);
+#define GST_META_XIMAGE_GET(buf) ((GstMetaXImage *)gst_buffer_get_meta(buf,gst_meta_ximage_get_info()))
+#define GST_META_XIMAGE_ADD(buf) ((GstMetaXImage *)gst_buffer_add_meta(buf,gst_meta_ximage_get_info(),NULL))
 
-GstXImageSrcBuffer *gst_ximageutil_ximage_new (GstXContext *xcontext,
+GstBuffer *gst_ximageutil_ximage_new (GstXContext *xcontext,
   GstElement *parent, int width, int height, BufferReturnFunc return_func);
 
 void gst_ximageutil_ximage_destroy (GstXContext *xcontext, 
-  GstXImageSrcBuffer * ximage);
+  GstBuffer * ximage);
   
 /* Call to manually release a buffer */
-void gst_ximage_buffer_free (GstXImageSrcBuffer *ximage);
-
-#define GST_TYPE_XIMAGESRC_BUFFER            (gst_ximagesrc_buffer_get_type())
-#define GST_IS_XIMAGESRC_BUFFER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XIMAGESRC_BUFFER))
-#define GST_IS_XIMAGESRC_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_XIMAGESRC_BUFFER))
-#define GST_XIMAGESRC_BUFFER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XIMAGESRC_BUFFER, GstXImageSrcBuffer))
-#define GST_XIMAGESRC_BUFFER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_XIMAGESRC_BUFFER, GstXImageSrcBufferClass))
-#define GST_XIMAGESRC_BUFFER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_XIMAGESRC_BUFFER, GstXImageSrcBufferClass))
+void gst_ximage_buffer_free (GstBuffer *ximage);
 
 G_END_DECLS 
 
index 046d0f3..f219428 100644 (file)
@@ -12,7 +12,7 @@ TESTS_ENVIRONMENT = \
        GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/ext:$(top_builddir)/sys:$(GSTPB_PLUGINS_DIR):$(GST_PLUGINS_DIR)                     \
        GST_PLUGIN_LOADING_WHITELIST="gstreamer@$(GST_PLUGINS_DIR):gst-plugins-base@$(GSTPB_PLUGINS_DIR):gst-plugins-good@$(top_builddir)"      \
        GST_STATE_IGNORE_ELEMENTS="aasink autoaudiosrc autoaudiosink autovideosrc autovideosink \
-               cacasink cairotextoverlay gconfaudiosrc gconfvideosrc gconfaudiosink gconfvideosink \
+               cacasink cairotextoverlay \
                halaudiosrc halaudiosink jackaudiosrc jackaudiosink \
                osssrc osssink osxaudiosink osxaudiosrc osxvideosrc osxvideosink \
                pulsesink pulsesrc pulsemixer v4l2src"
@@ -118,6 +118,7 @@ check_PROGRAMS = \
        elements/audiopanorama \
        elements/audiowsincband \
        elements/audiowsinclimit \
+       elements/autodetect \
        elements/avimux \
        elements/avisubtitle \
        elements/capssetter \
@@ -167,13 +168,8 @@ VALGRIND_TO_FIX = \
 
 TESTS = $(check_PROGRAMS)
 
-# these tests don't even pass
-# autodetect: temporarily disabled because of broken videosinks in -bad
-noinst_PROGRAMS = \
-       elements/autodetect
-
 AM_CFLAGS = $(GST_OBJ_CFLAGS) $(GST_CHECK_CFLAGS) $(CHECK_CFLAGS) \
-       $(GST_OPTION_CFLAGS) -DGST_TEST_FILES_PATH="\"$(TEST_FILES_DIRECTORY)\"" \
+       $(GST_OPTION_CFLAGS) $(GST_CFLAGS) -DGST_TEST_FILES_PATH="\"$(TEST_FILES_DIRECTORY)\"" \
        -UG_DISABLE_ASSERT -UG_DISABLE_CAST_CHECKS
 LDADD = $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS)
 
@@ -190,7 +186,7 @@ noinst_LTLIBRARIES = libparser.la
 libparser_la_SOURCES = elements/parser.c elements/parser.h
 libparser_la_CFLAGS = \
        -I$(top_srcdir)/tests/check \
-       $(GST_CHECK_CFLAGS) $(GST_OPTION_CFLAGS)
+       $(GST_CHECK_CFLAGS) $(GST_OPTION_CFLAGS) -DGST_USE_UNSTABLE_API
 
 elements_aacparse_LDADD = libparser.la $(LDADD)
 
index 39ff80e..35d0615 100644 (file)
@@ -37,31 +37,24 @@ GstPad *mysrcpad, *mysinkpad;
 
 
 #define INVERT_CAPS_STRING    \
-    "audio/x-raw-int, "                 \
+    "audio/x-raw, "                     \
+    "format = (string) "GST_AUDIO_NE(S16)", "   \
     "channels = (int) 1, "              \
-    "rate = (int) 44100, "              \
-    "endianness = (int) BYTE_ORDER, "   \
-    "width = (int) 16, "                \
-    "depth = (int) 16, "                \
-    "signed = (bool) TRUE"
+    "rate = (int) 44100"
 
 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "channels = (int) 1, "
-        "rate = (int) [ 1,  MAX ], "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " GST_AUDIO_NE (S16) ", "
+        "channels = (int) 1, " "rate = (int) [ 1,  MAX ]")
     );
 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "channels = (int) 1, "
-        "rate = (int) [ 1,  MAX ], "
-        "endianness = (int) BYTE_ORDER, "
-        "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " GST_AUDIO_NE (S16) ", "
+        "channels = (int) 1, " "rate = (int) [ 1,  MAX ]")
     );
 
 static GstElement *
index 0eb798b..b4ab60e 100644 (file)
@@ -30,23 +30,10 @@ GST_START_TEST (test_autovideosink_ghostpad_error_case)
   GstElement *pipeline, *src, *filter, *sink;
   GstCaps *caps;
 
-  /* check that there's a usable video sink (think of build bot case) */
-  sink = gst_element_factory_make ("autovideosink", NULL);
-  state_ret = gst_element_set_state (sink, GST_STATE_READY);
-
-  /* need to set state back to NULL, or our test won't work since we
-   * already have detected the real caps in ready and then linking fails */
-  gst_element_set_state (sink, GST_STATE_NULL);
-
-  if (state_ret != GST_STATE_CHANGE_SUCCESS) {
-    GST_WARNING ("No usable video sink, skipping test");
-    gst_object_unref (sink);
-    return;
-  }
-
   pipeline = gst_pipeline_new ("pipeline");
   src = gst_element_factory_make ("fakesrc", NULL);
   filter = gst_element_factory_make ("capsfilter", NULL);
+  sink = gst_element_factory_make ("autovideosink", NULL);
 
   caps = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC,
       GST_MAKE_FOURCC ('A', 'C', 'D', 'C'), NULL);
@@ -86,23 +73,10 @@ GST_START_TEST (test_autoaudiosink_ghostpad_error_case)
   GstElement *pipeline, *src, *filter, *sink;
   GstCaps *caps;
 
-  /* check that there's a usable audio sink (think of build bot case) */
-  sink = gst_element_factory_make ("autoaudiosink", NULL);
-  state_ret = gst_element_set_state (sink, GST_STATE_READY);
-
-  /* need to set state back to NULL, or our test won't work since we
-   * already have detected the real caps in ready and then linking fails */
-  gst_element_set_state (sink, GST_STATE_NULL);
-
-  if (state_ret != GST_STATE_CHANGE_SUCCESS) {
-    GST_WARNING ("No usable audio sink, skipping test");
-    gst_object_unref (sink);
-    return;
-  }
-
   pipeline = gst_pipeline_new ("pipeline");
   src = gst_element_factory_make ("fakesrc", NULL);
   filter = gst_element_factory_make ("capsfilter", NULL);
+  sink = gst_element_factory_make ("autoaudiosink", NULL);
 
   caps = gst_caps_new_simple ("audio/x-raw-int", "width", G_TYPE_INT, 42, NULL);
 
index 2bb4eb7..7969855 100644 (file)
@@ -33,23 +33,16 @@ gboolean have_eos = FALSE;
 GstPad *mysrcpad, *mysinkpad;
 
 #define LEVEL_CAPS_TEMPLATE_STRING \
-  "audio/x-raw-int, " \
+  "audio/x-raw, " \
+    "format = (string) { S8, "GST_AUDIO_NE(S16)" }, " \
     "rate = (int) [ 1, MAX ], " \
-    "channels = (int) [ 1, 8 ], " \
-    "endianness = (int) BYTE_ORDER, " \
-    "width = (int) {8, 16}, " \
-    "depth = (int) {8, 16}, " \
-    "signed = (boolean) true"
+    "channels = (int) [ 1, 8 ]"
 
 #define LEVEL_CAPS_STRING \
-  "audio/x-raw-int, " \
+  "audio/x-raw, " \
+    "format = (string) "GST_AUDIO_NE(S16)", " \
     "rate = (int) 1000, " \
-    "channels = (int) 2, " \
-    "endianness = (int) BYTE_ORDER, " \
-    "width = (int) 16, " \
-    "depth = (int) 16, " \
-    "signed = (boolean) true"
-
+    "channels = (int) 2"
 
 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
index 7596889..806b63f 100644 (file)
@@ -66,16 +66,21 @@ buffer_new (const unsigned char *buffer_data, guint size)
 
   buffer = gst_buffer_new_and_alloc (size);
   if (buffer_data) {
-    memcpy (GST_BUFFER_DATA (buffer), buffer_data, size);
+    gst_buffer_fill (buffer, 0, buffer_data, size);
   } else {
     guint i;
+    guint8 *data;
+    gsize wantsize = size;
+
+    data = gst_buffer_map (buffer, &wantsize, NULL, GST_MAP_WRITE);
     /* Create a recognizable pattern (loop 0x00 -> 0xff) in the data block */
-    for (i = 0; i < size; i++) {
-      GST_BUFFER_DATA (buffer)[i] = i % 0x100;
+    for (i = 0; i < wantsize; i++) {
+      data[i] = i % 0x100;
     }
+    gst_buffer_unmap (buffer, data, wantsize);
   }
 
-  gst_buffer_set_caps (buffer, GST_PAD_CAPS (srcpad));
+  /* gst_buffer_set_caps (buffer, GST_PAD_CAPS (srcpad)); */
   GST_BUFFER_OFFSET (buffer) = dataoffset;
   dataoffset += size;
   return buffer;
@@ -88,7 +93,7 @@ static void
 buffer_count_size (void *buffer, void *user_data)
 {
   guint *sum = (guint *) user_data;
-  *sum += GST_BUFFER_SIZE (buffer);
+  *sum += gst_buffer_get_size (buffer);
 }
 
 /*
@@ -115,8 +120,8 @@ buffer_verify_data (void *buffer, void *user_data)
     return;
   }
 
-  fail_unless (GST_BUFFER_SIZE (buffer) == vdata->data_to_verify_size);
-  fail_unless (memcmp (GST_BUFFER_DATA (buffer), vdata->data_to_verify,
+  fail_unless (gst_buffer_get_size (buffer) == vdata->data_to_verify_size);
+  fail_unless (gst_buffer_memcmp (buffer, 0, vdata->data_to_verify,
           vdata->data_to_verify_size) == 0);
 
   if (vdata->buffers_before_offset_skip) {
@@ -131,14 +136,8 @@ buffer_verify_data (void *buffer, void *user_data)
     fail_unless (GST_BUFFER_OFFSET (buffer) == offset_counter);
   }
 
-  if (vdata->caps) {
-    GST_LOG ("%" GST_PTR_FORMAT " = %" GST_PTR_FORMAT " ?",
-        GST_BUFFER_CAPS (buffer), vdata->caps);
-    fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), vdata->caps));
-  }
-
   ts_counter += GST_BUFFER_DURATION (buffer);
-  offset_counter += GST_BUFFER_SIZE (buffer);
+  offset_counter += gst_buffer_get_size (buffer);
   buffer_counter++;
 }
 
@@ -247,14 +246,8 @@ gst_parser_test_run (GstParserTest * test, GstCaps ** out_caps)
         if (!k)
           buffer = buffer_new (test->series[j].data, test->series[j].size);
         else {
-          GstCaps *caps = gst_buffer_get_caps (buffer);
-
           buffer = gst_buffer_join (buffer,
               buffer_new (test->series[j].data, test->series[j].size));
-          if (caps) {
-            gst_buffer_set_caps (buffer, caps);
-            gst_caps_unref (caps);
-          }
         }
       }
       fail_unless_equals_int (gst_pad_push (srcpad, buffer), GST_FLOW_OK);
@@ -293,7 +286,7 @@ gst_parser_test_run (GstParserTest * test, GstCaps ** out_caps)
     fail_unless_equals_int (datasum, size);
   }
 
-  src_caps = gst_pad_get_negotiated_caps (sinkpad);
+  src_caps = gst_pad_get_current_caps (sinkpad);
   GST_LOG ("output caps: %" GST_PTR_FORMAT, src_caps);
 
   if (test->sink_caps) {
index b2160f4..9025ab4 100644 (file)
@@ -600,7 +600,7 @@ GST_START_TEST (rtp_L16)
 {
   rtp_pipeline_test (rtp_L16_frame_data, rtp_L16_frame_data_size,
       rtp_L16_frame_count,
-      "audio/x-raw-int,endianess=4321,signed=true,width=16,depth=16,rate=1,channels=1",
+      "audio/x-raw,format=S16_BE,rate=1,channels=1",
       "rtpL16pay", "rtpL16depay", 0, 0, FALSE);
 }
 
index a8eaa61..619253b 100644 (file)
@@ -68,8 +68,8 @@ setup_jitterbuffer (gint num_buffers)
   GstBuffer *buffer;
   GstCaps *caps;
   /* a 20 sample audio block (2,5 ms) generated with
-   * gst-launch audiotestsrc wave=silence blocksize=40 num-buffers=3 ! 
-   *    "audio/x-raw-int,channels=1,rate=8000" ! mulawenc ! rtppcmupay !
+   * gst-launch audiotestsrc wave=silence blocksize=40 num-buffers=3 !
+   *    "audio/x-raw,channels=1,rate=8000" ! mulawenc ! rtppcmupay !
    *     fakesink dump=1
    */
   guint8 in[] = {               /* first 4 bytes are rtp-header, next 4 bytes are timestamp */
index a85d751..1ce625f 100644 (file)
@@ -87,7 +87,7 @@ main (int argc, char *argv[])
 
   gst_init (&argc, &argv);
 
-  caps = gst_caps_from_string ("audio/x-raw-int,channels=2");
+  caps = gst_caps_from_string ("audio/x-raw,channels=2");
 
   pipeline = gst_pipeline_new (NULL);
   g_assert (pipeline);
index 5d35e61..e9a2d96 100644 (file)
@@ -1,5 +1,5 @@
 noinst_PROGRAMS = pulse
 pulse_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
-pulse_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-0.10 $(GST_BASE_LIBS) $(GST_LIBS)
+pulse_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR) $(GST_BASE_LIBS) $(GST_LIBS)
 
 
index b552921..c843d0c 100644 (file)
@@ -95,7 +95,7 @@ main (int argc, char *argv[])
 
   gst_bin_add_many (GST_BIN (bin), src, audioconvert, spectrum, sink, NULL);
 
-  caps = gst_caps_new_simple ("audio/x-raw-int",
+  caps = gst_caps_new_simple ("audio/x-raw",
       "rate", G_TYPE_INT, AUDIOFREQ, NULL);
 
   if (!gst_element_link (src, audioconvert) ||
index 4fdb7e3..7db85d4 100644 (file)
@@ -6,5 +6,5 @@ camctrl_LDADD = $(GST_BASE_LIBS) $(GST_CONTROLLER_LIBS) $(GST_LIBS)
 
 probe_SOURCES = probe.c
 probe_CFLAGS  = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
-probe_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-0.10 $(GST_BASE_LIBS) $(GST_LIBS)
+probe_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR) $(GST_BASE_LIBS) $(GST_LIBS)
 
index 5b1eb22..8181846 100644 (file)
@@ -23,7 +23,7 @@ OSS4_TESTS=test-oss4
 
 test_oss4_SOURCES = test-oss4.c
 test_oss4_CFLAGS  = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-test_oss4_LDADD   = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-0.10 $(GST_LIBS)
+test_oss4_LDADD   = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR) $(GST_LIBS)
 test_oss4_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 else
 OSS4_TESTS=
index b09fe09..a700a4a 100644 (file)
@@ -72,7 +72,7 @@ new_decoded_pad (GstElement * dec, GstPad * new_pad, gboolean last,
 
   /* FIXME: is this racy or does decodebin2 make sure caps are always
    * negotiated at this point? */
-  caps = gst_pad_get_caps (new_pad);
+  caps = gst_pad_get_caps (new_pad, NULL);
   g_return_if_fail (caps != NULL);
 
   s = gst_caps_get_structure (caps, 0);
@@ -122,8 +122,6 @@ bus_message_cb (GstBus * bus, GstMessage * msg, AppInfo * info)
 {
   switch (GST_MESSAGE_TYPE (msg)) {
     case GST_MESSAGE_ASYNC_DONE:{
-      GstFormat fmt = GST_FORMAT_TIME;
-
       /* only interested in async-done messages from the top-level pipeline */
       if (msg->src != GST_OBJECT_CAST (info->pipe))
         break;
@@ -138,26 +136,29 @@ bus_message_cb (GstBus * bus, GstMessage * msg, AppInfo * info)
       }
 
       /* update position */
-      if (!gst_element_query_position (info->pipe, &fmt, &info->cur_pos))
+      if (!gst_element_query_position (info->pipe, GST_FORMAT_TIME,
+              &info->cur_pos))
         info->cur_pos = -1;
       break;
     }
     case GST_MESSAGE_ELEMENT:{
       const GValue *val;
       GdkPixbuf *pixbuf = NULL;
+      const GstStructure *structure;
 
       /* only interested in element messages from our gdkpixbufsink */
       if (msg->src != GST_OBJECT_CAST (info->sink))
         break;
 
       /* only interested in these two messages */
-      if (!gst_structure_has_name (msg->structure, "preroll-pixbuf") &&
-          !gst_structure_has_name (msg->structure, "pixbuf")) {
+      if (!gst_message_has_name (msg, "preroll-pixbuf") &&
+          !gst_message_has_name (msg, "pixbuf")) {
         break;
       }
 
       g_print ("pixbuf\n");
-      val = gst_structure_get_value (msg->structure, "pixbuf");
+      structure = gst_message_get_structure (msg);
+      val = gst_structure_get_value (structure, "pixbuf");
       g_return_if_fail (val != NULL);
 
       pixbuf = GDK_PIXBUF (g_value_dup_object (val));
@@ -211,10 +212,10 @@ static void
 seek_to (AppInfo * info, gdouble percent)
 {
   GstSeekFlags seek_flags;
-  GstFormat fmt = GST_FORMAT_TIME;
   gint64 seek_pos, dur = -1;
 
-  if (!gst_element_query_duration (info->pipe, &fmt, &dur) || dur <= 0) {
+  if (!gst_element_query_duration (info->pipe, GST_FORMAT_TIME, &dur)
+      || dur <= 0) {
     g_printerr ("Could not query duration\n");
     return;
   }
index a4874e1..0106e6d 100644 (file)
@@ -105,10 +105,10 @@ test_with_caps (GstElement * src, GstElement * videocrop, GstCaps * caps)
     /* need to block the streaming thread while changing these properties,
      * otherwise we might get random not-negotiated errors (when caps are
      * changed in between upstream calling pad_alloc_buffer() and pushing
-     * the processed buffer?) */
-    gst_pad_set_blocked (pad, TRUE);
+     * the processed buffer?)  FIXME should not be needed */
+    /* gst_pad_set_blocked (pad, TRUE); */
     g_object_set (videocrop, "left", hcrop, "top", vcrop, NULL);
-    gst_pad_set_blocked (pad, FALSE);
+    /* gst_pad_set_blocked (pad, FALSE); */
 
     waited_for_block = g_timer_elapsed (timer, NULL) * (double) GST_SECOND;
     /* GST_LOG ("waited: %" GST_TIME_FORMAT ", frame len: %" GST_TIME_FORMAT,