summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am15
-rw-r--r--REQUIREMENTS11
m---------common0
-rw-r--r--configure.ac90
-rw-r--r--docs/plugins/Makefile.am7
-rw-r--r--docs/plugins/gst-plugins-good-plugins-docs.sgml19
-rw-r--r--docs/plugins/gst-plugins-good-plugins-sections.txt90
-rw-r--r--docs/plugins/inspect/plugin-esdsink.xml28
-rw-r--r--docs/plugins/inspect/plugin-gconfelements.xml49
-rw-r--r--docs/plugins/inspect/plugin-rtpmanager.xml (renamed from docs/plugins/inspect/plugin-gstrtpmanager.xml)14
-rw-r--r--ext/Makefile.am24
-rw-r--r--ext/aalib/Makefile.am4
-rw-r--r--ext/aalib/gstaasink.c219
-rw-r--r--ext/aalib/gstaasink.h8
-rw-r--r--ext/annodex/gstannodex.c2
-rw-r--r--ext/annodex/gstcmmldec.c160
-rw-r--r--ext/annodex/gstcmmldec.h1
-rw-r--r--ext/annodex/gstcmmlenc.c76
-rw-r--r--ext/cairo/gstcairooverlay.c8
-rw-r--r--ext/cairo/gstcairorender.c4
-rw-r--r--ext/cairo/gsttextoverlay.c16
-rw-r--r--ext/cairo/gsttimeoverlay.c8
-rw-r--r--ext/dv/gstdvdec.c6
-rw-r--r--ext/dv/gstdvdemux.c11
-rw-r--r--ext/esd/Makefile.am14
-rw-r--r--ext/esd/esdmon.c465
-rw-r--r--ext/esd/esdmon.h77
-rw-r--r--ext/esd/esdsink.c468
-rw-r--r--ext/esd/esdsink.h64
-rw-r--r--ext/esd/gstesd.c60
-rw-r--r--ext/flac/gstflacdec.c1840
-rw-r--r--ext/flac/gstflacdec.h46
-rw-r--r--ext/flac/gstflacenc.c210
-rw-r--r--ext/flac/gstflactag.c202
-rw-r--r--ext/gconf/Makefile.am27
-rw-r--r--ext/gconf/gstgconf.c304
-rw-r--r--ext/gconf/gstgconf.h66
-rw-r--r--ext/gconf/gstgconfaudiosink.c310
-rw-r--r--ext/gconf/gstgconfaudiosink.h62
-rw-r--r--ext/gconf/gstgconfaudiosrc.c210
-rw-r--r--ext/gconf/gstgconfaudiosrc.h57
-rw-r--r--ext/gconf/gstgconfelements.c59
-rw-r--r--ext/gconf/gstgconfelements.h28
-rw-r--r--ext/gconf/gstgconfvideosink.c210
-rw-r--r--ext/gconf/gstgconfvideosink.h64
-rw-r--r--ext/gconf/gstgconfvideosrc.c209
-rw-r--r--ext/gconf/gstgconfvideosrc.h58
-rw-r--r--ext/gconf/gstswitchsink.c269
-rw-r--r--ext/gconf/gstswitchsink.h62
-rw-r--r--ext/gconf/gstswitchsrc.c261
-rw-r--r--ext/gconf/gstswitchsrc.h57
-rw-r--r--ext/gdk_pixbuf/gstgdkpixbuf.c8
-rw-r--r--ext/gdk_pixbuf/gstgdkpixbufsink.c4
-rw-r--r--ext/gdk_pixbuf/pixbufscale.c8
-rw-r--r--ext/hal/Makefile.am18
-rw-r--r--ext/hal/gsthalaudiosink.c250
-rw-r--r--ext/hal/gsthalaudiosink.h58
-rw-r--r--ext/hal/gsthalaudiosrc.c251
-rw-r--r--ext/hal/gsthalaudiosrc.h52
-rw-r--r--ext/hal/gsthalelements.c54
-rw-r--r--ext/hal/gsthalelements.h29
-rw-r--r--ext/hal/hal.c397
-rw-r--r--ext/hal/hal.h48
-rw-r--r--ext/jack/gstjack.h6
-rw-r--r--ext/jack/gstjackaudiosink.c128
-rw-r--r--ext/jack/gstjackaudiosink.h6
-rw-r--r--ext/jack/gstjackaudiosrc.c124
-rw-r--r--ext/jack/gstjackaudiosrc.h4
-rw-r--r--ext/jack/gstjackringbuffer.h22
-rw-r--r--ext/jpeg/Makefile.am11
-rw-r--r--ext/jpeg/gstjpeg.c4
-rw-r--r--ext/jpeg/gstjpegdec.c532
-rw-r--r--ext/jpeg/gstjpegdec.h23
-rw-r--r--ext/jpeg/gstjpegenc.c386
-rw-r--r--ext/jpeg/gstjpegenc.h28
-rw-r--r--ext/jpeg/gstsmokedec.c8
-rw-r--r--ext/jpeg/gstsmokeenc.c8
-rw-r--r--ext/libcaca/Makefile.am1
-rw-r--r--ext/libcaca/gstcacasink.c233
-rw-r--r--ext/libcaca/gstcacasink.h5
-rw-r--r--ext/libmng/gstmngdec.c8
-rw-r--r--ext/libmng/gstmngenc.c3
-rw-r--r--ext/libpng/gstpngdec.c8
-rw-r--r--ext/libpng/gstpngenc.c8
-rw-r--r--ext/mikmod/gstmikmod.c8
-rw-r--r--ext/pulse/plugin.c4
-rw-r--r--ext/pulse/pulseaudiosink.c348
-rw-r--r--ext/pulse/pulsemixer.c72
-rw-r--r--ext/pulse/pulsemixerctrl.h18
-rw-r--r--ext/pulse/pulsesink.c428
-rw-r--r--ext/pulse/pulsesink.h61
-rw-r--r--ext/pulse/pulsesrc.c332
-rw-r--r--ext/pulse/pulsesrc.h3
-rw-r--r--ext/pulse/pulseutil.c178
-rw-r--r--ext/pulse/pulseutil.h13
-rw-r--r--ext/raw1394/gstdv1394src.c3
-rw-r--r--ext/raw1394/gsthdv1394src.c3
-rw-r--r--ext/shout2/gstshout2.c4
-rw-r--r--ext/soup/gstsouphttpclientsink.c91
-rw-r--r--ext/soup/gstsouphttpsrc.c192
-rw-r--r--ext/soup/gstsouphttpsrc.h2
-rw-r--r--ext/speex/gstspeexdec.c121
-rw-r--r--ext/speex/gstspeexenc.c110
-rw-r--r--ext/taglib/gstapev2mux.cc3
-rw-r--r--ext/taglib/gstid3v2mux.cc7
-rw-r--r--ext/taglib/gsttaglibmux.c4
-rw-r--r--ext/wavpack/gstwavpackdec.c6
-rw-r--r--ext/wavpack/gstwavpackenc.c10
-rw-r--r--ext/wavpack/gstwavpackparse.c10
-rw-r--r--gconf/.gitignore2
-rw-r--r--gconf/Makefile.am31
-rw-r--r--gconf/gstreamer.schemas.in191
-rw-r--r--gst-plugins-good.spec.in46
-rw-r--r--gst/alpha/Makefile.am4
-rw-r--r--gst/alpha/gstalpha.c945
-rw-r--r--gst/alpha/gstalpha.h6
-rw-r--r--gst/alpha/gstalphacolor.c217
-rw-r--r--gst/alpha/gstalphacolor.h5
-rw-r--r--gst/apetag/gstapedemux.c55
-rw-r--r--gst/audiofx/Makefile.am2
-rw-r--r--gst/audiofx/audioamplify.c157
-rw-r--r--gst/audiofx/audioamplify.h3
-rw-r--r--gst/audiofx/audiochebband.c76
-rw-r--r--gst/audiofx/audiocheblimit.c55
-rw-r--r--gst/audiofx/audiodynamic.c98
-rw-r--r--gst/audiofx/audioecho.c101
-rw-r--r--gst/audiofx/audiofirfilter.c45
-rw-r--r--gst/audiofx/audiofirfilter.h1
-rw-r--r--gst/audiofx/audiofx.c4
-rw-r--r--gst/audiofx/audiofxbasefirfilter.c328
-rw-r--r--gst/audiofx/audiofxbaseiirfilter.c102
-rw-r--r--gst/audiofx/audioiirfilter.c46
-rw-r--r--gst/audiofx/audioiirfilter.h1
-rw-r--r--gst/audiofx/audioinvert.c101
-rw-r--r--gst/audiofx/audiokaraoke.c112
-rw-r--r--gst/audiofx/audiokaraoke.h3
-rw-r--r--gst/audiofx/audiopanorama.c166
-rw-r--r--gst/audiofx/audiopanorama.h8
-rw-r--r--gst/audiofx/audiowsincband.c68
-rw-r--r--gst/audiofx/audiowsincband.h6
-rw-r--r--gst/audiofx/audiowsinclimit.c60
-rw-r--r--gst/audioparsers/gstaacparse.c105
-rw-r--r--gst/audioparsers/gstac3parse.c136
-rw-r--r--gst/audioparsers/gstamrparse.c63
-rw-r--r--gst/audioparsers/gstdcaparse.c100
-rw-r--r--gst/audioparsers/gstflacparse.c384
-rw-r--r--gst/audioparsers/gstmpegaudioparse.c159
-rw-r--r--gst/auparse/Makefile.am2
-rw-r--r--gst/auparse/gstauparse.c322
-rw-r--r--gst/auparse/gstauparse.h1
-rw-r--r--gst/autodetect/gstautoaudiosink.c40
-rw-r--r--gst/autodetect/gstautoaudiosrc.c41
-rw-r--r--gst/autodetect/gstautovideosink.c38
-rw-r--r--gst/autodetect/gstautovideosrc.c39
-rw-r--r--gst/avi/Makefile.am3
-rw-r--r--gst/avi/gstavidemux.c820
-rw-r--r--gst/avi/gstavidemux.h2
-rw-r--r--gst/avi/gstavimux.c444
-rw-r--r--gst/avi/gstavisubtitle.c96
-rw-r--r--gst/cutter/gstcutter.c202
-rw-r--r--gst/cutter/gstcutter.h5
-rw-r--r--gst/debugutils/Makefile.am7
-rw-r--r--gst/debugutils/breakmydata.c64
-rw-r--r--gst/debugutils/cpureport.c34
-rw-r--r--gst/debugutils/efence.c135
-rw-r--r--gst/debugutils/gstcapsdebug.c35
-rw-r--r--gst/debugutils/gstcapssetter.c45
-rw-r--r--gst/debugutils/gstdebug.c4
-rw-r--r--gst/debugutils/gstnavigationtest.c171
-rw-r--r--gst/debugutils/gstnavigationtest.h5
-rw-r--r--gst/debugutils/gstnavseek.c76
-rw-r--r--gst/debugutils/gstpushfilesrc.c100
-rw-r--r--gst/debugutils/gsttaginject.c42
-rw-r--r--gst/debugutils/progressreport.c88
-rw-r--r--gst/debugutils/rndbuffersize.c120
-rw-r--r--gst/debugutils/testplugin.c36
-rw-r--r--gst/debugutils/tests.c10
-rw-r--r--gst/deinterlace/gstdeinterlace.c6
-rw-r--r--gst/effectv/Makefile.am2
-rw-r--r--gst/effectv/gstaging.c107
-rw-r--r--gst/effectv/gstaging.h4
-rw-r--r--gst/effectv/gstdice.c126
-rw-r--r--gst/effectv/gstdice.h4
-rw-r--r--gst/effectv/gstedge.c96
-rw-r--r--gst/effectv/gstedge.h4
-rw-r--r--gst/effectv/gstop.c126
-rw-r--r--gst/effectv/gstop.h3
-rw-r--r--gst/effectv/gstquark.c118
-rw-r--r--gst/effectv/gstquark.h3
-rw-r--r--gst/effectv/gstradioac.c181
-rw-r--r--gst/effectv/gstradioac.h3
-rw-r--r--gst/effectv/gstrev.c111
-rw-r--r--gst/effectv/gstrev.h3
-rw-r--r--gst/effectv/gstripple.c164
-rw-r--r--gst/effectv/gstripple.h3
-rw-r--r--gst/effectv/gstshagadelic.c144
-rw-r--r--gst/effectv/gstshagadelic.h4
-rw-r--r--gst/effectv/gststreak.c128
-rw-r--r--gst/effectv/gststreak.h3
-rw-r--r--gst/effectv/gstvertigo.c146
-rw-r--r--gst/effectv/gstvertigo.h3
-rw-r--r--gst/effectv/gstwarp.c160
-rw-r--r--gst/effectv/gstwarp.h4
-rw-r--r--gst/equalizer/Makefile.am4
-rw-r--r--gst/equalizer/gstiirequalizer.c131
-rw-r--r--gst/equalizer/gstiirequalizer.h2
-rw-r--r--gst/equalizer/gstiirequalizer10bands.c38
-rw-r--r--gst/equalizer/gstiirequalizer3bands.c37
-rw-r--r--gst/equalizer/gstiirequalizernbands.c25
-rw-r--r--gst/flv/gstflvdemux.c605
-rw-r--r--gst/flv/gstflvdemux.h1
-rw-r--r--gst/flv/gstflvmux.c246
-rw-r--r--gst/flx/gstflxdec.c8
-rw-r--r--gst/goom/gstgoom.c279
-rw-r--r--gst/goom/gstgoom.h1
-rw-r--r--gst/goom2k1/gstgoom.c7
-rw-r--r--gst/icydemux/gsticydemux.c123
-rw-r--r--gst/id3demux/gstid3demux.c39
-rw-r--r--gst/imagefreeze/gstimagefreeze.c10
-rw-r--r--gst/interleave/deinterleave.c12
-rw-r--r--gst/interleave/interleave.c13
-rw-r--r--gst/isomp4/Makefile.am1
-rw-r--r--gst/isomp4/atoms.c116
-rw-r--r--gst/isomp4/atoms.h2
-rw-r--r--gst/isomp4/atomsrecovery.c9
-rw-r--r--gst/isomp4/gstqtmoovrecover.c25
-rw-r--r--gst/isomp4/gstqtmux.c287
-rw-r--r--gst/isomp4/gstqtmux.h1
-rw-r--r--gst/isomp4/gstqtmuxmap.c14
-rw-r--r--gst/isomp4/gstrtpxqtdepay.c102
-rw-r--r--gst/isomp4/gstrtpxqtdepay.h6
-rw-r--r--gst/isomp4/qtdemux.c861
-rw-r--r--gst/isomp4/qtdemux.h1
-rw-r--r--gst/isomp4/qtdemux_dump.c2
-rw-r--r--gst/law/alaw-decode.c131
-rw-r--r--gst/law/alaw-encode.c149
-rw-r--r--gst/law/alaw.c22
-rw-r--r--gst/law/mulaw-decode.c173
-rw-r--r--gst/law/mulaw-encode.c169
-rw-r--r--gst/law/mulaw.c22
-rw-r--r--gst/level/Makefile.am2
-rw-r--r--gst/level/gstlevel.c197
-rw-r--r--gst/level/gstlevel.h8
-rw-r--r--gst/matroska/ebml-read.c11
-rw-r--r--gst/matroska/ebml-read.h1
-rw-r--r--gst/matroska/ebml-write.c75
-rw-r--r--gst/matroska/matroska-demux.c817
-rw-r--r--gst/matroska/matroska-demux.h2
-rw-r--r--gst/matroska/matroska-ids.h8
-rw-r--r--gst/matroska/matroska-mux.c428
-rw-r--r--gst/matroska/matroska-mux.h3
-rw-r--r--gst/matroska/matroska-parse.c171
-rw-r--r--gst/matroska/matroska-read-common.c147
-rw-r--r--gst/matroska/matroska-read-common.h5
-rw-r--r--gst/matroska/webm-mux.c30
-rw-r--r--gst/median/gstmedian.c8
-rw-r--r--gst/monoscope/gstmonoscope.c7
-rw-r--r--gst/multifile/gstmultifilesink.c127
-rw-r--r--gst/multifile/gstmultifilesrc.c55
-rw-r--r--gst/multifile/gstsplitfilesrc.c57
-rw-r--r--gst/multipart/multipartdemux.c94
-rw-r--r--gst/multipart/multipartdemux.h2
-rw-r--r--gst/multipart/multipartmux.c133
-rw-r--r--gst/multipart/multipartmux.h1
-rw-r--r--gst/replaygain/Makefile.am2
-rw-r--r--gst/replaygain/gstrganalysis.c159
-rw-r--r--gst/replaygain/gstrglimiter.c61
-rw-r--r--gst/replaygain/gstrgvolume.c80
-rw-r--r--gst/rtp/Makefile.am3
-rw-r--r--gst/rtp/README4
-rw-r--r--gst/rtp/fnv1hash.h2
-rw-r--r--gst/rtp/gstasteriskh263.c78
-rw-r--r--gst/rtp/gstrtp.c4
-rw-r--r--gst/rtp/gstrtpL16depay.c74
-rw-r--r--gst/rtp/gstrtpL16depay.h6
-rw-r--r--gst/rtp/gstrtpL16pay.c84
-rw-r--r--gst/rtp/gstrtpL16pay.h6
-rw-r--r--gst/rtp/gstrtpac3depay.c99
-rw-r--r--gst/rtp/gstrtpac3depay.h6
-rw-r--r--gst/rtp/gstrtpac3pay.c92
-rw-r--r--gst/rtp/gstrtpac3pay.h6
-rw-r--r--gst/rtp/gstrtpamrdepay.c74
-rw-r--r--gst/rtp/gstrtpamrdepay.h6
-rw-r--r--gst/rtp/gstrtpamrpay.c94
-rw-r--r--gst/rtp/gstrtpamrpay.h6
-rw-r--r--gst/rtp/gstrtpbvdepay.c61
-rw-r--r--gst/rtp/gstrtpbvdepay.h6
-rw-r--r--gst/rtp/gstrtpbvpay.c78
-rw-r--r--gst/rtp/gstrtpbvpay.h6
-rw-r--r--gst/rtp/gstrtpceltdepay.c129
-rw-r--r--gst/rtp/gstrtpceltdepay.h6
-rw-r--r--gst/rtp/gstrtpceltpay.c104
-rw-r--r--gst/rtp/gstrtpceltpay.h6
-rw-r--r--gst/rtp/gstrtpdepay.c162
-rw-r--r--gst/rtp/gstrtpdepay.h55
-rw-r--r--gst/rtp/gstrtpdvdepay.c71
-rw-r--r--gst/rtp/gstrtpdvdepay.h6
-rw-r--r--gst/rtp/gstrtpdvpay.c95
-rw-r--r--gst/rtp/gstrtpdvpay.h6
-rw-r--r--gst/rtp/gstrtpg722depay.c66
-rw-r--r--gst/rtp/gstrtpg722depay.h6
-rw-r--r--gst/rtp/gstrtpg722pay.c74
-rw-r--r--gst/rtp/gstrtpg722pay.h6
-rw-r--r--gst/rtp/gstrtpg723depay.c75
-rw-r--r--gst/rtp/gstrtpg723depay.h6
-rw-r--r--gst/rtp/gstrtpg723pay.c74
-rw-r--r--gst/rtp/gstrtpg723pay.h6
-rw-r--r--gst/rtp/gstrtpg726depay.c100
-rw-r--r--gst/rtp/gstrtpg726depay.h6
-rw-r--r--gst/rtp/gstrtpg726pay.c87
-rw-r--r--gst/rtp/gstrtpg726pay.h6
-rw-r--r--gst/rtp/gstrtpg729depay.c76
-rw-r--r--gst/rtp/gstrtpg729depay.h6
-rw-r--r--gst/rtp/gstrtpg729pay.c106
-rw-r--r--gst/rtp/gstrtpg729pay.h6
-rw-r--r--gst/rtp/gstrtpgsmdepay.c64
-rw-r--r--gst/rtp/gstrtpgsmdepay.h6
-rw-r--r--gst/rtp/gstrtpgsmpay.c100
-rw-r--r--gst/rtp/gstrtpgsmpay.h6
-rw-r--r--gst/rtp/gstrtpgstdepay.c96
-rw-r--r--gst/rtp/gstrtpgstdepay.h6
-rw-r--r--gst/rtp/gstrtpgstpay.c96
-rw-r--r--gst/rtp/gstrtpgstpay.h6
-rw-r--r--gst/rtp/gstrtph263depay.c82
-rw-r--r--gst/rtp/gstrtph263depay.h6
-rw-r--r--gst/rtp/gstrtph263pay.c71
-rw-r--r--gst/rtp/gstrtph263pay.h8
-rw-r--r--gst/rtp/gstrtph263pdepay.c222
-rw-r--r--gst/rtp/gstrtph263pdepay.h6
-rw-r--r--gst/rtp/gstrtph263ppay.c92
-rw-r--r--gst/rtp/gstrtph263ppay.h6
-rw-r--r--gst/rtp/gstrtph264depay.c170
-rw-r--r--gst/rtp/gstrtph264depay.h6
-rw-r--r--gst/rtp/gstrtph264pay.c278
-rw-r--r--gst/rtp/gstrtph264pay.h6
-rw-r--r--gst/rtp/gstrtpilbcdepay.c68
-rw-r--r--gst/rtp/gstrtpilbcdepay.h6
-rw-r--r--gst/rtp/gstrtpilbcpay.c82
-rw-r--r--gst/rtp/gstrtpilbcpay.h6
-rw-r--r--gst/rtp/gstrtpj2kdepay.c120
-rw-r--r--gst/rtp/gstrtpj2kdepay.h6
-rw-r--r--gst/rtp/gstrtpj2kpay.c93
-rw-r--r--gst/rtp/gstrtpj2kpay.h6
-rw-r--r--gst/rtp/gstrtpjpegdepay.c76
-rw-r--r--gst/rtp/gstrtpjpegdepay.h6
-rw-r--r--gst/rtp/gstrtpjpegpay.c122
-rw-r--r--gst/rtp/gstrtpjpegpay.h6
-rw-r--r--gst/rtp/gstrtpmp1sdepay.c58
-rw-r--r--gst/rtp/gstrtpmp1sdepay.h6
-rw-r--r--gst/rtp/gstrtpmp2tdepay.c74
-rw-r--r--gst/rtp/gstrtpmp2tdepay.h6
-rw-r--r--gst/rtp/gstrtpmp2tpay.c73
-rw-r--r--gst/rtp/gstrtpmp2tpay.h6
-rw-r--r--gst/rtp/gstrtpmp4adepay.c91
-rw-r--r--gst/rtp/gstrtpmp4adepay.h6
-rw-r--r--gst/rtp/gstrtpmp4apay.c111
-rw-r--r--gst/rtp/gstrtpmp4apay.h6
-rw-r--r--gst/rtp/gstrtpmp4gdepay.c96
-rw-r--r--gst/rtp/gstrtpmp4gdepay.h6
-rw-r--r--gst/rtp/gstrtpmp4gpay.c103
-rw-r--r--gst/rtp/gstrtpmp4gpay.h6
-rw-r--r--gst/rtp/gstrtpmp4vdepay.c70
-rw-r--r--gst/rtp/gstrtpmp4vdepay.h6
-rw-r--r--gst/rtp/gstrtpmp4vpay.c159
-rw-r--r--gst/rtp/gstrtpmp4vpay.h6
-rw-r--r--gst/rtp/gstrtpmpadepay.c129
-rw-r--r--gst/rtp/gstrtpmpadepay.h6
-rw-r--r--gst/rtp/gstrtpmpapay.c89
-rw-r--r--gst/rtp/gstrtpmpapay.h6
-rw-r--r--gst/rtp/gstrtpmparobustdepay.c131
-rw-r--r--gst/rtp/gstrtpmparobustdepay.h6
-rw-r--r--gst/rtp/gstrtpmpvdepay.c59
-rw-r--r--gst/rtp/gstrtpmpvdepay.h6
-rw-r--r--gst/rtp/gstrtpmpvpay.c84
-rw-r--r--gst/rtp/gstrtpmpvpay.h6
-rw-r--r--gst/rtp/gstrtppcmadepay.c76
-rw-r--r--gst/rtp/gstrtppcmadepay.h6
-rw-r--r--gst/rtp/gstrtppcmapay.c56
-rw-r--r--gst/rtp/gstrtppcmapay.h6
-rw-r--r--gst/rtp/gstrtppcmudepay.c75
-rw-r--r--gst/rtp/gstrtppcmudepay.h6
-rw-r--r--gst/rtp/gstrtppcmupay.c56
-rw-r--r--gst/rtp/gstrtppcmupay.h6
-rw-r--r--gst/rtp/gstrtpqcelpdepay.c81
-rw-r--r--gst/rtp/gstrtpqcelpdepay.h6
-rw-r--r--gst/rtp/gstrtpqdmdepay.c83
-rw-r--r--gst/rtp/gstrtpqdmdepay.h6
-rw-r--r--gst/rtp/gstrtpsirendepay.c54
-rw-r--r--gst/rtp/gstrtpsirendepay.h6
-rw-r--r--gst/rtp/gstrtpsirenpay.c67
-rw-r--r--gst/rtp/gstrtpsirenpay.h6
-rw-r--r--gst/rtp/gstrtpspeexdepay.c81
-rw-r--r--gst/rtp/gstrtpspeexdepay.h6
-rw-r--r--gst/rtp/gstrtpspeexpay.c99
-rw-r--r--gst/rtp/gstrtpspeexpay.h6
-rw-r--r--gst/rtp/gstrtpsv3vdepay.c84
-rw-r--r--gst/rtp/gstrtpsv3vdepay.h6
-rw-r--r--gst/rtp/gstrtptheoradepay.c143
-rw-r--r--gst/rtp/gstrtptheoradepay.h6
-rw-r--r--gst/rtp/gstrtptheorapay.c148
-rw-r--r--gst/rtp/gstrtptheorapay.h6
-rw-r--r--gst/rtp/gstrtpvorbisdepay.c124
-rw-r--r--gst/rtp/gstrtpvorbisdepay.h6
-rw-r--r--gst/rtp/gstrtpvorbispay.c137
-rw-r--r--gst/rtp/gstrtpvorbispay.h6
-rw-r--r--gst/rtp/gstrtpvrawdepay.c305
-rw-r--r--gst/rtp/gstrtpvrawdepay.h15
-rw-r--r--gst/rtp/gstrtpvrawpay.c370
-rw-r--r--gst/rtp/gstrtpvrawpay.h17
-rw-r--r--gst/rtpmanager/Makefile.am4
-rw-r--r--gst/rtpmanager/gstrtpbin.c180
-rw-r--r--gst/rtpmanager/gstrtpjitterbuffer.c350
-rw-r--r--gst/rtpmanager/gstrtpmanager.c13
-rw-r--r--gst/rtpmanager/gstrtpptdemux.c93
-rw-r--r--gst/rtpmanager/gstrtpsession.c301
-rw-r--r--gst/rtpmanager/gstrtpssrcdemux.c189
-rw-r--r--gst/rtpmanager/rtpjitterbuffer.c24
-rw-r--r--gst/rtpmanager/rtpsession.c148
-rw-r--r--gst/rtpmanager/rtpsession.h1
-rw-r--r--gst/rtpmanager/rtpsource.c89
-rw-r--r--gst/rtpmanager/rtpsource.h2
-rw-r--r--gst/rtpmanager/rtpstats.h2
-rw-r--r--gst/rtsp/gstrtpdec.c107
-rw-r--r--gst/rtsp/gstrtspsrc.c267
-rw-r--r--gst/rtsp/gstrtspsrc.h4
-rw-r--r--gst/shapewipe/Makefile.am4
-rw-r--r--gst/shapewipe/gstshapewipe.c532
-rw-r--r--gst/shapewipe/gstshapewipe.h3
-rw-r--r--gst/smpte/Makefile.am5
-rw-r--r--gst/smpte/gstsmpte.c16
-rw-r--r--gst/smpte/gstsmptealpha.c15
-rw-r--r--gst/spectrum/gstspectrum.c291
-rw-r--r--gst/udp/Makefile.am5
-rw-r--r--gst/udp/gstdynudpsink.c85
-rw-r--r--gst/udp/gstmultiudpsink.c220
-rw-r--r--gst/udp/gstudp.c9
-rw-r--r--gst/udp/gstudpsink.c90
-rw-r--r--gst/udp/gstudpsrc.c108
-rw-r--r--gst/videobox/Makefile.am2
-rw-r--r--gst/videobox/gstvideobox.c14
-rw-r--r--gst/videocrop/Makefile.am2
-rw-r--r--gst/videocrop/gstaspectratiocrop.c147
-rw-r--r--gst/videocrop/gstaspectratiocrop.h1
-rw-r--r--gst/videocrop/gstvideocrop.c299
-rw-r--r--gst/videocrop/gstvideocrop.h11
-rw-r--r--gst/videofilter/Makefile.am4
-rw-r--r--gst/videofilter/gstgamma.c178
-rw-r--r--gst/videofilter/gstgamma.h7
-rw-r--r--gst/videofilter/gstvideobalance.c285
-rw-r--r--gst/videofilter/gstvideobalance.h7
-rw-r--r--gst/videofilter/gstvideoflip.c378
-rw-r--r--gst/videofilter/gstvideoflip.h7
-rw-r--r--gst/videofilter/plugin.c3
-rw-r--r--gst/videomixer/Makefile.am4
-rw-r--r--gst/videomixer/videomixer.c17
-rw-r--r--gst/videomixer/videomixer2.c10
-rw-r--r--gst/wavenc/Makefile.am1
-rw-r--r--gst/wavenc/gstwavenc.c153
-rw-r--r--gst/wavparse/gstwavparse.c432
-rw-r--r--gst/wavparse/gstwavparse.h4
-rw-r--r--gst/y4m/Makefile.am2
-rw-r--r--gst/y4m/gsty4mencode.c216
-rw-r--r--gst/y4m/gsty4mencode.h8
-rw-r--r--m4/Makefile.am3
-rw-r--r--m4/as-arts.m4209
-rw-r--r--m4/esd.m4202
-rw-r--r--m4/gconf-2.m440
-rw-r--r--po/POTFILES.in7
-rw-r--r--po/af.po119
-rw-r--r--po/az.po119
-rw-r--r--po/bg.po134
-rw-r--r--po/ca.po117
-rw-r--r--po/cs.po130
-rw-r--r--po/da.po132
-rw-r--r--po/de.po153
-rw-r--r--po/el.po132
-rw-r--r--po/en_GB.po119
-rw-r--r--po/es.po152
-rw-r--r--po/eu.po138
-rw-r--r--po/fi.po130
-rw-r--r--po/fr.po147
-rw-r--r--po/gl.po150
-rw-r--r--po/hu.po138
-rw-r--r--po/id.po146
-rw-r--r--po/it.po136
-rw-r--r--po/ja.po144
-rw-r--r--po/lt.po132
-rw-r--r--po/lv.po133
-rw-r--r--po/mt.po146
-rw-r--r--po/nb.po128
-rw-r--r--po/nl.po135
-rw-r--r--po/or.po119
-rw-r--r--po/pl.po137
-rw-r--r--po/pt_BR.po142
-rw-r--r--po/ro.po141
-rw-r--r--po/ru.po144
-rw-r--r--po/sk.po148
-rw-r--r--po/sl.po136
-rw-r--r--po/sq.po119
-rw-r--r--po/sr.po119
-rw-r--r--po/sv.po145
-rw-r--r--po/tr.po146
-rw-r--r--po/uk.po147
-rw-r--r--po/vi.po138
-rw-r--r--po/zh_CN.po139
-rw-r--r--po/zh_HK.po117
-rw-r--r--po/zh_TW.po117
-rw-r--r--sys/directsound/gstdirectsoundsink.c9
-rw-r--r--sys/oss/gstosshelper.c37
-rw-r--r--sys/oss/gstossmixer.h14
-rw-r--r--sys/oss/gstosssink.c20
-rw-r--r--sys/oss/gstosssrc.c19
-rw-r--r--sys/oss4/oss4-mixer-slider.c4
-rw-r--r--sys/oss4/oss4-mixer.c22
-rw-r--r--sys/oss4/oss4-sink.c1
-rw-r--r--sys/oss4/oss4-source.c15
-rw-r--r--sys/osxaudio/gstosxaudioelement.c8
-rw-r--r--sys/osxaudio/gstosxaudiosink.c3
-rw-r--r--sys/osxaudio/gstosxaudiosrc.c3
-rw-r--r--sys/osxvideo/osxvideosink.m4
-rw-r--r--sys/sunaudio/gstsunaudiomixerctrl.h20
-rw-r--r--sys/sunaudio/gstsunaudiosink.c4
-rw-r--r--sys/sunaudio/gstsunaudiosrc.c4
-rw-r--r--sys/v4l2/Makefile.am13
-rw-r--r--sys/v4l2/gstv4l2.c8
-rw-r--r--sys/v4l2/gstv4l2bufferpool.c1360
-rw-r--r--sys/v4l2/gstv4l2bufferpool.h89
-rw-r--r--sys/v4l2/gstv4l2colorbalance.c14
-rw-r--r--sys/v4l2/gstv4l2colorbalance.h12
-rw-r--r--sys/v4l2/gstv4l2object.c893
-rw-r--r--sys/v4l2/gstv4l2object.h80
-rw-r--r--sys/v4l2/gstv4l2radio.c127
-rw-r--r--sys/v4l2/gstv4l2sink.c536
-rw-r--r--sys/v4l2/gstv4l2sink.h6
-rw-r--r--sys/v4l2/gstv4l2src.c672
-rw-r--r--sys/v4l2/gstv4l2src.h21
-rw-r--r--sys/v4l2/gstv4l2tuner.c1
-rw-r--r--sys/v4l2/gstv4l2tuner.h20
-rw-r--r--sys/v4l2/gstv4l2videooverlay.c (renamed from sys/v4l2/gstv4l2xoverlay.c)50
-rw-r--r--sys/v4l2/gstv4l2videooverlay.h (renamed from sys/v4l2/gstv4l2xoverlay.h)39
-rw-r--r--sys/v4l2/gstv4l2vidorient.c3
-rw-r--r--sys/v4l2/gstv4l2vidorient.h22
-rw-r--r--sys/v4l2/v4l2_calls.c7
-rw-r--r--sys/v4l2/v4l2_calls.h8
-rw-r--r--sys/v4l2/v4l2src_calls.c434
-rw-r--r--sys/v4l2/v4l2src_calls.h46
-rw-r--r--sys/waveform/gstwaveformsink.c4
-rw-r--r--sys/ximage/gstximagesrc.c126
-rw-r--r--sys/ximage/gstximagesrc.h2
-rw-r--r--sys/ximage/ximageutil.c178
-rw-r--r--sys/ximage/ximageutil.h30
-rw-r--r--tests/check/Makefile.am27
-rw-r--r--tests/check/elements/alphacolor.c54
-rw-r--r--tests/check/elements/aspectratiocrop.c79
-rw-r--r--tests/check/elements/audioamplify.c136
-rw-r--r--tests/check/elements/audiochebband.c269
-rw-r--r--tests/check/elements/audiocheblimit.c197
-rw-r--r--tests/check/elements/audiodynamic.c103
-rw-r--r--tests/check/elements/audioecho.c66
-rw-r--r--tests/check/elements/audioinvert.c29
-rw-r--r--tests/check/elements/audiopanorama.c220
-rw-r--r--tests/check/elements/audiowsincband.c4
-rw-r--r--tests/check/elements/audiowsinclimit.c4
-rw-r--r--tests/check/elements/autodetect.c30
-rw-r--r--tests/check/elements/avimux.c6
-rw-r--r--tests/check/elements/avisubtitle.c16
-rw-r--r--tests/check/elements/capssetter.c4
-rw-r--r--tests/check/elements/cmmldec.c42
-rw-r--r--tests/check/elements/cmmlenc.c37
-rw-r--r--tests/check/elements/equalizer.c4
-rw-r--r--tests/check/elements/icydemux.c2
-rw-r--r--tests/check/elements/id3demux.c23
-rw-r--r--tests/check/elements/interleave.c36
-rw-r--r--tests/check/elements/jpegenc.c4
-rw-r--r--tests/check/elements/level.c23
-rw-r--r--tests/check/elements/matroskamux.c66
-rw-r--r--tests/check/elements/parser.c41
-rw-r--r--tests/check/elements/qtmux.c57
-rw-r--r--tests/check/elements/rganalysis.c4
-rw-r--r--tests/check/elements/rglimiter.c4
-rw-r--r--tests/check/elements/rgvolume.c4
-rw-r--r--tests/check/elements/rtp-payloading.c2
-rw-r--r--tests/check/elements/rtpbin.c16
-rw-r--r--tests/check/elements/rtpjitterbuffer.c8
-rw-r--r--tests/check/elements/souphttpsrc.c1
-rw-r--r--tests/check/elements/spectrum.c110
-rw-r--r--tests/check/elements/videofilter.c4
-rw-r--r--tests/check/elements/y4menc.c4
-rw-r--r--tests/examples/level/level-example.c2
-rw-r--r--tests/examples/pulse/Makefile.am2
-rw-r--r--tests/examples/rtp/client-PCMA.c2
-rwxr-xr-xtests/examples/rtp/client-PCMA.py4
-rw-r--r--tests/examples/rtp/server-alsasrc-PCMA.c4
-rwxr-xr-xtests/examples/rtp/server-alsasrc-PCMA.py4
-rw-r--r--tests/examples/shapewipe/shapewipe-example.c11
-rw-r--r--tests/examples/spectrum/spectrum-example.c2
-rw-r--r--tests/examples/v4l2/Makefile.am2
-rw-r--r--tests/examples/v4l2/camctrl.c16
-rw-r--r--tests/icles/Makefile.am6
-rw-r--r--tests/icles/gdkpixbufsink-test.c19
-rw-r--r--tests/icles/v4l2src-test.c4
-rw-r--r--tests/icles/videocrop-test.c6
602 files changed, 22933 insertions, 29025 deletions
diff --git a/Makefile.am b/Makefile.am
index fb78f5d65..0119fad4c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
diff --git a/REQUIREMENTS b/REQUIREMENTS
index 2b9b535bf..ddae38a47 100644
--- a/REQUIREMENTS
+++ b/REQUIREMENTS
@@ -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
-Subproject 11f0cd5a3fba36f85cf3e434150bfe66b1bf08d
+Subproject 762b6927ffdd1726cb4f4783f49b5cfaa9edd94
diff --git a/configure.ac b/configure.ac
index f8a3f93fe..d7777b6dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
@@ -219,6 +215,7 @@ AG_GST_CHECK_GST($GST_MAJORMINOR, [$GST_REQ], yes)
AG_GST_CHECK_GST_BASE($GST_MAJORMINOR, [$GST_REQ], yes)
AG_GST_CHECK_GST_GDP($GST_MAJORMINOR, [$GST_REQ], yes)
AG_GST_CHECK_GST_CONTROLLER($GST_MAJORMINOR, [$GST_REQ], yes)
+AG_GST_CHECK_GST_NET($GST_MAJORMINOR, [$GST_REQ], yes)
AG_GST_CHECK_GST_CHECK($GST_MAJORMINOR, [$GST_REQ], no)
AG_GST_CHECK_GST_PLUGINS_BASE($GST_MAJORMINOR, [$GSTPB_REQ], yes)
@@ -267,19 +264,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
@@ -328,9 +312,19 @@ 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 \
+ imagefreeze interleave monoscope smpte \
+ videobox videomixer \
+ cairo cairo_gobject dv1394 gdk_pixbuf libdv libpng \
+ oss oss4 shout2 \
+ taglib wavpack \
+ osx_video osx_audio "
+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)
@@ -344,13 +338,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)
@@ -368,6 +362,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)
@@ -737,41 +732,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, [
@@ -835,15 +807,7 @@ AG_GST_CHECK_FEATURE(PULSE, [pulseaudio plug-in], pulseaudio, [
dnl used in ext/pulse/pulseutil.c
AC_CHECK_HEADERS([process.h])
- AG_GST_PKG_CHECK_MODULES(PULSE, libpulse >= 0.9.16)
- AG_GST_PKG_CHECK_MODULES(PULSE_0_9_20, libpulse >= 0.9.20)
- if test x$HAVE_PULSE_0_9_20 = xyes; then
- AC_DEFINE(HAVE_PULSE_0_9_20, 1, [defined if pulseaudio >= 0.9.20 is available])
- fi
- AG_GST_PKG_CHECK_MODULES(PULSE_1_0, libpulse >= 0.98)
- if test x$HAVE_PULSE_1_0 = xyes; then
- AC_DEFINE(HAVE_PULSE_1_0, 1, [defined if pulseaudio >= 1.0 is available])
- fi
+ AG_GST_PKG_CHECK_MODULES(PULSE, libpulse >= 1.0)
])
dnl *** dv1394 ***
@@ -1023,13 +987,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)
@@ -1092,6 +1052,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)
@@ -1161,11 +1122,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
@@ -1203,8 +1161,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
@@ -1248,7 +1204,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\"/" \
diff --git a/docs/plugins/Makefile.am b/docs/plugins/Makefile.am
index 1fc2e07ff..683475bdc 100644
--- a/docs/plugins/Makefile.am
+++ b/docs/plugins/Makefile.am
@@ -61,17 +61,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 \
diff --git a/docs/plugins/gst-plugins-good-plugins-docs.sgml b/docs/plugins/gst-plugins-good-plugins-docs.sgml
index 9f65e21eb..7d93c2a7a 100644
--- a/docs/plugins/gst-plugins-good-plugins-docs.sgml
+++ b/docs/plugins/gst-plugins-good-plugins-docs.sgml
@@ -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" />
@@ -81,18 +80,9 @@
<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/element-gstrtpbin.xml" />
- <xi:include href="xml/element-gstrtpjitterbuffer.xml" />
- <xi:include href="xml/element-gstrtpptdemux.xml" />
- <xi:include href="xml/element-gstrtpsession.xml" />
- <xi:include href="xml/element-gstrtpssrcdemux.xml" />
<xi:include href="xml/element-halaudiosink.xml" />
<xi:include href="xml/element-halaudiosrc.xml" />
<xi:include href="xml/element-hdv1394src.xml" />
@@ -150,6 +140,11 @@
<xi:include href="xml/element-rtpj2kpay.xml" />
<xi:include href="xml/element-rtpjpegpay.xml" />
<xi:include href="xml/element-rtspsrc.xml" />
+ <xi:include href="xml/element-rtpbin.xml" />
+ <xi:include href="xml/element-rtpjitterbuffer.xml" />
+ <xi:include href="xml/element-rtpptdemux.xml" />
+ <xi:include href="xml/element-rtpsession.xml" />
+ <xi:include href="xml/element-rtpssrcdemux.xml" />
<xi:include href="xml/element-shagadelictv.xml" />
<xi:include href="xml/element-shapewipe.xml" />
<xi:include href="xml/element-smokedec.xml" />
@@ -210,11 +205,9 @@
<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" />
@@ -241,7 +234,7 @@
<xi:include href="xml/plugin-pulseaudio.xml" />
<xi:include href="xml/plugin-replaygain.xml" />
<xi:include href="xml/plugin-rtp.xml" />
- <xi:include href="xml/plugin-gstrtpmanager.xml" />
+ <xi:include href="xml/plugin-rtpmanager.xml" />
<xi:include href="xml/plugin-rtsp.xml" />
<xi:include href="xml/plugin-shapewipe.xml" />
<xi:include href="xml/plugin-shout2send.xml" />
diff --git a/docs/plugins/gst-plugins-good-plugins-sections.txt b/docs/plugins/gst-plugins-good-plugins-sections.txt
index 0f03971e7..bd6f3a787 100644
--- a/docs/plugins/gst-plugins-good-plugins-sections.txt
+++ b/docs/plugins/gst-plugins-good-plugins-sections.txt
@@ -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
@@ -1027,8 +957,8 @@ GST_IS_GOOM_CLASS
</SECTION>
<SECTION>
-<FILE>element-gstrtpbin</FILE>
-<TITLE>gstrtpbin</TITLE>
+<FILE>element-rtpbin</FILE>
+<TITLE>rtpbin</TITLE>
GstRtpBin
<SUBSECTION Standard>
GstRtpBinPrivate
@@ -1042,8 +972,8 @@ GST_IS_RTP_BIN_CLASS
</SECTION>
<SECTION>
-<FILE>element-gstrtpjitterbuffer</FILE>
-<TITLE>gstrtpjitterbuffer</TITLE>
+<FILE>element-rtpjitterbuffer</FILE>
+<TITLE>rtpjitterbuffer</TITLE>
GstRtpJitterBuffer
<SUBSECTION Standard>
GstRtpJitterBufferClass
@@ -1057,8 +987,8 @@ GST_IS_RTP_JITTER_BUFFER_CLASS
</SECTION>
<SECTION>
-<FILE>element-gstrtpptdemux</FILE>
-<TITLE>gstrtpptdemux</TITLE>
+<FILE>element-rtpptdemux</FILE>
+<TITLE>rtpptdemux</TITLE>
GstRtpPtDemux
<SUBSECTION Standard>
GstRtpPtDemuxClass
@@ -1072,8 +1002,8 @@ GST_IS_RTP_PT_DEMUX_CLASS
</SECTION>
<SECTION>
-<FILE>element-gstrtpsession</FILE>
-<TITLE>gstrtpsession</TITLE>
+<FILE>element-rtpsession</FILE>
+<TITLE>rtpsession</TITLE>
GstRtpSession
<SUBSECTION Standard>
GstRtpSessionClass
@@ -1088,8 +1018,8 @@ GST_RTP_SESSION_CAST
</SECTION>
<SECTION>
-<FILE>element-gstrtpssrcdemux</FILE>
-<TITLE>gstrtpssrcdemux</TITLE>
+<FILE>element-rtpssrcdemux</FILE>
+<TITLE>rtpssrcdemux</TITLE>
GstRtpSsrcDemux
<SUBSECTION Standard>
GstRtpSsrcDemuxClass
diff --git a/docs/plugins/inspect/plugin-esdsink.xml b/docs/plugins/inspect/plugin-esdsink.xml
deleted file mode 100644
index 4508ffd70..000000000
--- a/docs/plugins/inspect/plugin-esdsink.xml
+++ /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> \ No newline at end of file
diff --git a/docs/plugins/inspect/plugin-gconfelements.xml b/docs/plugins/inspect/plugin-gconfelements.xml
deleted file mode 100644
index d7e6e2945..000000000
--- a/docs/plugins/inspect/plugin-gconfelements.xml
+++ /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> \ No newline at end of file
diff --git a/docs/plugins/inspect/plugin-gstrtpmanager.xml b/docs/plugins/inspect/plugin-rtpmanager.xml
index b72b3e704..56adfdcfb 100644
--- a/docs/plugins/inspect/plugin-gstrtpmanager.xml
+++ b/docs/plugins/inspect/plugin-rtpmanager.xml
@@ -1,5 +1,5 @@
<plugin>
- <name>gstrtpmanager</name>
+ <name>rtpmanager</name>
<description>RTP session management plugin library</description>
<filename>../../gst/rtpmanager/.libs/libgstrtpmanager.so</filename>
<basename>libgstrtpmanager.so</basename>
@@ -10,7 +10,7 @@
<origin>Unknown package origin</origin>
<elements>
<element>
- <name>gstrtpbin</name>
+ <name>rtpbin</name>
<longname>RTP Bin</longname>
<class>Filter/Network/RTP</class>
<description>Real-Time Transport Protocol bin</description>
@@ -55,7 +55,7 @@
</pads>
</element>
<element>
- <name>gstrtpjitterbuffer</name>
+ <name>rtpjitterbuffer</name>
<longname>RTP packet jitter-buffer</longname>
<class>Filter/Network/RTP</class>
<description>A buffer that deals with network jitter and other transmission faults</description>
@@ -82,7 +82,7 @@
</pads>
</element>
<element>
- <name>gstrtpptdemux</name>
+ <name>rtpptdemux</name>
<longname>RTP Demux</longname>
<class>Demux/Network/RTP</class>
<description>Parses codec streams transmitted in the same RTP session</description>
@@ -103,7 +103,7 @@
</pads>
</element>
<element>
- <name>gstrtpsession</name>
+ <name>rtpsession</name>
<longname>RTP Session</longname>
<class>Filter/Network/RTP</class>
<description>Implement an RTP session</description>
@@ -154,7 +154,7 @@
</pads>
</element>
<element>
- <name>gstrtpssrcdemux</name>
+ <name>rtpssrcdemux</name>
<longname>RTP SSRC Demux</longname>
<class>Demux/Network/RTP</class>
<description>Splits RTP streams based on the SSRC</description>
@@ -187,4 +187,4 @@
</pads>
</element>
</elements>
-</plugin> \ No newline at end of file
+</plugin>
diff --git a/ext/Makefile.am b/ext/Makefile.am
index 409408ea8..791fe0025 100644
--- a/ext/Makefile.am
+++ b/ext/Makefile.am
@@ -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 \
diff --git a/ext/aalib/Makefile.am b/ext/aalib/Makefile.am
index 5820b2431..894170419 100644
--- a/ext/aalib/Makefile.am
+++ b/ext/aalib/Makefile.am
@@ -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
diff --git a/ext/aalib/gstaasink.c b/ext/aalib/gstaasink.c
index 2909dde18..62a885b6e 100644
--- a/ext/aalib/gstaasink.c
+++ b/ext/aalib/gstaasink.c
@@ -41,45 +41,39 @@
#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,
+static void gst_aasink_fixate (GstBaseSink * bsink, GstCaps * caps);
+static gboolean gst_aasink_setcaps (GstBaseSink * bsink, GstCaps * caps);
+static void gst_aasink_get_times (GstBaseSink * bsink, GstBuffer * buffer,
GstClockTime * start, GstClockTime * end);
static GstFlowReturn gst_aasink_render (GstBaseSink * basesink,
GstBuffer * buffer);
@@ -92,33 +86,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 +155,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_static_pad_template (element_class,
- &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,58 +165,55 @@ 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);
+ gstbasesink_class->fixate = GST_DEBUG_FUNCPTR (gst_aasink_fixate);
gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_aasink_setcaps);
gstbasesink_class->get_times = GST_DEBUG_FUNCPTR (gst_aasink_get_times);
gstbasesink_class->preroll = GST_DEBUG_FUNCPTR (gst_aasink_render);
@@ -267,7 +221,7 @@ gst_aasink_class_init (GstAASinkClass * klass)
}
static void
-gst_aasink_fixate (GstPad * pad, GstCaps * caps)
+gst_aasink_fixate (GstBaseSink * bsink, GstCaps * caps)
{
GstStructure *structure;
@@ -276,40 +230,36 @@ gst_aasink_fixate (GstPad * pad, GstCaps * caps)
gst_structure_fixate_field_nearest_int (structure, "width", 320);
gst_structure_fixate_field_nearest_int (structure, "height", 240);
gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1);
+
+ GST_BASE_SINK_CLASS (parent_class)->fixate (bsink, caps);
}
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);
+ if (!gst_video_info_from_caps (&info, caps))
+ goto invalid_caps;
- /* 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));
-
- 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
gst_aasink_init (GstAASink * aasink)
{
- GstPad *pad;
-
- pad = GST_BASE_SINK_PAD (aasink);
- gst_pad_set_fixatecaps_function (pad, gst_aasink_fixate);
-
memcpy (&aasink->ascii_surf, &aa_defparams,
sizeof (struct aa_hardware_params));
aasink->ascii_parms.bright = 0;
@@ -319,10 +269,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 +313,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 +341,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 +363,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 +411,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;
}
diff --git a/ext/aalib/gstaasink.h b/ext/aalib/gstaasink.h
index 03bd2ea48..e36e2a6b7 100644
--- a/ext/aalib/gstaasink.h
+++ b/ext/aalib/gstaasink.h
@@ -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/annodex/gstannodex.c b/ext/annodex/gstannodex.c
index 05e10c8e4..789091cfe 100644
--- a/ext/annodex/gstannodex.c
+++ b/ext/annodex/gstannodex.c
@@ -26,6 +26,8 @@
#endif
#include <math.h>
+#include <string.h>
+
#include <gst/tag/tag.h>
#include "gstannodex.h"
#include "gstcmmlparser.h"
diff --git a/ext/annodex/gstcmmldec.c b/ext/annodex/gstcmmldec.c
index 695e99251..050224ae5 100644
--- a/ext/annodex/gstcmmldec.c
+++ b/ext/annodex/gstcmmldec.c
@@ -83,28 +83,34 @@ GST_STATIC_PAD_TEMPLATE ("sink",
);
/* GstCmmlDec */
-GST_BOILERPLATE (GstCmmlDec, gst_cmml_dec, GstElement, GST_TYPE_ELEMENT);
+#define gst_cmml_dec_parent_class parent_class
+G_DEFINE_TYPE (GstCmmlDec, gst_cmml_dec, GST_TYPE_ELEMENT);
+
static void gst_cmml_dec_get_property (GObject * dec, guint property_id,
GValue * value, GParamSpec * pspec);
static void gst_cmml_dec_set_property (GObject * dec, guint property_id,
const GValue * value, GParamSpec * pspec);
-static const GstQueryType *gst_cmml_dec_query_types (GstPad * pad);
-static gboolean gst_cmml_dec_sink_query (GstPad * pad, GstQuery * query);
-static gboolean gst_cmml_dec_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_cmml_dec_sink_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
+static gboolean gst_cmml_dec_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static gboolean gst_cmml_dec_convert (GstPad * pad, GstFormat src_fmt,
gint64 src_val, GstFormat * dest_fmt, gint64 * dest_val);
static GstStateChangeReturn gst_cmml_dec_change_state (GstElement * element,
GstStateChange transition);
-static GstFlowReturn gst_cmml_dec_chain (GstPad * pad, GstBuffer * buffer);
+static GstFlowReturn gst_cmml_dec_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
static GstCmmlPacketType gst_cmml_dec_parse_packet_type (GstCmmlDec * dec,
- GstBuffer * buffer);
-static void gst_cmml_dec_parse_ident_header (GstCmmlDec * dec, GstBuffer * buf);
-static void gst_cmml_dec_parse_first_header (GstCmmlDec * dec, GstBuffer * buf);
-static void gst_cmml_dec_parse_preamble (GstCmmlDec * dec,
- guchar * preamble, guchar * cmml_root_element);
-static void gst_cmml_dec_parse_xml (GstCmmlDec * dec,
- guchar * data, guint size);
+ gchar * data, gsize size);
+static void gst_cmml_dec_parse_ident_header (GstCmmlDec * dec, guint8 * data,
+ gsize size);
+static void gst_cmml_dec_parse_first_header (GstCmmlDec * dec, guint8 * data,
+ gsize size);
+static void gst_cmml_dec_parse_preamble (GstCmmlDec * dec, guchar * preamble,
+ guchar * cmml_root_element);
+static void gst_cmml_dec_parse_xml (GstCmmlDec * dec, guchar * data,
+ guint size);
static void gst_cmml_dec_parse_head (GstCmmlDec * dec, GstCmmlTagHead * head);
static void gst_cmml_dec_parse_clip (GstCmmlDec * dec, GstCmmlTagClip * clip);
@@ -117,45 +123,39 @@ static void gst_cmml_dec_send_clip_tag (GstCmmlDec * dec,
static void gst_cmml_dec_finalize (GObject * object);
static void
-gst_cmml_dec_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_cmml_dec_sink_factory);
- gst_element_class_add_static_pad_template (element_class,
- &gst_cmml_dec_src_factory);
- gst_element_class_set_details_simple (element_class, "CMML stream decoder",
- "Codec/Decoder",
- "Decodes CMML streams", "Alessandro Decina <alessandro@nnva.org>");
-}
-
-static void
-gst_cmml_dec_class_init (GstCmmlDecClass * dec_class)
+gst_cmml_dec_class_init (GstCmmlDecClass * klass)
{
- GObjectClass *klass = G_OBJECT_CLASS (dec_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- GST_ELEMENT_CLASS (klass)->change_state = gst_cmml_dec_change_state;
+ object_class->set_property = gst_cmml_dec_set_property;
+ object_class->get_property = gst_cmml_dec_get_property;
+ object_class->finalize = gst_cmml_dec_finalize;
- klass->set_property = gst_cmml_dec_set_property;
- klass->get_property = gst_cmml_dec_get_property;
- klass->finalize = gst_cmml_dec_finalize;
-
- g_object_class_install_property (klass, GST_CMML_DEC_WAIT_CLIP_END,
+ g_object_class_install_property (object_class, GST_CMML_DEC_WAIT_CLIP_END,
g_param_spec_boolean ("wait-clip-end-time",
"Wait clip end time",
"Send a tag for a clip when the clip ends, setting its end-time. "
"Use when you need to know both clip's start-time and end-time.",
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ element_class->change_state = gst_cmml_dec_change_state;
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cmml_dec_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cmml_dec_src_factory));
+ gst_element_class_set_details_simple (element_class, "CMML stream decoder",
+ "Codec/Decoder",
+ "Decodes CMML streams", "Alessandro Decina <alessandro@nnva.org>");
}
static void
-gst_cmml_dec_init (GstCmmlDec * dec, GstCmmlDecClass * klass)
+gst_cmml_dec_init (GstCmmlDec * dec)
{
dec->sinkpad =
gst_pad_new_from_static_template (&gst_cmml_dec_sink_factory, "sink");
gst_pad_set_chain_function (dec->sinkpad, gst_cmml_dec_chain);
- gst_pad_set_query_type_function (dec->sinkpad, gst_cmml_dec_query_types);
gst_pad_set_query_function (dec->sinkpad, gst_cmml_dec_sink_query);
gst_pad_set_event_function (dec->sinkpad, gst_cmml_dec_sink_event);
gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
@@ -240,7 +240,7 @@ gst_cmml_dec_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_READY:
@@ -255,19 +255,8 @@ gst_cmml_dec_change_state (GstElement * element, GstStateChange transition)
return res;
}
-static const GstQueryType *
-gst_cmml_dec_query_types (GstPad * pad)
-{
- static const GstQueryType query_types[] = {
- GST_QUERY_CONVERT,
- 0
- };
-
- return query_types;
-}
-
static gboolean
-gst_cmml_dec_sink_query (GstPad * pad, GstQuery * query)
+gst_cmml_dec_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
gboolean res = FALSE;
@@ -319,9 +308,9 @@ gst_cmml_dec_convert (GstPad * pad,
}
static gboolean
-gst_cmml_dec_sink_event (GstPad * pad, GstEvent * event)
+gst_cmml_dec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
- GstCmmlDec *dec = GST_CMML_DEC (GST_PAD_PARENT (pad));
+ GstCmmlDec *dec = GST_CMML_DEC (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
@@ -361,16 +350,20 @@ gst_cmml_dec_sink_event (GstPad * pad, GstEvent * event)
break;
}
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
}
static GstFlowReturn
-gst_cmml_dec_chain (GstPad * pad, GstBuffer * buffer)
+gst_cmml_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
- GstCmmlDec *dec = GST_CMML_DEC (GST_PAD_PARENT (pad));
+ GstCmmlDec *dec = GST_CMML_DEC (parent);
GstCmmlPacketType packet;
+ guint8 *data;
+ gsize size;
+
+ data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
- if (GST_BUFFER_SIZE (buffer) == 0) {
+ if (size == 0) {
/* the EOS page could be empty */
dec->flow_return = GST_FLOW_OK;
goto done;
@@ -381,25 +374,24 @@ gst_cmml_dec_chain (GstPad * pad, GstBuffer * buffer)
dec->granulerate_n, dec->granulerate_d, dec->granuleshift);
/* identify the packet type */
- packet = gst_cmml_dec_parse_packet_type (dec, buffer);
+ packet = gst_cmml_dec_parse_packet_type (dec, (gchar *) data, size);
/* handle the packet. the handler will set dec->flow_return */
switch (packet) {
case GST_CMML_PACKET_IDENT_HEADER:
if (dec->sent_root == FALSE)
/* don't parse the ident again in case of seeking to the beginning */
- gst_cmml_dec_parse_ident_header (dec, buffer);
+ gst_cmml_dec_parse_ident_header (dec, data, size);
break;
case GST_CMML_PACKET_FIRST_HEADER:
if (dec->sent_root == FALSE)
/* don't parse the xml preamble if it has already been parsed because it
* would error out, so seeking to the beginning would fail */
- gst_cmml_dec_parse_first_header (dec, buffer);
+ gst_cmml_dec_parse_first_header (dec, data, size);
break;
case GST_CMML_PACKET_SECOND_HEADER:
case GST_CMML_PACKET_CLIP:
- gst_cmml_dec_parse_xml (dec,
- GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
+ gst_cmml_dec_parse_xml (dec, data, size);
break;
case GST_CMML_PACKET_UNKNOWN:
default:
@@ -408,18 +400,18 @@ gst_cmml_dec_chain (GstPad * pad, GstBuffer * buffer)
}
done:
+ gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
+
return dec->flow_return;
}
/* finds the packet type of the buffer
*/
static GstCmmlPacketType
-gst_cmml_dec_parse_packet_type (GstCmmlDec * dec, GstBuffer * buffer)
+gst_cmml_dec_parse_packet_type (GstCmmlDec * dec, gchar * data, gsize size)
{
GstCmmlPacketType packet_type = GST_CMML_PACKET_UNKNOWN;
- gchar *data = (gchar *) GST_BUFFER_DATA (buffer);
- guint size = GST_BUFFER_SIZE (buffer);
if (size >= 8 && !memcmp (data, "CMML\0\0\0\0", 8)) {
packet_type = GST_CMML_PACKET_IDENT_HEADER;
@@ -443,19 +435,15 @@ gst_cmml_dec_new_buffer (GstCmmlDec * dec,
{
GstFlowReturn res;
- res = gst_pad_alloc_buffer (dec->srcpad, GST_BUFFER_OFFSET_NONE,
- size, gst_static_pad_template_get_caps (&gst_cmml_dec_src_factory),
- buffer);
-
- if (res == GST_FLOW_OK) {
+ *buffer = gst_buffer_new_allocate (NULL, size, 0);
+ if (*buffer != NULL) {
if (data)
- memcpy (GST_BUFFER_DATA (*buffer), data, size);
+ gst_buffer_fill (*buffer, 0, data, size);
GST_BUFFER_TIMESTAMP (*buffer) = dec->timestamp;
- } else if (res == GST_FLOW_NOT_LINKED) {
- GST_DEBUG_OBJECT (dec, "alloc function return NOT-LINKED, ignoring");
+ res = GST_FLOW_OK;
} else {
- GST_WARNING_OBJECT (dec, "alloc function returned error %s",
- gst_flow_get_name (res));
+ GST_WARNING_OBJECT (dec, "could not allocate buffer");
+ res = GST_FLOW_ERROR;
}
return res;
@@ -464,14 +452,12 @@ gst_cmml_dec_new_buffer (GstCmmlDec * dec,
/* parses the first CMML packet (the ident header)
*/
static void
-gst_cmml_dec_parse_ident_header (GstCmmlDec * dec, GstBuffer * buffer)
+gst_cmml_dec_parse_ident_header (GstCmmlDec * dec, guint8 * data, gsize size)
{
- guint8 *data = GST_BUFFER_DATA (buffer);
-
/* the ident header has a fixed length */
- if (GST_BUFFER_SIZE (buffer) != CMML_IDENT_HEADER_SIZE) {
+ if (size != CMML_IDENT_HEADER_SIZE) {
GST_ELEMENT_ERROR (dec, STREAM, DECODE,
- (NULL), ("wrong ident header size: %d", GST_BUFFER_SIZE (buffer)));
+ (NULL), ("wrong ident header size: %" G_GSIZE_FORMAT, size));
dec->flow_return = GST_FLOW_ERROR;
return;
@@ -503,17 +489,15 @@ gst_cmml_dec_parse_ident_header (GstCmmlDec * dec, GstBuffer * buffer)
* optional "cmml" processing instruction.
*/
static void
-gst_cmml_dec_parse_first_header (GstCmmlDec * dec, GstBuffer * buffer)
+gst_cmml_dec_parse_first_header (GstCmmlDec * dec, guint8 * data, gsize size)
{
- gst_cmml_dec_parse_xml (dec,
- GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
+ gst_cmml_dec_parse_xml (dec, data, size);
/* if there is a processing instruction, gst_cmml_dec_parse_preamble
* will be triggered. Otherwise we need to call it manually.
*/
if (dec->flow_return == GST_FLOW_OK && !dec->sent_root) {
- guchar *preamble = (guchar *) g_strndup ((gchar *) GST_BUFFER_DATA (buffer),
- GST_BUFFER_SIZE (buffer));
+ guchar *preamble = (guchar *) g_strndup ((gchar *) data, size);
gst_cmml_dec_parse_preamble (dec, preamble, (guchar *) "<cmml>");
g_free (preamble);
@@ -579,17 +563,18 @@ gst_cmml_dec_parse_head (GstCmmlDec * dec, GstCmmlTagHead * head)
GST_DEBUG_OBJECT (dec, "found CMML head (title: %s base: %s)",
head->title, head->base);
+ /* FIXME: what's the point of all this GValue transform crack? */
/* create the GST_TAG_TITLE tag */
g_value_init (&str_val, G_TYPE_STRING);
g_value_init (&title_val, gst_tag_get_type (GST_TAG_TITLE));
g_value_set_string (&str_val, (gchar *) head->title);
g_value_transform (&str_val, &title_val);
- tags = gst_tag_list_new ();
+ tags = gst_tag_list_new_empty ();
gst_tag_list_add_values (tags, GST_TAG_MERGE_APPEND,
GST_TAG_TITLE, &title_val, NULL);
gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_CMML_HEAD, head, NULL);
- gst_element_found_tags_for_pad (GST_ELEMENT (dec), dec->srcpad, tags);
+ gst_pad_push_event (dec->srcpad, gst_event_new_tag (tags));
g_value_unset (&str_val);
g_value_unset (&title_val);
@@ -613,9 +598,8 @@ gst_cmml_dec_send_clip_tag (GstCmmlDec * dec, GstCmmlTagClip * clip)
GST_DEBUG_OBJECT (dec, "sending clip tag %s", clip->id);
- tags = gst_tag_list_new ();
- gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_CMML_CLIP, clip, NULL);
- gst_element_found_tags_for_pad (GST_ELEMENT (dec), dec->srcpad, tags);
+ tags = gst_tag_list_new (GST_TAG_CMML_CLIP, clip, NULL);
+ gst_pad_push_event (dec->srcpad, gst_event_new_tag (tags));
}
/* push the string representation of a clip */
diff --git a/ext/annodex/gstcmmldec.h b/ext/annodex/gstcmmldec.h
index 27a6c5597..b7b302de8 100644
--- a/ext/annodex/gstcmmldec.h
+++ b/ext/annodex/gstcmmldec.h
@@ -26,7 +26,6 @@
#include <gst/gst.h>
#include <gst/gstformat.h>
-#include <gst/controller/gstcontroller.h>
#include "gstcmmlparser.h"
diff --git a/ext/annodex/gstcmmlenc.c b/ext/annodex/gstcmmlenc.c
index 7bdfc1e0a..57675581f 100644
--- a/ext/annodex/gstcmmlenc.c
+++ b/ext/annodex/gstcmmlenc.c
@@ -79,17 +79,21 @@ GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("text/x-cmml, encoded = (boolean) false")
);
-GST_BOILERPLATE (GstCmmlEnc, gst_cmml_enc, GstElement, GST_TYPE_ELEMENT);
+#define gst_cmml_enc_parent_class parent_class
+G_DEFINE_TYPE (GstCmmlEnc, gst_cmml_enc, GST_TYPE_ELEMENT);
+
static void gst_cmml_enc_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec);
static void gst_cmml_enc_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec);
-static gboolean gst_cmml_enc_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_cmml_enc_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static GstStateChangeReturn gst_cmml_enc_change_state (GstElement * element,
GstStateChange transition);
-static GstFlowReturn gst_cmml_enc_chain (GstPad * pad, GstBuffer * buffer);
-static void gst_cmml_enc_parse_preamble (GstCmmlEnc * enc,
- guchar * preamble, guchar * processing_instruction);
+static GstFlowReturn gst_cmml_enc_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
+static void gst_cmml_enc_parse_preamble (GstCmmlEnc * enc, guchar * preamble,
+ guchar * processing_instruction);
static void gst_cmml_enc_parse_end_tag (GstCmmlEnc * enc);
static void gst_cmml_enc_parse_tag_head (GstCmmlEnc * enc,
GstCmmlTagHead * head);
@@ -104,23 +108,10 @@ static GstFlowReturn gst_cmml_enc_push (GstCmmlEnc * enc, GstBuffer * buffer);
static void gst_cmml_enc_finalize (GObject * object);
static void
-gst_cmml_enc_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_cmml_enc_sink_factory);
- gst_element_class_add_static_pad_template (element_class,
- &gst_cmml_enc_src_factory);
- gst_element_class_set_details_simple (element_class, "CMML streams encoder",
- "Codec/Encoder",
- "Encodes CMML streams", "Alessandro Decina <alessandro@nnva.org>");
-}
-
-static void
gst_cmml_enc_class_init (GstCmmlEncClass * enc_class)
{
GObjectClass *klass = G_OBJECT_CLASS (enc_class);
+ GstElementClass *element_class = GST_ELEMENT_CLASS (enc_class);
klass->get_property = gst_cmml_enc_get_property;
klass->set_property = gst_cmml_enc_set_property;
@@ -147,11 +138,19 @@ gst_cmml_enc_class_init (GstCmmlEncClass * enc_class)
0, 64, 32,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
- GST_ELEMENT_CLASS (klass)->change_state = gst_cmml_enc_change_state;
+ element_class->change_state = gst_cmml_enc_change_state;
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cmml_enc_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cmml_enc_src_factory));
+ gst_element_class_set_details_simple (element_class, "CMML streams encoder",
+ "Codec/Encoder",
+ "Encodes CMML streams", "Alessandro Decina <alessandro@nnva.org>");
}
static void
-gst_cmml_enc_init (GstCmmlEnc * enc, GstCmmlEncClass * klass)
+gst_cmml_enc_init (GstCmmlEnc * enc)
{
enc->sinkpad =
gst_pad_new_from_static_template (&gst_cmml_enc_sink_factory, "sink");
@@ -250,7 +249,7 @@ gst_cmml_enc_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_READY:
@@ -270,9 +269,9 @@ gst_cmml_enc_change_state (GstElement * element, GstStateChange transition)
}
static gboolean
-gst_cmml_enc_sink_event (GstPad * pad, GstEvent * event)
+gst_cmml_enc_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
- GstCmmlEnc *enc = GST_CMML_ENC (GST_PAD_PARENT (pad));
+ GstCmmlEnc *enc = GST_CMML_ENC (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
@@ -286,7 +285,7 @@ gst_cmml_enc_sink_event (GstPad * pad, GstEvent * event)
break;
}
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
}
static GstFlowReturn
@@ -295,14 +294,14 @@ gst_cmml_enc_new_buffer (GstCmmlEnc * enc,
{
GstFlowReturn res;
- res = gst_pad_alloc_buffer (enc->srcpad, GST_BUFFER_OFFSET_NONE, size,
- NULL, buffer);
- if (res == GST_FLOW_OK) {
+ *buffer = gst_buffer_new_allocate (NULL, size, 0);
+ if (*buffer != NULL) {
if (data)
- memcpy (GST_BUFFER_DATA (*buffer), data, size);
+ gst_buffer_fill (*buffer, 0, data, size);
+ res = GST_FLOW_OK;
} else {
- GST_WARNING_OBJECT (enc, "alloc function returned error %s",
- gst_flow_get_name (res));
+ GST_WARNING_OBJECT (enc, "could not allocate buffer");
+ res = GST_FLOW_ERROR;
}
return res;
@@ -443,7 +442,7 @@ gst_cmml_enc_parse_tag_head (GstCmmlEnc * enc, GstCmmlTagHead * head)
goto alloc_error;
headers = g_list_append (headers, head_buf);
- caps = gst_pad_get_caps (enc->srcpad);
+ caps = gst_pad_get_current_caps (enc->srcpad);
caps = gst_cmml_enc_set_header_on_caps (enc, caps,
ident_buf, preamble_buf, head_buf);
@@ -451,7 +450,6 @@ gst_cmml_enc_parse_tag_head (GstCmmlEnc * enc, GstCmmlTagHead * head)
buffer = GST_BUFFER (headers->data);
/* set granulepos 0 on headers */
GST_BUFFER_OFFSET_END (buffer) = 0;
- gst_buffer_set_caps (buffer, caps);
enc->flow_return = gst_cmml_enc_push (enc, buffer);
headers = g_list_delete_link (headers, headers);
@@ -596,23 +594,27 @@ gst_cmml_enc_push (GstCmmlEnc * enc, GstBuffer * buffer)
}
static GstFlowReturn
-gst_cmml_enc_chain (GstPad * pad, GstBuffer * buffer)
+gst_cmml_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GError *err = NULL;
- GstCmmlEnc *enc = GST_CMML_ENC (GST_PAD_PARENT (pad));
+ GstCmmlEnc *enc = GST_CMML_ENC (parent);
+ gchar *data;
+ gsize size;
/* the CMML handlers registered with enc->parser will override this when
* encoding/pushing the buffers downstream
*/
enc->flow_return = GST_FLOW_OK;
- if (!gst_cmml_parser_parse_chunk (enc->parser,
- (gchar *) GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer), &err)) {
+ data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
+ if (!gst_cmml_parser_parse_chunk (enc->parser, data, size, &err)) {
GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL), ("%s", err->message));
g_error_free (err);
enc->flow_return = GST_FLOW_ERROR;
}
+ gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return enc->flow_return;
}
diff --git a/ext/cairo/gstcairooverlay.c b/ext/cairo/gstcairooverlay.c
index a19aed646..bdb0a39d1 100644
--- a/ext/cairo/gstcairooverlay.c
+++ b/ext/cairo/gstcairooverlay.c
@@ -194,10 +194,10 @@ gst_cairo_overlay_base_init (gpointer g_class)
"Render overlay on a video stream using Cairo",
"Jon Nordby <jononor@gmail.com>");
- gst_element_class_add_static_pad_template (element_class,
- &gst_cairo_overlay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_cairo_overlay_src_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cairo_overlay_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cairo_overlay_src_template));
}
static void
diff --git a/ext/cairo/gstcairorender.c b/ext/cairo/gstcairorender.c
index 870ac17cf..cf1b563aa 100644
--- a/ext/cairo/gstcairorender.c
+++ b/ext/cairo/gstcairorender.c
@@ -354,8 +354,8 @@ gst_cairo_render_base_init (gpointer g_class)
gst_element_class_set_details_simple (ec, "Cairo encoder",
"Codec/Encoder", "Encodes streams using Cairo",
"Lutz Mueller <lutz@topfrose.de>");
- gst_element_class_add_static_pad_template (ec, &t_snk);
- gst_element_class_add_static_pad_template (ec, &t_src);
+ gst_element_class_add_pad_template (ec, gst_static_pad_template_get (&t_snk));
+ gst_element_class_add_pad_template (ec, gst_static_pad_template_get (&t_src));
}
static void
diff --git a/ext/cairo/gsttextoverlay.c b/ext/cairo/gsttextoverlay.c
index 8cb39cc11..839d9daa9 100644
--- a/ext/cairo/gsttextoverlay.c
+++ b/ext/cairo/gsttextoverlay.c
@@ -132,12 +132,12 @@ gst_text_overlay_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class,
- &cairo_text_overlay_src_template_factory);
- gst_element_class_add_static_pad_template (element_class,
- &video_sink_template_factory);
- gst_element_class_add_static_pad_template (element_class,
- &text_sink_template_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&cairo_text_overlay_src_template_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&video_sink_template_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&text_sink_template_factory));
gst_element_class_set_details_simple (element_class, "Text overlay",
"Filter/Editor/Video",
@@ -285,7 +285,7 @@ gst_text_overlay_init (GstCairoTextOverlay * overlay,
GST_DEBUG_FUNCPTR (gst_text_overlay_collected), overlay);
overlay->video_collect_data = gst_collect_pads_add_pad (overlay->collect,
- overlay->video_sinkpad, sizeof (GstCollectData));
+ overlay->video_sinkpad, sizeof (GstCollectData), NULL);
/* FIXME: hacked way to override/extend the event function of
* GstCollectPads; because it sets its own event function giving the
@@ -641,7 +641,7 @@ gst_text_overlay_text_pad_linked (GstPad * pad, GstPad * peer)
if (overlay->text_collect_data == NULL) {
overlay->text_collect_data = gst_collect_pads_add_pad (overlay->collect,
- overlay->text_sinkpad, sizeof (GstCollectData));
+ overlay->text_sinkpad, sizeof (GstCollectData), NULL);
}
overlay->need_render = TRUE;
diff --git a/ext/cairo/gsttimeoverlay.c b/ext/cairo/gsttimeoverlay.c
index 10973b19a..b731c3789 100644
--- a/ext/cairo/gsttimeoverlay.c
+++ b/ext/cairo/gsttimeoverlay.c
@@ -265,10 +265,10 @@ gst_cairo_time_overlay_base_init (gpointer g_class)
"Filter/Editor/Video",
"Overlays the time on a video stream", "David Schleef <ds@schleef.org>");
- gst_element_class_add_static_pad_template (element_class,
- &gst_cairo_time_overlay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_cairo_time_overlay_src_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cairo_time_overlay_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cairo_time_overlay_src_template));
}
static void
diff --git a/ext/dv/gstdvdec.c b/ext/dv/gstdvdec.c
index e4257440d..e7fd946ce 100644
--- a/ext/dv/gstdvdec.c
+++ b/ext/dv/gstdvdec.c
@@ -166,8 +166,10 @@ gst_dvdec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class, &sink_temp);
- gst_element_class_add_static_pad_template (element_class, &src_temp);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_temp));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_temp));
gst_element_class_set_details_simple (element_class, "DV video decoder",
"Codec/Decoder/Video",
diff --git a/ext/dv/gstdvdemux.c b/ext/dv/gstdvdemux.c
index 7563203e9..1eef31e3b 100644
--- a/ext/dv/gstdvdemux.c
+++ b/ext/dv/gstdvdemux.c
@@ -174,11 +174,12 @@ gst_dvdemux_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class, &sink_temp);
- gst_element_class_add_static_pad_template (element_class,
- &video_src_temp);
- gst_element_class_add_static_pad_template (element_class,
- &audio_src_temp);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_temp));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&video_src_temp));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&audio_src_temp));
gst_element_class_set_details_simple (element_class,
"DV system stream demuxer", "Codec/Demuxer",
diff --git a/ext/esd/Makefile.am b/ext/esd/Makefile.am
deleted file mode 100644
index a7a1464b3..000000000
--- a/ext/esd/Makefile.am
+++ /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
index 8b61b1805..000000000
--- a/ext/esd/esdmon.c
+++ /dev/null
@@ -1,465 +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_static_pad_template (element_class, &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
index 50fc7ee23..000000000
--- a/ext/esd/esdmon.h
+++ /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
index 6dfb36454..000000000
--- a/ext/esd/esdsink.c
+++ /dev/null
@@ -1,468 +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_static_pad_template (element_class, &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
index 2e69ea8e1..000000000
--- a/ext/esd/esdsink.h
+++ /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
index dc6500141..000000000
--- a/ext/esd/gstesd.c
+++ /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)
diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c
index f6c0d813c..9dc0ca239 100644
--- a/ext/flac/gstflacdec.c
+++ b/ext/flac/gstflacdec.c
@@ -1,6 +1,6 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
- * Copyright (C) <2006> Tim-Philipp Müller <tim centricular net>
+ * Copyright (C) <2006,2011> Tim-Philipp Müller <tim centricular net>
* Copyright (C) <2006> Jan Schmidt <thaytan at mad scientist com>
*
* This library is free software; you can redistribute it and/or
@@ -30,17 +30,14 @@
* <refsect2>
* <title>Example launch line</title>
* |[
- * gst-launch filesrc location=media/small/dark.441-16-s.flac ! flacdec ! audioconvert ! audioresample ! autoaudiosink
+ * gst-launch-0.11 filesrc location=media/small/dark.441-16-s.flac ! flacparse ! flacdec ! audioconvert ! audioresample ! autoaudiosink
* ]|
* |[
- * gst-launch gnomevfssrc location=http://gstreamer.freedesktop.org/media/small/dark.441-16-s.flac ! flacdec ! audioconvert ! audioresample ! queue min-threshold-buffers=10 ! autoaudiosink
+ * gst-launch-0.11 souphttpsrc location=http://gstreamer.freedesktop.org/media/small/dark.441-16-s.flac ! flacparse ! flacdec ! audioconvert ! audioresample ! queue min-threshold-buffers=10 ! autoaudiosink
* ]|
* </refsect2>
*/
-/* TODO: add seeking when operating chain-based with unframed input */
-/* FIXME: demote/remove granulepos handling and make more time-centric */
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -48,8 +45,6 @@
#include "gstflacdec.h"
#include <gst/gst-i18n-plugin.h>
-#include <gst/gsttagsetter.h>
-#include <gst/base/gsttypefindhelper.h>
#include <gst/audio/multichannel.h>
#include <gst/tag/tag.h>
@@ -98,46 +93,9 @@ static const GstAudioChannelPosition channel_positions[8][8] = {
GST_DEBUG_CATEGORY_STATIC (flacdec_debug);
#define GST_CAT_DEFAULT flacdec_debug
-static void gst_flac_dec_finalize (GObject * object);
-static void gst_flac_dec_loop (GstPad * pad);
-
-static GstStateChangeReturn gst_flac_dec_change_state (GstElement * element,
- GstStateChange transition);
-static const GstQueryType *gst_flac_dec_get_src_query_types (GstPad * pad);
-static const GstQueryType *gst_flac_dec_get_sink_query_types (GstPad * pad);
-static gboolean gst_flac_dec_sink_query (GstPad * pad, GstQuery * query);
-static gboolean gst_flac_dec_src_query (GstPad * pad, GstQuery * query);
-static gboolean gst_flac_dec_convert_src (GstPad * pad, GstFormat src_format,
- gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
-static gboolean gst_flac_dec_src_event (GstPad * pad, GstEvent * event);
-static gboolean gst_flac_dec_sink_activate (GstPad * sinkpad);
-static gboolean gst_flac_dec_sink_activate_pull (GstPad * sinkpad,
- gboolean active);
-static gboolean gst_flac_dec_sink_activate_push (GstPad * sinkpad,
- gboolean active);
-static gboolean gst_flac_dec_sink_event (GstPad * pad, GstEvent * event);
-static GstFlowReturn gst_flac_dec_chain (GstPad * pad, GstBuffer * buf);
-
-static void gst_flac_dec_reset_decoders (GstFlacDec * flacdec);
-static void gst_flac_dec_setup_decoder (GstFlacDec * flacdec);
-
-static FLAC__StreamDecoderReadStatus
-gst_flac_dec_read_seekable (const FLAC__StreamDecoder * decoder,
- FLAC__byte buffer[], size_t * bytes, void *client_data);
static FLAC__StreamDecoderReadStatus
gst_flac_dec_read_stream (const FLAC__StreamDecoder * decoder,
FLAC__byte buffer[], size_t * bytes, void *client_data);
-static FLAC__StreamDecoderSeekStatus
-gst_flac_dec_seek (const FLAC__StreamDecoder * decoder,
- FLAC__uint64 position, void *client_data);
-static FLAC__StreamDecoderTellStatus
-gst_flac_dec_tell (const FLAC__StreamDecoder * decoder,
- FLAC__uint64 * position, void *client_data);
-static FLAC__StreamDecoderLengthStatus
-gst_flac_dec_length (const FLAC__StreamDecoder * decoder,
- FLAC__uint64 * length, void *client_data);
-static FLAC__bool gst_flac_dec_eof (const FLAC__StreamDecoder * decoder,
- void *client_data);
static FLAC__StreamDecoderWriteStatus
gst_flac_dec_write_stream (const FLAC__StreamDecoder * decoder,
const FLAC__Frame * frame,
@@ -147,17 +105,33 @@ 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);
+static void gst_flac_dec_flush (GstAudioDecoder * audio_dec, gboolean hard);
+static gboolean gst_flac_dec_set_format (GstAudioDecoder * dec, GstCaps * caps);
+static gboolean gst_flac_dec_start (GstAudioDecoder * dec);
+static gboolean gst_flac_dec_stop (GstAudioDecoder * dec);
+static GstFlowReturn gst_flac_dec_handle_frame (GstAudioDecoder * audio_dec,
+ GstBuffer * buf);
+
+G_DEFINE_TYPE (GstFlacDec, gst_flac_dec, GST_TYPE_AUDIO_DECODER);
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define FORMATS "{ S8LE, S16LE, S32LE } "
+#else
+#define FORMATS "{ S8BE, S16BE, S32BE } "
+#endif
/* FIXME 0.11: Use width=32 for all depths and let audioconvert
* handle the conversions instead of doing it ourself.
*/
#define GST_FLAC_DEC_SRC_CAPS \
- "audio/x-raw-int, " \
- "endianness = (int) BYTE_ORDER, " \
- "signed = (boolean) true, " \
- "width = (int) { 8, 16, 32 }, " \
- "depth = (int) [ 4, 32 ], " \
+ "audio/x-raw, " \
+ "format = (string) " FORMATS ", " \
+ "rate = (int) [ 1, 655350 ], " \
+ "channels = (int) [ 1, 8 ]"
+
+#define GST_FLAC_DEC_SINK_CAPS \
+ "audio/x-flac, " \
+ "framed = (boolean) true, " \
"rate = (int) [ 1, 655350 ], " \
"channels = (int) [ 1, 8 ]"
@@ -170,178 +144,138 @@ static GstStaticPadTemplate flac_dec_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-flac")
- );
-
-static void
-gst_flac_dec_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_static_pad_template (element_class,
- &flac_dec_src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &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");
-}
+ GST_STATIC_CAPS (GST_FLAC_DEC_SINK_CAPS));
static void
gst_flac_dec_class_init (GstFlacDecClass * klass)
{
+ GstAudioDecoderClass *audiodecoder_class;
GstElementClass *gstelement_class;
- GObjectClass *gobject_class;
+ audiodecoder_class = (GstAudioDecoderClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gobject_class = (GObjectClass *) klass;
- gobject_class->finalize = gst_flac_dec_finalize;
+ GST_DEBUG_CATEGORY_INIT (flacdec_debug, "flacdec", 0, "flac decoder");
- gstelement_class->change_state =
- GST_DEBUG_FUNCPTR (gst_flac_dec_change_state);
-}
+ audiodecoder_class->stop = GST_DEBUG_FUNCPTR (gst_flac_dec_stop);
+ audiodecoder_class->start = GST_DEBUG_FUNCPTR (gst_flac_dec_start);
+ audiodecoder_class->flush = GST_DEBUG_FUNCPTR (gst_flac_dec_flush);
+ audiodecoder_class->set_format = GST_DEBUG_FUNCPTR (gst_flac_dec_set_format);
+ audiodecoder_class->handle_frame =
+ GST_DEBUG_FUNCPTR (gst_flac_dec_handle_frame);
-static void
-gst_flac_dec_init (GstFlacDec * flacdec, GstFlacDecClass * klass)
-{
- flacdec->sinkpad =
- gst_pad_new_from_static_template (&flac_dec_sink_factory, "sink");
- gst_pad_set_activate_function (flacdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_flac_dec_sink_activate));
- gst_pad_set_activatepull_function (flacdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_flac_dec_sink_activate_pull));
- gst_pad_set_activatepush_function (flacdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_flac_dec_sink_activate_push));
- gst_pad_set_query_type_function (flacdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_flac_dec_get_sink_query_types));
- gst_pad_set_query_function (flacdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_flac_dec_sink_query));
- gst_pad_set_event_function (flacdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_flac_dec_sink_event));
- gst_pad_set_chain_function (flacdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_flac_dec_chain));
- gst_element_add_pad (GST_ELEMENT (flacdec), flacdec->sinkpad);
-
- flacdec->srcpad =
- gst_pad_new_from_static_template (&flac_dec_src_factory, "src");
- gst_pad_set_query_type_function (flacdec->srcpad,
- GST_DEBUG_FUNCPTR (gst_flac_dec_get_src_query_types));
- gst_pad_set_query_function (flacdec->srcpad,
- GST_DEBUG_FUNCPTR (gst_flac_dec_src_query));
- gst_pad_set_event_function (flacdec->srcpad,
- GST_DEBUG_FUNCPTR (gst_flac_dec_src_event));
- gst_pad_use_fixed_caps (flacdec->srcpad);
- gst_element_add_pad (GST_ELEMENT (flacdec), flacdec->srcpad);
-
- gst_flac_dec_reset_decoders (flacdec);
+ 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",
+ "Tim-Philipp Müller <tim@centricular.net>, "
+ "Wim Taymans <wim.taymans@gmail.com>");
}
static void
-gst_flac_dec_reset_decoders (GstFlacDec * flacdec)
+gst_flac_dec_init (GstFlacDec * flacdec)
{
- /* Clean up the decoder */
- if (flacdec->decoder) {
- FLAC__stream_decoder_delete (flacdec->decoder);
- flacdec->decoder = NULL;
- }
-
- if (flacdec->adapter) {
- gst_adapter_clear (flacdec->adapter);
- g_object_unref (flacdec->adapter);
- flacdec->adapter = NULL;
- }
-
- if (flacdec->close_segment) {
- gst_event_unref (flacdec->close_segment);
- flacdec->close_segment = NULL;
- }
- if (flacdec->start_segment) {
- gst_event_unref (flacdec->start_segment);
- flacdec->start_segment = NULL;
- }
- if (flacdec->tags) {
- gst_tag_list_free (flacdec->tags);
- flacdec->tags = NULL;
- }
- if (flacdec->pending) {
- gst_buffer_unref (flacdec->pending);
- flacdec->pending = NULL;
- }
-
- flacdec->segment.last_stop = 0;
- flacdec->offset = 0;
- flacdec->init = TRUE;
+ /* nothing to do here */
}
-static void
-gst_flac_dec_setup_decoder (GstFlacDec * dec)
+static gboolean
+gst_flac_dec_start (GstAudioDecoder * audio_dec)
{
- gst_flac_dec_reset_decoders (dec);
+ FLAC__StreamDecoderInitStatus s;
+ GstFlacDec *dec;
- dec->tags = gst_tag_list_new ();
- gst_tag_list_add (dec->tags, GST_TAG_MERGE_REPLACE,
- GST_TAG_AUDIO_CODEC, "FLAC", NULL);
+ dec = GST_FLAC_DEC (audio_dec);
dec->adapter = gst_adapter_new ();
dec->decoder = FLAC__stream_decoder_new ();
- /* no point calculating since it's never checked here */
+ /* no point calculating MD5 since it's never checked here */
FLAC__stream_decoder_set_md5_checking (dec->decoder, false);
- FLAC__stream_decoder_set_metadata_respond (dec->decoder,
- FLAC__METADATA_TYPE_VORBIS_COMMENT);
- FLAC__stream_decoder_set_metadata_respond (dec->decoder,
- FLAC__METADATA_TYPE_PICTURE);
+
+ GST_DEBUG_OBJECT (dec, "initializing decoder");
+ s = FLAC__stream_decoder_init_stream (dec->decoder,
+ gst_flac_dec_read_stream, NULL, NULL, NULL, NULL,
+ gst_flac_dec_write_stream, gst_flac_dec_metadata_cb,
+ gst_flac_dec_error_cb, dec);
+
+ if (s != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
+ GST_ELEMENT_ERROR (GST_ELEMENT (dec), LIBRARY, INIT, (NULL), (NULL));
+ return FALSE;
+ }
+
+ dec->got_headers = FALSE;
+
+ return TRUE;
}
-static void
-gst_flac_dec_finalize (GObject * object)
+static gboolean
+gst_flac_dec_stop (GstAudioDecoder * dec)
{
- GstFlacDec *flacdec;
+ GstFlacDec *flacdec = GST_FLAC_DEC (dec);
- flacdec = GST_FLAC_DEC (object);
+ if (flacdec->decoder) {
+ FLAC__stream_decoder_delete (flacdec->decoder);
+ flacdec->decoder = NULL;
+ }
- gst_flac_dec_reset_decoders (flacdec);
+ if (flacdec->adapter) {
+ gst_adapter_clear (flacdec->adapter);
+ g_object_unref (flacdec->adapter);
+ flacdec->adapter = NULL;
+ }
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ return TRUE;
}
-
static gboolean
-gst_flac_dec_update_metadata (GstFlacDec * flacdec,
- const FLAC__StreamMetadata * metadata)
+gst_flac_dec_set_format (GstAudioDecoder * dec, GstCaps * caps)
{
- GstTagList *list;
- guint num, i;
+ const GValue *headers;
+ GstFlacDec *flacdec;
+ GstStructure *s;
+ guint i, num;
- if (flacdec->tags)
- list = flacdec->tags;
- else
- flacdec->tags = list = gst_tag_list_new ();
+ flacdec = GST_FLAC_DEC (dec);
- num = metadata->data.vorbis_comment.num_comments;
- GST_DEBUG_OBJECT (flacdec, "%u tag(s) found", num);
+ GST_LOG_OBJECT (dec, "sink caps: %" GST_PTR_FORMAT, caps);
- for (i = 0; i < num; ++i) {
- gchar *vc, *name, *value;
+ s = gst_caps_get_structure (caps, 0);
+ headers = gst_structure_get_value (s, "streamheader");
+ if (headers == NULL || !GST_VALUE_HOLDS_ARRAY (headers)) {
+ GST_WARNING_OBJECT (dec, "no 'streamheader' field in input caps, try "
+ "adding a flacparse element upstream");
+ return FALSE;
+ }
- vc = g_strndup ((gchar *) metadata->data.vorbis_comment.comments[i].entry,
- metadata->data.vorbis_comment.comments[i].length);
+ if (gst_adapter_available (flacdec->adapter) > 0) {
+ GST_WARNING_OBJECT (dec, "unexpected data left in adapter");
+ gst_adapter_clear (flacdec->adapter);
+ }
- if (gst_tag_parse_extended_comment (vc, &name, NULL, &value, TRUE)) {
- GST_DEBUG_OBJECT (flacdec, "%s : %s", name, value);
- if (value && strlen (value))
- gst_vorbis_tag_add (list, name, value);
- g_free (name);
- g_free (value);
- }
+ num = gst_value_array_get_size (headers);
+ for (i = 0; i < num; ++i) {
+ const GValue *header_val;
+ GstBuffer *header_buf;
- g_free (vc);
+ header_val = gst_value_array_get_value (headers, i);
+ if (header_val == NULL || !GST_VALUE_HOLDS_BUFFER (header_val))
+ return FALSE;
+
+ header_buf = g_value_dup_boxed (header_val);
+ GST_INFO_OBJECT (dec, "pushing header buffer of %" G_GSIZE_FORMAT " bytes "
+ "into adapter", gst_buffer_get_size (header_buf));
+ gst_adapter_push (flacdec->adapter, header_buf);
}
+ GST_DEBUG_OBJECT (dec, "Processing headers and metadata");
+ if (!FLAC__stream_decoder_process_until_end_of_metadata (flacdec->decoder)) {
+ GST_WARNING_OBJECT (dec, "process_until_end_of_metadata failed");
+ }
+ GST_INFO_OBJECT (dec, "headers and metadata are now processed");
return TRUE;
}
@@ -394,6 +328,8 @@ gst_flac_calculate_crc8 (guint8 * data, guint length)
return crc;
}
+/* FIXME: for our purposes it's probably enough to just check for the sync
+ * marker - we just want to know if it's a header frame or not */
static gboolean
gst_flac_dec_scan_got_frame (GstFlacDec * flacdec, guint8 * data, guint size,
gint64 * last_sample_num)
@@ -478,94 +414,6 @@ gst_flac_dec_scan_got_frame (GstFlacDec * flacdec, guint8 * data, guint size,
return TRUE;
}
-#define SCANBLOCK_SIZE (64*1024)
-
-static void
-gst_flac_dec_scan_for_last_block (GstFlacDec * flacdec, gint64 * samples)
-{
- GstFormat format = GST_FORMAT_BYTES;
- gint64 file_size, offset;
-
- GST_INFO_OBJECT (flacdec, "total number of samples unknown, scanning file");
-
- if (!gst_pad_query_peer_duration (flacdec->sinkpad, &format, &file_size)) {
- GST_WARNING_OBJECT (flacdec, "failed to query upstream size!");
- return;
- }
-
- if (flacdec->min_blocksize != flacdec->max_blocksize) {
- GST_WARNING_OBJECT (flacdec, "scanning for last sample only works "
- "for FLAC files with constant blocksize");
- return;
- }
-
- GST_DEBUG_OBJECT (flacdec, "upstream size: %" G_GINT64_FORMAT, file_size);
-
- offset = file_size - 1;
- while (offset >= MAX (SCANBLOCK_SIZE / 2, file_size / 2)) {
- GstFlowReturn flow;
- GstBuffer *buf = NULL;
- guint8 *data;
- guint size;
-
- /* divide by 2 = not very sophisticated way to deal with overlapping */
- offset -= SCANBLOCK_SIZE / 2;
- GST_LOG_OBJECT (flacdec, "looking for frame at %" G_GINT64_FORMAT
- "-%" G_GINT64_FORMAT, offset, offset + SCANBLOCK_SIZE);
-
- flow = gst_pad_pull_range (flacdec->sinkpad, offset, SCANBLOCK_SIZE, &buf);
- if (flow != GST_FLOW_OK) {
- GST_DEBUG_OBJECT (flacdec, "flow = %s", gst_flow_get_name (flow));
- return;
- }
-
- size = GST_BUFFER_SIZE (buf);
- data = GST_BUFFER_DATA (buf);
-
- while (size > 16) {
- if (gst_flac_dec_scan_got_frame (flacdec, data, size, samples)) {
- GST_DEBUG_OBJECT (flacdec, "frame sync at offset %" G_GINT64_FORMAT,
- offset + GST_BUFFER_SIZE (buf) - size);
- gst_buffer_unref (buf);
- return;
- }
- ++data;
- --size;
- }
-
- gst_buffer_unref (buf);
- }
-}
-
-static void
-gst_flac_extract_picture_buffer (GstFlacDec * dec,
- const FLAC__StreamMetadata * metadata)
-{
- FLAC__StreamMetadata_Picture picture;
- GstTagList *tags;
-
- g_return_if_fail (metadata->type == FLAC__METADATA_TYPE_PICTURE);
-
- GST_LOG_OBJECT (dec, "Got PICTURE block");
- picture = metadata->data.picture;
-
- GST_DEBUG_OBJECT (dec, "declared MIME type is: '%s'",
- GST_STR_NULL (picture.mime_type));
- GST_DEBUG_OBJECT (dec, "image data is %u bytes", picture.data_length);
-
- tags = gst_tag_list_new ();
-
- gst_tag_list_add_id3_image (tags, (guint8 *) picture.data,
- picture.data_length, picture.type);
-
- if (!gst_tag_list_is_empty (tags)) {
- gst_element_found_tags_for_pad (GST_ELEMENT (dec), dec->srcpad, tags);
- } else {
- GST_DEBUG_OBJECT (dec, "problem parsing PICTURE block, skipping");
- gst_tag_list_free (tags);
- }
-}
-
static void
gst_flac_dec_metadata_cb (const FLAC__StreamDecoder * decoder,
const FLAC__StreamMetadata * metadata, void *client_data)
@@ -601,43 +449,9 @@ gst_flac_dec_metadata_cb (const FLAC__StreamDecoder * decoder,
GST_DEBUG_OBJECT (flacdec, "depth: %u, width: %u", flacdec->depth,
flacdec->width);
- /* Only scan for last block in pull-mode, since it uses pull_range() */
- if (samples == 0 && !flacdec->streaming) {
- gst_flac_dec_scan_for_last_block (flacdec, &samples);
- }
-
GST_DEBUG_OBJECT (flacdec, "total samples = %" G_GINT64_FORMAT, samples);
-
- /* in framed mode the demuxer/parser upstream has already pushed a
- * newsegment event in TIME format which we've passed on */
- if (samples > 0 && !flacdec->framed) {
- gint64 duration;
-
- gst_segment_set_duration (&flacdec->segment, GST_FORMAT_DEFAULT,
- samples);
-
- /* convert duration to time */
- duration = gst_util_uint64_scale_int (samples, GST_SECOND,
- flacdec->sample_rate);
-
- /* fixme, at this time we could seek to the queued seek event if we have
- * any */
- if (flacdec->start_segment)
- gst_event_unref (flacdec->start_segment);
- flacdec->start_segment =
- gst_event_new_new_segment_full (FALSE,
- flacdec->segment.rate, flacdec->segment.applied_rate,
- GST_FORMAT_TIME, 0, duration, 0);
- }
- break;
- }
- case FLAC__METADATA_TYPE_PICTURE:{
- gst_flac_extract_picture_buffer (flacdec, metadata);
break;
}
- case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- gst_flac_dec_update_metadata (flacdec, metadata);
- break;
default:
break;
}
@@ -671,126 +485,6 @@ gst_flac_dec_error_cb (const FLAC__StreamDecoder * d,
dec->last_flow = GST_FLOW_ERROR;
}
-static FLAC__StreamDecoderSeekStatus
-gst_flac_dec_seek (const FLAC__StreamDecoder * decoder,
- FLAC__uint64 position, void *client_data)
-{
- GstFlacDec *flacdec;
-
- flacdec = GST_FLAC_DEC (client_data);
-
- GST_DEBUG_OBJECT (flacdec, "seek %" G_GUINT64_FORMAT, (guint64) position);
- flacdec->offset = position;
-
- return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
-}
-
-static FLAC__StreamDecoderTellStatus
-gst_flac_dec_tell (const FLAC__StreamDecoder * decoder,
- FLAC__uint64 * position, void *client_data)
-{
- GstFlacDec *flacdec;
-
- flacdec = GST_FLAC_DEC (client_data);
-
- *position = flacdec->offset;
-
- GST_DEBUG_OBJECT (flacdec, "tell %" G_GINT64_FORMAT, (gint64) * position);
-
- return FLAC__STREAM_DECODER_TELL_STATUS_OK;
-}
-
-static FLAC__StreamDecoderLengthStatus
-gst_flac_dec_length (const FLAC__StreamDecoder * decoder,
- FLAC__uint64 * length, void *client_data)
-{
- GstFlacDec *flacdec;
- GstFormat fmt = GST_FORMAT_BYTES;
- gint64 len;
- GstPad *peer;
-
- flacdec = GST_FLAC_DEC (client_data);
-
- if (!(peer = gst_pad_get_peer (flacdec->sinkpad)))
- return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
-
- gst_pad_query_duration (peer, &fmt, &len);
- gst_object_unref (peer);
- if (fmt != GST_FORMAT_BYTES || len == -1)
- return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
-
- *length = len;
-
- GST_DEBUG_OBJECT (flacdec, "encoded byte length %" G_GINT64_FORMAT,
- (gint64) * length);
-
- return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
-}
-
-static FLAC__bool
-gst_flac_dec_eof (const FLAC__StreamDecoder * decoder, void *client_data)
-{
- GstFlacDec *flacdec;
- GstFormat fmt;
- GstPad *peer;
- gboolean ret = FALSE;
- gint64 len;
-
- flacdec = GST_FLAC_DEC (client_data);
-
- if (!(peer = gst_pad_get_peer (flacdec->sinkpad))) {
- GST_WARNING_OBJECT (flacdec, "no peer pad, returning EOF");
- return TRUE;
- }
-
- fmt = GST_FORMAT_BYTES;
- if (gst_pad_query_duration (peer, &fmt, &len) && fmt == GST_FORMAT_BYTES &&
- len != -1 && flacdec->offset >= len) {
- GST_DEBUG_OBJECT (flacdec,
- "offset=%" G_GINT64_FORMAT ", len=%" G_GINT64_FORMAT
- ", returning EOF", flacdec->offset, len);
- ret = TRUE;
- }
-
- gst_object_unref (peer);
-
- return ret;
-}
-
-static FLAC__StreamDecoderReadStatus
-gst_flac_dec_read_seekable (const FLAC__StreamDecoder * decoder,
- FLAC__byte buffer[], size_t * bytes, void *client_data)
-{
- GstFlowReturn flow;
- GstFlacDec *flacdec;
- GstBuffer *buf;
-
- flacdec = GST_FLAC_DEC (client_data);
-
- flow = gst_pad_pull_range (flacdec->sinkpad, flacdec->offset, *bytes, &buf);
-
- GST_PAD_STREAM_LOCK (flacdec->sinkpad);
- flacdec->pull_flow = flow;
- GST_PAD_STREAM_UNLOCK (flacdec->sinkpad);
-
- if (G_UNLIKELY (flow != GST_FLOW_OK)) {
- GST_INFO_OBJECT (flacdec, "pull_range flow: %s", gst_flow_get_name (flow));
- if (flow == GST_FLOW_UNEXPECTED)
- return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
- else
- return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
- }
-
- 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);
- gst_buffer_unref (buf);
- flacdec->offset += *bytes;
-
- return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
-}
-
static FLAC__StreamDecoderReadStatus
gst_flac_dec_read_stream (const FLAC__StreamDecoder * decoder,
FLAC__byte buffer[], size_t * bytes, void *client_data)
@@ -805,7 +499,8 @@ gst_flac_dec_read_stream (const FLAC__StreamDecoder * decoder,
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
}
- GST_LOG_OBJECT (dec, "feeding %u bytes to decoder (available=%u, bytes=%u)",
+ GST_LOG_OBJECT (dec, "feeding %u bytes to decoder "
+ "(available=%" G_GSIZE_FORMAT ", bytes=%u)",
len, gst_adapter_available (dec->adapter), (guint) * bytes);
gst_adapter_copy (dec->adapter, buffer, 0, len);
*bytes = len;
@@ -827,50 +522,44 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
guint channels = frame->header.channels;
guint samples = frame->header.blocksize;
guint j, i;
- GstClockTime next;
+ gpointer data;
+ gsize size;
+ const gchar *format;
GST_LOG_OBJECT (flacdec, "samples in frame header: %d", samples);
- /* if a DEFAULT segment is configured, don't send samples past the end
- * of the segment */
- if (flacdec->segment.format == GST_FORMAT_DEFAULT &&
- flacdec->segment.stop != -1 &&
- flacdec->segment.last_stop >= 0 &&
- flacdec->segment.last_stop + samples > flacdec->segment.stop) {
- samples = flacdec->segment.stop - flacdec->segment.last_stop;
- GST_DEBUG_OBJECT (flacdec,
- "clipping last buffer to %d samples because of segment", samples);
+ if (depth == 0) {
+ if (flacdec->depth < 4 || flacdec->depth > 32) {
+ GST_ERROR_OBJECT (flacdec, "unsupported depth %d from STREAMINFO",
+ flacdec->depth);
+ ret = GST_FLOW_ERROR;
+ goto done;
+ }
+
+ depth = flacdec->depth;
+ if (depth < 9)
+ depth = 8;
+ else if (depth < 17)
+ depth = 16;
+ else
+ depth = 32;
}
switch (depth) {
case 8:
width = 8;
+ format = GST_AUDIO_NE (S8);
break;
case 12:
case 16:
width = 16;
+ format = GST_AUDIO_NE (S16);
break;
case 20:
case 24:
case 32:
width = 32;
- break;
- case 0:
- if (flacdec->depth < 4 || flacdec->depth > 32) {
- GST_ERROR_OBJECT (flacdec, "unsupported depth %d from STREAMINFO",
- flacdec->depth);
- ret = GST_FLOW_ERROR;
- goto done;
- }
-
- depth = flacdec->depth;
- if (depth < 9)
- width = 8;
- else if (depth < 17)
- width = 16;
- else
- width = 32;
-
+ format = GST_AUDIO_NE (S32);
break;
default:
GST_ERROR_OBJECT (flacdec, "unsupported depth %d", depth);
@@ -888,17 +577,14 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
}
}
- if (!GST_PAD_CAPS (flacdec->srcpad)) {
+ if (!gst_pad_has_current_caps (GST_AUDIO_DECODER_SRC_PAD (flacdec))) {
GstCaps *caps;
GST_DEBUG_OBJECT (flacdec, "Negotiating %d Hz @ %d channels",
frame->header.sample_rate, channels);
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "width", G_TYPE_INT, width,
- "depth", G_TYPE_INT, depth,
+ caps = gst_caps_new_simple ("audio/x-raw",
+ "format", G_TYPE_STRING, format,
"rate", G_TYPE_INT, frame->header.sample_rate,
"channels", G_TYPE_INT, channels, NULL);
@@ -913,90 +599,16 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
flacdec->channels = channels;
flacdec->sample_rate = sample_rate;
- gst_pad_set_caps (flacdec->srcpad, caps);
+ gst_audio_decoder_set_outcaps (GST_AUDIO_DECODER (flacdec), caps);
gst_caps_unref (caps);
}
- if (flacdec->close_segment) {
- GST_DEBUG_OBJECT (flacdec, "pushing close segment");
- gst_pad_push_event (flacdec->srcpad, flacdec->close_segment);
- flacdec->close_segment = NULL;
- }
- if (flacdec->start_segment) {
- GST_DEBUG_OBJECT (flacdec, "pushing start segment");
- gst_pad_push_event (flacdec->srcpad, flacdec->start_segment);
- flacdec->start_segment = NULL;
- }
-
- if (flacdec->tags) {
- gst_element_found_tags_for_pad (GST_ELEMENT (flacdec), flacdec->srcpad,
- flacdec->tags);
- flacdec->tags = NULL;
- }
-
- if (flacdec->pending) {
- GST_DEBUG_OBJECT (flacdec,
- "pushing pending samples at offset %" G_GINT64_FORMAT " (%"
- GST_TIME_FORMAT " + %" GST_TIME_FORMAT ")",
- GST_BUFFER_OFFSET (flacdec->pending),
- GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (flacdec->pending)),
- GST_TIME_ARGS (GST_BUFFER_DURATION (flacdec->pending)));
- /* Pending buffer was always allocated from the seeking thread,
- * which means it wasn't gst_buffer_alloc'd. Do so now to let
- * 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_CAPS (flacdec->pending), &outbuf);
- if (ret == GST_FLOW_OK) {
- gst_pad_push (flacdec->srcpad, flacdec->pending);
- gst_buffer_unref (outbuf);
- }
-
- outbuf = flacdec->pending = NULL;
- flacdec->segment.last_stop += flacdec->pending_samples;
- flacdec->pending_samples = 0;
- }
-
- if (flacdec->seeking) {
- GST_DEBUG_OBJECT (flacdec, "a pad_alloc would block here, do normal alloc");
- outbuf = gst_buffer_new_and_alloc (samples * channels * (width / 8));
- gst_buffer_set_caps (outbuf, GST_PAD_CAPS (flacdec->srcpad));
- GST_BUFFER_OFFSET (outbuf) = flacdec->segment.last_stop;
- } else {
- GST_LOG_OBJECT (flacdec, "alloc_buffer_and_set_caps");
- ret = gst_pad_alloc_buffer_and_set_caps (flacdec->srcpad,
- flacdec->segment.last_stop, samples * channels * (width / 8),
- GST_PAD_CAPS (flacdec->srcpad), &outbuf);
-
- if (ret != GST_FLOW_OK) {
- GST_DEBUG_OBJECT (flacdec, "gst_pad_alloc_buffer() returned %s",
- gst_flow_get_name (ret));
- goto done;
- }
- }
-
- if (flacdec->cur_granulepos != GST_BUFFER_OFFSET_NONE) {
- /* this should be fine since it should be one flac frame per ogg packet */
- /* note the + 1, as the granpos is the presentation time of the last sample,
- whereas the last stop represents the end time of that sample */
- flacdec->segment.last_stop = flacdec->cur_granulepos - samples + 1;
- GST_LOG_OBJECT (flacdec, "granulepos = %" G_GINT64_FORMAT ", samples = %u",
- flacdec->cur_granulepos, samples);
- }
-
- GST_BUFFER_TIMESTAMP (outbuf) =
- gst_util_uint64_scale_int (flacdec->segment.last_stop, GST_SECOND,
- frame->header.sample_rate);
-
- /* get next timestamp to calculate the duration */
- next = gst_util_uint64_scale_int (flacdec->segment.last_stop + samples,
- GST_SECOND, frame->header.sample_rate);
-
- GST_BUFFER_DURATION (outbuf) = next - GST_BUFFER_TIMESTAMP (outbuf);
+ GST_LOG_OBJECT (flacdec, "alloc_buffer_and_set_caps");
+ outbuf = gst_buffer_new_allocate (NULL, samples * channels * (width / 8), 0);
+ 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++) {
@@ -1004,7 +616,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++) {
@@ -1012,7 +624,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++) {
@@ -1022,44 +634,21 @@ 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
- " (%" GST_TIME_FORMAT " + %" GST_TIME_FORMAT ")",
- samples, GST_BUFFER_OFFSET (outbuf),
- GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
- GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
-
- if (flacdec->discont) {
- GST_DEBUG_OBJECT (flacdec, "marking discont");
- outbuf = gst_buffer_make_metadata_writable (outbuf);
- GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
- flacdec->discont = FALSE;
- }
- ret = gst_pad_push (flacdec->srcpad, outbuf);
- GST_DEBUG_OBJECT (flacdec, "returned %s", gst_flow_get_name (ret));
- flacdec->segment.last_stop += samples;
- } else {
- GST_DEBUG_OBJECT (flacdec,
- "not pushing %d samples at offset %" G_GINT64_FORMAT
- " (in seek)", samples, GST_BUFFER_OFFSET (outbuf));
- gst_buffer_replace (&flacdec->pending, outbuf);
- gst_buffer_unref (outbuf);
- flacdec->pending_samples = samples;
- ret = GST_FLOW_OK;
- }
+ GST_DEBUG_OBJECT (flacdec, "pushing %d samples", samples);
- if (ret != GST_FLOW_OK) {
- GST_DEBUG_OBJECT (flacdec, "gst_pad_push() returned %s",
- gst_flow_get_name (ret));
+ ret = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (flacdec), outbuf, 1);
+
+ if (G_UNLIKELY (ret != GST_FLOW_OK)) {
+ GST_DEBUG_OBJECT (flacdec, "finish_frame flow %s", gst_flow_get_name (ret));
}
done:
-
- /* we act on the flow return value later in the loop function, as we don't
- * want to mess up the internal decoder state by returning ABORT when the
- * error is in fact non-fatal (like a pad in flushing mode) and we want
+ /* we act on the flow return value later in the handle_frame function, as we
+ * don't want to mess up the internal decoder state by returning ABORT when
+ * the error is in fact non-fatal (like a pad in flushing mode) and we want
* to continue later. So just pretend everything's dandy and act later. */
flacdec->last_flow = ret;
@@ -1075,1102 +664,75 @@ gst_flac_dec_write_stream (const FLAC__StreamDecoder * decoder,
}
static void
-gst_flac_dec_loop (GstPad * sinkpad)
+gst_flac_dec_flush (GstAudioDecoder * audio_dec, gboolean hard)
{
- GstFlacDec *flacdec;
- FLAC__StreamDecoderState s;
- FLAC__StreamDecoderInitStatus is;
-
- flacdec = GST_FLAC_DEC (GST_OBJECT_PARENT (sinkpad));
-
- GST_LOG_OBJECT (flacdec, "entering loop");
-
- if (flacdec->eos) {
- GST_DEBUG_OBJECT (flacdec, "Seeked after end of file");
-
- if (flacdec->close_segment) {
- GST_DEBUG_OBJECT (flacdec, "pushing close segment");
- gst_pad_push_event (flacdec->srcpad, flacdec->close_segment);
- flacdec->close_segment = NULL;
- }
- if (flacdec->start_segment) {
- GST_DEBUG_OBJECT (flacdec, "pushing start segment");
- gst_pad_push_event (flacdec->srcpad, flacdec->start_segment);
- flacdec->start_segment = NULL;
- }
-
- if (flacdec->tags) {
- gst_element_found_tags_for_pad (GST_ELEMENT (flacdec), flacdec->srcpad,
- flacdec->tags);
- flacdec->tags = NULL;
- }
-
- if ((flacdec->segment.flags & GST_SEEK_FLAG_SEGMENT) == 0) {
- goto eos_and_pause;
- } else {
- goto segment_done_and_pause;
- }
- }
-
- if (flacdec->init) {
- GST_DEBUG_OBJECT (flacdec, "initializing new decoder");
- is = FLAC__stream_decoder_init_stream (flacdec->decoder,
- gst_flac_dec_read_seekable, gst_flac_dec_seek, gst_flac_dec_tell,
- gst_flac_dec_length, gst_flac_dec_eof, gst_flac_dec_write_stream,
- gst_flac_dec_metadata_cb, gst_flac_dec_error_cb, flacdec);
- if (is != FLAC__STREAM_DECODER_INIT_STATUS_OK)
- goto analyze_state;
-
- /* FLAC__seekable_decoder_process_metadata (flacdec->decoder); */
- flacdec->init = FALSE;
- }
-
- flacdec->cur_granulepos = GST_BUFFER_OFFSET_NONE;
-
- flacdec->last_flow = GST_FLOW_OK;
-
- GST_LOG_OBJECT (flacdec, "processing single");
- FLAC__stream_decoder_process_single (flacdec->decoder);
-
-analyze_state:
-
- GST_LOG_OBJECT (flacdec, "done processing, checking encoder state");
- s = FLAC__stream_decoder_get_state (flacdec->decoder);
- switch (s) {
- case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
- case FLAC__STREAM_DECODER_READ_METADATA:
- case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
- case FLAC__STREAM_DECODER_READ_FRAME:
- {
- GST_DEBUG_OBJECT (flacdec, "everything ok");
-
- if (flacdec->last_flow < GST_FLOW_UNEXPECTED ||
- flacdec->last_flow == GST_FLOW_NOT_LINKED) {
- GST_ELEMENT_ERROR (flacdec, STREAM, FAILED,
- (_("Internal data stream error.")),
- ("stream stopped, reason %s",
- gst_flow_get_name (flacdec->last_flow)));
- goto eos_and_pause;
- } else if (flacdec->last_flow == GST_FLOW_UNEXPECTED) {
- goto eos_and_pause;
- } else if (flacdec->last_flow != GST_FLOW_OK) {
- goto pause;
- }
+ GstFlacDec *dec = GST_FLAC_DEC (audio_dec);
- /* check if we're at the end of a configured segment */
- if (flacdec->segment.stop != -1 &&
- flacdec->segment.last_stop > 0 &&
- flacdec->segment.last_stop >= flacdec->segment.stop) {
- GST_DEBUG_OBJECT (flacdec, "reached end of the configured segment");
+ if (!hard) {
+ guint available = gst_adapter_available (dec->adapter);
- if ((flacdec->segment.flags & GST_SEEK_FLAG_SEGMENT) == 0) {
- goto eos_and_pause;
- } else {
- goto segment_done_and_pause;
- }
-
- g_assert_not_reached ();
- }
-
- return;
- }
-
- case FLAC__STREAM_DECODER_END_OF_STREAM:{
- GST_DEBUG_OBJECT (flacdec, "EOS");
- FLAC__stream_decoder_reset (flacdec->decoder);
-
- if ((flacdec->segment.flags & GST_SEEK_FLAG_SEGMENT) != 0) {
- if (flacdec->segment.duration > 0) {
- flacdec->segment.stop = flacdec->segment.duration;
- } else {
- flacdec->segment.stop = flacdec->segment.last_stop;
- }
- goto segment_done_and_pause;
- }
-
- goto eos_and_pause;
- }
-
- /* gst_flac_dec_read_seekable() returned ABORTED */
- case FLAC__STREAM_DECODER_ABORTED:
- {
- GST_INFO_OBJECT (flacdec, "read aborted: last pull_range flow = %s",
- gst_flow_get_name (flacdec->pull_flow));
- if (flacdec->pull_flow == GST_FLOW_WRONG_STATE) {
- /* it seems we need to flush the decoder here to reset the decoder
- * state after the abort for FLAC__stream_decoder_seek_absolute()
- * to work properly */
- GST_DEBUG_OBJECT (flacdec, "flushing decoder to reset decoder state");
- FLAC__stream_decoder_flush (flacdec->decoder);
- goto pause;
- }
- /* fall through */
- }
- case FLAC__STREAM_DECODER_OGG_ERROR:
- case FLAC__STREAM_DECODER_SEEK_ERROR:
- case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
- case FLAC__STREAM_DECODER_UNINITIALIZED:
- default:{
- /* fixme: this error sucks -- should try to figure out when/if an more
- specific error was already sent via the callback */
- GST_ELEMENT_ERROR (flacdec, STREAM, DECODE, (NULL),
- ("%s", FLAC__StreamDecoderStateString[s]));
- goto eos_and_pause;
+ if (available > 0) {
+ GST_INFO_OBJECT (dec, "draining, %u bytes left in adapter", available);
+ FLAC__stream_decoder_process_until_end_of_stream (dec->decoder);
}
}
- return;
-
-segment_done_and_pause:
- {
- gint64 stop_time;
-
- stop_time = gst_util_uint64_scale_int (flacdec->segment.stop,
- GST_SECOND, flacdec->sample_rate);
-
- GST_DEBUG_OBJECT (flacdec, "posting SEGMENT_DONE message, stop time %"
- GST_TIME_FORMAT, GST_TIME_ARGS (stop_time));
-
- gst_element_post_message (GST_ELEMENT (flacdec),
- gst_message_new_segment_done (GST_OBJECT (flacdec),
- GST_FORMAT_TIME, stop_time));
-
- goto pause;
- }
-eos_and_pause:
- {
- GST_DEBUG_OBJECT (flacdec, "sending EOS event");
- flacdec->running = FALSE;
- gst_pad_push_event (flacdec->srcpad, gst_event_new_eos ());
- /* fall through to pause */
- }
-pause:
- {
- GST_DEBUG_OBJECT (flacdec, "pausing");
- gst_pad_pause_task (sinkpad);
- return;
- }
+ FLAC__stream_decoder_flush (dec->decoder);
+ gst_adapter_clear (dec->adapter);
}
-static gboolean
-gst_flac_dec_sink_event (GstPad * pad, GstEvent * event)
+static GstFlowReturn
+gst_flac_dec_handle_frame (GstAudioDecoder * audio_dec, GstBuffer * buf)
{
GstFlacDec *dec;
- gboolean res;
- dec = GST_FLAC_DEC (gst_pad_get_parent (pad));
+ dec = GST_FLAC_DEC (audio_dec);
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_FLUSH_STOP:{
- if (dec->init == FALSE) {
- FLAC__stream_decoder_flush (dec->decoder);
- gst_adapter_clear (dec->adapter);
- }
- res = gst_pad_push_event (dec->srcpad, event);
- break;
- }
- case GST_EVENT_NEWSEGMENT:{
- GstFormat fmt;
- gboolean update;
- gdouble rate, applied_rate;
- gint64 cur, stop, time;
-
- gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate,
- &fmt, &cur, &stop, &time);
-
- if (fmt == GST_FORMAT_TIME) {
- GstFormat dformat = GST_FORMAT_DEFAULT;
-
- GST_DEBUG_OBJECT (dec, "newsegment event in TIME format => framed");
- dec->framed = TRUE;
- res = gst_pad_push_event (dec->srcpad, event);
-
- /* this won't work for the first newsegment event though ... */
- if (gst_flac_dec_convert_src (dec->srcpad, GST_FORMAT_TIME, cur,
- &dformat, &cur) && cur != -1 &&
- gst_flac_dec_convert_src (dec->srcpad, GST_FORMAT_TIME, stop,
- &dformat, &stop) && stop != -1) {
- gst_segment_set_newsegment_full (&dec->segment, update, rate,
- applied_rate, dformat, cur, stop, time);
- GST_DEBUG_OBJECT (dec, "segment %" GST_SEGMENT_FORMAT, &dec->segment);
- } else {
- GST_WARNING_OBJECT (dec, "couldn't convert time => samples");
- }
- } else if (fmt == GST_FORMAT_BYTES || TRUE) {
- GST_DEBUG_OBJECT (dec, "newsegment event in %s format => not framed",
- gst_format_get_name (fmt));
- dec->framed = FALSE;
-
- /* prepare generic newsegment event, for some reason our metadata
- * callback where we usually set this up is not being called in
- * push mode */
- if (dec->start_segment)
- gst_event_unref (dec->start_segment);
- dec->start_segment = gst_event_new_new_segment (FALSE, 1.0,
- GST_FORMAT_TIME, 0, -1, 0);
-
- gst_event_unref (event);
- res = TRUE;
- }
- break;
- }
- case GST_EVENT_EOS:{
- GST_LOG_OBJECT (dec, "EOS, with %u bytes available in adapter",
- gst_adapter_available (dec->adapter));
- if (dec->init == FALSE) {
- if (gst_adapter_available (dec->adapter) > 0) {
- FLAC__stream_decoder_process_until_end_of_stream (dec->decoder);
- }
- FLAC__stream_decoder_flush (dec->decoder);
- }
- gst_adapter_clear (dec->adapter);
- res = gst_pad_push_event (dec->srcpad, event);
- break;
- }
- default:
- res = gst_pad_event_default (pad, event);
- break;
- }
-
- gst_object_unref (dec);
-
- return res;
-}
-
-static gboolean
-gst_flac_dec_chain_parse_headers (GstFlacDec * dec)
-{
- guint8 marker[4];
- guint avail, off;
-
- avail = gst_adapter_available (dec->adapter);
- if (avail < 4)
- return FALSE;
-
- gst_adapter_copy (dec->adapter, marker, 0, 4);
- if (strncmp ((const gchar *) marker, "fLaC", 4) != 0) {
- GST_ERROR_OBJECT (dec, "Unexpected header, expected fLaC header");
- return TRUE; /* abort header parsing */
- }
-
- GST_DEBUG_OBJECT (dec, "fLaC header : len 4 @ %7u", 0);
-
- off = 4;
- while (avail > (off + 1 + 3)) {
- gboolean is_last;
- guint8 mb_hdr[4];
- guint len, block_type;
-
- gst_adapter_copy (dec->adapter, mb_hdr, off, 4);
-
- is_last = ((mb_hdr[0] & 0x80) == 0x80);
- block_type = mb_hdr[0] & 0x7f;
- len = GST_READ_UINT24_BE (mb_hdr + 1);
- GST_DEBUG_OBJECT (dec, "Metadata block type %u: len %7u + 4 @ %7u%s",
- block_type, len, off, (is_last) ? " (last)" : "");
- off += 4 + len;
-
- if (is_last)
- break;
-
- if (off >= avail) {
- GST_LOG_OBJECT (dec, "Need more data: next offset %u > avail %u", off,
- avail);
- return FALSE;
- }
+ /* drain remaining data? */
+ if (G_UNLIKELY (buf == NULL)) {
+ gst_flac_dec_flush (audio_dec, FALSE);
+ return GST_FLOW_OK;
}
- /* want metadata blocks plus at least one frame */
- return (off + FLAC__MAX_BLOCK_SIZE >= avail);
-}
+ GST_LOG_OBJECT (dec, "frame: ts %" GST_TIME_FORMAT ", flags 0x%04x, "
+ "%" G_GSIZE_FORMAT " bytes", GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
+ GST_BUFFER_FLAGS (buf), gst_buffer_get_size (buf));
-static GstFlowReturn
-gst_flac_dec_chain (GstPad * pad, GstBuffer * buf)
-{
- FLAC__StreamDecoderInitStatus s;
- GstFlacDec *dec;
- gboolean got_audio_frame;
-
- dec = GST_FLAC_DEC (GST_PAD_PARENT (pad));
-
- GST_LOG_OBJECT (dec,
- "buffer with ts=%" GST_TIME_FORMAT ", offset=%" G_GINT64_FORMAT
- ", end_offset=%" G_GINT64_FORMAT ", size=%u",
- GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_BUFFER_OFFSET (buf),
- GST_BUFFER_OFFSET_END (buf), GST_BUFFER_SIZE (buf));
-
- if (dec->init) {
- GST_DEBUG_OBJECT (dec, "initializing decoder");
- s = FLAC__stream_decoder_init_stream (dec->decoder,
- gst_flac_dec_read_stream, NULL, NULL, NULL, NULL,
- gst_flac_dec_write_stream, gst_flac_dec_metadata_cb,
- gst_flac_dec_error_cb, dec);
- if (s != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
- GST_ELEMENT_ERROR (GST_ELEMENT (dec), LIBRARY, INIT, (NULL), (NULL));
- return GST_FLOW_ERROR;
- }
- GST_DEBUG_OBJECT (dec, "initialized (framed=%d)", dec->framed);
- dec->init = FALSE;
- } else if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT)) {
- /* Clear the adapter and the decoder */
- gst_adapter_clear (dec->adapter);
- FLAC__stream_decoder_flush (dec->decoder);
- }
-
- if (dec->framed) {
+ /* drop any in-stream headers, we've processed those in set_format already */
+ if (G_UNLIKELY (!dec->got_headers)) {
+ gboolean got_audio_frame;
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);
-
- /* oggdemux will set granulepos in OFFSET_END instead of timestamp */
- if (G_LIKELY (got_audio_frame)) {
- /* old oggdemux for now */
- if (!GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
- dec->cur_granulepos = GST_BUFFER_OFFSET_END (buf);
- } else {
- GstFormat dformat = GST_FORMAT_DEFAULT;
-
- /* upstream (e.g. demuxer) presents us time,
- * convert to default samples */
- gst_flac_dec_convert_src (dec->srcpad, GST_FORMAT_TIME,
- GST_BUFFER_TIMESTAMP (buf), &dformat, &dec->segment.last_stop);
- dec->cur_granulepos = GST_BUFFER_OFFSET_NONE;
- }
+ 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);
+
+ if (!got_audio_frame) {
+ GST_INFO_OBJECT (dec, "dropping in-stream header, %" G_GSIZE_FORMAT " "
+ "bytes", size);
+ gst_audio_decoder_finish_frame (audio_dec, NULL, 1);
+ return GST_FLOW_OK;
}
- } else {
- dec->cur_granulepos = GST_BUFFER_OFFSET_NONE;
- got_audio_frame = TRUE;
+
+ GST_INFO_OBJECT (dec, "first audio frame, got all in-stream headers now");
+ dec->got_headers = TRUE;
}
- gst_adapter_push (dec->adapter, buf);
+ gst_adapter_push (dec->adapter, gst_buffer_ref (buf));
buf = NULL;
dec->last_flow = GST_FLOW_OK;
- if (!dec->framed) {
- if (G_UNLIKELY (!dec->got_headers)) {
- if (!gst_flac_dec_chain_parse_headers (dec)) {
- GST_LOG_OBJECT (dec, "don't have metadata blocks yet, need more data");
- goto out;
- }
- GST_INFO_OBJECT (dec, "have all metadata blocks now");
- dec->got_headers = TRUE;
- }
-
- /* wait until we have at least 64kB because libflac's StreamDecoder
- * interface is a bit dumb it seems (if we don't have as much data as
- * it wants it will call our read callback repeatedly and the only
- * way to stop that is to error out or EOS, which will affect the
- * decoder state). And the decoder seems to always ask for MAX_BLOCK_SIZE
- * bytes rather than the max. block size from the header). Requiring
- * MAX_BLOCK_SIZE bytes here should make sure it always gets enough data
- * to decode at least one block */
- while (gst_adapter_available (dec->adapter) >= FLAC__MAX_BLOCK_SIZE &&
- dec->last_flow == GST_FLOW_OK) {
- GST_LOG_OBJECT (dec, "%u bytes available",
- gst_adapter_available (dec->adapter));
- if (!FLAC__stream_decoder_process_single (dec->decoder)) {
- GST_DEBUG_OBJECT (dec, "process_single failed");
- break;
- }
+ /* framed - there should always be enough data to decode something */
+ GST_LOG_OBJECT (dec, "%" G_GSIZE_FORMAT " bytes available",
+ gst_adapter_available (dec->adapter));
- if (FLAC__stream_decoder_get_state (dec->decoder) ==
- FLAC__STREAM_DECODER_ABORTED) {
- GST_WARNING_OBJECT (dec, "Read callback caused internal abort");
- dec->last_flow = GST_FLOW_ERROR;
- break;
- }
- }
- } else if (dec->framed && got_audio_frame) {
- /* framed - there should always be enough data to decode something */
- GST_LOG_OBJECT (dec, "%u bytes available",
- gst_adapter_available (dec->adapter));
- if (G_UNLIKELY (!dec->got_headers)) {
- /* The first time we get audio data, we know we got all the headers.
- * We then loop until all the metadata is processed, then do an extra
- * "process_single" step for the audio frame. */
- GST_DEBUG_OBJECT (dec,
- "First audio frame, ensuring all metadata is processed");
- if (!FLAC__stream_decoder_process_until_end_of_metadata (dec->decoder)) {
- GST_DEBUG_OBJECT (dec, "process_until_end_of_metadata failed");
- }
- GST_DEBUG_OBJECT (dec,
- "All metadata is now processed, reading to process audio data");
- dec->got_headers = TRUE;
- }
- if (!FLAC__stream_decoder_process_single (dec->decoder)) {
- GST_DEBUG_OBJECT (dec, "process_single failed");
- }
- } else {
- GST_DEBUG_OBJECT (dec, "don't have all headers yet");
+ if (!FLAC__stream_decoder_process_single (dec->decoder)) {
+ GST_INFO_OBJECT (dec, "process_single failed");
}
-out:
-
return dec->last_flow;
}
-
-static gboolean
-gst_flac_dec_convert_sink (GstFlacDec * dec, GstFormat src_format,
- gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
-{
- gboolean res = TRUE;
-
- if (dec->width == 0 || dec->channels == 0 || dec->sample_rate == 0) {
- /* no frame decoded yet */
- GST_DEBUG_OBJECT (dec, "cannot convert: not set up yet");
- return FALSE;
- }
-
- switch (src_format) {
- case GST_FORMAT_BYTES:{
- res = FALSE;
- break;
- }
- case GST_FORMAT_DEFAULT:
- switch (*dest_format) {
- case GST_FORMAT_BYTES:
- res = FALSE;
- break;
- case GST_FORMAT_TIME:
- /* granulepos = sample */
- *dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND,
- dec->sample_rate);
- break;
- default:
- res = FALSE;
- break;
- }
- break;
- case GST_FORMAT_TIME:
- switch (*dest_format) {
- case GST_FORMAT_BYTES:
- res = FALSE;
- break;
- case GST_FORMAT_DEFAULT:
- *dest_value = gst_util_uint64_scale_int (src_value,
- dec->sample_rate, GST_SECOND);
- break;
- default:
- res = FALSE;
- break;
- }
- break;
- default:
- res = FALSE;
- break;
- }
- return res;
-}
-
-static const GstQueryType *
-gst_flac_dec_get_sink_query_types (GstPad * pad)
-{
- static const GstQueryType types[] = {
- GST_QUERY_CONVERT,
- 0,
- };
-
- return types;
-}
-
-static gboolean
-gst_flac_dec_sink_query (GstPad * pad, GstQuery * query)
-{
- GstFlacDec *dec;
- gboolean res = FALSE;
-
- dec = GST_FLAC_DEC (gst_pad_get_parent (pad));
-
- GST_LOG_OBJECT (dec, "%s query", GST_QUERY_TYPE_NAME (query));
-
- switch (GST_QUERY_TYPE (query)) {
- case GST_QUERY_CONVERT:{
- GstFormat src_fmt, dest_fmt;
-
- gint64 src_val, dest_val;
-
- gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, NULL);
-
- res = gst_flac_dec_convert_sink (dec, src_fmt, src_val, &dest_fmt,
- &dest_val);
-
- if (res) {
- gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
- }
- GST_LOG_OBJECT (dec, "conversion %s", (res) ? "ok" : "FAILED");
- break;
- }
-
- default:{
- res = gst_pad_query_default (pad, query);
- break;
- }
- }
-
- gst_object_unref (dec);
- return res;
-}
-
-static gboolean
-gst_flac_dec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
- GstFormat * dest_format, gint64 * dest_value)
-{
- GstFlacDec *flacdec = GST_FLAC_DEC (GST_PAD_PARENT (pad));
- gboolean res = TRUE;
- guint bytes_per_sample;
- guint scale = 1;
-
- if (flacdec->width == 0 || flacdec->channels == 0 ||
- flacdec->sample_rate == 0) {
- /* no frame decoded yet */
- GST_DEBUG_OBJECT (flacdec, "cannot convert: not set up yet");
- return FALSE;
- }
-
- bytes_per_sample = flacdec->channels * (flacdec->width / 8);
-
- switch (src_format) {
- case GST_FORMAT_BYTES:{
- switch (*dest_format) {
- case GST_FORMAT_DEFAULT:
- *dest_value =
- gst_util_uint64_scale_int (src_value, 1, bytes_per_sample);
- break;
- case GST_FORMAT_TIME:
- {
- gint byterate = bytes_per_sample * flacdec->sample_rate;
-
- *dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND,
- byterate);
- break;
- }
- default:
- res = FALSE;
- }
- break;
- }
- case GST_FORMAT_DEFAULT:
- switch (*dest_format) {
- case GST_FORMAT_BYTES:
- *dest_value = src_value * bytes_per_sample;
- break;
- case GST_FORMAT_TIME:
- *dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND,
- flacdec->sample_rate);
- break;
- default:
- res = FALSE;
- }
- break;
- case GST_FORMAT_TIME:
- switch (*dest_format) {
- case GST_FORMAT_BYTES:
- scale = bytes_per_sample;
- case GST_FORMAT_DEFAULT:
- *dest_value = gst_util_uint64_scale_int_round (src_value,
- scale * flacdec->sample_rate, GST_SECOND);
- break;
- default:
- res = FALSE;
- }
- break;
- default:
- res = FALSE;
- }
- return res;
-}
-
-static const GstQueryType *
-gst_flac_dec_get_src_query_types (GstPad * pad)
-{
- static const GstQueryType types[] = {
- GST_QUERY_POSITION,
- GST_QUERY_DURATION,
- GST_QUERY_CONVERT,
- GST_QUERY_SEEKING,
- 0,
- };
-
- return types;
-}
-
-static gboolean
-gst_flac_dec_src_query (GstPad * pad, GstQuery * query)
-{
- GstFlacDec *flacdec;
- gboolean res = TRUE;
- GstPad *peer;
-
- flacdec = GST_FLAC_DEC (gst_pad_get_parent (pad));
- peer = gst_pad_get_peer (flacdec->sinkpad);
-
- switch (GST_QUERY_TYPE (query)) {
- case GST_QUERY_POSITION:{
- GstFormat fmt;
- gint64 pos;
-
- gst_query_parse_position (query, &fmt, NULL);
-
- /* there might be a demuxer in front of us who can handle this */
- if (fmt == GST_FORMAT_TIME && (res = gst_pad_query (peer, query)))
- break;
-
- if (fmt != GST_FORMAT_DEFAULT) {
- if (!gst_flac_dec_convert_src (flacdec->srcpad, GST_FORMAT_DEFAULT,
- flacdec->segment.last_stop, &fmt, &pos)) {
- GST_DEBUG_OBJECT (flacdec, "failed to convert position into %s "
- "format", gst_format_get_name (fmt));
- res = FALSE;
- goto done;
- }
- } else {
- pos = flacdec->segment.last_stop;
- }
-
- gst_query_set_position (query, fmt, pos);
-
- GST_DEBUG_OBJECT (flacdec, "returning position %" G_GUINT64_FORMAT
- " (format: %s)", pos, gst_format_get_name (fmt));
-
- res = TRUE;
- break;
- }
-
- case GST_QUERY_DURATION:{
- GstFormat fmt;
- gint64 len;
-
- gst_query_parse_duration (query, &fmt, NULL);
-
- /* try any demuxers or parsers before us first */
- if ((fmt == GST_FORMAT_TIME || fmt == GST_FORMAT_DEFAULT) &&
- peer != NULL && gst_pad_query (peer, query)) {
- gst_query_parse_duration (query, NULL, &len);
- GST_DEBUG_OBJECT (flacdec, "peer returned duration %" GST_TIME_FORMAT,
- GST_TIME_ARGS (len));
- res = TRUE;
- goto done;
- }
-
- if (flacdec->segment.duration == 0 || flacdec->segment.duration == -1) {
- GST_DEBUG_OBJECT (flacdec, "duration not known yet");
- res = FALSE;
- goto done;
- }
-
- /* convert total number of samples to request format */
- if (fmt != GST_FORMAT_DEFAULT) {
- if (!gst_flac_dec_convert_src (flacdec->srcpad, GST_FORMAT_DEFAULT,
- flacdec->segment.duration, &fmt, &len)) {
- GST_DEBUG_OBJECT (flacdec, "failed to convert duration into %s "
- "format", gst_format_get_name (fmt));
- res = FALSE;
- goto done;
- }
- } else {
- len = flacdec->segment.duration;
- }
-
- gst_query_set_duration (query, fmt, len);
-
- GST_DEBUG_OBJECT (flacdec, "returning duration %" G_GUINT64_FORMAT
- " (format: %s)", len, gst_format_get_name (fmt));
-
- res = TRUE;
- break;
- }
-
- case GST_QUERY_CONVERT:{
- GstFormat src_fmt, dest_fmt;
- gint64 src_val, dest_val;
-
- gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, NULL);
-
- res = gst_flac_dec_convert_src (pad, src_fmt, src_val, &dest_fmt,
- &dest_val);
-
- if (res) {
- gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
- }
-
- break;
- }
- case GST_QUERY_SEEKING:{
- GstFormat fmt;
- gboolean seekable = FALSE;
-
- res = TRUE;
- /* If upstream can handle the query we're done */
- seekable = gst_pad_peer_query (flacdec->sinkpad, query);
- if (seekable)
- gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL);
- if (seekable)
- goto done;
-
- gst_query_parse_seeking (query, &fmt, NULL, NULL, NULL);
- if ((fmt != GST_FORMAT_TIME && fmt != GST_FORMAT_DEFAULT) ||
- flacdec->streaming) {
- gst_query_set_seeking (query, fmt, FALSE, -1, -1);
- } else {
- gst_query_set_seeking (query, GST_FORMAT_TIME, TRUE, 0, -1);
- }
- break;
- }
-
- default:{
- res = gst_pad_query_default (pad, query);
- break;
- }
- }
-
-done:
-
- if (peer)
- gst_object_unref (peer);
-
- gst_object_unref (flacdec);
-
- return res;
-}
-
-static gboolean
-gst_flac_dec_handle_seek_event (GstFlacDec * flacdec, GstEvent * event)
-{
- FLAC__bool seek_ok;
- GstSeekFlags seek_flags;
- GstSeekType start_type;
- GstSeekType stop_type;
- GstSegment segment;
- GstFormat seek_format;
- gboolean only_update = FALSE;
- gboolean flush;
- gdouble rate;
- gint64 start, last_stop;
- gint64 stop;
-
- if (flacdec->streaming) {
- GST_DEBUG_OBJECT (flacdec, "seeking in streaming mode not implemented yet");
- return FALSE;
- }
-
- gst_event_parse_seek (event, &rate, &seek_format, &seek_flags, &start_type,
- &start, &stop_type, &stop);
-
- if (seek_format != GST_FORMAT_DEFAULT && seek_format != GST_FORMAT_TIME) {
- GST_DEBUG_OBJECT (flacdec,
- "seeking is only supported in TIME or DEFAULT format");
- return FALSE;
- }
-
- if (rate < 0.0) {
- GST_DEBUG_OBJECT (flacdec,
- "only forward playback supported, rate %f not allowed", rate);
- return FALSE;
- }
-
- if (seek_format != GST_FORMAT_DEFAULT) {
- GstFormat target_format = GST_FORMAT_DEFAULT;
-
- if (start_type != GST_SEEK_TYPE_NONE &&
- !gst_flac_dec_convert_src (flacdec->srcpad, seek_format, start,
- &target_format, &start)) {
- GST_DEBUG_OBJECT (flacdec, "failed to convert start to DEFAULT format");
- return FALSE;
- }
-
- if (stop_type != GST_SEEK_TYPE_NONE &&
- !gst_flac_dec_convert_src (flacdec->srcpad, seek_format, stop,
- &target_format, &stop)) {
- GST_DEBUG_OBJECT (flacdec, "failed to convert stop to DEFAULT format");
- return FALSE;
- }
- }
-
- /* Check if we seeked after the end of file */
- if (start_type != GST_SEEK_TYPE_NONE && flacdec->segment.duration > 0 &&
- start >= flacdec->segment.duration) {
- flacdec->eos = TRUE;
- } else {
- flacdec->eos = FALSE;
- }
-
- flush = ((seek_flags & GST_SEEK_FLAG_FLUSH) == GST_SEEK_FLAG_FLUSH);
-
- if (flush) {
- /* flushing seek, clear the pipeline of stuff, we need a newsegment after
- * this. */
- GST_DEBUG_OBJECT (flacdec, "flushing");
- gst_pad_push_event (flacdec->sinkpad, gst_event_new_flush_start ());
- gst_pad_push_event (flacdec->srcpad, gst_event_new_flush_start ());
- } else {
- /* non flushing seek, pause the task */
- GST_DEBUG_OBJECT (flacdec, "stopping task");
- gst_pad_stop_task (flacdec->sinkpad);
- }
-
- /* acquire the stream lock, this either happens when the streaming thread
- * stopped because of the flush or when the task is paused after the loop
- * function finished an iteration, which can never happen when it's blocked
- * downstream in PAUSED, for example */
- GST_PAD_STREAM_LOCK (flacdec->sinkpad);
-
- /* start seek with clear state to avoid seeking thread pushing segments/data.
- * Note current state may have some pending,
- * e.g. multi-sink seek leads to immediate subsequent seek events */
- if (flacdec->start_segment) {
- gst_event_unref (flacdec->start_segment);
- flacdec->start_segment = NULL;
- }
- gst_buffer_replace (&flacdec->pending, NULL);
- flacdec->pending_samples = 0;
-
- /* save a segment copy until we know the seek worked. The idea is that
- * when the seek fails, we want to restore with what we were doing. */
- segment = flacdec->segment;
-
- /* update the segment with the seek values, last_stop will contain the new
- * position we should seek to */
- gst_segment_set_seek (&flacdec->segment, rate, GST_FORMAT_DEFAULT,
- seek_flags, start_type, start, stop_type, stop, &only_update);
-
- GST_DEBUG_OBJECT (flacdec,
- "configured segment: [%" G_GINT64_FORMAT "-%" G_GINT64_FORMAT
- "] = [%" GST_TIME_FORMAT "-%" GST_TIME_FORMAT "]",
- flacdec->segment.start, flacdec->segment.stop,
- GST_TIME_ARGS (flacdec->segment.start * GST_SECOND /
- flacdec->sample_rate),
- GST_TIME_ARGS (flacdec->segment.stop * GST_SECOND /
- flacdec->sample_rate));
-
- GST_DEBUG_OBJECT (flacdec, "performing seek to sample %" G_GINT64_FORMAT,
- flacdec->segment.last_stop);
-
- /* flush sinkpad again because we need to pull and push buffers while doing
- * the seek */
- if (flush) {
- GST_DEBUG_OBJECT (flacdec, "flushing stop");
- gst_pad_push_event (flacdec->sinkpad, gst_event_new_flush_stop ());
- gst_pad_push_event (flacdec->srcpad, gst_event_new_flush_stop ());
- }
-
- /* mark ourselves as seeking because the above lines will trigger some
- * callbacks that need to behave differently when seeking */
- flacdec->seeking = TRUE;
-
- if (!flacdec->eos) {
- GST_LOG_OBJECT (flacdec, "calling seek_absolute");
- seek_ok = FLAC__stream_decoder_seek_absolute (flacdec->decoder,
- flacdec->segment.last_stop);
- GST_LOG_OBJECT (flacdec, "done with seek_absolute, seek_ok=%d", seek_ok);
- } else {
- GST_LOG_OBJECT (flacdec, "not seeking, seeked after end of file");
- seek_ok = TRUE;
- }
-
- flacdec->seeking = FALSE;
-
- GST_DEBUG_OBJECT (flacdec, "performed seek to sample %" G_GINT64_FORMAT,
- flacdec->segment.last_stop);
-
- if (!seek_ok) {
- GST_WARNING_OBJECT (flacdec, "seek failed");
- /* seek failed, restore the segment and start streaming again with
- * the previous segment values */
- flacdec->segment = segment;
- } else if (!flush && flacdec->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 (flacdec, "closing running segment %" G_GINT64_FORMAT
- " to %" G_GINT64_FORMAT, segment.start, segment.last_stop);
-
- /* convert the old segment values to time to close the old segment */
- start = gst_util_uint64_scale_int (segment.start, GST_SECOND,
- flacdec->sample_rate);
- last_stop =
- gst_util_uint64_scale_int (segment.last_stop, GST_SECOND,
- flacdec->sample_rate);
-
- /* queue the segment for sending in the stream thread, start and time are
- * always the same. */
- if (flacdec->close_segment)
- gst_event_unref (flacdec->close_segment);
- flacdec->close_segment =
- gst_event_new_new_segment_full (TRUE,
- segment.rate, segment.applied_rate, GST_FORMAT_TIME,
- start, last_stop, start);
- }
-
- if (seek_ok) {
- /* seek succeeded, flacdec->segment contains the new positions */
- GST_DEBUG_OBJECT (flacdec, "seek successful");
- }
-
- /* convert the (new) segment values to time, we will need them to generate the
- * new segment events. */
- start = gst_util_uint64_scale_int (flacdec->segment.start, GST_SECOND,
- flacdec->sample_rate);
- last_stop = gst_util_uint64_scale_int (flacdec->segment.last_stop, GST_SECOND,
- flacdec->sample_rate);
-
- /* for deriving a stop position for the playback segment from the seek
- * segment, we must take the duration when the stop is not set */
- if (flacdec->segment.stop != -1)
- stop = gst_util_uint64_scale_int (flacdec->segment.stop, GST_SECOND,
- flacdec->sample_rate);
- else
- stop = gst_util_uint64_scale_int (flacdec->segment.duration, GST_SECOND,
- flacdec->sample_rate);
-
- /* notify start of new segment when we were asked to do so. */
- if (flacdec->segment.flags & GST_SEEK_FLAG_SEGMENT) {
- /* last_stop contains the position we start from */
- gst_element_post_message (GST_ELEMENT (flacdec),
- gst_message_new_segment_start (GST_OBJECT (flacdec),
- GST_FORMAT_TIME, last_stop));
- }
-
- /* if the seek was ok or (when it failed) we are flushing, we need to send out
- * a new segment. If we did not flush and the seek failed, we simply do
- * nothing here and continue where we were. */
- if (seek_ok || flush) {
- GST_DEBUG_OBJECT (flacdec, "Creating newsegment from %" GST_TIME_FORMAT
- " to %" GST_TIME_FORMAT, GST_TIME_ARGS (last_stop),
- GST_TIME_ARGS (stop));
- /* now replace the old segment so that we send it in the stream thread the
- * next time it is scheduled. */
- if (flacdec->start_segment)
- gst_event_unref (flacdec->start_segment);
- flacdec->start_segment =
- gst_event_new_new_segment_full (FALSE,
- flacdec->segment.rate, flacdec->segment.applied_rate, GST_FORMAT_TIME,
- last_stop, stop, last_stop);
- }
-
- /* we'll generate a discont on the next buffer */
- flacdec->discont = TRUE;
- /* the task is running again now */
- flacdec->running = TRUE;
- gst_pad_start_task (flacdec->sinkpad,
- (GstTaskFunction) gst_flac_dec_loop, flacdec->sinkpad);
-
- GST_PAD_STREAM_UNLOCK (flacdec->sinkpad);
-
- return seek_ok;
-}
-
-static gboolean
-gst_flac_dec_src_event (GstPad * pad, GstEvent * event)
-{
- gboolean res = TRUE;
- GstFlacDec *flacdec;
-
- flacdec = GST_FLAC_DEC (gst_pad_get_parent (pad));
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_SEEK:{
- GST_DEBUG_OBJECT (flacdec, "received seek event %p", event);
- /* first, see if we're before a demuxer that
- * might handle the seek for us */
- gst_event_ref (event);
- res = gst_pad_event_default (pad, event);
- /* if not, try to handle it ourselves */
- if (!res) {
- GST_DEBUG_OBJECT (flacdec, "default failed, handling ourselves");
- res = gst_flac_dec_handle_seek_event (flacdec, event);
- }
- gst_event_unref (event);
- break;
- }
- default:
- res = gst_pad_event_default (pad, event);
- break;
- }
-
- gst_object_unref (flacdec);
-
- return res;
-}
-
-static gboolean
-gst_flac_dec_sink_activate (GstPad * sinkpad)
-{
- if (gst_pad_check_pull_range (sinkpad))
- return gst_pad_activate_pull (sinkpad, TRUE);
-
- return gst_pad_activate_push (sinkpad, TRUE);
-}
-
-static gboolean
-gst_flac_dec_sink_activate_push (GstPad * sinkpad, gboolean active)
-{
- GstFlacDec *dec = GST_FLAC_DEC (GST_OBJECT_PARENT (sinkpad));
-
- if (active) {
- gst_flac_dec_setup_decoder (dec);
- dec->streaming = TRUE;
- dec->got_headers = FALSE;
- }
- return TRUE;
-}
-
-static gboolean
-gst_flac_dec_sink_activate_pull (GstPad * sinkpad, gboolean active)
-{
- gboolean res;
-
- if (active) {
- GstFlacDec *flacdec;
-
- flacdec = GST_FLAC_DEC (GST_PAD_PARENT (sinkpad));
-
- flacdec->offset = 0;
- gst_flac_dec_setup_decoder (flacdec);
- flacdec->running = TRUE;
- flacdec->streaming = FALSE;
-
- res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_flac_dec_loop,
- sinkpad);
- } else {
- res = gst_pad_stop_task (sinkpad);
- }
- return res;
-}
-
-static GstStateChangeReturn
-gst_flac_dec_change_state (GstElement * element, GstStateChange transition)
-{
- GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
- GstFlacDec *flacdec = GST_FLAC_DEC (element);
-
- switch (transition) {
- case GST_STATE_CHANGE_READY_TO_PAUSED:
- flacdec->eos = FALSE;
- flacdec->seeking = FALSE;
- flacdec->channels = 0;
- flacdec->depth = 0;
- flacdec->width = 0;
- flacdec->sample_rate = 0;
- gst_segment_init (&flacdec->segment, GST_FORMAT_DEFAULT);
- break;
- default:
- break;
- }
-
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- if (ret == GST_STATE_CHANGE_FAILURE)
- return ret;
-
- switch (transition) {
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- gst_segment_init (&flacdec->segment, GST_FORMAT_UNDEFINED);
- gst_flac_dec_reset_decoders (flacdec);
- break;
- default:
- break;
- }
-
- return ret;
-}
diff --git a/ext/flac/gstflacdec.h b/ext/flac/gstflacdec.h
index 835bdbd8c..8572e8db8 100644
--- a/ext/flac/gstflacdec.h
+++ b/ext/flac/gstflacdec.h
@@ -1,5 +1,6 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) <2011> 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
@@ -21,9 +22,8 @@
#ifndef __GST_FLAC_DEC_H__
#define __GST_FLAC_DEC_H__
-
#include <gst/gst.h>
-#include <gst/base/gstadapter.h>
+#include <gst/audio/gstaudiodecoder.h>
#include <FLAC/all.h>
@@ -39,44 +39,16 @@ typedef struct _GstFlacDec GstFlacDec;
typedef struct _GstFlacDecClass GstFlacDecClass;
struct _GstFlacDec {
- GstElement element;
-
- /* < private > */
+ GstAudioDecoder audiodecoder;
+ /*< private >*/
FLAC__StreamDecoder *decoder;
GstAdapter *adapter;
- gboolean framed;
- gboolean streaming;
-
- gboolean got_headers; /* if we've parsed the headers (unframed push mode only) */
-
- GstPad *sinkpad;
- GstPad *srcpad;
-
- gboolean init;
- guint64 offset; /* current byte offset of input */
+ gboolean got_headers; /* have we received all the header buffers yet? */
- gboolean seeking; /* set to TRUE while seeking to make sure we
- * don't push any buffers in the write callback
- * until we are actually at the new position */
-
- gboolean eos; /* set to TRUE if seeked after the end of file */
-
- GstSegment segment; /* the currently configured segment, in
- * samples/audio frames (DEFAULT format) */
- gboolean running;
- gboolean discont;
- GstBuffer *pending; /* pending buffer, produced in seek */
- guint pending_samples;
- GstEvent *close_segment;
- GstEvent *start_segment;
- GstTagList *tags;
-
- GstFlowReturn pull_flow; /* last flow from pull_range */ /* STREAM_LOCK */
-
- GstFlowReturn last_flow; /* the last flow return received from either
- * gst_pad_push or gst_pad_buffer_alloc */
+ GstFlowReturn last_flow; /* to marshal flow return from finis_frame to
+ * handle_frame via flac callbacks */
gint channels;
gint depth;
@@ -86,12 +58,10 @@ struct _GstFlacDec {
/* from the stream info, needed for scanning */
guint16 min_blocksize;
guint16 max_blocksize;
-
- gint64 cur_granulepos; /* only used in framed mode (flac-in-ogg) */
};
struct _GstFlacDecClass {
- GstElementClass parent_class;
+ GstAudioDecoderClass audiodecoder;
};
GType gst_flac_dec_get_type (void);
diff --git a/ext/flac/gstflacenc.c b/ext/flac/gstflacenc.c
index d30d31419..1b3dac225 100644
--- a/ext/flac/gstflacenc.c
+++ b/ext/flac/gstflacenc.c
@@ -149,20 +149,9 @@ 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 \
- }; \
- g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, \
- &tag_setter_info); \
- }G_STMT_END
-
-GST_BOILERPLATE_FULL (GstFlacEnc, gst_flac_enc, GstAudioEncoder,
- GST_TYPE_AUDIO_ENCODER, _do_init);
+#define gst_flac_enc_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstFlacEnc, gst_flac_enc, GST_TYPE_AUDIO_ENCODER,
+ G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
static gboolean gst_flac_enc_start (GstAudioEncoder * enc);
static gboolean gst_flac_enc_stop (GstAudioEncoder * enc);
@@ -170,7 +159,7 @@ static gboolean gst_flac_enc_set_format (GstAudioEncoder * enc,
GstAudioInfo * info);
static GstFlowReturn gst_flac_enc_handle_frame (GstAudioEncoder * enc,
GstBuffer * in_buf);
-static GstCaps *gst_flac_enc_getcaps (GstAudioEncoder * enc);
+static GstCaps *gst_flac_enc_getcaps (GstAudioEncoder * enc, GstCaps * filter);
static gboolean gst_flac_enc_sink_event (GstAudioEncoder * enc,
GstEvent * event);
@@ -254,42 +243,23 @@ 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_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &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;
+ GstElementClass *gstelement_class;
GstAudioEncoderClass *base_class;
gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
base_class = (GstAudioEncoderClass *) (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;
- base_class->start = GST_DEBUG_FUNCPTR (gst_flac_enc_start);
- base_class->stop = GST_DEBUG_FUNCPTR (gst_flac_enc_stop);
- base_class->set_format = GST_DEBUG_FUNCPTR (gst_flac_enc_set_format);
- base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_flac_enc_handle_frame);
- base_class->getcaps = GST_DEBUG_FUNCPTR (gst_flac_enc_getcaps);
- base_class->event = GST_DEBUG_FUNCPTR (gst_flac_enc_sink_event);
-
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_QUALITY,
g_param_spec_enum ("quality",
"Quality",
@@ -402,10 +372,27 @@ gst_flac_enc_class_init (GstFlacEncClass * klass)
-G_MAXINT, G_MAXINT,
DEFAULT_SEEKPOINTS,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ 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>");
+
+ base_class->start = GST_DEBUG_FUNCPTR (gst_flac_enc_start);
+ base_class->stop = GST_DEBUG_FUNCPTR (gst_flac_enc_stop);
+ base_class->set_format = GST_DEBUG_FUNCPTR (gst_flac_enc_set_format);
+ base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_flac_enc_handle_frame);
+ base_class->getcaps = GST_DEBUG_FUNCPTR (gst_flac_enc_getcaps);
+ base_class->event = GST_DEBUG_FUNCPTR (gst_flac_enc_sink_event);
}
static void
-gst_flac_enc_init (GstFlacEnc * flacenc, GstFlacEncClass * klass)
+gst_flac_enc_init (GstFlacEnc * flacenc)
{
GstAudioEncoder *enc = GST_AUDIO_ENCODER (flacenc);
@@ -441,7 +428,7 @@ gst_flac_enc_start (GstAudioEncoder * enc)
flacenc->depth = 0;
flacenc->sample_rate = 0;
flacenc->eos = FALSE;
- flacenc->tags = gst_tag_list_new ();
+ flacenc->tags = gst_tag_list_new_empty ();
return TRUE;
}
@@ -535,10 +522,14 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
if (n_images + n_preview_images > 0) {
GstBuffer *buffer;
+#if 0
GstCaps *caps;
GstStructure *structure;
GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE;
+#endif
gint i;
+ guint8 *data;
+ gsize size;
for (i = 0; i < n_images + n_preview_images; i++) {
if (i < n_images) {
@@ -553,6 +544,7 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
flacenc->meta[entries] =
FLAC__metadata_object_new (FLAC__METADATA_TYPE_PICTURE);
+#if 0
caps = gst_buffer_get_caps (buffer);
structure = gst_caps_get_structure (caps, 0);
@@ -563,15 +555,21 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
image_type = (i < n_images) ? 0x00 : 0x01;
else
image_type = image_type + 2;
+#endif
+ 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);
+
+#if 0
/* 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],
(char *) gst_structure_get_name (structure), TRUE);
-
gst_caps_unref (caps);
+#endif
+
gst_buffer_unref (buffer);
entries++;
}
@@ -663,7 +661,7 @@ gst_flac_enc_caps_append_structure_with_widths (GstCaps * caps,
}
static GstCaps *
-gst_flac_enc_getcaps (GstAudioEncoder * enc)
+gst_flac_enc_getcaps (GstAudioEncoder * enc, GstCaps * filter)
{
GstCaps *ret = NULL, *caps = NULL;
GstPad *pad;
@@ -672,8 +670,8 @@ gst_flac_enc_getcaps (GstAudioEncoder * enc)
GST_OBJECT_LOCK (pad);
- if (GST_PAD_CAPS (pad)) {
- ret = gst_caps_ref (GST_PAD_CAPS (pad));
+ if (gst_pad_has_current_caps (pad)) {
+ ret = gst_pad_get_current_caps (pad);
} else {
gint i, c;
@@ -723,21 +721,19 @@ gst_flac_enc_getcaps (GstAudioEncoder * enc)
}
static guint64
-gst_flac_enc_query_peer_total_samples (GstFlacEnc * flacenc, GstPad * pad)
+gst_flac_enc_peer_query_total_samples (GstFlacEnc * flacenc, GstPad * pad)
{
- GstFormat fmt = GST_FORMAT_DEFAULT;
gint64 duration;
GST_DEBUG_OBJECT (flacenc, "querying peer for DEFAULT format duration");
- if (gst_pad_query_peer_duration (pad, &fmt, &duration)
- && fmt == GST_FORMAT_DEFAULT && duration != GST_CLOCK_TIME_NONE)
+ if (gst_pad_peer_query_duration (pad, GST_FORMAT_DEFAULT, &duration)
+ && duration != GST_CLOCK_TIME_NONE)
goto done;
- fmt = GST_FORMAT_TIME;
GST_DEBUG_OBJECT (flacenc, "querying peer for TIME format duration");
- if (gst_pad_query_peer_duration (pad, &fmt, &duration) &&
- fmt == GST_FORMAT_TIME && duration != GST_CLOCK_TIME_NONE) {
+ if (gst_pad_peer_query_duration (pad, GST_FORMAT_TIME, &duration)
+ && duration != GST_CLOCK_TIME_NONE) {
GST_DEBUG_OBJECT (flacenc, "peer reported duration %" GST_TIME_FORMAT,
GST_TIME_ARGS (duration));
duration = GST_CLOCK_TIME_TO_FRAMES (duration, flacenc->sample_rate);
@@ -784,7 +780,7 @@ gst_flac_enc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
gst_caps_unref (caps);
- total_samples = gst_flac_enc_query_peer_total_samples (flacenc,
+ total_samples = gst_flac_enc_peer_query_total_samples (flacenc,
GST_AUDIO_ENCODER_SINK_PAD (enc));
FLAC__stream_encoder_set_bits_per_sample (flacenc->encoder, flacenc->depth);
@@ -885,14 +881,18 @@ gst_flac_enc_seek_callback (const FLAC__StreamEncoder * encoder,
GstFlacEnc *flacenc;
GstEvent *event;
GstPad *peerpad;
+ GstSegment seg;
flacenc = GST_FLAC_ENC (client_data);
if (flacenc->stopped)
return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
- event = gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES,
- absolute_byte_offset, GST_BUFFER_OFFSET_NONE, 0);
+ gst_segment_init (&seg, GST_FORMAT_BYTES);
+ seg.start = absolute_byte_offset;
+ seg.stop = GST_BUFFER_OFFSET_NONE;
+ seg.time = 0;
+ event = gst_event_new_segment (&seg);
if ((peerpad = gst_pad_get_peer (GST_AUDIO_ENCODER_SRC_PAD (flacenc)))) {
gboolean ret = gst_pad_send_event (peerpad, event);
@@ -951,25 +951,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));
+
+ buf = GST_BUFFER_CAST (l->data);
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
- data = GST_BUFFER_DATA (GST_BUFFER_CAST (l->data));
- size = GST_BUFFER_SIZE (GST_BUFFER_CAST (l->data));
+ 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) {
@@ -984,20 +988,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);
}
@@ -1007,10 +1017,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);
}
}
@@ -1026,11 +1036,13 @@ push_headers:
GstBuffer *buf;
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_LOG_OBJECT (enc,
+ "Pushing header buffer, size %" G_GSIZE_FORMAT " bytes",
+ gst_buffer_get_size (buf));
+#if 0
GST_MEMDUMP_OBJECT (enc, "header buffer", GST_BUFFER_DATA (buf),
GST_BUFFER_SIZE (buf));
+#endif
ret = gst_pad_push (GST_AUDIO_ENCODER_SRC_PAD (enc), buf);
l->data = NULL;
}
@@ -1057,7 +1069,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);
/* we assume libflac passes us stuff neatly framed */
if (!flacenc->got_headers) {
@@ -1076,10 +1088,10 @@ gst_flac_enc_write_callback (const FLAC__StreamEncoder * encoder,
/* header fixup, push downstream directly */
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));
- gst_buffer_set_caps (outbuf,
- GST_PAD_CAPS (GST_AUDIO_ENCODER_SRC_PAD (flacenc)));
+#endif
ret = gst_pad_push (GST_AUDIO_ENCODER_SRC_PAD (flacenc), outbuf);
} else {
/* regular frame data, pass to base class */
@@ -1127,13 +1139,14 @@ gst_flac_enc_sink_event (GstAudioEncoder * enc, GstEvent * event)
GST_DEBUG ("Received %s event on sinkpad", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_NEWSEGMENT:{
- GstFormat format;
+ case GST_EVENT_SEGMENT:{
+ GstSegment seg;
gint64 start, stream_time;
if (flacenc->offset == 0) {
- gst_event_parse_new_segment (event, NULL, NULL, &format, &start, NULL,
- &stream_time);
+ gst_event_copy_segment (event, &seg);
+ start = seg.start;
+ stream_time = seg.time;
} else {
start = -1;
stream_time = -1;
@@ -1145,9 +1158,10 @@ gst_flac_enc_sink_event (GstAudioEncoder * enc, GstEvent * event)
else
GST_DEBUG ("Not handling newsegment event with non-zero start");
} else {
- GstEvent *e = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
- 0, -1, 0);
+ GstEvent *e;
+ gst_segment_init (&seg, GST_FORMAT_BYTES);
+ e = gst_event_new_segment (&seg);
ret = gst_pad_push_event (GST_AUDIO_ENCODER_SRC_PAD (enc), e);
}
@@ -1184,10 +1198,11 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, 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 (enc);
@@ -1209,29 +1224,30 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
return flacenc->last_flow;
}
- 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);
res = FLAC__stream_encoder_process_interleaved (flacenc->encoder,
(const FLAC__int32 *) data, samples / flacenc->channels);
diff --git a/ext/flac/gstflactag.c b/ext/flac/gstflactag.c
index ff06ce903..4a1428e06 100644
--- a/ext/flac/gstflactag.c
+++ b/ext/flac/gstflactag.c
@@ -89,41 +89,19 @@ enum
static void gst_flac_tag_dispose (GObject * object);
-static GstFlowReturn gst_flac_tag_chain (GstPad * pad, GstBuffer * buffer);
+static GstFlowReturn gst_flac_tag_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
static GstStateChangeReturn gst_flac_tag_change_state (GstElement * element,
GstStateChange transition);
-static gboolean gst_flac_tag_sink_setcaps (GstPad * pad, GstCaps * caps);
+static gboolean gst_flac_tag_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
-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_static_pad_template (element_class,
- &flac_tag_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +109,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,15 +151,15 @@ 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 =
gst_pad_new_from_static_template (&flac_tag_sink_template, "sink");
gst_pad_set_chain_function (tag->sinkpad,
GST_DEBUG_FUNCPTR (gst_flac_tag_chain));
- gst_pad_set_setcaps_function (tag->sinkpad,
- GST_DEBUG_FUNCPTR (gst_flac_tag_sink_setcaps));
+ gst_pad_set_event_function (tag->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_flac_tag_sink_event));
gst_element_add_pad (GST_ELEMENT (tag), tag->sinkpad);
tag->srcpad =
@@ -182,24 +170,32 @@ gst_flac_tag_init (GstFlacTag * tag, GstFlacTagClass * klass)
}
static gboolean
-gst_flac_tag_sink_setcaps (GstPad * pad, GstCaps * caps)
+gst_flac_tag_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
- GstFlacTag *tag = GST_FLAC_TAG (GST_PAD_PARENT (pad));
+ gboolean ret;
+
+ switch (GST_EVENT_TYPE (event)) {
+ default:
+ ret = gst_pad_event_default (pad, parent, event);
+ break;
+ }
- return gst_pad_set_caps (tag->srcpad, caps);
+ return ret;
}
#define FLAC_MAGIC "fLaC"
#define FLAC_MAGIC_SIZE (sizeof (FLAC_MAGIC) - 1)
static GstFlowReturn
-gst_flac_tag_chain (GstPad * pad, GstBuffer * buffer)
+gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstFlacTag *tag;
GstFlowReturn ret;
+ guint8 *data;
+ gsize size;
ret = GST_FLOW_OK;
- tag = GST_FLAC_TAG (gst_pad_get_parent (pad));
+ tag = GST_FLAC_TAG (parent);
gst_adapter_push (tag->adapter, buffer);
@@ -212,10 +208,9 @@ 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));
ret = gst_pad_push (tag->srcpad, id_buffer);
if (ret != GST_FLOW_OK)
goto cleanup;
@@ -234,7 +229,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,20 +244,22 @@ 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);
/* The 4 bytes long header isn't included in the metadata size */
tag->metadata_block_size = size + 4;
tag->metadata_last_block = is_last;
GST_DEBUG_OBJECT (tag,
- "got metadata block: %d bytes, type %d, is vorbiscomment: %d, is last: %d",
+ "got metadata block: %" G_GSIZE_FORMAT " bytes, type %d, "
+ "is vorbiscomment: %d, is last: %d",
size, type, (type == 0x04), is_last);
/* Metadata blocks of type 4 are vorbis comment blocks */
@@ -288,11 +284,12 @@ 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");
- gst_buffer_set_caps (metadata_buffer, GST_PAD_CAPS (tag->srcpad));
ret = gst_pad_push (tag->srcpad, metadata_buffer);
if (ret != GST_FLOW_OK)
goto cleanup;
@@ -312,15 +309,17 @@ 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));
+ gst_pad_push_event (tag->srcpad,
+ gst_event_new_tag (gst_tag_list_copy (tag->tags)));
}
gst_buffer_unref (tag->vorbiscomment);
@@ -341,7 +340,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,69 +359,55 @@ 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;
-
- 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));
+ 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 %" G_GSIZE_FORMAT " byte vorbiscomment "
+ "buffer", size);
+
ret = gst_pad_push (tag->srcpad, buffer);
if (ret != GST_FLOW_OK) {
goto cleanup;
@@ -439,17 +423,41 @@ gst_flac_tag_chain (GstPad * pad, GstBuffer * buffer)
avail = gst_adapter_available (tag->adapter);
if (avail > 0) {
buffer = gst_adapter_take_buffer (tag->adapter, avail);
- gst_buffer_set_caps (buffer, GST_PAD_CAPS (tag->srcpad));
ret = gst_pad_push (tag->srcpad, buffer);
}
}
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 %" G_GSIZE_FORMAT " too long", size));
+ ret = GST_FLOW_ERROR;
+ goto cleanup;
+ }
+}
static GstStateChangeReturn
gst_flac_tag_change_state (GstElement * element, GstStateChange transition)
@@ -486,5 +494,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
index 0f1cffbe9..000000000
--- a/ext/gconf/Makefile.am
+++ /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
index eee80c9d9..000000000
--- a/ext/gconf/gstgconf.c
+++ /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
index b1153e93d..000000000
--- a/ext/gconf/gstgconf.h
+++ /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
index d60f2befe..000000000
--- a/ext/gconf/gstgconfaudiosink.c
+++ /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
index 2d730f3a9..000000000
--- a/ext/gconf/gstgconfaudiosink.h
+++ /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
index 2fdd61fbd..000000000
--- a/ext/gconf/gstgconfaudiosrc.c
+++ /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
index 40fb94b24..000000000
--- a/ext/gconf/gstgconfaudiosrc.h
+++ /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
index 06f0113b8..000000000
--- a/ext/gconf/gstgconfelements.c
+++ /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
index 872b2f2d9..000000000
--- a/ext/gconf/gstgconfelements.h
+++ /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
index 10fe90d10..000000000
--- a/ext/gconf/gstgconfvideosink.c
+++ /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
index faaa0a8a9..000000000
--- a/ext/gconf/gstgconfvideosink.h
+++ /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
index 2d9d5dfc4..000000000
--- a/ext/gconf/gstgconfvideosrc.c
+++ /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
index 5c8300d82..000000000
--- a/ext/gconf/gstgconfvideosrc.h
+++ /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
index da31df2b0..000000000
--- a/ext/gconf/gstswitchsink.c
+++ /dev/null
@@ -1,269 +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_static_pad_template (eklass, &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
index 556e75536..000000000
--- a/ext/gconf/gstswitchsink.h
+++ /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
index 664e0bd8a..000000000
--- a/ext/gconf/gstswitchsrc.c
+++ /dev/null
@@ -1,261 +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_static_pad_template (eklass, &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
index 6c550adc3..000000000
--- a/ext/gconf/gstswitchsrc.h
+++ /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/gdk_pixbuf/gstgdkpixbuf.c b/ext/gdk_pixbuf/gstgdkpixbuf.c
index 0a09400b3..51c24a1ca 100644
--- a/ext/gdk_pixbuf/gstgdkpixbuf.c
+++ b/ext/gdk_pixbuf/gstgdkpixbuf.c
@@ -157,10 +157,10 @@ gst_gdk_pixbuf_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class,
- &gst_gdk_pixbuf_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_gdk_pixbuf_sink_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_gdk_pixbuf_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_gdk_pixbuf_sink_template));
gst_element_class_set_details_simple (element_class,
"GdkPixbuf image decoder", "Codec/Decoder/Image",
"Decodes images in a video stream using GdkPixbuf",
diff --git a/ext/gdk_pixbuf/gstgdkpixbufsink.c b/ext/gdk_pixbuf/gstgdkpixbufsink.c
index 8a9677a2c..f18d3c183 100644
--- a/ext/gdk_pixbuf/gstgdkpixbufsink.c
+++ b/ext/gdk_pixbuf/gstgdkpixbufsink.c
@@ -146,8 +146,8 @@ gst_gdk_pixbuf_sink_base_init (gpointer g_class)
"Sink/Video", "Output images as GdkPixbuf objects in bus messages",
"Tim-Philipp Müller <tim centricular net>");
- gst_element_class_add_static_pad_template (element_class,
- &pixbufsink_sink_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&pixbufsink_sink_factory));
}
static void
diff --git a/ext/gdk_pixbuf/pixbufscale.c b/ext/gdk_pixbuf/pixbufscale.c
index ba98f6223..bedd98252 100644
--- a/ext/gdk_pixbuf/pixbufscale.c
+++ b/ext/gdk_pixbuf/pixbufscale.c
@@ -122,10 +122,10 @@ gst_pixbufscale_base_init (gpointer g_class)
"Wim Taymans <wim.taymans@chello.be>, "
"Renato Filho <renato.filho@indt.org.br>");
- gst_element_class_add_static_pad_template (element_class,
- &gst_pixbufscale_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_pixbufscale_sink_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_pixbufscale_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_pixbufscale_sink_template));
}
static void
diff --git a/ext/hal/Makefile.am b/ext/hal/Makefile.am
deleted file mode 100644
index 8862aebf1..000000000
--- a/ext/hal/Makefile.am
+++ /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
index 88fac005d..000000000
--- a/ext/hal/gsthalaudiosink.c
+++ /dev/null
@@ -1,250 +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_static_pad_template (eklass, &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
index 3f07fde4a..000000000
--- a/ext/hal/gsthalaudiosink.h
+++ /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
index 339a767c3..000000000
--- a/ext/hal/gsthalaudiosrc.c
+++ /dev/null
@@ -1,251 +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_static_pad_template (eklass, &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
index 7afdadda2..000000000
--- a/ext/hal/gsthalaudiosrc.h
+++ /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
index dd5122aa5..000000000
--- a/ext/hal/gsthalelements.c
+++ /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
index 6a9462fff..000000000
--- a/ext/hal/gsthalelements.h
+++ /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
index 6957f5691..000000000
--- a/ext/hal/hal.c
+++ /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
index 9cc5aed39..000000000
--- a/ext/hal/hal.h
+++ /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 */
diff --git a/ext/jack/gstjack.h b/ext/jack/gstjack.h
index d923866df..2b5dbe89e 100644
--- a/ext/jack/gstjack.h
+++ b/ext/jack/gstjack.h
@@ -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 "F32LE"
+#else
+#define GST_JACK_FORMAT_STR "F32BE"
+#endif
+
GType gst_jack_client_get_type(void);
GType gst_jack_connect_get_type(void);
diff --git a/ext/jack/gstjackaudiosink.c b/ext/jack/gstjackaudiosink.c
index 58e2acf62..1f1a8ac02 100644
--- a/ext/jack/gstjackaudiosink.c
+++ b/ext/jack/gstjackaudiosink.c
@@ -21,7 +21,7 @@
/**
* SECTION:element-jackaudiosink
- * @see_also: #GstBaseAudioSink, #GstRingBuffer
+ * @see_also: #GstAudioBaseSink, #GstAudioRingBuffer
*
* A Sink that outputs data to Jack ports.
*
@@ -147,7 +147,7 @@ gst_jack_ring_buffer_get_type (void)
(GInstanceInitFunc) gst_jack_ring_buffer_init,
NULL
};
- GType tmp = g_type_register_static (GST_TYPE_RING_BUFFER,
+ GType tmp = g_type_register_static (GST_TYPE_AUDIO_RING_BUFFER,
"GstJackAudioSinkRingBuffer", &ringbuffer_info, 0);
g_once_init_leave (&ringbuffer_type, tmp);
}
@@ -158,9 +158,9 @@ gst_jack_ring_buffer_get_type (void)
static void
gst_jack_ring_buffer_class_init (GstJackRingBufferClass * klass)
{
- GstRingBufferClass *gstringbuffer_class;
+ GstAudioRingBufferClass *gstringbuffer_class;
- gstringbuffer_class = (GstRingBufferClass *) klass;
+ gstringbuffer_class = (GstAudioRingBufferClass *) klass;
ring_parent_class = g_type_class_peek_parent (klass);
@@ -186,16 +186,16 @@ static int
jack_process_cb (jack_nframes_t nframes, void *arg)
{
GstJackAudioSink *sink;
- GstRingBuffer *buf;
+ GstAudioRingBuffer *buf;
gint readseg, len;
guint8 *readptr;
gint i, j, flen, channels;
sample_t *data;
- buf = GST_RING_BUFFER_CAST (arg);
+ buf = GST_AUDIO_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++) {
@@ -203,7 +203,7 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
(sample_t *) jack_port_get_buffer (sink->ports[i], nframes);
}
- if (gst_ring_buffer_prepare_read (buf, &readseg, &readptr, &len)) {
+ if (gst_audio_ring_buffer_prepare_read (buf, &readseg, &readptr, &len)) {
flen = len / channels;
/* the number of samples must be exactly the segment size */
@@ -223,10 +223,10 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
}
/* clear written samples in the ringbuffer */
- gst_ring_buffer_clear (buf, readseg);
+ gst_audio_ring_buffer_clear (buf, readseg);
/* we wrote one segment */
- gst_ring_buffer_advance (buf, 1);
+ gst_audio_ring_buffer_advance (buf, 1);
} else {
GST_DEBUG_OBJECT (sink, "write %d frames silence", nframes);
/* We are not allowed to read from the ringbuffer, write silence to all
@@ -319,7 +319,7 @@ gst_jack_ring_buffer_init (GstJackRingBuffer * buf,
/* the _open_device method should make a connection with the server
*/
static gboolean
-gst_jack_ring_buffer_open_device (GstRingBuffer * buf)
+gst_jack_ring_buffer_open_device (GstAudioRingBuffer * buf)
{
GstJackAudioSink *sink;
jack_status_t status = 0;
@@ -363,7 +363,7 @@ could_not_open:
/* close the connection with the server
*/
static gboolean
-gst_jack_ring_buffer_close_device (GstRingBuffer * buf)
+gst_jack_ring_buffer_close_device (GstAudioRingBuffer * buf)
{
GstJackAudioSink *sink;
@@ -390,13 +390,14 @@ gst_jack_ring_buffer_close_device (GstRingBuffer * buf)
* received for some reason, we fail here.
*/
static gboolean
-gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
+gst_jack_ring_buffer_acquire (GstAudioRingBuffer * buf,
+ GstAudioRingBufferSpec * spec)
{
GstJackAudioSink *sink;
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 +407,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 +426,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 +442,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 +486,7 @@ done:
abuf->sample_rate = sample_rate;
abuf->buffer_size = buffer_size;
- abuf->channels = spec->channels;
+ abuf->channels = channels;
return TRUE;
@@ -491,7 +495,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:
@@ -518,7 +522,7 @@ cannot_connect:
/* function is called with LOCK */
static gboolean
-gst_jack_ring_buffer_release (GstRingBuffer * buf)
+gst_jack_ring_buffer_release (GstAudioRingBuffer * buf)
{
GstJackAudioSink *sink;
GstJackRingBuffer *abuf;
@@ -541,14 +545,14 @@ 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;
}
static gboolean
-gst_jack_ring_buffer_start (GstRingBuffer * buf)
+gst_jack_ring_buffer_start (GstAudioRingBuffer * buf)
{
GstJackAudioSink *sink;
@@ -560,7 +564,7 @@ gst_jack_ring_buffer_start (GstRingBuffer * buf)
}
static gboolean
-gst_jack_ring_buffer_pause (GstRingBuffer * buf)
+gst_jack_ring_buffer_pause (GstAudioRingBuffer * buf)
{
GstJackAudioSink *sink;
@@ -572,7 +576,7 @@ gst_jack_ring_buffer_pause (GstRingBuffer * buf)
}
static gboolean
-gst_jack_ring_buffer_stop (GstRingBuffer * buf)
+gst_jack_ring_buffer_stop (GstAudioRingBuffer * buf)
{
GstJackAudioSink *sink;
@@ -585,7 +589,7 @@ gst_jack_ring_buffer_stop (GstRingBuffer * buf)
#if defined (HAVE_JACK_0_120_1) || defined(HAVE_JACK_1_9_7)
static guint
-gst_jack_ring_buffer_delay (GstRingBuffer * buf)
+gst_jack_ring_buffer_delay (GstAudioRingBuffer * buf)
{
GstJackAudioSink *sink;
guint i, res = 0;
@@ -605,7 +609,7 @@ gst_jack_ring_buffer_delay (GstRingBuffer * buf)
}
#else /* !(defined (HAVE_JACK_0_120_1) || defined(HAVE_JACK_1_9_7)) */
static guint
-gst_jack_ring_buffer_delay (GstRingBuffer * buf)
+gst_jack_ring_buffer_delay (GstAudioRingBuffer * buf)
{
GstJackAudioSink *sink;
guint i, res = 0;
@@ -631,9 +635,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 +659,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_AUDIO_BASE_SINK);
static void gst_jack_audio_sink_dispose (GObject * object);
static void gst_jack_audio_sink_set_property (GObject * object, guint prop_id,
@@ -668,33 +668,26 @@ 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 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_static_pad_template (element_class,
- &jackaudiosink_sink_factory);
-}
+static GstCaps *gst_jack_audio_sink_getcaps (GstBaseSink * bsink,
+ GstCaps * filter);
+static GstAudioRingBuffer
+ * gst_jack_audio_sink_create_ringbuffer (GstAudioBaseSink * sink);
static void
gst_jack_audio_sink_class_init (GstJackAudioSinkClass * klass)
{
GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
GstBaseSinkClass *gstbasesink_class;
- GstBaseAudioSinkClass *gstbaseaudiosink_class;
+ GstAudioBaseSinkClass *gstaudiobasesink_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;
+ gstaudiobasesink_class = (GstAudioBaseSinkClass *) klass;
gobject_class->dispose = gst_jack_audio_sink_dispose;
gobject_class->get_property = gst_jack_audio_sink_get_property;
@@ -717,9 +710,16 @@ 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 =
+ gstaudiobasesink_class->create_ringbuffer =
GST_DEBUG_FUNCPTR (gst_jack_audio_sink_create_ringbuffer);
/* ref class from a thread-safe context to work around missing bit of
@@ -730,8 +730,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 +802,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 +838,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);
}
@@ -858,10 +856,10 @@ no_client:
}
}
-static GstRingBuffer *
-gst_jack_audio_sink_create_ringbuffer (GstBaseAudioSink * sink)
+static GstAudioRingBuffer *
+gst_jack_audio_sink_create_ringbuffer (GstAudioBaseSink * sink)
{
- GstRingBuffer *buffer;
+ GstAudioRingBuffer *buffer;
buffer = g_object_new (GST_TYPE_JACK_RING_BUFFER, NULL);
GST_DEBUG_OBJECT (sink, "created ringbuffer @%p", buffer);
diff --git a/ext/jack/gstjackaudiosink.h b/ext/jack/gstjackaudiosink.h
index 6f9c45c8e..02a8db9fc 100644
--- a/ext/jack/gstjackaudiosink.h
+++ b/ext/jack/gstjackaudiosink.h
@@ -25,7 +25,7 @@
#include <jack/jack.h>
#include <gst/gst.h>
-#include <gst/audio/gstbaseaudiosink.h>
+#include <gst/audio/gstaudiobasesink.h>
#include "gstjack.h"
#include "gstjackaudioclient.h"
@@ -48,7 +48,7 @@ typedef struct _GstJackAudioSinkClass GstJackAudioSinkClass;
* Opaque #GstJackAudioSink.
*/
struct _GstJackAudioSink {
- GstBaseAudioSink element;
+ GstAudioBaseSink element;
/*< private >*/
/* cached caps */
@@ -69,7 +69,7 @@ struct _GstJackAudioSink {
};
struct _GstJackAudioSinkClass {
- GstBaseAudioSinkClass parent_class;
+ GstAudioBaseSinkClass parent_class;
};
GType gst_jack_audio_sink_get_type (void);
diff --git a/ext/jack/gstjackaudiosrc.c b/ext/jack/gstjackaudiosrc.c
index 27faa82bd..1453ba180 100644
--- a/ext/jack/gstjackaudiosrc.c
+++ b/ext/jack/gstjackaudiosrc.c
@@ -42,7 +42,7 @@
/**
* SECTION:element-jackaudiosrc
- * @see_also: #GstBaseAudioSrc, #GstRingBuffer
+ * @see_also: #GstAudioBaseSrc, #GstAudioRingBuffer
*
* A Src that inputs data from Jack ports.
*
@@ -165,7 +165,7 @@ gst_jack_ring_buffer_get_type (void)
(GInstanceInitFunc) gst_jack_ring_buffer_init,
NULL
};
- GType tmp = g_type_register_static (GST_TYPE_RING_BUFFER,
+ GType tmp = g_type_register_static (GST_TYPE_AUDIO_RING_BUFFER,
"GstJackAudioSrcRingBuffer", &ringbuffer_info, 0);
g_once_init_leave (&ringbuffer_type, tmp);
}
@@ -176,9 +176,9 @@ gst_jack_ring_buffer_get_type (void)
static void
gst_jack_ring_buffer_class_init (GstJackRingBufferClass * klass)
{
- GstRingBufferClass *gstringbuffer_class;
+ GstAudioRingBufferClass *gstringbuffer_class;
- gstringbuffer_class = (GstRingBufferClass *) klass;
+ gstringbuffer_class = (GstAudioRingBufferClass *) klass;
ring_parent_class = g_type_class_peek_parent (klass);
@@ -205,24 +205,24 @@ static int
jack_process_cb (jack_nframes_t nframes, void *arg)
{
GstJackAudioSrc *src;
- GstRingBuffer *buf;
+ GstAudioRingBuffer *buf;
gint len;
guint8 *writeptr;
gint writeseg;
gint channels, i, j, flen;
sample_t *data;
- buf = GST_RING_BUFFER_CAST (arg);
+ buf = GST_AUDIO_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++)
src->buffers[i] =
(sample_t *) jack_port_get_buffer (src->ports[i], nframes);
- if (gst_ring_buffer_prepare_read (buf, &writeseg, &writeptr, &len)) {
+ if (gst_audio_ring_buffer_prepare_read (buf, &writeseg, &writeptr, &len)) {
flen = len / channels;
/* the number of samples must be exactly the segment size */
@@ -240,7 +240,7 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
len / channels, channels);
/* we wrote one segment */
- gst_ring_buffer_advance (buf, 1);
+ gst_audio_ring_buffer_advance (buf, 1);
}
return 0;
@@ -326,7 +326,7 @@ gst_jack_ring_buffer_init (GstJackRingBuffer * buf,
/* the _open_device method should make a connection with the server
*/
static gboolean
-gst_jack_ring_buffer_open_device (GstRingBuffer * buf)
+gst_jack_ring_buffer_open_device (GstAudioRingBuffer * buf)
{
GstJackAudioSrc *src;
jack_status_t status = 0;
@@ -370,7 +370,7 @@ could_not_open:
/* close the connection with the server
*/
static gboolean
-gst_jack_ring_buffer_close_device (GstRingBuffer * buf)
+gst_jack_ring_buffer_close_device (GstAudioRingBuffer * buf)
{
GstJackAudioSrc *src;
@@ -398,13 +398,14 @@ gst_jack_ring_buffer_close_device (GstRingBuffer * buf)
* received for some reason, we fail here.
*/
static gboolean
-gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
+gst_jack_ring_buffer_acquire (GstAudioRingBuffer * buf,
+ GstAudioRingBufferSpec * spec)
{
GstJackAudioSrc *src;
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 +415,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 +436,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 +452,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 +498,7 @@ done:
abuf->sample_rate = sample_rate;
abuf->buffer_size = buffer_size;
- abuf->channels = spec->channels;
+ abuf->channels = channels;
return TRUE;
@@ -503,7 +507,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:
@@ -530,7 +534,7 @@ cannot_connect:
/* function is called with LOCK */
static gboolean
-gst_jack_ring_buffer_release (GstRingBuffer * buf)
+gst_jack_ring_buffer_release (GstAudioRingBuffer * buf)
{
GstJackAudioSrc *src;
GstJackRingBuffer *abuf;
@@ -553,14 +557,14 @@ 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;
}
static gboolean
-gst_jack_ring_buffer_start (GstRingBuffer * buf)
+gst_jack_ring_buffer_start (GstAudioRingBuffer * buf)
{
GstJackAudioSrc *src;
@@ -572,7 +576,7 @@ gst_jack_ring_buffer_start (GstRingBuffer * buf)
}
static gboolean
-gst_jack_ring_buffer_pause (GstRingBuffer * buf)
+gst_jack_ring_buffer_pause (GstAudioRingBuffer * buf)
{
GstJackAudioSrc *src;
@@ -584,7 +588,7 @@ gst_jack_ring_buffer_pause (GstRingBuffer * buf)
}
static gboolean
-gst_jack_ring_buffer_stop (GstRingBuffer * buf)
+gst_jack_ring_buffer_stop (GstAudioRingBuffer * buf)
{
GstJackAudioSrc *src;
@@ -597,7 +601,7 @@ gst_jack_ring_buffer_stop (GstRingBuffer * buf)
#if defined (HAVE_JACK_0_120_1) || defined(HAVE_JACK_1_9_7)
static guint
-gst_jack_ring_buffer_delay (GstRingBuffer * buf)
+gst_jack_ring_buffer_delay (GstAudioRingBuffer * buf)
{
GstJackAudioSrc *src;
guint i, res = 0;
@@ -617,7 +621,7 @@ gst_jack_ring_buffer_delay (GstRingBuffer * buf)
}
#else /* !(defined (HAVE_JACK_0_120_1) || defined(HAVE_JACK_1_9_7)) */
static guint
-gst_jack_ring_buffer_delay (GstRingBuffer * buf)
+gst_jack_ring_buffer_delay (GstAudioRingBuffer * buf)
{
GstJackAudioSrc *src;
guint i, res = 0;
@@ -668,17 +672,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_AUDIO_BASE_SRC);
static void gst_jack_audio_src_dispose (GObject * object);
static void gst_jack_audio_src_set_property (GObject * object, guint prop_id,
@@ -686,35 +686,29 @@ 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 GstRingBuffer *gst_jack_audio_src_create_ringbuffer (GstBaseAudioSrc *
- src);
+static GstCaps *gst_jack_audio_src_getcaps (GstBaseSrc * bsrc,
+ GstCaps * filter);
+static GstAudioRingBuffer *gst_jack_audio_src_create_ringbuffer (GstAudioBaseSrc
+ * 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_static_pad_template (element_class, &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;
+ GstAudioBaseSrcClass *gstaudiobasesrc_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;
+ gstaudiobasesrc_class = (GstAudioBaseSrcClass *) klass;
gobject_class->dispose = gst_jack_audio_src_dispose;
gobject_class->set_property = gst_jack_audio_src_set_property;
@@ -737,8 +731,15 @@ 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 =
+ gstaudiobasesrc_class->create_ringbuffer =
GST_DEBUG_FUNCPTR (gst_jack_audio_src_create_ringbuffer);
/* ref class from a thread-safe context to work around missing bit of
@@ -754,7 +755,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;
@@ -823,7 +824,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;
@@ -860,9 +861,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);
}
@@ -879,10 +879,10 @@ no_client:
}
}
-static GstRingBuffer *
-gst_jack_audio_src_create_ringbuffer (GstBaseAudioSrc * src)
+static GstAudioRingBuffer *
+gst_jack_audio_src_create_ringbuffer (GstAudioBaseSrc * src)
{
- GstRingBuffer *buffer;
+ GstAudioRingBuffer *buffer;
buffer = g_object_new (GST_TYPE_JACK_RING_BUFFER, NULL);
GST_DEBUG_OBJECT (src, "created ringbuffer @%p", buffer);
diff --git a/ext/jack/gstjackaudiosrc.h b/ext/jack/gstjackaudiosrc.h
index 7e99b69df..fa119472c 100644
--- a/ext/jack/gstjackaudiosrc.h
+++ b/ext/jack/gstjackaudiosrc.h
@@ -65,7 +65,7 @@ typedef struct _GstJackAudioSrcClass GstJackAudioSrcClass;
struct _GstJackAudioSrc
{
- GstBaseAudioSrc src;
+ GstAudioBaseSrc src;
/*< private >*/
/* cached caps */
@@ -87,7 +87,7 @@ struct _GstJackAudioSrc
struct _GstJackAudioSrcClass
{
- GstBaseAudioSrcClass parent_class;
+ GstAudioBaseSrcClass parent_class;
};
GType gst_jack_audio_src_get_type (void);
diff --git a/ext/jack/gstjackringbuffer.h b/ext/jack/gstjackringbuffer.h
index 266fdfa31..9705ef059 100644
--- a/ext/jack/gstjackringbuffer.h
+++ b/ext/jack/gstjackringbuffer.h
@@ -58,7 +58,7 @@ typedef struct _GstJackRingBufferClass GstJackRingBufferClass;
struct _GstJackRingBuffer
{
- GstRingBuffer object;
+ GstAudioRingBuffer object;
gint sample_rate;
gint buffer_size;
@@ -67,22 +67,22 @@ struct _GstJackRingBuffer
struct _GstJackRingBufferClass
{
- GstRingBufferClass parent_class;
+ GstAudioRingBufferClass parent_class;
};
static void gst_jack_ring_buffer_class_init(GstJackRingBufferClass * klass);
static void gst_jack_ring_buffer_init(GstJackRingBuffer * ringbuffer,
GstJackRingBufferClass * klass);
-static GstRingBufferClass *ring_parent_class = NULL;
+static GstAudioRingBufferClass *ring_parent_class = NULL;
-static gboolean gst_jack_ring_buffer_open_device(GstRingBuffer * buf);
-static gboolean gst_jack_ring_buffer_close_device(GstRingBuffer * buf);
-static gboolean gst_jack_ring_buffer_acquire(GstRingBuffer * buf,GstRingBufferSpec * spec);
-static gboolean gst_jack_ring_buffer_release(GstRingBuffer * buf);
-static gboolean gst_jack_ring_buffer_start(GstRingBuffer * buf);
-static gboolean gst_jack_ring_buffer_pause(GstRingBuffer * buf);
-static gboolean gst_jack_ring_buffer_stop(GstRingBuffer * buf);
-static guint gst_jack_ring_buffer_delay(GstRingBuffer * buf);
+static gboolean gst_jack_ring_buffer_open_device(GstAudioRingBuffer * buf);
+static gboolean gst_jack_ring_buffer_close_device(GstAudioRingBuffer * buf);
+static gboolean gst_jack_ring_buffer_acquire(GstAudioRingBuffer * buf,GstAudioRingBufferSpec * spec);
+static gboolean gst_jack_ring_buffer_release(GstAudioRingBuffer * buf);
+static gboolean gst_jack_ring_buffer_start(GstAudioRingBuffer * buf);
+static gboolean gst_jack_ring_buffer_pause(GstAudioRingBuffer * buf);
+static gboolean gst_jack_ring_buffer_stop(GstAudioRingBuffer * buf);
+static guint gst_jack_ring_buffer_delay(GstAudioRingBuffer * buf);
#endif
diff --git a/ext/jpeg/Makefile.am b/ext/jpeg/Makefile.am
index a72f12ff3..eb581e1c5 100644
--- a/ext/jpeg/Makefile.am
+++ b/ext/jpeg/Makefile.am
@@ -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
diff --git a/ext/jpeg/gstjpeg.c b/ext/jpeg/gstjpeg.c
index b9d6e0461..1a7006bf1 100644
--- a/ext/jpeg/gstjpeg.c
+++ b/ext/jpeg/gstjpeg.c
@@ -27,8 +27,10 @@
#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;
}
diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c
index fe5652bb9..3c47a4c7a 100644
--- a/ext/jpeg/gstjpegdec.c
+++ b/ext/jpeg/gstjpegdec.c
@@ -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* */
/* FIXME: sof-marker is for IJG libjpeg 8, should be different for 6.2 */
@@ -90,34 +88,20 @@ 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 GstCaps *gst_jpeg_dec_getcaps (GstPad * pad);
-static gboolean gst_jpeg_dec_sink_event (GstPad * pad, GstEvent * event);
-static gboolean gst_jpeg_dec_src_event (GstPad * pad, GstEvent * event);
+static GstFlowReturn gst_jpeg_dec_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
+static GstCaps *gst_jpeg_dec_getcaps (GstPad * pad, GstCaps * filter);
+static gboolean gst_jpeg_dec_sink_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
+static gboolean gst_jpeg_dec_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static gboolean gst_jpeg_dec_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static GstStateChangeReturn gst_jpeg_dec_change_state (GstElement * element,
GstStateChange transition);
static void gst_jpeg_dec_update_qos (GstJpegDec * dec, gdouble proportion,
@@ -126,29 +110,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)
@@ -163,20 +126,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_static_pad_template (element_class,
- &gst_jpeg_dec_src_pad_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
@@ -212,6 +161,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);
@@ -407,14 +364,12 @@ 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_getcaps_function (dec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_jpeg_dec_getcaps));
gst_pad_set_chain_function (dec->sinkpad,
GST_DEBUG_FUNCPTR (gst_jpeg_dec_chain));
gst_pad_set_event_function (dec->sinkpad,
GST_DEBUG_FUNCPTR (gst_jpeg_dec_sink_event));
+ gst_pad_set_query_function (dec->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_jpeg_dec_sink_query));
dec->srcpad =
gst_pad_new_from_static_template (&gst_jpeg_dec_src_pad_template, "src");
@@ -748,21 +703,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
@@ -775,7 +728,7 @@ gst_jpeg_dec_setcaps (GstPad * pad, GstCaps * caps)
}
static GstCaps *
-gst_jpeg_dec_getcaps (GstPad * pad)
+gst_jpeg_dec_getcaps (GstPad * pad, GstCaps * filter)
{
GstJpegDec *dec;
GstCaps *caps;
@@ -783,8 +736,8 @@ gst_jpeg_dec_getcaps (GstPad * pad)
dec = GST_JPEG_DEC (GST_OBJECT_PARENT (pad));
- if (GST_PAD_CAPS (pad))
- return gst_caps_ref (GST_PAD_CAPS (pad));
+ if (gst_pad_has_current_caps (pad))
+ return gst_pad_get_current_caps (pad);
peer = gst_pad_get_peer (dec->srcpad);
@@ -794,7 +747,7 @@ gst_jpeg_dec_getcaps (GstPad * pad)
GstStructure *s;
guint i, n;
- peer_caps = gst_pad_get_caps (peer);
+ peer_caps = gst_pad_query_caps (peer, filter);
/* Translate peercaps to image/jpeg */
peer_caps = gst_caps_make_writable (peer_caps);
@@ -855,7 +808,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? */
@@ -876,19 +829,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;
@@ -912,19 +874,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));
@@ -954,20 +927,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));
@@ -986,30 +974,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 {
@@ -1018,27 +1006,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 */
@@ -1046,6 +1015,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 height;
line[0] = y;
line[1] = u;
@@ -1058,35 +1030,44 @@ 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;
+ 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");
@@ -1110,7 +1091,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;
@@ -1176,38 +1157,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
@@ -1219,7 +1258,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;
@@ -1230,12 +1269,13 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc)
gst_caps_unref (caps);
caps = gst_caps_copy_nth (allowed_caps, i);
/* sigh, ds and _parse_caps need fixed caps for parsing, fixate */
- gst_pad_fixate_caps (dec->srcpad, caps);
+ gst_caps_fixate (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;
@@ -1243,72 +1283,47 @@ 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
-gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
+gst_jpeg_dec_chain (GstPad * pad, GstObject * parent, 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));
+ dec = GST_JPEG_DEC (parent);
timestamp = GST_BUFFER_TIMESTAMP (buf);
duration = GST_BUFFER_DURATION (buf);
@@ -1335,8 +1350,9 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
(dec->segment.stop != -1) &&
(gst_adapter_available (dec->adapter) < dec->segment.stop)) {
/* We assume that non-packetized input in bytes is *one* single jpeg image */
- GST_DEBUG ("Non-packetized mode. Got %d bytes, need %" G_GINT64_FORMAT,
- gst_adapter_available (dec->adapter), dec->segment.stop);
+ GST_DEBUG ("Non-packetized mode. Got %" G_GSIZE_FORMAT " bytes, "
+ "need %" G_GINT64_FORMAT, gst_adapter_available (dec->adapter),
+ dec->segment.stop);
goto need_more_data;
}
@@ -1372,9 +1388,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);
@@ -1474,16 +1494,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;
@@ -1491,10 +1509,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;
@@ -1506,32 +1523,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);
@@ -1546,11 +1541,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;
}
@@ -1559,9 +1553,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");
@@ -1667,6 +1663,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");
@@ -1699,24 +1702,21 @@ invalid_yuvrgbgrayscale:
}
static gboolean
-gst_jpeg_dec_src_event (GstPad * pad, GstEvent * event)
+gst_jpeg_dec_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstJpegDec *dec;
gboolean res;
- dec = GST_JPEG_DEC (gst_pad_get_parent (pad));
- if (G_UNLIKELY (dec == NULL)) {
- gst_event_unref (event);
- return FALSE;
- }
+ dec = GST_JPEG_DEC (parent);
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;
}
@@ -1726,15 +1726,14 @@ gst_jpeg_dec_src_event (GstPad * pad, GstEvent * event)
res = gst_pad_push_event (dec->sinkpad, event);
- gst_object_unref (dec);
return res;
}
static gboolean
-gst_jpeg_dec_sink_event (GstPad * pad, GstEvent * event)
+gst_jpeg_dec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
- gboolean ret = TRUE;
- GstJpegDec *dec = GST_JPEG_DEC (GST_OBJECT_PARENT (pad));
+ gboolean ret = TRUE, forward = TRUE;
+ GstJpegDec *dec = GST_JPEG_DEC (parent);
GST_DEBUG_OBJECT (dec, "event : %s", GST_EVENT_TYPE_NAME (event));
@@ -1751,34 +1750,56 @@ 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;
}
+static gboolean
+gst_jpeg_dec_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
+{
+ gboolean res = FALSE;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = gst_jpeg_dec_getcaps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_query_default (pad, parent, query);
+ break;
+ }
+ return res;
+}
+
static void
gst_jpeg_dec_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
@@ -1835,11 +1856,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;
@@ -1864,6 +1883,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;
diff --git a/ext/jpeg/gstjpegdec.h b/ext/jpeg/gstjpegdec.h
index 7daf7b6f2..4946ee5aa 100644
--- a/ext/jpeg/gstjpegdec.h
+++ b/ext/jpeg/gstjpegdec.h
@@ -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;
diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c
index 98c7e09a9..9250619ed 100644
--- a/ext/jpeg/gstjpegenc.c
+++ b/ext/jpeg/gstjpegenc.c
@@ -54,7 +54,6 @@ GST_DEBUG_CATEGORY_STATIC (jpegenc_debug);
/* JpegEnc signals and args */
enum
{
- FRAME_ENCODED,
/* FILL ME */
LAST_SIGNAL
};
@@ -68,14 +67,15 @@ 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 GstFlowReturn gst_jpegenc_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buf);
+static gboolean gst_jpegenc_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static GstCaps *gst_jpegenc_getcaps (GstPad * pad, GstCaps * filter);
+static gboolean gst_jpegenc_sink_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
static void gst_jpegenc_resync (GstJpegEnc * jpegenc);
static void gst_jpegenc_set_property (GObject * object, guint prop_id,
@@ -85,46 +85,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 +108,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_static_pad_template (element_class,
- &gst_jpegenc_sink_pad_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +118,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 +143,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 +200,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 +216,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
@@ -262,10 +231,10 @@ gst_jpegenc_init (GstJpegEnc * jpegenc)
gst_pad_new_from_static_template (&gst_jpegenc_sink_pad_template, "sink");
gst_pad_set_chain_function (jpegenc->sinkpad,
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_query_function (jpegenc->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_jpegenc_sink_query));
+ 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 +243,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 +283,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 +297,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 +308,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_query_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 +345,65 @@ done:
}
static gboolean
-gst_jpegenc_setcaps (GstPad * pad, GstCaps * caps)
+gst_jpegenc_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
- GstJpegEnc *enc = GST_JPEGENC (gst_pad_get_parent (pad));
- GstVideoFormat format;
- gint width, height;
- gint fps_num, fps_den;
- gint par_num, par_den;
+ gboolean res;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = gst_jpegenc_getcaps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_query_default (pad, parent, query);
+ break;
+ }
+ return res;
+}
+
+static gboolean
+gst_jpegenc_setcaps (GstJpegEnc * enc, GstCaps * caps)
+{
+ 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 +419,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 +433,63 @@ 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, GstObject * parent, GstEvent * event)
+{
+ gboolean res;
+ GstJpegEnc *enc = GST_JPEGENC (parent);
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ res = gst_jpegenc_setcaps (enc, caps);
+ gst_event_unref (event);
+ break;
+ }
+ default:
+ res = gst_pad_event_default (pad, parent, event);
+ break;
+ }
+
+ 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 +498,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 */
@@ -540,46 +534,44 @@ gst_jpegenc_resync (GstJpegEnc * jpegenc)
}
static GstFlowReturn
-gst_jpegenc_chain (GstPad * pad, GstBuffer * buf)
+gst_jpegenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstFlowReturn ret;
GstJpegEnc *jpegenc;
- guchar *data;
- gulong size;
guint height;
guchar *base[3], *end[3];
+ guint stride[3];
gint i, j, k;
+ GstBuffer *outbuf;
+ GstVideoFrame frame;
- jpegenc = GST_JPEGENC (GST_OBJECT_PARENT (pad));
+ jpegenc = GST_JPEGENC (parent);
- 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);
- 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 +589,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 +611,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 +620,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;
}
}
diff --git a/ext/jpeg/gstjpegenc.h b/ext/jpeg/gstjpegenc.h
index f7a3ef0e7..f677887d8 100644
--- a/ext/jpeg/gstjpegenc.h
+++ b/ext/jpeg/gstjpegenc.h
@@ -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);
diff --git a/ext/jpeg/gstsmokedec.c b/ext/jpeg/gstsmokedec.c
index 6e38bb9d4..f2cfc0aed 100644
--- a/ext/jpeg/gstsmokedec.c
+++ b/ext/jpeg/gstsmokedec.c
@@ -106,10 +106,10 @@ gst_smokedec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class,
- &gst_smokedec_src_pad_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_smokedec_sink_pad_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smokedec_src_pad_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smokedec_sink_pad_template));
gst_element_class_set_details_simple (element_class, "Smoke video decoder",
"Codec/Decoder/Video",
"Decode video from Smoke format", "Wim Taymans <wim@fluendo.com>");
diff --git a/ext/jpeg/gstsmokeenc.c b/ext/jpeg/gstsmokeenc.c
index 5bd4d9960..2acddc6ba 100644
--- a/ext/jpeg/gstsmokeenc.c
+++ b/ext/jpeg/gstsmokeenc.c
@@ -123,10 +123,10 @@ gst_smokeenc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class,
- &gst_smokeenc_sink_pad_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_smokeenc_src_pad_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smokeenc_sink_pad_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smokeenc_src_pad_template));
gst_element_class_set_details_simple (element_class, "Smoke video encoder",
"Codec/Encoder/Video",
"Encode images into the Smoke format", "Wim Taymans <wim@fluendo.com>");
diff --git a/ext/libcaca/Makefile.am b/ext/libcaca/Makefile.am
index e44c0488f..9443f8441 100644
--- a/ext/libcaca/Makefile.am
+++ b/ext/libcaca/Makefile.am
@@ -7,6 +7,7 @@ libgstcacasink_la_CFLAGS = \
$(GST_CFLAGS) \
$(LIBCACA_CFLAGS)
libgstcacasink_la_LIBADD = \
+ -lgstvideo-$(GST_MAJORMINOR) \
$(GST_BASE_LIBS) \
$(GST_LIBS) \
$(LIBCACA_LIBS)
diff --git a/ext/libcaca/gstcacasink.c b/ext/libcaca/gstcacasink.c
index 5c3a58938..668013cab 100644
--- a/ext/libcaca/gstcacasink.c
+++ b/ext/libcaca/gstcacasink.c
@@ -43,12 +43,6 @@
#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_static_pad_template (element_class,
- &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->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);
+ cacasink->info = info;
- if (!cacasink->bitmap) {
+ return TRUE;
+
+ /* 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
diff --git a/ext/libcaca/gstcacasink.h b/ext/libcaca/gstcacasink.h
index 580567aa2..db041d9be 100644
--- a/ext/libcaca/gstcacasink.h
+++ b/ext/libcaca/gstcacasink.h
@@ -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;
};
diff --git a/ext/libmng/gstmngdec.c b/ext/libmng/gstmngdec.c
index c8ac9c11a..1976729da 100644
--- a/ext/libmng/gstmngdec.c
+++ b/ext/libmng/gstmngdec.c
@@ -66,10 +66,10 @@ gst_mng_dec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class,
- &gst_mng_dec_src_pad_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_mng_dec_sink_pad_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_mng_dec_src_pad_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_mng_dec_sink_pad_template));
gst_element_class_set_details_simple (element_class, "MNG video decoder",
"Codec/Decoder/Video",
"Decode a mng video to raw images", "Wim Taymans <wim@fluendo.com>");
diff --git a/ext/libmng/gstmngenc.c b/ext/libmng/gstmngenc.c
index e0c2beb59..5dc01ebd9 100644
--- a/ext/libmng/gstmngenc.c
+++ b/ext/libmng/gstmngenc.c
@@ -87,9 +87,6 @@ gst_mng_enc_base_init (gpointer g_class)
gst_element_class_set_details_simple (element_class, "MNG video encoder",
"Codec/Encoder/Video",
"Encode a video frame to an .mng video", "Wim Taymans <wim@fluendo.com>");
-
- gst_object_unref (mngenc_src_template);
- gst_object_unref (mngenc_sink_template);
}
static void
diff --git a/ext/libpng/gstpngdec.c b/ext/libpng/gstpngdec.c
index 4a2b5479f..965310096 100644
--- a/ext/libpng/gstpngdec.c
+++ b/ext/libpng/gstpngdec.c
@@ -102,10 +102,10 @@ gst_pngdec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class,
- &gst_pngdec_src_pad_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_pngdec_sink_pad_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_pngdec_src_pad_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_pngdec_sink_pad_template));
gst_element_class_set_details_simple (element_class, "PNG image decoder",
"Codec/Decoder/Image",
"Decode a png video frame to a raw image",
diff --git a/ext/libpng/gstpngenc.c b/ext/libpng/gstpngenc.c
index 30986cdbb..578d568db 100644
--- a/ext/libpng/gstpngenc.c
+++ b/ext/libpng/gstpngenc.c
@@ -97,10 +97,10 @@ gst_pngenc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template
- (element_class, &pngenc_sink_template);
- gst_element_class_add_static_pad_template
- (element_class, &pngenc_src_template);
+ gst_element_class_add_pad_template
+ (element_class, gst_static_pad_template_get (&pngenc_sink_template));
+ gst_element_class_add_pad_template
+ (element_class, gst_static_pad_template_get (&pngenc_src_template));
gst_element_class_set_details_simple (element_class, "PNG image encoder",
"Codec/Encoder/Image",
"Encode a video frame to a .png image",
diff --git a/ext/mikmod/gstmikmod.c b/ext/mikmod/gstmikmod.c
index 454cf35a9..6b2dfa917 100644
--- a/ext/mikmod/gstmikmod.c
+++ b/ext/mikmod/gstmikmod.c
@@ -128,10 +128,10 @@ gst_mikmod_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class,
- &mikmod_src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &mikmod_sink_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&mikmod_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&mikmod_sink_factory));
gst_element_class_set_details_simple (element_class, "MikMod audio decoder",
"Codec/Decoder/Audio",
"Module decoder based on libmikmod", "Jeremy SIMON <jsimon13@yahoo.fr>");
diff --git a/ext/pulse/plugin.c b/ext/pulse/plugin.c
index 6b2e6b4bf..25fc95af8 100644
--- a/ext/pulse/plugin.c
+++ b/ext/pulse/plugin.c
@@ -49,11 +49,11 @@ plugin_init (GstPlugin * plugin)
GST_TYPE_PULSESRC))
return FALSE;
-#ifdef HAVE_PULSE_1_0
+ /* FIXME 0.11: this helper bin sink should just go away, reconfiguration
+ * should be handled using reconfigure events */
if (!gst_element_register (plugin, "pulseaudiosink", GST_RANK_PRIMARY + 11,
GST_TYPE_PULSE_AUDIO_SINK))
return FALSE;
-#endif
if (!gst_element_register (plugin, "pulsemixer", GST_RANK_NONE,
GST_TYPE_PULSEMIXER))
diff --git a/ext/pulse/pulseaudiosink.c b/ext/pulse/pulseaudiosink.c
index 389ce4674..adaa95ea3 100644
--- a/ext/pulse/pulseaudiosink.c
+++ b/ext/pulse/pulseaudiosink.c
@@ -49,7 +49,7 @@
#include "config.h"
#endif
-#ifdef HAVE_PULSE_1_0
+/* FIXME 0.11: pulseaudiosink helper bin must die */
#include <gst/pbutils/pbutils.h>
#include <gst/gst-i18n-plugin.h>
@@ -88,12 +88,13 @@ typedef struct
GstPadEventFunction proxypad_old_eventfunc;
GstPulseSink *psink;
- GstElement *dbin2;
+ GstElement *dbin;
GstSegment segment;
guint event_probe_id;
gulong pad_added_id;
+ guint block_probe_id;
gboolean format_lost;
} GstPulseAudioSink;
@@ -110,45 +111,26 @@ static void gst_pulse_audio_sink_get_property (GObject * object, guint prop_id,
static void gst_pulse_audio_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_pulse_audio_sink_dispose (GObject * object);
-static gboolean gst_pulse_audio_sink_src_event (GstPad * pad, GstEvent * event);
+static gboolean gst_pulse_audio_sink_src_event (GstPad * pad,
+ GstObject * parent, GstEvent * event);
static gboolean gst_pulse_audio_sink_sink_event (GstPad * pad,
- GstEvent * event);
-static gboolean gst_pulse_audio_sink_sink_acceptcaps (GstPad * pad,
+ GstObject * parent, GstEvent * event);
+static gboolean gst_pulse_audio_sink_sink_query (GstPad * pad,
+ GstObject * parent, GstQuery * query);
+static gboolean gst_pulse_audio_sink_sink_acceptcaps (GstPulseAudioSink * pbin,
+ GstPad * pad, GstCaps * caps);
+static GstStateChangeReturn gst_pulse_audio_sink_change_state (GstElement *
+ element, GstStateChange transition);
+static gboolean gst_pulse_audio_sink_set_caps (GstPulseAudioSink * pbin,
GstCaps * caps);
-static gboolean gst_pulse_audio_sink_sink_setcaps (GstPad * pad,
- GstCaps * caps);
-static GstStateChangeReturn
-gst_pulse_audio_sink_change_state (GstElement * element,
- GstStateChange transition);
-
-static void
-gst_pulse_audio_sink_do_init (GType type)
-{
- GST_DEBUG_CATEGORY_INIT (pulseaudiosink_debug, "pulseaudiosink", 0,
- "Bin that wraps pulsesink for handling compressed formats");
-}
-GST_BOILERPLATE_FULL (GstPulseAudioSink, gst_pulse_audio_sink, GstBin,
- GST_TYPE_BIN, gst_pulse_audio_sink_do_init);
+#define gst_pulse_audio_sink_parent_class parent_class
+G_DEFINE_TYPE (GstPulseAudioSink, gst_pulse_audio_sink, GST_TYPE_BIN);
static GstStaticPadTemplate sink_template =
GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
GST_STATIC_CAPS (PULSE_SINK_TEMPLATE_CAPS));
-static void
-gst_pulse_audio_sink_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &sink_template);
-
- gst_element_class_set_details_simple (element_class,
- "Bin wrapping pulsesink", "Sink/Audio/Bin",
- "Correctly handles sink changes when streaming compressed formats to "
- "pulsesink", "Arun Raghavan <arun.raghavan@collabora.co.uk>");
-}
-
static GParamSpec *
param_spec_copy (GParamSpec * spec)
{
@@ -272,11 +254,6 @@ param_spec_copy (GParamSpec * spec)
vspec->default_value, flags);
}
- if (G_PARAM_SPEC_TYPE (spec) == GST_TYPE_PARAM_MINI_OBJECT) {
- return gst_param_spec_mini_object (name, nick, blurb, spec->value_type,
- flags);
- }
-
g_warning ("Unknown param type %ld for '%s'",
(long) G_PARAM_SPEC_TYPE (spec), name);
g_assert_not_reached ();
@@ -292,6 +269,17 @@ gst_pulse_audio_sink_class_init (GstPulseAudioSinkClass * klass)
GParamSpec **specs;
guint n, i, j;
+ GST_DEBUG_CATEGORY_INIT (pulseaudiosink_debug, "pulseaudiosink", 0,
+ "Bin that wraps pulsesink for handling compressed formats");
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_template));
+
+ gst_element_class_set_details_simple (element_class,
+ "Bin wrapping pulsesink", "Sink/Audio/Bin",
+ "Correctly handles sink changes when streaming compressed formats to "
+ "pulsesink", "Arun Raghavan <arun.raghavan@collabora.co.uk>");
+
gobject_class->get_property = gst_pulse_audio_sink_get_property;
gobject_class->set_property = gst_pulse_audio_sink_set_property;
gobject_class->dispose = gst_pulse_audio_sink_dispose;
@@ -325,12 +313,15 @@ static GstPad *
get_proxypad (GstPad * sinkpad)
{
GstIterator *iter = NULL;
+ GValue res = { 0 };
GstPad *proxypad = NULL;
iter = gst_pad_iterate_internal_links (sinkpad);
if (iter) {
- if (gst_iterator_next (iter, (gpointer) & proxypad) != GST_ITERATOR_OK)
- proxypad = NULL;
+ if (gst_iterator_next (iter, &res) == GST_ITERATOR_OK) {
+ proxypad = g_value_dup_object (&res);
+ g_value_reset (&res);
+ }
gst_iterator_free (iter);
}
@@ -353,9 +344,10 @@ notify_cb (GObject * selector, GParamSpec * pspec, GstPulseAudioSink * pbin)
}
static void
-gst_pulse_audio_sink_init (GstPulseAudioSink * pbin,
- GstPulseAudioSinkClass * klass)
+gst_pulse_audio_sink_init (GstPulseAudioSink * pbin)
{
+ GstPulseAudioSinkClass *klass =
+ GST_PULSE_AUDIO_SINK_CLASS (G_OBJECT_GET_CLASS (pbin));
GstPad *pad = NULL;
GParamSpec **specs;
GString *prop;
@@ -381,10 +373,8 @@ gst_pulse_audio_sink_init (GstPulseAudioSink * pbin,
pbin->sinkpad_old_eventfunc = GST_PAD_EVENTFUNC (pbin->sinkpad);
gst_pad_set_event_function (pbin->sinkpad,
GST_DEBUG_FUNCPTR (gst_pulse_audio_sink_sink_event));
- gst_pad_set_setcaps_function (pbin->sinkpad,
- GST_DEBUG_FUNCPTR (gst_pulse_audio_sink_sink_setcaps));
- gst_pad_set_acceptcaps_function (pbin->sinkpad,
- GST_DEBUG_FUNCPTR (gst_pulse_audio_sink_sink_acceptcaps));
+ gst_pad_set_query_function (pbin->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pulse_audio_sink_sink_query));
gst_element_add_pad (GST_ELEMENT (pbin), pbin->sinkpad);
@@ -451,14 +441,14 @@ gst_pulse_audio_sink_get_property (GObject * object, guint prop_id,
}
static void
-gst_pulse_audio_sink_free_dbin2 (GstPulseAudioSink * pbin)
+gst_pulse_audio_sink_free_dbin (GstPulseAudioSink * pbin)
{
- g_signal_handler_disconnect (pbin->dbin2, pbin->pad_added_id);
- gst_element_set_state (pbin->dbin2, GST_STATE_NULL);
+ g_signal_handler_disconnect (pbin->dbin, pbin->pad_added_id);
+ gst_element_set_state (pbin->dbin, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (pbin), pbin->dbin2);
+ gst_bin_remove (GST_BIN (pbin), pbin->dbin);
- pbin->dbin2 = NULL;
+ pbin->dbin = NULL;
}
static void
@@ -476,9 +466,9 @@ gst_pulse_audio_sink_dispose (GObject * object)
pbin->sink_proxypad = NULL;
}
- if (pbin->dbin2) {
- g_signal_handler_disconnect (pbin->dbin2, pbin->pad_added_id);
- pbin->dbin2 = NULL;
+ if (pbin->dbin) {
+ g_signal_handler_disconnect (pbin->dbin, pbin->pad_added_id);
+ pbin->dbin = NULL;
}
pbin->sinkpad = NULL;
@@ -509,7 +499,7 @@ distribute_running_time (GstElement * element, const GstSegment * segment)
pad = gst_element_get_static_pad (element, "sink");
/* FIXME: Some decoders collect newsegments and send them out at once, making
- * them lose accumulator events (and thus making dbin2_event_probe() hard to
+ * them lose accumulator events (and thus making dbin_event_probe() hard to
* do right if we're sending these as well. We can get away with not sending
* these at the moment, but this should be fixed! */
#if 0
@@ -520,31 +510,30 @@ distribute_running_time (GstElement * element, const GstSegment * segment)
}
#endif
- event = gst_event_new_new_segment_full (FALSE, segment->rate,
- segment->applied_rate, segment->format,
- segment->start, segment->stop, segment->time);
+ /* TODO review this copy, see if it can be avoided */
+ event = gst_event_new_segment (gst_segment_copy (segment));
gst_pad_send_event (pad, event);
gst_object_unref (pad);
}
-static gboolean
-dbin2_event_probe (GstPad * pad, GstMiniObject * obj, gpointer data)
+static GstPadProbeReturn
+dbin_event_probe (GstPad * pad, GstPadProbeInfo * info, gpointer data)
{
+ GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info);
GstPulseAudioSink *pbin = GST_PULSE_AUDIO_SINK (data);
- GstEvent *event = GST_EVENT (obj);
- if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
+ if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {
GST_DEBUG_OBJECT (pbin, "Got newsegment - dropping");
- gst_pad_remove_event_probe (pad, pbin->event_probe_id);
- return FALSE;
+ pbin->event_probe_id = 0;
+ return GST_PAD_PROBE_REMOVE;
}
- return TRUE;
+ return GST_PAD_PROBE_OK;
}
static void
-pad_added_cb (GstElement * dbin2, GstPad * pad, gpointer * data)
+pad_added_cb (GstElement * dbin, GstPad * pad, gpointer * data)
{
GstPulseAudioSink *pbin;
GstPad *sinkpad = NULL;
@@ -554,7 +543,7 @@ pad_added_cb (GstElement * dbin2, GstPad * pad, gpointer * data)
GST_PULSE_AUDIO_SINK_LOCK (pbin);
if (gst_pad_link (pad, sinkpad) != GST_PAD_LINK_OK)
- GST_ERROR_OBJECT (pbin, "Failed to link decodebin2 to pulsesink");
+ GST_ERROR_OBJECT (pbin, "Failed to link decodebin to pulsesink");
else
GST_DEBUG_OBJECT (pbin, "Linked new pad to pulsesink");
GST_PULSE_AUDIO_SINK_UNLOCK (pbin);
@@ -564,47 +553,51 @@ pad_added_cb (GstElement * dbin2, GstPad * pad, gpointer * data)
/* Called with pbin lock held */
static void
-gst_pulse_audio_sink_add_dbin2 (GstPulseAudioSink * pbin)
+gst_pulse_audio_sink_add_dbin (GstPulseAudioSink * pbin)
{
GstPad *sinkpad = NULL;
- g_assert (pbin->dbin2 == NULL);
+ g_assert (pbin->dbin == NULL);
- pbin->dbin2 = gst_element_factory_make ("decodebin2", "pulseaudiosink-dbin2");
+ pbin->dbin = gst_element_factory_make ("decodebin", "pulseaudiosink-dbin");
- if (!pbin->dbin2) {
- post_missing_element_message (pbin, "decodebin2");
+ if (!pbin->dbin) {
+ post_missing_element_message (pbin, "decodebin");
GST_ELEMENT_WARNING (pbin, CORE, MISSING_PLUGIN,
(_("Missing element '%s' - check your GStreamer installation."),
- "decodebin2"), ("audio playback might fail"));
+ "decodebin"), ("audio playback might fail"));
goto out;
}
- if (!gst_bin_add (GST_BIN (pbin), pbin->dbin2)) {
- GST_ERROR_OBJECT (pbin, "Failed to add decodebin2 to bin");
+ if (!gst_bin_add (GST_BIN (pbin), pbin->dbin)) {
+ GST_ERROR_OBJECT (pbin, "Failed to add decodebin to bin");
goto out;
}
- pbin->pad_added_id = g_signal_connect (pbin->dbin2, "pad-added",
+ pbin->pad_added_id = g_signal_connect (pbin->dbin, "pad-added",
G_CALLBACK (pad_added_cb), pbin);
- if (!gst_element_sync_state_with_parent (pbin->dbin2)) {
- GST_ERROR_OBJECT (pbin, "Failed to set decodebin2 to parent state");
+ if (!gst_element_sync_state_with_parent (pbin->dbin)) {
+ GST_ERROR_OBJECT (pbin, "Failed to set decodebin to parent state");
goto out;
}
/* Trap the newsegment events that we feed the decodebin and discard them */
sinkpad = gst_element_get_static_pad (GST_ELEMENT (pbin->psink), "sink");
- pbin->event_probe_id = gst_pad_add_event_probe_full (sinkpad,
- G_CALLBACK (dbin2_event_probe), gst_object_ref (pbin),
- (GDestroyNotify) gst_object_unref);
+
+ if (pbin->event_probe_id == 0)
+ pbin->event_probe_id =
+ gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
+ dbin_event_probe, gst_object_ref (pbin),
+ (GDestroyNotify) gst_object_unref);
+
gst_object_unref (sinkpad);
sinkpad = NULL;
GST_DEBUG_OBJECT (pbin, "Distributing running time to decodebin");
- distribute_running_time (pbin->dbin2, &pbin->segment);
+ distribute_running_time (pbin->dbin, &pbin->segment);
- sinkpad = gst_element_get_static_pad (pbin->dbin2, "sink");
+ sinkpad = gst_element_get_static_pad (pbin->dbin, "sink");
gst_pulse_audio_sink_update_sinkpad (pbin, sinkpad);
@@ -616,7 +609,7 @@ out:
static void
update_eac3_alignment (GstPulseAudioSink * pbin)
{
- GstCaps *caps = gst_pad_peer_get_caps_reffed (pbin->sinkpad);
+ GstCaps *caps = gst_pad_peer_query_caps (pbin->sinkpad, NULL);
GstStructure *st;
if (!caps)
@@ -626,7 +619,7 @@ update_eac3_alignment (GstPulseAudioSink * pbin)
if (g_str_equal (gst_structure_get_name (st), "audio/x-eac3")) {
GstStructure *event_st = gst_structure_new ("ac3parse-set-alignment",
- "alignment", G_TYPE_STRING, pbin->dbin2 ? "frame" : "iec61937", NULL);
+ "alignment", G_TYPE_STRING, pbin->dbin ? "frame" : "iec61937", NULL);
if (!gst_pad_push_event (pbin->sinkpad,
gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, event_st)))
@@ -636,19 +629,13 @@ update_eac3_alignment (GstPulseAudioSink * pbin)
gst_caps_unref (caps);
}
-static void
-proxypad_blocked_cb (GstPad * pad, gboolean blocked, gpointer data)
+static GstPadProbeReturn
+proxypad_blocked_cb (GstPad * pad, GstPadProbeInfo * info, gpointer data)
{
GstPulseAudioSink *pbin = GST_PULSE_AUDIO_SINK (data);
GstCaps *caps;
GstPad *sinkpad = NULL;
- if (!blocked) {
- /* Unblocked, don't need to do anything */
- GST_DEBUG_OBJECT (pbin, "unblocked");
- return;
- }
-
GST_DEBUG_OBJECT (pbin, "blocked");
GST_PULSE_AUDIO_SINK_LOCK (pbin);
@@ -656,60 +643,63 @@ proxypad_blocked_cb (GstPad * pad, gboolean blocked, gpointer data)
if (!pbin->format_lost) {
sinkpad = gst_element_get_static_pad (GST_ELEMENT (pbin->psink), "sink");
- if (GST_PAD_CAPS (pbin->sinkpad)) {
+ if (gst_pad_has_current_caps (pbin->sinkpad)) {
/* See if we already got caps on our sinkpad */
- caps = gst_caps_ref (GST_PAD_CAPS (pbin->sinkpad));
+ caps = gst_pad_get_current_caps (pbin->sinkpad);
} else {
/* We haven't, so get caps from upstream */
- caps = gst_pad_get_caps_reffed (pad);
+ caps = gst_pad_query_caps (pad, NULL);
}
- if (gst_pad_accept_caps (sinkpad, caps)) {
- if (pbin->dbin2) {
+ if (gst_pad_query_accept_caps (sinkpad, caps)) {
+ if (pbin->dbin) {
GST_DEBUG_OBJECT (pbin, "Removing decodebin");
- gst_pulse_audio_sink_free_dbin2 (pbin);
+ gst_pulse_audio_sink_free_dbin (pbin);
gst_pulse_audio_sink_update_sinkpad (pbin, sinkpad);
- } else
+ } else {
GST_DEBUG_OBJECT (pbin, "Doing nothing");
+ gst_pad_send_event (sinkpad, gst_event_new_caps (caps));
+ }
gst_caps_unref (caps);
gst_object_unref (sinkpad);
goto done;
}
/* pulsesink doesn't accept the incoming caps, so add a decodebin
- * (potentially after removing the existing once, since decodebin2 can't
+ * (potentially after removing the existing once, since decodebin can't
* renegotiate). */
} else {
/* Format lost, proceed to try plugging a decodebin */
pbin->format_lost = FALSE;
}
- if (pbin->dbin2 != NULL) {
- /* decodebin2 doesn't support reconfiguration, so throw this one away and
+ if (pbin->dbin != NULL) {
+ /* decodebin doesn't support reconfiguration, so throw this one away and
* create a new one. */
- gst_pulse_audio_sink_free_dbin2 (pbin);
+ gst_pulse_audio_sink_free_dbin (pbin);
}
GST_DEBUG_OBJECT (pbin, "Adding decodebin");
- gst_pulse_audio_sink_add_dbin2 (pbin);
+ gst_pulse_audio_sink_add_dbin (pbin);
done:
update_eac3_alignment (pbin);
- gst_pad_set_blocked_async_full (pad, FALSE, proxypad_blocked_cb,
- gst_object_ref (pbin), (GDestroyNotify) gst_object_unref);
-
+ pbin->block_probe_id = 0;
GST_PULSE_AUDIO_SINK_UNLOCK (pbin);
+
+ return GST_PAD_PROBE_REMOVE;
}
static gboolean
-gst_pulse_audio_sink_src_event (GstPad * pad, GstEvent * event)
+gst_pulse_audio_sink_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstPulseAudioSink *pbin = NULL;
GstPad *ghostpad = NULL;
gboolean ret = FALSE;
- ghostpad = GST_PAD_CAST (gst_pad_get_parent (pad));
+ ghostpad = GST_PAD_CAST (parent);
if (G_UNLIKELY (!ghostpad)) {
GST_WARNING_OBJECT (pad, "Could not get ghostpad");
goto out;
@@ -724,26 +714,26 @@ gst_pulse_audio_sink_src_event (GstPad * pad, GstEvent * event)
if (G_UNLIKELY (GST_EVENT_TYPE (event) == GST_EVENT_CUSTOM_UPSTREAM) &&
(gst_event_has_name (event, "pulse-format-lost") ||
gst_event_has_name (event, "pulse-sink-changed"))) {
- g_return_val_if_fail (pad->mode != GST_ACTIVATE_PULL, FALSE);
+ g_return_val_if_fail (pad->mode != GST_PAD_MODE_PULL, FALSE);
GST_PULSE_AUDIO_SINK_LOCK (pbin);
if (gst_event_has_name (event, "pulse-format-lost"))
pbin->format_lost = TRUE;
- if (!gst_pad_is_blocked (pad))
- gst_pad_set_blocked_async_full (pad, TRUE, proxypad_blocked_cb,
- gst_object_ref (pbin), (GDestroyNotify) gst_object_unref);
+ if (pbin->block_probe_id == 0)
+ pbin->block_probe_id =
+ gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
+ proxypad_blocked_cb, gst_object_ref (pbin),
+ (GDestroyNotify) gst_object_unref);
GST_PULSE_AUDIO_SINK_UNLOCK (pbin);
ret = TRUE;
} else if (pbin->proxypad_old_eventfunc) {
- ret = pbin->proxypad_old_eventfunc (pad, event);
+ ret = pbin->proxypad_old_eventfunc (pad, parent, event);
event = NULL;
}
out:
- if (ghostpad)
- gst_object_unref (ghostpad);
if (pbin)
gst_object_unref (pbin);
if (event)
@@ -753,35 +743,35 @@ out:
}
static gboolean
-gst_pulse_audio_sink_sink_event (GstPad * pad, GstEvent * event)
+gst_pulse_audio_sink_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
- GstPulseAudioSink *pbin = GST_PULSE_AUDIO_SINK (gst_pad_get_parent (pad));
+ GstPulseAudioSink *pbin = GST_PULSE_AUDIO_SINK (parent);
gboolean ret;
-
- ret = pbin->sinkpad_old_eventfunc (pad, gst_event_ref (event));
+ gboolean forward = TRUE;
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);
+ ret = gst_pulse_audio_sink_set_caps (pbin, caps);
+ forward = FALSE;
+ break;
+ }
+ case GST_EVENT_SEGMENT:
+ {
+ const GstSegment *segment = NULL;
GST_PULSE_AUDIO_SINK_LOCK (pbin);
- gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
- &start, &stop, &time);
+ gst_event_parse_segment (event, &segment);
- GST_DEBUG_OBJECT (pbin,
- "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));
+ GST_DEBUG_OBJECT (pbin, "newsegment: %" GST_SEGMENT_FORMAT, segment);
- if (format == GST_FORMAT_TIME) {
+ if (segment->format == GST_FORMAT_TIME) {
/* Store the values for feeding to sub-elements */
- gst_segment_set_newsegment_full (&pbin->segment, update,
- rate, arate, format, start, stop, time);
+ gst_segment_copy_into (segment, &pbin->segment);
} else {
GST_WARNING_OBJECT (pbin, "Got a non-TIME format segment");
gst_segment_init (&pbin->segment, GST_FORMAT_TIME);
@@ -801,8 +791,10 @@ gst_pulse_audio_sink_sink_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (pbin);
- gst_event_unref (event);
+ if (forward)
+ ret = pbin->sinkpad_old_eventfunc (pad, parent, event);
+ else
+ gst_event_unref (event);
return ret;
}
@@ -812,16 +804,16 @@ gst_pulse_audio_sink_sink_event (GstPad * pad, GstEvent * event)
* means that upstream will have to have everything possibly upto a parser
* plugged and we plugin a decoder whenever required. */
static gboolean
-gst_pulse_audio_sink_sink_acceptcaps (GstPad * pad, GstCaps * caps)
+gst_pulse_audio_sink_sink_acceptcaps (GstPulseAudioSink * pbin, GstPad * pad,
+ GstCaps * caps)
{
- GstPulseAudioSink *pbin = GST_PULSE_AUDIO_SINK (gst_pad_get_parent (pad));
- GstRingBufferSpec spec = { 0 };
+ GstAudioRingBufferSpec spec = { 0 };
const GstStructure *st;
GstCaps *pad_caps = NULL;
gboolean ret = FALSE;
- pad_caps = gst_pad_get_caps_reffed (pad);
- if (!pad_caps || !gst_caps_can_intersect (pad_caps, caps))
+ pad_caps = gst_pad_query_caps (pad, caps);
+ if (!pad_caps || gst_caps_is_empty (pad_caps))
goto out;
/* If we've not got fixed caps, creating a stream might fail, so let's just
@@ -829,8 +821,8 @@ gst_pulse_audio_sink_sink_acceptcaps (GstPad * pad, GstCaps * caps)
if (!gst_caps_is_fixed (caps))
goto out;
- spec.latency_time = GST_BASE_AUDIO_SINK (pbin->psink)->latency_time;
- if (!gst_ring_buffer_parse_caps (&spec, caps))
+ spec.latency_time = GST_AUDIO_BASE_SINK (pbin->psink)->latency_time;
+ if (!gst_audio_ring_buffer_parse_caps (&spec, caps))
goto out;
/* Make sure non-raw input is framed (one frame per buffer) and can be
@@ -852,27 +844,62 @@ out:
if (pad_caps)
gst_caps_unref (pad_caps);
- gst_object_unref (pbin);
+ return ret;
+}
+static gboolean
+gst_pulse_audio_sink_sink_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
+{
+ GstPulseAudioSink *pbin = GST_PULSE_AUDIO_SINK (parent);
+ gboolean ret = FALSE;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_ACCEPT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_query_parse_accept_caps (query, &caps);
+ ret = gst_pulse_audio_sink_sink_acceptcaps (pbin, pad, caps);
+ gst_query_set_accept_caps_result (query, ret);
+ ret = TRUE;
+ break;
+ }
+ default:
+ ret = gst_pad_query_default (pad, parent, query);
+ break;
+ }
return ret;
+
}
static gboolean
-gst_pulse_audio_sink_sink_setcaps (GstPad * pad, GstCaps * caps)
+gst_pulse_audio_sink_set_caps (GstPulseAudioSink * pbin, GstCaps * caps)
{
- GstPulseAudioSink *pbin = GST_PULSE_AUDIO_SINK (gst_pad_get_parent (pad));
gboolean ret = TRUE;
GST_PULSE_AUDIO_SINK_LOCK (pbin);
- if (!gst_pad_is_blocked (pbin->sinkpad))
- gst_pad_set_blocked_async_full (pbin->sink_proxypad, TRUE,
- proxypad_blocked_cb, gst_object_ref (pbin),
- (GDestroyNotify) gst_object_unref);
+ GST_DEBUG_OBJECT (pbin, "got caps %" GST_PTR_FORMAT, caps);
- GST_PULSE_AUDIO_SINK_UNLOCK (pbin);
+ if (gst_pad_has_current_caps (pbin->sinkpad)) {
+ GstCaps *current;
+ /* See if we already got caps on our sinkpad */
+ current = gst_pad_get_current_caps (pbin->sinkpad);
+ ret = gst_caps_is_equal (caps, current);
+ gst_caps_unref (current);
+ if (ret)
+ goto done;
+ }
- gst_object_unref (pbin);
+ if (pbin->block_probe_id == 0)
+ pbin->block_probe_id =
+ gst_pad_add_probe (pbin->sink_proxypad,
+ GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM, proxypad_blocked_cb,
+ gst_object_ref (pbin), (GDestroyNotify) gst_object_unref);
+
+done:
+ GST_PULSE_AUDIO_SINK_UNLOCK (pbin);
return ret;
}
@@ -888,10 +915,9 @@ gst_pulse_audio_sink_change_state (GstElement * element,
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
GST_PULSE_AUDIO_SINK_LOCK (pbin);
- if (gst_pad_is_blocked (pbin->sinkpad)) {
- gst_pad_set_blocked_async_full (pbin->sink_proxypad, FALSE,
- proxypad_blocked_cb, gst_object_ref (pbin),
- (GDestroyNotify) gst_object_unref);
+ if (pbin->block_probe_id) {
+ gst_pad_remove_probe (pbin->sink_proxypad, pbin->block_probe_id);
+ pbin->block_probe_id = 0;
}
GST_PULSE_AUDIO_SINK_UNLOCK (pbin);
break;
@@ -911,11 +937,11 @@ gst_pulse_audio_sink_change_state (GstElement * element,
GST_PULSE_AUDIO_SINK_LOCK (pbin);
gst_segment_init (&pbin->segment, GST_FORMAT_UNDEFINED);
- if (pbin->dbin2) {
+ if (pbin->dbin) {
GstPad *pad = gst_element_get_static_pad (GST_ELEMENT (pbin->psink),
"sink");
- gst_pulse_audio_sink_free_dbin2 (pbin);
+ gst_pulse_audio_sink_free_dbin (pbin);
gst_pulse_audio_sink_update_sinkpad (pbin, pad);
gst_object_unref (pad);
@@ -932,5 +958,3 @@ gst_pulse_audio_sink_change_state (GstElement * element,
out:
return ret;
}
-
-#endif /* HAVE_PULSE_1_0 */
diff --git a/ext/pulse/pulsemixer.c b/ext/pulse/pulsemixer.c
index 96468ce94..2a479cd79 100644
--- a/ext/pulse/pulsemixer.c
+++ b/ext/pulse/pulsemixer.c
@@ -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;
diff --git a/ext/pulse/pulsemixerctrl.h b/ext/pulse/pulsemixerctrl.h
index c1d1e8528..077b8841a 100644
--- a/ext/pulse/pulsemixerctrl.h
+++ b/ext/pulse/pulsemixerctrl.h
@@ -25,7 +25,7 @@
#define __GST_PULSEMIXERCTRL_H__
#include <gst/gst.h>
-#include <gst/interfaces/mixer.h>
+#include <gst/audio/mixer.h>
#include <pulse/pulseaudio.h>
#include <pulse/thread-mainloop.h>
@@ -158,16 +158,16 @@ interface_as_function ## _get_mixer_flags (GstMixer * mixer)
return gst_pulsemixer_ctrl_get_mixer_flags (this->mixer); \
} \
static void \
-interface_as_function ## _mixer_interface_init (GstMixerClass * klass) \
+interface_as_function ## _mixer_interface_init (GstMixerInterface * iface) \
{ \
- GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE; \
+ GST_MIXER_TYPE (iface) = GST_MIXER_HARDWARE; \
\
- klass->list_tracks = interface_as_function ## _list_tracks; \
- klass->set_volume = interface_as_function ## _set_volume; \
- klass->get_volume = interface_as_function ## _get_volume; \
- klass->set_mute = interface_as_function ## _set_mute; \
- klass->set_record = interface_as_function ## _set_record; \
- klass->get_mixer_flags = interface_as_function ## _get_mixer_flags; \
+ iface->list_tracks = interface_as_function ## _list_tracks; \
+ iface->set_volume = interface_as_function ## _set_volume; \
+ iface->get_volume = interface_as_function ## _get_volume; \
+ iface->set_mute = interface_as_function ## _set_mute; \
+ iface->set_record = interface_as_function ## _set_record; \
+ iface->get_mixer_flags = interface_as_function ## _get_mixer_flags; \
}
G_END_DECLS
diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c
index cfab338b5..f02a0651e 100644
--- a/ext/pulse/pulsesink.c
+++ b/ext/pulse/pulsesink.c
@@ -52,7 +52,7 @@
#include <gst/base/gstbasesink.h>
#include <gst/gsttaglist.h>
-#include <gst/interfaces/streamvolume.h>
+#include <gst/audio/streamvolume.h>
#include <gst/gst-i18n-plugin.h>
#include <gst/audio/gstaudioiec61937.h>
@@ -131,7 +131,7 @@ static GMutex *pa_shared_resource_mutex = NULL;
* pulseaudio memory instead. */
struct _GstPulseRingBuffer
{
- GstRingBuffer object;
+ GstAudioRingBuffer object;
gchar *context_name;
gchar *stream_name;
@@ -139,13 +139,9 @@ struct _GstPulseRingBuffer
pa_context *context;
pa_stream *stream;
-#ifdef HAVE_PULSE_1_0
pa_format_info *format;
guint channels;
gboolean is_pcm;
-#else
- pa_sample_spec sample_spec;
-#endif
void *m_data;
size_t m_towrite;
@@ -159,28 +155,29 @@ struct _GstPulseRingBuffer
};
struct _GstPulseRingBufferClass
{
- GstRingBufferClass parent_class;
+ GstAudioRingBufferClass parent_class;
};
static GType gst_pulseringbuffer_get_type (void);
static void gst_pulseringbuffer_finalize (GObject * object);
-static GstRingBufferClass *ring_parent_class = NULL;
-
-static gboolean gst_pulseringbuffer_open_device (GstRingBuffer * buf);
-static gboolean gst_pulseringbuffer_close_device (GstRingBuffer * buf);
-static gboolean gst_pulseringbuffer_acquire (GstRingBuffer * buf,
- GstRingBufferSpec * spec);
-static gboolean gst_pulseringbuffer_release (GstRingBuffer * buf);
-static gboolean gst_pulseringbuffer_start (GstRingBuffer * buf);
-static gboolean gst_pulseringbuffer_pause (GstRingBuffer * buf);
-static gboolean gst_pulseringbuffer_stop (GstRingBuffer * buf);
-static void gst_pulseringbuffer_clear (GstRingBuffer * buf);
-static guint gst_pulseringbuffer_commit (GstRingBuffer * buf,
+static GstAudioRingBufferClass *ring_parent_class = NULL;
+
+static gboolean gst_pulseringbuffer_open_device (GstAudioRingBuffer * buf);
+static gboolean gst_pulseringbuffer_close_device (GstAudioRingBuffer * buf);
+static gboolean gst_pulseringbuffer_acquire (GstAudioRingBuffer * buf,
+ GstAudioRingBufferSpec * spec);
+static gboolean gst_pulseringbuffer_release (GstAudioRingBuffer * buf);
+static gboolean gst_pulseringbuffer_start (GstAudioRingBuffer * buf);
+static gboolean gst_pulseringbuffer_pause (GstAudioRingBuffer * buf);
+static gboolean gst_pulseringbuffer_stop (GstAudioRingBuffer * buf);
+static void gst_pulseringbuffer_clear (GstAudioRingBuffer * buf);
+static guint gst_pulseringbuffer_commit (GstAudioRingBuffer * buf,
guint64 * sample, guchar * data, gint in_samples, gint out_samples,
gint * accum);
-G_DEFINE_TYPE (GstPulseRingBuffer, gst_pulseringbuffer, GST_TYPE_RING_BUFFER);
+G_DEFINE_TYPE (GstPulseRingBuffer, gst_pulseringbuffer,
+ GST_TYPE_AUDIO_RING_BUFFER);
static void
gst_pulsesink_init_contexts (void)
@@ -195,10 +192,10 @@ static void
gst_pulseringbuffer_class_init (GstPulseRingBufferClass * klass)
{
GObjectClass *gobject_class;
- GstRingBufferClass *gstringbuffer_class;
+ GstAudioRingBufferClass *gstringbuffer_class;
gobject_class = (GObjectClass *) klass;
- gstringbuffer_class = (GstRingBufferClass *) klass;
+ gstringbuffer_class = (GstAudioRingBufferClass *) klass;
ring_parent_class = g_type_class_peek_parent (klass);
@@ -229,13 +226,9 @@ gst_pulseringbuffer_init (GstPulseRingBuffer * pbuf)
pbuf->context = NULL;
pbuf->stream = NULL;
-#ifdef HAVE_PULSE_1_0
pbuf->format = NULL;
pbuf->channels = 0;
pbuf->is_pcm = FALSE;
-#else
- pa_sample_spec_init (&pbuf->sample_spec);
-#endif
pbuf->m_data = NULL;
pbuf->m_towrite = 0;
@@ -264,14 +257,12 @@ gst_pulsering_destroy_stream (GstPulseRingBuffer * pbuf)
pbuf->m_offset = 0;
pbuf->m_lastoffset = 0;
}
-#ifdef HAVE_PULSE_1_0
if (pbuf->format) {
pa_format_info_free (pbuf->format);
pbuf->format = NULL;
pbuf->channels = 0;
pbuf->is_pcm = FALSE;
}
-#endif
pa_stream_disconnect (pbuf->stream);
@@ -423,7 +414,6 @@ gst_pulsering_context_subscribe_cb (pa_context * c,
if (idx != pa_stream_get_index (pbuf->stream))
continue;
-#ifdef HAVE_PULSE_1_0
if (psink->device && pbuf->is_pcm &&
!g_str_equal (psink->device,
pa_stream_get_device_name (pbuf->stream))) {
@@ -437,12 +427,11 @@ gst_pulsering_context_subscribe_cb (pa_context * c,
GST_INFO_OBJECT (psink, "emitting sink-changed");
renego = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM,
- gst_structure_new ("pulse-sink-changed", NULL));
+ gst_structure_new_empty ("pulse-sink-changed"));
if (!gst_pad_push_event (GST_BASE_SINK (psink)->sinkpad, renego))
GST_DEBUG_OBJECT (psink, "Emitted sink-changed - nobody was listening");
}
-#endif
/* Actually this event is also triggered when other properties of
* the stream change that are unrelated to the volume. However it is
@@ -457,7 +446,7 @@ gst_pulsering_context_subscribe_cb (pa_context * c,
/* will be called when the device should be opened. In this case we will connect
* to the server. We should not try to open any streams in this state. */
static gboolean
-gst_pulseringbuffer_open_device (GstRingBuffer * buf)
+gst_pulseringbuffer_open_device (GstAudioRingBuffer * buf)
{
GstPulseSink *psink;
GstPulseRingBuffer *pbuf;
@@ -572,7 +561,7 @@ connect_failed:
/* close the device */
static gboolean
-gst_pulseringbuffer_close_device (GstRingBuffer * buf)
+gst_pulseringbuffer_close_device (GstAudioRingBuffer * buf)
{
GstPulseSink *psink;
GstPulseRingBuffer *pbuf;
@@ -621,10 +610,10 @@ static void
gst_pulsering_stream_request_cb (pa_stream * s, size_t length, void *userdata)
{
GstPulseSink *psink;
- GstRingBuffer *rbuf;
+ GstAudioRingBuffer *rbuf;
GstPulseRingBuffer *pbuf;
- rbuf = GST_RING_BUFFER_CAST (userdata);
+ rbuf = GST_AUDIO_RING_BUFFER_CAST (userdata);
pbuf = GST_PULSERING_BUFFER_CAST (userdata);
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
@@ -737,7 +726,6 @@ gst_pulsering_stream_event_cb (pa_stream * p, const char *name,
gst_element_post_message (GST_ELEMENT_CAST (psink),
gst_message_new_request_state (GST_OBJECT_CAST (psink),
GST_STATE_PLAYING));
-#ifdef HAVE_PULSE_1_0
} else if (!strcmp (name, PA_STREAM_EVENT_FORMAT_LOST)) {
GstEvent *renego;
@@ -755,14 +743,13 @@ gst_pulsering_stream_event_cb (pa_stream * p, const char *name,
psink->device = g_strdup (pa_proplist_gets (pl, "device"));
renego = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM,
- gst_structure_new ("pulse-format-lost", NULL));
+ gst_structure_new_empty ("pulse-format-lost"));
if (!gst_pad_push_event (GST_BASE_SINK (psink)->sinkpad, renego)) {
/* Nobody handled the format change - emit an error */
GST_ELEMENT_ERROR (psink, STREAM, FORMAT, ("Sink format changed"),
("Sink format changed"));
}
-#endif
} else {
GST_DEBUG_OBJECT (psink, "got unknown event %s", name);
}
@@ -794,7 +781,8 @@ gst_pulsering_wait_for_stream_ready (GstPulseSink * psink, pa_stream * stream)
/* This method should create a new stream of the given @spec. No playback should
* start yet so we start in the corked state. */
static gboolean
-gst_pulseringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
+gst_pulseringbuffer_acquire (GstAudioRingBuffer * buf,
+ GstAudioRingBufferSpec * spec)
{
GstPulseSink *psink;
GstPulseRingBuffer *pbuf;
@@ -802,33 +790,24 @@ gst_pulseringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
const pa_buffer_attr *actual;
pa_channel_map channel_map;
pa_operation *o = NULL;
-#ifdef HAVE_PULSE_0_9_20
pa_cvolume v;
-#endif
pa_cvolume *pv = NULL;
pa_stream_flags_t flags;
const gchar *name;
GstAudioClock *clock;
-#ifdef HAVE_PULSE_1_0
pa_format_info *formats[1];
#ifndef GST_DISABLE_GST_DEBUG
gchar print_buf[PA_FORMAT_INFO_SNPRINT_MAX];
#endif
-#endif
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (buf));
pbuf = GST_PULSERING_BUFFER_CAST (buf);
GST_LOG_OBJECT (psink, "creating sample spec");
/* convert the gstreamer sample spec to the pulseaudio format */
-#ifdef HAVE_PULSE_1_0
if (!gst_pulse_fill_format_info (spec, &pbuf->format, &pbuf->channels))
goto invalid_spec;
pbuf->is_pcm = pa_format_info_is_pcm (pbuf->format);
-#else
- if (!gst_pulse_fill_sample_spec (spec, &pbuf->sample_spec))
- goto invalid_spec;
-#endif
pa_threaded_mainloop_lock (mainloop);
@@ -845,12 +824,8 @@ gst_pulseringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
pa_operation_unref (o);
/* initialize the channel map */
-#ifdef HAVE_PULSE_1_0
if (pbuf->is_pcm && gst_pulse_gst_to_channel_map (&channel_map, spec))
pa_format_info_set_channel_map (pbuf->format, &channel_map);
-#else
- gst_pulse_gst_to_channel_map (&channel_map, spec);
-#endif
/* find a good name for the stream */
if (psink->stream_name)
@@ -859,17 +834,10 @@ gst_pulseringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
name = "Playback Stream";
/* create a stream */
-#ifdef HAVE_PULSE_1_0
formats[0] = pbuf->format;
if (!(pbuf->stream = pa_stream_new_extended (pbuf->context, name, formats, 1,
psink->proplist)))
goto stream_failed;
-#else
- GST_LOG_OBJECT (psink, "creating stream with name %s", name);
- if (!(pbuf->stream = pa_stream_new_with_proplist (pbuf->context, name,
- &pbuf->sample_spec, &channel_map, psink->proplist)))
- goto stream_failed;
-#endif
/* install essential callbacks */
pa_stream_set_state_callback (pbuf->stream,
@@ -902,26 +870,19 @@ gst_pulseringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
GST_INFO_OBJECT (psink, "prebuf: %d", wanted.prebuf);
GST_INFO_OBJECT (psink, "minreq: %d", wanted.minreq);
-#ifdef HAVE_PULSE_0_9_20
/* configure volume when we changed it, else we leave the default */
if (psink->volume_set) {
GST_LOG_OBJECT (psink, "have volume of %f", psink->volume);
pv = &v;
-#ifdef HAVE_PULSE_1_0
if (pbuf->is_pcm)
gst_pulse_cvolume_from_linear (pv, pbuf->channels, psink->volume);
else {
GST_DEBUG_OBJECT (psink, "passthrough stream, not setting volume");
pv = NULL;
}
-#else
- gst_pulse_cvolume_from_linear (pv, pbuf->sample_spec.channels,
- psink->volume);
-#endif
} else {
pv = NULL;
}
-#endif
/* construct the flags */
flags = PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE |
@@ -941,13 +902,12 @@ gst_pulseringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
goto connect_failed;
/* our clock will now start from 0 again */
- clock = GST_AUDIO_CLOCK (GST_BASE_AUDIO_SINK (psink)->provided_clock);
+ clock = GST_AUDIO_CLOCK (GST_AUDIO_BASE_SINK (psink)->provided_clock);
gst_audio_clock_reset (clock, 0);
if (!gst_pulsering_wait_for_stream_ready (psink, pbuf->stream))
goto connect_failed;
-#ifdef HAVE_PULSE_1_0
g_free (psink->device);
psink->device = g_strdup (pa_stream_get_device_name (pbuf->stream));
@@ -956,7 +916,6 @@ gst_pulseringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
pa_stream_get_format_info (pbuf->stream));
GST_INFO_OBJECT (psink, "negotiated to: %s", print_buf);
#endif
-#endif
/* After we passed the volume off of to PA we never want to set it
again, since it is PA's job to save/restore volumes. */
@@ -1020,7 +979,7 @@ connect_failed:
/* free the stream that we acquired before */
static gboolean
-gst_pulseringbuffer_release (GstRingBuffer * buf)
+gst_pulseringbuffer_release (GstAudioRingBuffer * buf)
{
GstPulseRingBuffer *pbuf;
@@ -1030,7 +989,6 @@ gst_pulseringbuffer_release (GstRingBuffer * buf)
gst_pulsering_destroy_stream (pbuf);
pa_threaded_mainloop_unlock (mainloop);
-#ifdef HAVE_PULSE_1_0
{
GstPulseSink *psink;
@@ -1038,7 +996,6 @@ gst_pulseringbuffer_release (GstRingBuffer * buf)
g_atomic_int_set (&psink->format_lost, FALSE);
psink->format_lost_time = GST_CLOCK_TIME_NONE;
}
-#endif
return TRUE;
}
@@ -1061,12 +1018,10 @@ gst_pulsering_set_corked (GstPulseRingBuffer * pbuf, gboolean corked,
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
-#ifdef HAVE_PULSE_1_0
if (g_atomic_int_get (&psink->format_lost)) {
/* Sink format changed, stream's gone so fake being paused */
return TRUE;
}
-#endif
GST_DEBUG_OBJECT (psink, "setting corked state to %d", corked);
if (pbuf->corked != corked) {
@@ -1107,7 +1062,7 @@ cork_failed:
}
static void
-gst_pulseringbuffer_clear (GstRingBuffer * buf)
+gst_pulseringbuffer_clear (GstAudioRingBuffer * buf)
{
GstPulseSink *psink;
GstPulseRingBuffer *pbuf;
@@ -1151,7 +1106,7 @@ mainloop_enter_defer_cb (pa_mainloop_api * api, void *userdata)
/* start/resume playback ASAP, we don't uncork here but in the commit method */
static gboolean
-gst_pulseringbuffer_start (GstRingBuffer * buf)
+gst_pulseringbuffer_start (GstAudioRingBuffer * buf)
{
GstPulseSink *psink;
GstPulseRingBuffer *pbuf;
@@ -1171,8 +1126,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_AUDIO_BASE_SINK (psink)->eos_rendering))
gst_pulsering_set_corked (pbuf, FALSE, FALSE);
pa_threaded_mainloop_unlock (mainloop);
@@ -1182,7 +1136,7 @@ gst_pulseringbuffer_start (GstRingBuffer * buf)
/* pause/stop playback ASAP */
static gboolean
-gst_pulseringbuffer_pause (GstRingBuffer * buf)
+gst_pulseringbuffer_pause (GstAudioRingBuffer * buf)
{
GstPulseSink *psink;
GstPulseRingBuffer *pbuf;
@@ -1230,7 +1184,7 @@ mainloop_leave_defer_cb (pa_mainloop_api * api, void *userdata)
/* stop playback, we flush everything. */
static gboolean
-gst_pulseringbuffer_stop (GstRingBuffer * buf)
+gst_pulseringbuffer_stop (GstAudioRingBuffer * buf)
{
GstPulseSink *psink;
GstPulseRingBuffer *pbuf;
@@ -1250,13 +1204,11 @@ gst_pulseringbuffer_stop (GstRingBuffer * buf)
GST_DEBUG_OBJECT (psink, "signal commit thread");
pa_threaded_mainloop_signal (mainloop, 0);
}
-#ifdef HAVE_PULSE_1_0
if (g_atomic_int_get (&psink->format_lost)) {
/* Don't try to flush, the stream's probably gone by now */
res = TRUE;
goto cleanup;
}
-#endif
/* then try to flush, it's not fatal when this fails */
GST_DEBUG_OBJECT (psink, "flushing");
@@ -1299,16 +1251,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
@@ -1317,16 +1269,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
@@ -1334,16 +1286,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
@@ -1351,23 +1303,23 @@ 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
/* our custom commit function because we write into the buffer of pulseaudio
* instead of keeping our own buffer */
static guint
-gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
+gst_pulseringbuffer_commit (GstAudioRingBuffer * buf, guint64 * sample,
guchar * data, gint in_samples, gint out_samples, gint * accum)
{
GstPulseSink *psink;
@@ -1376,7 +1328,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;
@@ -1391,13 +1343,13 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
/* make sure the ringbuffer is started */
if (G_UNLIKELY (g_atomic_int_get (&buf->state) !=
- GST_RING_BUFFER_STATE_STARTED)) {
+ GST_AUDIO_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!");
- if (!gst_ring_buffer_start (buf))
+ if (!gst_audio_ring_buffer_start (buf))
goto start_failed;
}
@@ -1406,7 +1358,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 */
@@ -1425,20 +1377,18 @@ 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)) {
/* Sink format changed, drop the data and hope upstream renegotiates */
goto fake_done;
}
-#endif
if (pbuf->paused)
goto was_paused;
/* offset is in bytes */
- offset = *sample * bps;
+ offset = *sample * bpf;
while (*toprocess > 0) {
size_t avail;
@@ -1452,7 +1402,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)
@@ -1467,7 +1417,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) {
@@ -1481,18 +1431,16 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
for (;;) {
pbuf->m_writable = pa_stream_writable_size (pbuf->stream);
-#ifdef HAVE_PULSE_1_0
if (g_atomic_int_get (&psink->format_lost)) {
/* Sink format changed, give up and hope upstream renegotiates */
goto fake_done;
}
-#endif
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;
@@ -1512,7 +1460,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;
@@ -1532,18 +1480,16 @@ 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);
-#ifdef HAVE_PULSE_1_0
/* No trick modes for passthrough streams */
if (G_UNLIKELY (!pbuf->is_pcm && (inr != outr || reverse))) {
GST_WARNING_OBJECT (psink, "Passthrough stream can't run in trick mode");
goto unlock_and_fail;
}
-#endif
if (G_LIKELY (inr == outr && !reverse)) {
/* no rate conversion, simply write out the samples */
@@ -1583,14 +1529,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) {
@@ -1601,7 +1547,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 */
@@ -1625,17 +1571,15 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
}
}
-#ifdef HAVE_PULSE_1_0
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;
@@ -1700,12 +1644,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_AUDIO_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,
@@ -1737,85 +1681,30 @@ static void gst_pulsesink_get_property (GObject * object, guint prop_id,
static void gst_pulsesink_finalize (GObject * object);
static gboolean gst_pulsesink_event (GstBaseSink * sink, GstEvent * event);
+static gboolean gst_pulsesink_query (GstBaseSink * sink, GstQuery * query);
static GstStateChangeReturn gst_pulsesink_change_state (GstElement * element,
GstStateChange transition);
-static void gst_pulsesink_init_interfaces (GType type);
+static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (PULSE_SINK_TEMPLATE_CAPS));
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);
-}
+#define gst_pulsesink_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstPulseSink, gst_pulsesink, GST_TYPE_AUDIO_BASE_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 void
-gst_pulsesink_base_init (gpointer g_class)
+static GstAudioRingBuffer *
+gst_pulsesink_create_ringbuffer (GstAudioBaseSink * sink)
{
- static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (PULSE_SINK_TEMPLATE_CAPS));
-
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- 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_static_pad_template (element_class, &pad_template);
-}
-
-static GstRingBuffer *
-gst_pulsesink_create_ringbuffer (GstBaseAudioSink * sink)
-{
- GstRingBuffer *buffer;
+ GstAudioRingBuffer *buffer;
GST_DEBUG_OBJECT (sink, "creating ringbuffer");
buffer = g_object_new (GST_TYPE_PULSERING_BUFFER, NULL);
@@ -1825,7 +1714,7 @@ gst_pulsesink_create_ringbuffer (GstBaseAudioSink * sink)
}
static GstBuffer *
-gst_pulsesink_payload (GstBaseAudioSink * sink, GstBuffer * buf)
+gst_pulsesink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
{
switch (sink->ringbuffer->spec.type) {
case GST_BUFTYPE_AC3:
@@ -1836,20 +1725,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;
}
@@ -1864,7 +1763,7 @@ gst_pulsesink_class_init (GstPulseSinkClass * klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstBaseSinkClass *gstbasesink_class = GST_BASE_SINK_CLASS (klass);
GstBaseSinkClass *bc;
- GstBaseAudioSinkClass *gstaudiosink_class = GST_BASE_AUDIO_SINK_CLASS (klass);
+ GstAudioBaseSinkClass *gstaudiosink_class = GST_AUDIO_BASE_SINK_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
gchar *clientname;
@@ -1873,6 +1772,7 @@ gst_pulsesink_class_init (GstPulseSinkClass * klass)
gobject_class->get_property = gst_pulsesink_get_property;
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_pulsesink_event);
+ gstbasesink_class->query = GST_DEBUG_FUNCPTR (gst_pulsesink_query);
/* restore the original basesink pull methods */
bc = g_type_class_peek (GST_TYPE_BASE_SINK);
@@ -1952,11 +1852,17 @@ 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 */
static GstClockTime
-gst_pulsesink_get_time (GstClock * clock, GstBaseAudioSink * sink)
+gst_pulsesink_get_time (GstClock * clock, GstAudioBaseSink * sink)
{
GstPulseSink *psink;
GstPulseRingBuffer *pbuf;
@@ -1968,13 +1874,11 @@ gst_pulsesink_get_time (GstClock * clock, GstBaseAudioSink * sink)
pbuf = GST_PULSERING_BUFFER_CAST (sink->ringbuffer);
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
-#ifdef HAVE_PULSE_1_0
if (g_atomic_int_get (&psink->format_lost)) {
/* Stream was lost in a format change, it'll get set up again once
* upstream renegotiates */
return psink->format_lost_time;
}
-#endif
pa_threaded_mainloop_lock (mainloop);
if (gst_pulsering_is_dead (psink, pbuf, TRUE))
@@ -2010,10 +1914,8 @@ gst_pulsesink_sink_info_cb (pa_context * c, const pa_sink_info * i, int eol,
{
GstPulseRingBuffer *pbuf;
GstPulseSink *psink;
-#ifdef HAVE_PULSE_1_0
GList *l;
guint8 j;
-#endif
pbuf = GST_PULSERING_BUFFER_CAST (userdata);
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
@@ -2024,7 +1926,6 @@ gst_pulsesink_sink_info_cb (pa_context * c, const pa_sink_info * i, int eol,
g_free (psink->device_description);
psink->device_description = g_strdup (i->description);
-#ifdef HAVE_PULSE_1_0
g_mutex_lock (psink->sink_formats_lock);
for (l = g_list_first (psink->sink_formats); l; l = g_list_next (l))
@@ -2038,26 +1939,24 @@ gst_pulsesink_sink_info_cb (pa_context * c, const pa_sink_info * i, int eol,
pa_format_info_copy (i->formats[j]));
g_mutex_unlock (psink->sink_formats_lock);
-#endif
done:
pa_threaded_mainloop_signal (mainloop, 0);
}
-#ifdef HAVE_PULSE_1_0
/* NOTE: If you're making changes here, see if pulseaudiosink acceptcaps also
* needs to be changed accordingly. */
static gboolean
-gst_pulsesink_pad_acceptcaps (GstPad * pad, GstCaps * caps)
+gst_pulsesink_query_acceptcaps (GstPulseSink * psink, GstCaps * caps)
{
- GstPulseSink *psink = GST_PULSESINK (gst_pad_get_parent_element (pad));
- GstPulseRingBuffer *pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK
+ GstPulseRingBuffer *pbuf = GST_PULSERING_BUFFER_CAST (GST_AUDIO_BASE_SINK
(psink)->ringbuffer);
+ GstPad *pad = GST_BASE_SINK_PAD (psink);
GstCaps *pad_caps;
GstStructure *st;
gboolean ret = FALSE;
- GstRingBufferSpec spec = { 0 };
+ GstAudioRingBufferSpec spec = { 0 };
pa_stream *stream = NULL;
pa_operation *o = NULL;
pa_channel_map channel_map;
@@ -2065,11 +1964,9 @@ gst_pulsesink_pad_acceptcaps (GstPad * pad, GstCaps * caps)
pa_format_info *format = NULL, *formats[1];
guint channels;
- pad_caps = gst_pad_get_caps_reffed (pad);
- if (pad_caps) {
- ret = gst_caps_can_intersect (pad_caps, caps);
- gst_caps_unref (pad_caps);
- }
+ pad_caps = gst_pad_query_caps (pad, caps);
+ ret = pad_caps != NULL;
+ gst_caps_unref (pad_caps);
/* Either template caps didn't match, or we're still in NULL state */
if (!ret || !pbuf->context)
@@ -2084,8 +1981,8 @@ gst_pulsesink_pad_acceptcaps (GstPad * pad, GstCaps * caps)
pa_threaded_mainloop_lock (mainloop);
- spec.latency_time = GST_BASE_AUDIO_SINK (psink)->latency_time;
- if (!gst_ring_buffer_parse_caps (&spec, caps))
+ spec.latency_time = GST_AUDIO_BASE_SINK (psink)->latency_time;
+ if (!gst_audio_ring_buffer_parse_caps (&spec, caps))
goto out;
if (!gst_pulse_fill_format_info (&spec, &format, &channels))
@@ -2168,7 +2065,6 @@ out:
pa_threaded_mainloop_unlock (mainloop);
done:
- gst_object_unref (psink);
return ret;
info_failed:
@@ -2179,20 +2075,17 @@ info_failed:
goto out;
}
}
-#endif
static void
-gst_pulsesink_init (GstPulseSink * pulsesink, GstPulseSinkClass * klass)
+gst_pulsesink_init (GstPulseSink * pulsesink)
{
pulsesink->server = NULL;
pulsesink->device = NULL;
pulsesink->device_description = NULL;
pulsesink->client_name = gst_pulse_client_name ();
-#ifdef HAVE_PULSE_1_0
pulsesink->sink_formats_lock = g_mutex_new ();
pulsesink->sink_formats = NULL;
-#endif
pulsesink->volume = DEFAULT_VOLUME;
pulsesink->volume_set = FALSE;
@@ -2202,26 +2095,19 @@ gst_pulsesink_init (GstPulseSink * pulsesink, GstPulseSinkClass * klass)
pulsesink->notify = 0;
-#ifdef HAVE_PULSE_1_0
g_atomic_int_set (&pulsesink->format_lost, FALSE);
pulsesink->format_lost_time = GST_CLOCK_TIME_NONE;
-#endif
pulsesink->properties = NULL;
pulsesink->proplist = NULL;
/* override with a custom clock */
- if (GST_BASE_AUDIO_SINK (pulsesink)->provided_clock)
- gst_object_unref (GST_BASE_AUDIO_SINK (pulsesink)->provided_clock);
+ if (GST_AUDIO_BASE_SINK (pulsesink)->provided_clock)
+ gst_object_unref (GST_AUDIO_BASE_SINK (pulsesink)->provided_clock);
- GST_BASE_AUDIO_SINK (pulsesink)->provided_clock =
+ GST_AUDIO_BASE_SINK (pulsesink)->provided_clock =
gst_audio_clock_new ("GstPulseSinkClock",
- (GstAudioClockGetTimeFunc) gst_pulsesink_get_time, pulsesink);
-
-#ifdef HAVE_PULSE_1_0
- gst_pad_set_acceptcaps_function (GST_BASE_SINK (pulsesink)->sinkpad,
- GST_DEBUG_FUNCPTR (gst_pulsesink_pad_acceptcaps));
-#endif
+ (GstAudioClockGetTimeFunc) gst_pulsesink_get_time, pulsesink, NULL);
/* TRUE for sinks, FALSE for sources */
pulsesink->probe = gst_pulseprobe_new (G_OBJECT (pulsesink),
@@ -2233,22 +2119,18 @@ static void
gst_pulsesink_finalize (GObject * object)
{
GstPulseSink *pulsesink = GST_PULSESINK_CAST (object);
-#ifdef HAVE_PULSE_1_0
GList *i;
-#endif
g_free (pulsesink->server);
g_free (pulsesink->device);
g_free (pulsesink->device_description);
g_free (pulsesink->client_name);
-#ifdef HAVE_PULSE_1_0
for (i = g_list_first (pulsesink->sink_formats); i; i = g_list_next (i))
pa_format_info_free ((pa_format_info *) i->data);
g_list_free (pulsesink->sink_formats);
g_mutex_free (pulsesink->sink_formats_lock);
-#endif
if (pulsesink->properties)
gst_structure_free (pulsesink->properties);
@@ -2278,23 +2160,19 @@ gst_pulsesink_set_volume (GstPulseSink * psink, gdouble volume)
GST_DEBUG_OBJECT (psink, "setting volume to %f", volume);
- pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
+ pbuf = GST_PULSERING_BUFFER_CAST (GST_AUDIO_BASE_SINK (psink)->ringbuffer);
if (pbuf == NULL || pbuf->stream == NULL)
goto no_buffer;
if ((idx = pa_stream_get_index (pbuf->stream)) == PA_INVALID_INDEX)
goto no_index;
-#ifdef HAVE_PULSE_1_0
if (pbuf->is_pcm)
gst_pulse_cvolume_from_linear (&v, pbuf->channels, volume);
else
/* FIXME: this will eventually be superceded by checks to see if the volume
* is readable/writable */
goto unlock;
-#else
- gst_pulse_cvolume_from_linear (&v, pbuf->sample_spec.channels, volume);
-#endif
if (!(o = pa_context_set_sink_input_volume (pbuf->context, idx,
&v, NULL, NULL)))
@@ -2355,7 +2233,7 @@ gst_pulsesink_set_mute (GstPulseSink * psink, gboolean mute)
GST_DEBUG_OBJECT (psink, "setting mute state to %d", mute);
- pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
+ pbuf = GST_PULSERING_BUFFER_CAST (GST_AUDIO_BASE_SINK (psink)->ringbuffer);
if (pbuf == NULL || pbuf->stream == NULL)
goto no_buffer;
@@ -2448,7 +2326,7 @@ gst_pulsesink_get_volume (GstPulseSink * psink)
pa_threaded_mainloop_lock (mainloop);
- pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
+ pbuf = GST_PULSERING_BUFFER_CAST (GST_AUDIO_BASE_SINK (psink)->ringbuffer);
if (pbuf == NULL || pbuf->stream == NULL)
goto no_buffer;
@@ -2520,7 +2398,7 @@ gst_pulsesink_get_mute (GstPulseSink * psink)
pa_threaded_mainloop_lock (mainloop);
mute = psink->mute;
- pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
+ pbuf = GST_PULSERING_BUFFER_CAST (GST_AUDIO_BASE_SINK (psink)->ringbuffer);
if (pbuf == NULL || pbuf->stream == NULL)
goto no_buffer;
@@ -2582,7 +2460,7 @@ gst_pulsesink_device_description (GstPulseSink * psink)
goto no_mainloop;
pa_threaded_mainloop_lock (mainloop);
- pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
+ pbuf = GST_PULSERING_BUFFER_CAST (GST_AUDIO_BASE_SINK (psink)->ringbuffer);
if (pbuf == NULL)
goto no_buffer;
@@ -2715,7 +2593,7 @@ gst_pulsesink_change_title (GstPulseSink * psink, const gchar * t)
pa_threaded_mainloop_lock (mainloop);
- pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
+ pbuf = GST_PULSERING_BUFFER_CAST (GST_AUDIO_BASE_SINK (psink)->ringbuffer);
if (pbuf == NULL || pbuf->stream == NULL)
goto no_buffer;
@@ -2790,7 +2668,7 @@ gst_pulsesink_change_props (GstPulseSink * psink, GstTagList * l)
goto finish;
pa_threaded_mainloop_lock (mainloop);
- pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
+ pbuf = GST_PULSERING_BUFFER_CAST (GST_AUDIO_BASE_SINK (psink)->ringbuffer);
if (pbuf == NULL || pbuf->stream == NULL)
goto no_buffer;
@@ -2835,7 +2713,7 @@ gst_pulsesink_flush_ringbuffer (GstPulseSink * psink)
pa_threaded_mainloop_lock (mainloop);
- pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
+ pbuf = GST_PULSERING_BUFFER_CAST (GST_AUDIO_BASE_SINK (psink)->ringbuffer);
if (pbuf == NULL || pbuf->stream == NULL)
goto no_buffer;
@@ -2916,6 +2794,30 @@ gst_pulsesink_event (GstBaseSink * sink, GstEvent * event)
return GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
}
+static gboolean
+gst_pulsesink_query (GstBaseSink * sink, GstQuery * query)
+{
+ GstPulseSink *pulsesink = GST_PULSESINK_CAST (sink);
+ gboolean ret;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_ACCEPT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_query_parse_accept_caps (query, &caps);
+ ret = gst_pulsesink_query_acceptcaps (pulsesink, caps);
+ gst_query_set_accept_caps_result (query, ret);
+ ret = TRUE;
+ break;
+ }
+ default:
+ ret = GST_BASE_SINK_CLASS (parent_class)->query (sink, query);
+ break;
+ }
+ return ret;
+}
+
static void
gst_pulsesink_release_mainloop (GstPulseSink * psink)
{
@@ -2965,7 +2867,7 @@ gst_pulsesink_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_READY_TO_PAUSED:
gst_element_post_message (element,
gst_message_new_clock_provide (GST_OBJECT_CAST (element),
- GST_BASE_AUDIO_SINK (pulsesink)->provided_clock, TRUE));
+ GST_AUDIO_BASE_SINK (pulsesink)->provided_clock, TRUE));
break;
default:
@@ -2978,10 +2880,10 @@ gst_pulsesink_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
- /* format_lost is reset in release() in baseaudiosink */
+ /* format_lost is reset in release() in audiobasesink */
gst_element_post_message (element,
gst_message_new_clock_lost (GST_OBJECT_CAST (element),
- GST_BASE_AUDIO_SINK (pulsesink)->provided_clock));
+ GST_AUDIO_BASE_SINK (pulsesink)->provided_clock));
break;
case GST_STATE_CHANGE_READY_TO_NULL:
gst_pulsesink_release_mainloop (pulsesink);
@@ -3003,7 +2905,7 @@ mainloop_failed:
state_failure:
{
if (transition == GST_STATE_CHANGE_NULL_TO_READY) {
- /* Clear the PA mainloop if baseaudiosink failed to open the ring_buffer */
+ /* Clear the PA mainloop if audiobasesink failed to open the ring_buffer */
g_assert (mainloop);
gst_pulsesink_release_mainloop (pulsesink);
}
diff --git a/ext/pulse/pulsesink.h b/ext/pulse/pulsesink.h
index 340b4819f..9a0c58eab 100644
--- a/ext/pulse/pulsesink.h
+++ b/ext/pulse/pulsesink.h
@@ -56,7 +56,7 @@ typedef struct _GstPulseSinkClass GstPulseSinkClass;
struct _GstPulseSink
{
- GstBaseAudioSink sink;
+ GstAudioBaseSink sink;
gchar *server, *device, *stream_name, *client_name;
gchar *device_description;
@@ -77,72 +77,38 @@ struct _GstPulseSink
GstStructure *properties;
pa_proplist *proplist;
-#ifdef HAVE_PULSE_1_0
GMutex *sink_formats_lock;
GList *sink_formats;
volatile gint format_lost;
GstClockTime format_lost_time;
-#endif
};
struct _GstPulseSinkClass
{
- GstBaseAudioSinkClass parent_class;
+ GstAudioBaseSinkClass parent_class;
};
GType gst_pulsesink_get_type (void);
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
-# define ENDIANNESS "LITTLE_ENDIAN, BIG_ENDIAN"
+# define FORMATS "{ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, " \
+ "S24LE, S24BE, S24_32LE, S24_32BE, S8 }"
#else
-# define ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN"
+# define FORMATS "{ S16BE, S16LE, F32BE, F32LE, S32BE, S32LE, " \
+ "S24BE, S24LE, S24_32BE, S24_32LE, S8 }"
#endif
#define _PULSE_SINK_CAPS_COMMON \
- "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, " \
+ "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 ];" \
- "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 ];"
-
-#ifdef HAVE_PULSE_1_0
+ "rate = (int) [ 1, MAX], " "channels = (int) [ 1, 32 ];"
+
#define _PULSE_SINK_CAPS_1_0 \
"audio/x-ac3, framed = (boolean) true;" \
"audio/x-eac3, framed = (boolean) true; " \
@@ -150,15 +116,12 @@ GType gst_pulsesink_get_type (void);
"block-size = (int) { 512, 1024, 2048 }; " \
"audio/mpeg, mpegversion = (int) 1, " \
"mpegaudioversion = (int) [ 1, 2 ], parsed = (boolean) true;"
-#else
-#define _PULSE_SINK_CAPS_1_0 ""
-#endif
#define PULSE_SINK_TEMPLATE_CAPS \
_PULSE_SINK_CAPS_COMMON \
_PULSE_SINK_CAPS_1_0
-#ifdef HAVE_PULSE_1_0
+/* FIXME 0.11: pulseaudiosink helper bin must die */
#define GST_TYPE_PULSE_AUDIO_SINK \
(gst_pulse_audio_sink_get_type())
@@ -175,8 +138,6 @@ GType gst_pulsesink_get_type (void);
GType gst_pulse_audio_sink_get_type (void);
-#endif /* HAVE_PULSE_1_0 */
-
G_END_DECLS
#endif /* __GST_PULSESINK_H__ */
diff --git a/ext/pulse/pulsesrc.c b/ext/pulse/pulsesrc.c
index 88c8b002f..0599deb9b 100644
--- a/ext/pulse/pulsesrc.c
+++ b/ext/pulse/pulsesrc.c
@@ -43,9 +43,7 @@
#include <gst/base/gstbasesrc.h>
#include <gst/gsttaglist.h>
-#ifdef HAVE_PULSE_1_0
-#include <gst/interfaces/streamvolume.h>
-#endif
+#include <gst/audio/streamvolume.h>
#include "pulsesrc.h"
#include "pulseutil.h"
@@ -58,11 +56,9 @@ GST_DEBUG_CATEGORY_EXTERN (pulse_debug);
#define DEFAULT_DEVICE NULL
#define DEFAULT_DEVICE_NAME NULL
-#ifdef HAVE_PULSE_1_0
#define DEFAULT_VOLUME 1.0
#define DEFAULT_MUTE FALSE
#define MAX_VOLUME 10.0
-#endif
enum
{
@@ -73,10 +69,8 @@ enum
PROP_CLIENT,
PROP_STREAM_PROPERTIES,
PROP_SOURCE_OUTPUT_INDEX,
-#ifdef HAVE_PULSE_1_0
PROP_VOLUME,
PROP_MUTE,
-#endif
PROP_LAST
};
@@ -89,12 +83,14 @@ 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);
static gboolean gst_pulsesrc_prepare (GstAudioSrc * asrc,
- GstRingBufferSpec * spec);
+ GstAudioRingBufferSpec * spec);
static gboolean gst_pulsesrc_unprepare (GstAudioSrc * asrc);
@@ -109,126 +105,36 @@ 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 "{ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, U8 }"
#else
-# define ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN"
+# define FORMATS "{ S16BE, S16LE, F32BE, F32LE, S32BE, S32LE, 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 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 ]")
+ );
-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;
-
- if (interface_type == GST_TYPE_PROPERTY_PROBE && this->probe)
- return TRUE;
-
-#ifdef HAVE_PULSE_1_0
- if (interface_type == GST_TYPE_STREAM_VOLUME)
- return TRUE;
-#endif
-
- 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)
-{
-#ifdef HAVE_PULSE_1_0
- static const GInterfaceInfo svol_iface_info = {
- NULL, NULL, NULL,
- };
-#endif
- 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,
- };
-
-#ifdef HAVE_PULSE_1_0
- g_type_add_interface_static (type, GST_TYPE_STREAM_VOLUME, &svol_iface_info);
-#endif
- 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_static_pad_template (element_class, &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);
+ G_IMPLEMENT_INTERFACE (GST_TYPE_STREAM_VOLUME, NULL));
static void
gst_pulsesrc_class_init (GstPulseSrcClass * klass)
@@ -312,7 +218,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
*
@@ -327,14 +232,17 @@ gst_pulsesrc_class_init (GstPulseSrcClass * klass)
"record stream", 0, G_MAXUINT, PA_INVALID_INDEX,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-#ifdef HAVE_PULSE_1_0
+ 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));
+
/**
* GstPulseSrc:volume
*
- * The volume of the record stream. Only works when using PulseAudio 1.0 or
- * later.
- *
- * Since: 0.10.36
+ * The volume of the record stream.
*/
g_object_class_install_property (gobject_class,
PROP_VOLUME, g_param_spec_double ("volume", "Volume",
@@ -345,20 +253,16 @@ gst_pulsesrc_class_init (GstPulseSrcClass * klass)
/**
* GstPulseSrc:mute
*
- * Whether the stream is muted or not. Only works when using PulseAudio 1.0
- * or later.
- *
- * Since: 0.10.36
+ * Whether the stream is muted or not.
*/
g_object_class_install_property (gobject_class,
PROP_MUTE, g_param_spec_boolean ("mute", "Mute",
"Mute state of this stream",
DEFAULT_MUTE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-#endif
}
static void
-gst_pulsesrc_init (GstPulseSrc * pulsesrc, GstPulseSrcClass * klass)
+gst_pulsesrc_init (GstPulseSrc * pulsesrc)
{
pulsesrc->server = NULL;
pulsesrc->device = NULL;
@@ -367,6 +271,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;
@@ -375,10 +280,9 @@ 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;
-#ifdef HAVE_PULSE_1_0
pulsesrc->volume = DEFAULT_VOLUME;
pulsesrc->volume_set = FALSE;
@@ -386,7 +290,6 @@ gst_pulsesrc_init (GstPulseSrc * pulsesrc, GstPulseSrcClass * klass)
pulsesrc->mute_set = FALSE;
pulsesrc->notify = 0;
-#endif
pulsesrc->mixer = NULL;
@@ -396,8 +299,8 @@ gst_pulsesrc_init (GstPulseSrc * pulsesrc, GstPulseSrcClass * klass)
pulsesrc->probe = gst_pulseprobe_new (G_OBJECT (pulsesrc), G_OBJECT_GET_CLASS (pulsesrc), PROP_DEVICE, pulsesrc->server, FALSE, TRUE); /* FALSE for sinks, TRUE for sources */
/* this should be the default but it isn't yet */
- gst_base_audio_src_set_slave_method (GST_BASE_AUDIO_SRC (pulsesrc),
- GST_BASE_AUDIO_SRC_SLAVE_SKEW);
+ gst_audio_base_src_set_slave_method (GST_AUDIO_BASE_SRC (pulsesrc),
+ GST_AUDIO_BASE_SRC_SLAVE_SKEW);
}
static void
@@ -407,6 +310,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");
}
@@ -426,9 +330,7 @@ gst_pulsesrc_destroy_context (GstPulseSrc * pulsesrc)
/* Make sure we don't get any further callbacks */
pa_context_set_state_callback (pulsesrc->context, NULL, NULL);
-#ifdef HAVE_PULSE_1_0
pa_context_set_subscribe_callback (pulsesrc->context, NULL, NULL);
-#endif
pa_context_unref (pulsesrc->context);
@@ -549,7 +451,6 @@ no_mainloop:
}
}
-#ifdef HAVE_PULSE_1_0
static void
gst_pulsesrc_source_output_info_cb (pa_context * c,
const pa_source_output_info * i, int eol, void *userdata)
@@ -801,7 +702,6 @@ mute_failed:
goto unlock;
}
}
-#endif
static void
gst_pulsesrc_set_property (GObject * object,
@@ -839,14 +739,12 @@ gst_pulsesrc_set_property (GObject * object,
pa_proplist_free (pulsesrc->proplist);
pulsesrc->proplist = gst_pulse_make_proplist (pulsesrc->properties);
break;
-#ifdef HAVE_PULSE_1_0
case PROP_VOLUME:
gst_pulsesrc_set_stream_volume (pulsesrc, g_value_get_double (value));
break;
case PROP_MUTE:
gst_pulsesrc_set_stream_mute (pulsesrc, g_value_get_boolean (value));
break;
-#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -879,14 +777,12 @@ gst_pulsesrc_get_property (GObject * object,
case PROP_SOURCE_OUTPUT_INDEX:
g_value_set_uint (value, pulsesrc->source_output_idx);
break;
-#ifdef HAVE_PULSE_1_0
case PROP_VOLUME:
g_value_set_double (value, gst_pulsesrc_get_stream_volume (pulsesrc));
break;
case PROP_MUTE:
g_value_set_boolean (value, gst_pulsesrc_get_stream_mute (pulsesrc));
break;
-#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -980,7 +876,6 @@ gst_pulsesrc_stream_overflow_cb (pa_stream * s, void *userdata)
GST_WARNING_OBJECT (GST_PULSESRC_CAST (userdata), "Got overflow");
}
-#ifdef HAVE_PULSE_1_0
static void
gst_pulsesrc_context_subscribe_cb (pa_context * c,
pa_subscription_event_type_t t, uint32_t idx, void *userdata)
@@ -1002,7 +897,6 @@ gst_pulsesrc_context_subscribe_cb (pa_context * c,
/* inform streaming thread to notify */
g_atomic_int_compare_and_exchange (&psrc->notify, 0, 1);
}
-#endif
static gboolean
gst_pulsesrc_open (GstAudioSrc * asrc)
@@ -1026,10 +920,8 @@ gst_pulsesrc_open (GstAudioSrc * asrc)
pa_context_set_state_callback (pulsesrc->context,
gst_pulsesrc_context_state_cb, pulsesrc);
-#ifdef HAVE_PULSE_1_0
pa_context_set_subscribe_callback (pulsesrc->context,
gst_pulsesrc_context_subscribe_cb, pulsesrc);
-#endif
GST_DEBUG_OBJECT (pulsesrc, "connect to server %s",
GST_STR_NULL (pulsesrc->server));
@@ -1111,12 +1003,10 @@ gst_pulsesrc_read (GstAudioSrc * asrc, gpointer data, guint length)
pa_threaded_mainloop_lock (pulsesrc->mainloop);
pulsesrc->in_read = TRUE;
-#ifdef HAVE_PULSE_1_0
if (g_atomic_int_compare_and_exchange (&pulsesrc->notify, 1, 0)) {
g_object_notify (G_OBJECT (pulsesrc), "volume");
g_object_notify (G_OBJECT (pulsesrc), "mute");
}
-#endif
if (pulsesrc->paused)
goto was_paused;
@@ -1256,38 +1146,31 @@ gst_pulsesrc_create_stream (GstPulseSrc * pulsesrc, GstCaps * caps)
pa_channel_map channel_map;
GstStructure *s;
gboolean need_channel_layout = FALSE;
- GstRingBufferSpec spec;
+ GstAudioRingBufferSpec spec;
const gchar *name;
- memset (&spec, 0, sizeof (GstRingBufferSpec));
+ memset (&spec, 0, sizeof (GstAudioRingBufferSpec));
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_audio_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;
@@ -1298,20 +1181,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);
@@ -1337,13 +1213,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
@@ -1352,20 +1255,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_query_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_query_caps (GST_BASE_SRC_PAD (basesrc), NULL);
GST_DEBUG_OBJECT (basesrc, "caps of peer: %" GST_PTR_FORMAT, peercaps);
if (peercaps) {
/* get intersection */
@@ -1384,7 +1288,7 @@ gst_pulsesrc_negotiate (GstBaseSrc * basesrc)
/* now fixate */
if (!gst_caps_is_empty (caps)) {
- gst_pad_fixate_caps (GST_BASE_SRC_PAD (basesrc), caps);
+ GST_BASE_SRC_CLASS (parent_class)->fixate (basesrc, caps);
GST_DEBUG_OBJECT (basesrc, "fixated to: %" GST_PTR_FORMAT, caps);
if (gst_caps_is_any (caps)) {
@@ -1393,9 +1297,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);
@@ -1412,19 +1316,16 @@ no_nego_needed:
}
static gboolean
-gst_pulsesrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
+gst_pulsesrc_prepare (GstAudioSrc * asrc, GstAudioRingBufferSpec * spec)
{
pa_buffer_attr wanted;
const pa_buffer_attr *actual;
GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (asrc);
pa_stream_flags_t flags;
-#ifdef HAVE_PULSE_1_0
pa_operation *o;
-#endif
pa_threaded_mainloop_lock (pulsesrc->mainloop);
-#ifdef HAVE_PULSE_1_0
/* enable event notifications */
GST_LOG_OBJECT (pulsesrc, "subscribing to context events");
if (!(o = pa_context_subscribe (pulsesrc->context,
@@ -1436,7 +1337,6 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
}
pa_operation_unref (o);
-#endif
wanted.maxlength = -1;
wanted.tlength = -1;
@@ -1454,17 +1354,12 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
PA_STREAM_NOT_MONOTONIC | PA_STREAM_ADJUST_LATENCY |
PA_STREAM_START_CORKED;
-#ifdef HAVE_PULSE_1_0
if (pulsesrc->mute_set && pulsesrc->mute)
flags |= PA_STREAM_START_MUTED;
-#endif
if (pa_stream_connect_record (pulsesrc->stream, pulsesrc->device, &wanted,
flags) < 0) {
- GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED,
- ("Failed to connect stream: %s",
- pa_strerror (pa_context_errno (pulsesrc->context))), (NULL));
- goto unlock_and_fail;
+ goto connect_failed;
}
pulsesrc->corked = TRUE;
@@ -1474,12 +1369,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;
@@ -1487,17 +1378,16 @@ 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);
g_object_notify (G_OBJECT (pulsesrc), "source-output-index");
-#ifdef HAVE_PULSE_1_0
if (pulsesrc->volume_set) {
gst_pulsesrc_set_stream_volume (pulsesrc, pulsesrc->volume);
pulsesrc->volume_set = FALSE;
}
-#endif
/* get the actual buffering properties now */
actual = pa_stream_get_buffer_attr (pulsesrc->stream);
@@ -1518,10 +1408,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);
@@ -1601,6 +1510,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)))
diff --git a/ext/pulse/pulsesrc.h b/ext/pulse/pulsesrc.h
index 655417f1d..d4d20f8c3 100644
--- a/ext/pulse/pulsesrc.h
+++ b/ext/pulse/pulsesrc.h
@@ -72,16 +72,15 @@ struct _GstPulseSrc
GstPulseMixerCtrl *mixer;
GstPulseProbe *probe;
-#ifdef HAVE_PULSE_1_0
gdouble volume;
gboolean volume_set:1;
gboolean mute:1;
gboolean mute_set:1;
gint notify; /* atomic */
-#endif
gboolean corked:1;
+ gboolean stream_connected:1;
gboolean operation_success:1;
gboolean paused:1;
gboolean in_read:1;
diff --git a/ext/pulse/pulseutil.c b/ext/pulse/pulseutil.c
index 0d8af79d9..2c7dd5669 100644
--- a/ext/pulse/pulseutil.c
+++ b/ext/pulse/pulseutil.c
@@ -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
};
@@ -76,41 +89,66 @@ static const GstAudioChannelPosition
[PA_CHANNEL_POSITION_INVALID + 1] = GST_AUDIO_CHANNEL_POSITION_NONE,
};
-gboolean
-gst_pulse_fill_sample_spec (GstRingBufferSpec * spec, pa_sample_spec * ss)
+static gboolean
+gstaudioformat_to_pasampleformat (GstAudioFormat format,
+ pa_sample_format_t * sf)
{
+ switch (format) {
+ case GST_AUDIO_FORMAT_U8:
+ *sf = PA_SAMPLE_U8;
+ break;
+ case GST_AUDIO_FORMAT_S16LE:
+ *sf = PA_SAMPLE_S16LE;
+ break;
+ case GST_AUDIO_FORMAT_S16BE:
+ *sf = PA_SAMPLE_S16BE;
+ break;
+ case GST_AUDIO_FORMAT_F32LE:
+ *sf = PA_SAMPLE_FLOAT32LE;
+ break;
+ case GST_AUDIO_FORMAT_F32BE:
+ *sf = PA_SAMPLE_FLOAT32BE;
+ break;
+ case GST_AUDIO_FORMAT_S32LE:
+ *sf = PA_SAMPLE_S32LE;
+ break;
+ case GST_AUDIO_FORMAT_S32BE:
+ *sf = PA_SAMPLE_S32BE;
+ break;
+ case GST_AUDIO_FORMAT_S24LE:
+ *sf = PA_SAMPLE_S24LE;
+ break;
+ case GST_AUDIO_FORMAT_S24BE:
+ *sf = PA_SAMPLE_S24BE;
+ break;
+ case GST_AUDIO_FORMAT_S24_32LE:
+ *sf = PA_SAMPLE_S24_32LE;
+ break;
+ case GST_AUDIO_FORMAT_S24_32BE:
+ *sf = PA_SAMPLE_S24_32BE;
+ break;
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
- if (spec->format == GST_MU_LAW && spec->width == 8)
+gboolean
+gst_pulse_fill_sample_spec (GstAudioRingBufferSpec * spec, pa_sample_spec * ss)
+{
+ if (spec->type == GST_BUFTYPE_RAW) {
+ if (!gstaudioformat_to_pasampleformat (GST_AUDIO_INFO_FORMAT (&spec->info),
+ &ss->format))
+ 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;
@@ -118,62 +156,34 @@ gst_pulse_fill_sample_spec (GstRingBufferSpec * spec, pa_sample_spec * ss)
return TRUE;
}
-#ifdef HAVE_PULSE_1_0
gboolean
-gst_pulse_fill_format_info (GstRingBufferSpec * spec, pa_format_info ** f,
+gst_pulse_fill_format_info (GstAudioRingBufferSpec * spec, pa_format_info ** f,
guint * channels)
{
pa_format_info *format;
pa_sample_format_t sf = PA_SAMPLE_INVALID;
+ GstAudioInfo *ainfo = &spec->info;
format = pa_format_info_new ();
- if (spec->format == GST_MU_LAW && spec->width == 8) {
+ if (spec->type == GST_BUFTYPE_MU_LAW && GST_AUDIO_INFO_WIDTH (ainfo) == 8) {
format->encoding = PA_ENCODING_PCM;
sf = PA_SAMPLE_ULAW;
- } else if (spec->format == GST_A_LAW && spec->width == 8) {
+ } else if (spec->type == GST_BUFTYPE_A_LAW
+ && GST_AUDIO_INFO_WIDTH (ainfo) == 8) {
format->encoding = PA_ENCODING_PCM;
sf = PA_SAMPLE_ALAW;
- } else if (spec->format == GST_U8 && spec->width == 8) {
- format->encoding = PA_ENCODING_PCM;
- sf = PA_SAMPLE_U8;
- } else if (spec->format == GST_S16_LE && spec->width == 16) {
- format->encoding = PA_ENCODING_PCM;
- sf = PA_SAMPLE_S16LE;
- } else if (spec->format == GST_S16_BE && spec->width == 16) {
- format->encoding = PA_ENCODING_PCM;
- sf = PA_SAMPLE_S16BE;
- } else if (spec->format == GST_FLOAT32_LE && spec->width == 32) {
- format->encoding = PA_ENCODING_PCM;
- sf = PA_SAMPLE_FLOAT32LE;
- } else if (spec->format == GST_FLOAT32_BE && spec->width == 32) {
+ } else if (spec->type == GST_BUFTYPE_RAW) {
format->encoding = PA_ENCODING_PCM;
- sf = PA_SAMPLE_FLOAT32BE;
- } else if (spec->format == GST_S32_LE && spec->width == 32) {
- format->encoding = PA_ENCODING_PCM;
- sf = PA_SAMPLE_S32LE;
- } else if (spec->format == GST_S32_BE && spec->width == 32) {
- format->encoding = PA_ENCODING_PCM;
- sf = PA_SAMPLE_S32BE;
- } else if (spec->format == GST_S24_3LE && spec->width == 24) {
- format->encoding = PA_ENCODING_PCM;
- sf = PA_SAMPLE_S24LE;
- } else if (spec->format == GST_S24_3BE && spec->width == 24) {
- format->encoding = PA_ENCODING_PCM;
- sf = PA_SAMPLE_S24BE;
- } else if (spec->format == GST_S24_LE && spec->width == 32) {
- format->encoding = PA_ENCODING_PCM;
- sf = PA_SAMPLE_S24_32LE;
- } else if (spec->format == GST_S24_BE && spec->width == 32) {
- format->encoding = PA_ENCODING_PCM;
- sf = PA_SAMPLE_S24_32BE;
- } else if (spec->format == GST_AC3) {
+ if (!gstaudioformat_to_pasampleformat (GST_AUDIO_INFO_FORMAT (ainfo), &sf))
+ goto fail;
+ } else if (spec->type == GST_BUFTYPE_AC3) {
format->encoding = PA_ENCODING_AC3_IEC61937;
- } else if (spec->format == GST_EAC3) {
+ } else if (spec->type == GST_BUFTYPE_EAC3) {
format->encoding = PA_ENCODING_EAC3_IEC61937;
- } else if (spec->format == GST_DTS) {
+ } else if (spec->type == GST_BUFTYPE_DTS) {
format->encoding = PA_ENCODING_DTS_IEC61937;
- } else if (spec->format == GST_MPEG) {
+ } else if (spec->type == GST_BUFTYPE_MPEG) {
format->encoding = PA_ENCODING_MPEG_IEC61937;
} else {
goto fail;
@@ -181,16 +191,16 @@ gst_pulse_fill_format_info (GstRingBufferSpec * spec, pa_format_info ** f,
if (format->encoding == PA_ENCODING_PCM) {
pa_format_info_set_sample_format (format, sf);
- pa_format_info_set_channels (format, spec->channels);
+ pa_format_info_set_channels (format, GST_AUDIO_INFO_CHANNELS (ainfo));
}
- pa_format_info_set_rate (format, spec->rate);
+ pa_format_info_set_rate (format, GST_AUDIO_INFO_RATE (ainfo));
if (!pa_format_info_valid (format))
goto fail;
*f = format;
- *channels = spec->channels;
+ *channels = GST_AUDIO_INFO_CHANNELS (ainfo);
return TRUE;
@@ -199,7 +209,6 @@ fail:
pa_format_info_free (format);
return FALSE;
}
-#endif
/* PATH_MAX is not defined everywhere, e.g. on GNU Hurd */
#ifndef PATH_MAX
@@ -223,7 +232,7 @@ gst_pulse_client_name (void)
pa_channel_map *
gst_pulse_gst_to_channel_map (pa_channel_map * map,
- const GstRingBufferSpec * spec)
+ const GstAudioRingBufferSpec * spec)
{
int i;
GstAudioChannelPosition *pos;
@@ -236,7 +245,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 +257,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;
@@ -257,19 +266,22 @@ gst_pulse_gst_to_channel_map (pa_channel_map * map,
return map;
}
-GstRingBufferSpec *
+GstAudioRingBufferSpec *
gst_pulse_channel_map_to_gst (const pa_channel_map * map,
- GstRingBufferSpec * spec)
+ GstAudioRingBufferSpec * spec)
{
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 +293,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;
}
diff --git a/ext/pulse/pulseutil.h b/ext/pulse/pulseutil.h
index 4adfeb1ed..8b50fa58a 100644
--- a/ext/pulse/pulseutil.h
+++ b/ext/pulse/pulseutil.h
@@ -28,22 +28,21 @@
#include <gst/gst.h>
#include <pulse/pulseaudio.h>
+#include <gst/audio/gstaudioringbuffer.h>
#include <gst/audio/gstaudiosink.h>
-gboolean gst_pulse_fill_sample_spec (GstRingBufferSpec * spec,
+gboolean gst_pulse_fill_sample_spec (GstAudioRingBufferSpec * spec,
pa_sample_spec * ss);
-#ifdef HAVE_PULSE_1_0
-gboolean gst_pulse_fill_format_info (GstRingBufferSpec * spec,
+gboolean gst_pulse_fill_format_info (GstAudioRingBufferSpec * spec,
pa_format_info ** f, guint * channels);
-#endif
gchar *gst_pulse_client_name (void);
pa_channel_map *gst_pulse_gst_to_channel_map (pa_channel_map * map,
- const GstRingBufferSpec * spec);
+ const GstAudioRingBufferSpec * spec);
-GstRingBufferSpec *gst_pulse_channel_map_to_gst (const pa_channel_map * map,
- GstRingBufferSpec * spec);
+GstAudioRingBufferSpec *gst_pulse_channel_map_to_gst (const pa_channel_map * map,
+ GstAudioRingBufferSpec * spec);
void gst_pulse_cvolume_from_linear (pa_cvolume *v, unsigned channels, gdouble volume);
diff --git a/ext/raw1394/gstdv1394src.c b/ext/raw1394/gstdv1394src.c
index 1a3cae631..a175b6201 100644
--- a/ext/raw1394/gstdv1394src.c
+++ b/ext/raw1394/gstdv1394src.c
@@ -170,7 +170,8 @@ gst_dv1394src_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class, &src_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_factory));
gst_element_class_set_details_simple (element_class,
"Firewire (1394) DV video source", "Source/Video",
diff --git a/ext/raw1394/gsthdv1394src.c b/ext/raw1394/gsthdv1394src.c
index 33ef11e6f..70b602bf6 100644
--- a/ext/raw1394/gsthdv1394src.c
+++ b/ext/raw1394/gsthdv1394src.c
@@ -140,7 +140,8 @@ gst_hdv1394src_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class, &src_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_factory));
gst_element_class_set_details_simple (element_class,
"Firewire (1394) HDV video source", "Source/Video",
diff --git a/ext/shout2/gstshout2.c b/ext/shout2/gstshout2.c
index 8b0ddbf79..9a6363bb5 100644
--- a/ext/shout2/gstshout2.c
+++ b/ext/shout2/gstshout2.c
@@ -160,8 +160,8 @@ gst_shout2send_base_init (GstShout2sendClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class,
- &sink_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_template));
gst_element_class_set_details_simple (element_class, "Icecast network sink",
"Sink/Network", "Sends data to an icecast server",
"Wim Taymans <wim.taymans@chello.be>, "
diff --git a/ext/soup/gstsouphttpclientsink.c b/ext/soup/gstsouphttpclientsink.c
index 494dd8d69..af238277f 100644
--- a/ext/soup/gstsouphttpclientsink.c
+++ b/ext/soup/gstsouphttpclientsink.c
@@ -107,51 +107,21 @@ GST_STATIC_PAD_TEMPLATE ("sink",
/* class initialization */
-#define DEBUG_INIT(bla) \
- GST_DEBUG_CATEGORY_INIT (souphttpclientsink_dbg, "souphttpclientsink", 0, \
- "souphttpclientsink element");
-
-GST_BOILERPLATE_FULL (GstSoupHttpClientSink, gst_soup_http_client_sink,
- GstBaseSink, GST_TYPE_BASE_SINK, DEBUG_INIT);
-
-static void
-gst_soup_http_client_sink_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_soup_http_client_sink_sink_template);
-
- gst_element_class_set_details_simple (element_class, "HTTP client sink",
- "Generic", "Sends streams to HTTP server via PUT",
- "David Schleef <ds@entropywave.com>");
-}
+#define gst_soup_http_client_sink_parent_class parent_class
+G_DEFINE_TYPE (GstSoupHttpClientSink, gst_soup_http_client_sink,
+ GST_TYPE_BASE_SINK);
static void
gst_soup_http_client_sink_class_init (GstSoupHttpClientSinkClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
GstBaseSinkClass *base_sink_class = GST_BASE_SINK_CLASS (klass);
gobject_class->set_property = gst_soup_http_client_sink_set_property;
gobject_class->get_property = gst_soup_http_client_sink_get_property;
gobject_class->dispose = gst_soup_http_client_sink_dispose;
gobject_class->finalize = gst_soup_http_client_sink_finalize;
- base_sink_class->set_caps =
- GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_set_caps);
- if (0)
- base_sink_class->get_times =
- GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_get_times);
- base_sink_class->start = GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_start);
- base_sink_class->stop = GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_stop);
- base_sink_class->unlock =
- GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_unlock);
- base_sink_class->event = GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_event);
- if (0)
- base_sink_class->preroll =
- GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_preroll);
- base_sink_class->render =
- GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_render);
g_object_class_install_property (gobject_class,
PROP_LOCATION,
@@ -197,11 +167,36 @@ gst_soup_http_client_sink_class_init (GstSoupHttpClientSinkClass * klass)
g_param_spec_boxed ("cookies", "Cookies", "HTTP request cookies",
G_TYPE_STRV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_soup_http_client_sink_sink_template));
+
+ gst_element_class_set_details_simple (gstelement_class, "HTTP client sink",
+ "Generic", "Sends streams to HTTP server via PUT",
+ "David Schleef <ds@entropywave.com>");
+
+ base_sink_class->set_caps =
+ GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_set_caps);
+ if (0)
+ base_sink_class->get_times =
+ GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_get_times);
+ base_sink_class->start = GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_start);
+ base_sink_class->stop = GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_stop);
+ base_sink_class->unlock =
+ GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_unlock);
+ base_sink_class->event = GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_event);
+ if (0)
+ base_sink_class->preroll =
+ GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_preroll);
+ base_sink_class->render =
+ GST_DEBUG_FUNCPTR (gst_soup_http_client_sink_render);
+
+ GST_DEBUG_CATEGORY_INIT (souphttpclientsink_dbg, "souphttpclientsink", 0,
+ "souphttpclientsink element");
+
}
static void
-gst_soup_http_client_sink_init (GstSoupHttpClientSink * souphttpsink,
- GstSoupHttpClientSinkClass * souphttpsink_class)
+gst_soup_http_client_sink_init (GstSoupHttpClientSink * souphttpsink)
{
const char *proxy;
@@ -550,7 +545,7 @@ gst_soup_http_client_sink_event (GstBaseSink * sink, GstEvent * event)
GST_DEBUG_OBJECT (souphttpsink, "finished eos");
}
- return TRUE;
+ return GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
}
static GstFlowReturn
@@ -595,20 +590,30 @@ send_message_locked (GstSoupHttpClientSink * souphttpsink)
if (souphttpsink->offset == 0) {
for (g = souphttpsink->streamheader_buffers; g; g = g_list_next (g)) {
GstBuffer *buffer = g->data;
+ gpointer data;
+ gsize size;
+
+ /* FIXME, lifetime of the buffer? */
+ data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
soup_message_body_append (souphttpsink->message->request_body,
- SOUP_MEMORY_STATIC, GST_BUFFER_DATA (buffer),
- GST_BUFFER_SIZE (buffer));
- n += GST_BUFFER_SIZE (buffer);
+ SOUP_MEMORY_STATIC, data, size);
+ n += size;
+ gst_buffer_unmap (buffer, data, size);
}
}
for (g = souphttpsink->queued_buffers; g; g = g_list_next (g)) {
GstBuffer *buffer = g->data;
if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) {
+ gpointer data;
+ gsize size;
+
+ /* FIXME, lifetime of the buffer? */
+ data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
soup_message_body_append (souphttpsink->message->request_body,
- SOUP_MEMORY_STATIC, GST_BUFFER_DATA (buffer),
- GST_BUFFER_SIZE (buffer));
- n += GST_BUFFER_SIZE (buffer);
+ SOUP_MEMORY_STATIC, data, size);
+ n += size;
+ gst_buffer_unmap (buffer, data, size);
}
}
diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c
index 4d2fdefa4..9e0235cf1 100644
--- a/ext/soup/gstsouphttpsrc.c
+++ b/ext/soup/gstsouphttpsrc.c
@@ -107,11 +107,6 @@ enum
PROP_PROXY_ID,
PROP_PROXY_PW,
PROP_COOKIES,
- PROP_IRADIO_MODE,
- PROP_IRADIO_NAME,
- PROP_IRADIO_GENRE,
- PROP_IRADIO_URL,
- PROP_IRADIO_TITLE,
PROP_TIMEOUT,
PROP_EXTRA_HEADERS
};
@@ -139,7 +134,7 @@ static gboolean gst_soup_http_src_query (GstBaseSrc * bsrc, GstQuery * query);
static gboolean gst_soup_http_src_unlock (GstBaseSrc * bsrc);
static gboolean gst_soup_http_src_unlock_stop (GstBaseSrc * bsrc);
static gboolean gst_soup_http_src_set_location (GstSoupHTTPSrc * src,
- const gchar * uri);
+ const gchar * uri, GError ** error);
static gboolean gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src,
const gchar * uri);
static char *gst_soup_http_src_unicodify (const char *str);
@@ -170,45 +165,21 @@ static void gst_soup_http_src_authenticate_cb (SoupSession * session,
SoupMessage * msg, SoupAuth * auth, gboolean retrying,
GstSoupHTTPSrc * src);
-static void
-_do_init (GType type)
-{
- static const GInterfaceInfo urihandler_info = {
- gst_soup_http_src_uri_handler_init,
- NULL,
- NULL
- };
-
- g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
-
- GST_DEBUG_CATEGORY_INIT (souphttpsrc_debug, "souphttpsrc", 0,
- "SOUP HTTP src");
-}
-
-GST_BOILERPLATE_FULL (GstSoupHTTPSrc, gst_soup_http_src, GstPushSrc,
- GST_TYPE_PUSH_SRC, _do_init);
-
-static void
-gst_soup_http_src_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_static_pad_template (element_class, &srctemplate);
-
- gst_element_class_set_details_simple (element_class, "HTTP client source",
- "Source/Network",
- "Receive data as a client over the network via HTTP using SOUP",
- "Wouter Cloetens <wouter@mind.be>");
-}
+#define gst_soup_http_src_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstSoupHTTPSrc, gst_soup_http_src, GST_TYPE_PUSH_SRC,
+ G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
+ gst_soup_http_src_uri_handler_init));
static void
gst_soup_http_src_class_init (GstSoupHTTPSrcClass * 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;
@@ -268,35 +239,13 @@ gst_soup_http_src_class_init (GstSoupHTTPSrcClass * klass)
"Extra headers to append to the HTTP request",
GST_TYPE_STRUCTURE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- /* icecast stuff */
- g_object_class_install_property (gobject_class,
- PROP_IRADIO_MODE,
- g_param_spec_boolean ("iradio-mode",
- "iradio-mode",
- "Enable internet radio mode (extraction of shoutcast/icecast metadata)",
- FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_IRADIO_NAME,
- g_param_spec_string ("iradio-name",
- "iradio-name", "Name of the stream", NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_IRADIO_GENRE,
- g_param_spec_string ("iradio-genre",
- "iradio-genre", "Genre of the stream", NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_IRADIO_URL,
- g_param_spec_string ("iradio-url",
- "iradio-url",
- "Homepage URL for radio stream", NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_IRADIO_TITLE,
- g_param_spec_string ("iradio-title",
- "iradio-title",
- "Name of currently playing song", NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&srctemplate));
+
+ gst_element_class_set_details_simple (gstelement_class, "HTTP client source",
+ "Source/Network",
+ "Receive data as a client over the network via HTTP using SOUP",
+ "Wouter Cloetens <wouter@mind.be>");
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_soup_http_src_start);
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_soup_http_src_stop);
@@ -310,6 +259,9 @@ gst_soup_http_src_class_init (GstSoupHTTPSrcClass * klass)
gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_soup_http_src_query);
gstpushsrc_class->create = GST_DEBUG_FUNCPTR (gst_soup_http_src_create);
+
+ GST_DEBUG_CATEGORY_INIT (souphttpsrc_debug, "souphttpsrc", 0,
+ "SOUP HTTP src");
}
static void
@@ -330,12 +282,10 @@ gst_soup_http_src_reset (GstSoupHTTPSrc * src)
src->iradio_genre = NULL;
g_free (src->iradio_url);
src->iradio_url = NULL;
- g_free (src->iradio_title);
- src->iradio_title = NULL;
}
static void
-gst_soup_http_src_init (GstSoupHTTPSrc * src, GstSoupHTTPSrcClass * g_class)
+gst_soup_http_src_init (GstSoupHTTPSrc * src)
{
const gchar *proxy;
@@ -347,7 +297,6 @@ gst_soup_http_src_init (GstSoupHTTPSrc * src, GstSoupHTTPSrcClass * g_class)
src->proxy_id = NULL;
src->proxy_pw = NULL;
src->cookies = NULL;
- src->iradio_mode = FALSE;
src->loop = NULL;
src->context = NULL;
src->session = NULL;
@@ -400,7 +349,7 @@ gst_soup_http_src_set_property (GObject * object, guint prop_id,
GST_WARNING ("location property cannot be NULL");
goto done;
}
- if (!gst_soup_http_src_set_location (src, location)) {
+ if (!gst_soup_http_src_set_location (src, location, NULL)) {
GST_WARNING ("badly formatted location");
goto done;
}
@@ -411,9 +360,6 @@ gst_soup_http_src_set_property (GObject * object, guint prop_id,
g_free (src->user_agent);
src->user_agent = g_value_dup_string (value);
break;
- case PROP_IRADIO_MODE:
- src->iradio_mode = g_value_get_boolean (value);
- break;
case PROP_AUTOMATIC_REDIRECT:
src->automatic_redirect = g_value_get_boolean (value);
break;
@@ -512,21 +458,6 @@ gst_soup_http_src_get_property (GObject * object, guint prop_id,
case PROP_IS_LIVE:
g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (src)));
break;
- case PROP_IRADIO_MODE:
- g_value_set_boolean (value, src->iradio_mode);
- break;
- case PROP_IRADIO_NAME:
- g_value_set_string (value, src->iradio_name);
- break;
- case PROP_IRADIO_GENRE:
- g_value_set_string (value, src->iradio_genre);
- break;
- case PROP_IRADIO_URL:
- g_value_set_string (value, src->iradio_url);
- break;
- case PROP_IRADIO_TITLE:
- g_value_set_string (value, src->iradio_title);
- break;
case PROP_USER_ID:
g_value_set_string (value, src->user_id);
break;
@@ -759,8 +690,7 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
GST_DEBUG_OBJECT (src, "size = %" G_GUINT64_FORMAT, src->content_size);
basesrc = GST_BASE_SRC_CAST (src);
- gst_segment_set_duration (&basesrc->segment, GST_FORMAT_BYTES,
- src->content_size);
+ basesrc->segment.duration = src->content_size;
gst_element_post_message (GST_ELEMENT (src),
gst_message_new_duration (GST_OBJECT (src), GST_FORMAT_BYTES,
src->content_size));
@@ -768,7 +698,7 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
}
/* Icecast stuff */
- tag_list = gst_tag_list_new ();
+ tag_list = gst_tag_list_new_empty ();
if ((value =
soup_message_headers_get (msg->response_headers,
@@ -804,13 +734,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)
@@ -828,7 +754,6 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
g_free (src->iradio_name);
src->iradio_name = gst_soup_http_src_unicodify (value);
if (src->iradio_name) {
- g_object_notify (G_OBJECT (src), "iradio-name");
gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_ORGANIZATION,
src->iradio_name, NULL);
}
@@ -839,7 +764,6 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
g_free (src->iradio_genre);
src->iradio_genre = gst_soup_http_src_unicodify (value);
if (src->iradio_genre) {
- g_object_notify (G_OBJECT (src), "iradio-genre");
gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE,
src->iradio_genre, NULL);
}
@@ -849,7 +773,6 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
g_free (src->iradio_url);
src->iradio_url = gst_soup_http_src_unicodify (value);
if (src->iradio_url) {
- g_object_notify (G_OBJECT (src), "iradio-url");
gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_LOCATION,
src->iradio_url, NULL);
}
@@ -857,7 +780,7 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
if (!gst_tag_list_is_empty (tag_list)) {
GST_DEBUG_OBJECT (src,
"calling gst_element_found_tags with %" GST_PTR_FORMAT, tag_list);
- gst_element_found_tags (GST_ELEMENT_CAST (src), tag_list);
+ gst_pad_push_event (GST_BASE_SRC_PAD (src), gst_event_new_tag (tag_list));
} else {
gst_tag_list_free (tag_list);
}
@@ -950,10 +873,20 @@ gst_soup_http_src_finished_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
* refcount to 0, freeing it.
*/
+typedef struct
+{
+ GstBuffer *buffer;
+ gpointer data;
+} SoupGstChunk;
+
static void
-gst_soup_http_src_chunk_free (gpointer gstbuf)
+gst_soup_http_src_chunk_free (gpointer user_data)
{
- gst_buffer_unref (GST_BUFFER_CAST (gstbuf));
+ SoupGstChunk *chunk = (SoupGstChunk *) user_data;
+
+ gst_buffer_unmap (chunk->buffer, chunk->data, -1);
+ gst_buffer_unref (chunk->buffer);
+ g_slice_free (SoupGstChunk, chunk);
}
static SoupBuffer *
@@ -966,6 +899,7 @@ gst_soup_http_src_chunk_allocator (SoupMessage * msg, gsize max_len,
SoupBuffer *soupbuf;
gsize length;
GstFlowReturn rc;
+ SoupGstChunk *chunk;
if (max_len)
length = MIN (basesrc->blocksize, max_len);
@@ -974,11 +908,7 @@ gst_soup_http_src_chunk_allocator (SoupMessage * msg, gsize max_len,
GST_DEBUG_OBJECT (src, "alloc %" G_GSIZE_FORMAT " bytes <= %" G_GSIZE_FORMAT,
length, max_len);
-
- rc = gst_pad_alloc_buffer (GST_BASE_SRC_PAD (basesrc),
- GST_BUFFER_OFFSET_NONE, length,
- src->src_caps ? src->src_caps :
- GST_PAD_CAPS (GST_BASE_SRC_PAD (basesrc)), &gstbuf);
+ rc = GST_BASE_SRC_CLASS (parent_class)->alloc (basesrc, -1, length, &gstbuf);
if (G_UNLIKELY (rc != GST_FLOW_OK)) {
/* Failed to allocate buffer. Stall SoupSession and return error code
* to create(). */
@@ -987,8 +917,12 @@ gst_soup_http_src_chunk_allocator (SoupMessage * msg, gsize max_len,
return NULL;
}
- soupbuf = soup_buffer_new_with_owner (GST_BUFFER_DATA (gstbuf), length,
- gstbuf, gst_soup_http_src_chunk_free);
+ chunk = g_slice_new0 (SoupGstChunk);
+ chunk->buffer = gstbuf;
+ chunk->data = gst_buffer_map (gstbuf, &length, NULL, GST_MAP_READWRITE);
+
+ soupbuf = soup_buffer_new_with_owner (chunk->data, length,
+ chunk, gst_soup_http_src_chunk_free);
return soupbuf;
}
@@ -1016,12 +950,8 @@ gst_soup_http_src_got_chunk_cb (SoupMessage * msg, SoupBuffer * chunk,
/* Extract the GstBuffer from the SoupBuffer and set its fields. */
*src->outbuf = GST_BUFFER_CAST (soup_buffer_get_owner (chunk));
- GST_BUFFER_SIZE (*src->outbuf) = chunk->length;
- GST_BUFFER_OFFSET (*src->outbuf) = basesrc->segment.last_stop;
-
- gst_buffer_set_caps (*src->outbuf,
- (src->src_caps) ? src->src_caps :
- GST_PAD_CAPS (GST_BASE_SRC_PAD (basesrc)));
+ gst_buffer_resize (*src->outbuf, 0, chunk->length);
+ GST_BUFFER_OFFSET (*src->outbuf) = basesrc->segment.position;
gst_buffer_ref (*src->outbuf);
@@ -1133,10 +1063,8 @@ gst_soup_http_src_build_message (GstSoupHTTPSrc * src)
src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE;
soup_message_headers_append (src->msg->request_headers, "Connection",
"close");
- if (src->iradio_mode) {
- soup_message_headers_append (src->msg->request_headers, "icy-metadata",
- "1");
- }
+ soup_message_headers_append (src->msg->request_headers, "icy-metadata", "1");
+
if (src->cookies) {
gchar **cookie;
@@ -1421,7 +1349,8 @@ gst_soup_http_src_query (GstBaseSrc * bsrc, GstQuery * query)
}
static gboolean
-gst_soup_http_src_set_location (GstSoupHTTPSrc * src, const gchar * uri)
+gst_soup_http_src_set_location (GstSoupHTTPSrc * src, const gchar * uri,
+ GError ** error)
{
if (src->location) {
g_free (src->location);
@@ -1452,32 +1381,35 @@ gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src, const gchar * uri)
}
static guint
-gst_soup_http_src_uri_get_type (void)
+gst_soup_http_src_uri_get_type (GType type)
{
return GST_URI_SRC;
}
-static gchar **
-gst_soup_http_src_uri_get_protocols (void)
+static const gchar *const *
+gst_soup_http_src_uri_get_protocols (GType type)
{
static const gchar *protocols[] = { "http", "https", NULL };
- return (gchar **) protocols;
+
+ return protocols;
}
-static const gchar *
+static gchar *
gst_soup_http_src_uri_get_uri (GstURIHandler * handler)
{
GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (handler);
- return src->location;
+ /* FIXME: make thread-safe */
+ return g_strdup (src->location);
}
static gboolean
-gst_soup_http_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_soup_http_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (handler);
- return gst_soup_http_src_set_location (src, uri);
+ return gst_soup_http_src_set_location (src, uri, error);
}
static void
diff --git a/ext/soup/gstsouphttpsrc.h b/ext/soup/gstsouphttpsrc.h
index 1427e1c29..186c6d067 100644
--- a/ext/soup/gstsouphttpsrc.h
+++ b/ext/soup/gstsouphttpsrc.h
@@ -77,12 +77,10 @@ struct _GstSoupHTTPSrc {
guint64 request_position; /* Seek to this position. */
/* Shoutcast/icecast metadata extraction handling. */
- gboolean iradio_mode;
GstCaps *src_caps;
gchar *iradio_name;
gchar *iradio_genre;
gchar *iradio_url;
- gchar *iradio_title;
GstStructure *extra_headers;
diff --git a/ext/speex/gstspeexdec.c b/ext/speex/gstspeexdec.c
index e1d80b640..19368202b 100644
--- a/ext/speex/gstspeexdec.c
+++ b/ext/speex/gstspeexdec.c
@@ -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,9 +77,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("audio/x-speex")
);
-GST_BOILERPLATE (GstSpeexDec, gst_speex_dec, GstAudioDecoder,
- GST_TYPE_AUDIO_DECODER);
-
+#define gst_speex_dec_parent_class parent_class
+G_DEFINE_TYPE (GstSpeexDec, gst_speex_dec, GST_TYPE_AUDIO_DECODER);
static gboolean gst_speex_dec_start (GstAudioDecoder * dec);
static gboolean gst_speex_dec_stop (GstAudioDecoder * dec);
@@ -93,26 +93,14 @@ static void gst_speex_dec_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void
-gst_speex_dec_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_static_pad_template (element_class,
- &speex_dec_src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &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;
+ GstElementClass *gstelement_class;
GstAudioDecoderClass *base_class;
gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
base_class = (GstAudioDecoderClass *) klass;
gobject_class->set_property = gst_speex_dec_set_property;
@@ -127,6 +115,14 @@ gst_speex_dec_class_init (GstSpeexDecClass * klass)
g_param_spec_boolean ("enh", "Enh", "Enable perceptual enhancement",
DEFAULT_ENH, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ 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");
}
@@ -157,7 +153,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->enh = DEFAULT_ENH;
@@ -193,10 +189,13 @@ static GstFlowReturn
gst_speex_dec_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;
@@ -230,12 +229,10 @@ gst_speex_dec_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 (GST_AUDIO_DECODER_SRC_PAD (dec), caps))
goto nego_failed;
@@ -283,7 +280,7 @@ gst_speex_dec_parse_comments (GstSpeexDec * dec, GstBuffer * buf)
if (!list) {
GST_WARNING_OBJECT (dec, "couldn't decode comments");
- list = gst_tag_list_new ();
+ list = gst_tag_list_new_empty ();
}
if (encoder) {
@@ -309,8 +306,8 @@ gst_speex_dec_parse_comments (GstSpeexDec * dec, GstBuffer * buf)
GST_INFO_OBJECT (dec, "tags: %" GST_PTR_FORMAT, list);
- gst_element_found_tags_for_pad (GST_ELEMENT (dec),
- GST_AUDIO_DECODER_SRC_PAD (dec), list);
+ gst_pad_push_event (GST_AUDIO_DECODER_SRC_PAD (dec),
+ gst_event_new_tag (list));
g_free (encoder);
g_free (ver);
@@ -362,25 +359,24 @@ gst_speex_dec_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 (G_LIKELY (GST_BUFFER_SIZE (buf))) {
- data = GST_BUFFER_DATA (buf);
- size = GST_BUFFER_SIZE (buf);
-
+ if (G_LIKELY (gst_buffer_get_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;
- GST_DEBUG_OBJECT (dec, "received buffer of size %u, fpp %d, %d bits",
- size, fpp, speex_bits_remaining (bits));
+ GST_DEBUG_OBJECT (dec, "received buffer of size %" G_GSIZE_FORMAT
+ ", fpp %d, %d bits", size, fpp, speex_bits_remaining (bits));
} else {
/* FIXME ? actually consider how much concealment is needed */
/* concealment data, pass NULL as the bits parameters */
@@ -397,7 +393,7 @@ gst_speex_dec_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 (GST_AUDIO_DECODER_SRC_PAD (dec),
GST_BUFFER_OFFSET_NONE, dec->frame_size * dec->header->nb_channels * 2,
@@ -407,10 +403,17 @@ gst_speex_dec_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) {
@@ -455,6 +458,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
gst_speex_dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buf)
{
@@ -470,15 +493,11 @@ gst_speex_dec_handle_frame (GstAudioDecoder * bdec, 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)) {
GST_DEBUG_OBJECT (dec, "found streamheader");
gst_audio_decoder_finish_frame (bdec, NULL, 1);
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)) {
GST_DEBUG_OBJECT (dec, "found vorbiscomments");
gst_audio_decoder_finish_frame (bdec, NULL, 1);
res = GST_FLOW_OK;
diff --git a/ext/speex/gstspeexenc.c b/ext/speex/gstspeexenc.c
index b866e5cad..01202ea85 100644
--- a/ext/speex/gstspeexenc.c
+++ b/ext/speex/gstspeexenc.c
@@ -52,14 +52,14 @@
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,41 +135,23 @@ static gboolean gst_speex_enc_sink_event (GstAudioEncoder * enc,
static GstFlowReturn
gst_speex_enc_pre_push (GstAudioEncoder * benc, GstBuffer ** buffer);
-static void
-gst_speex_enc_setup_interfaces (GType speexenc_type)
-{
- static const GInterfaceInfo tag_setter_info = { NULL, NULL, NULL };
-
- g_type_add_interface_static (speexenc_type, GST_TYPE_TAG_SETTER,
- &tag_setter_info);
-
- GST_DEBUG_CATEGORY_INIT (speexenc_debug, "speexenc", 0, "Speex encoder");
-}
-
-GST_BOILERPLATE_FULL (GstSpeexEnc, gst_speex_enc, GstAudioEncoder,
- GST_TYPE_AUDIO_ENCODER, 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_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &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_AUDIO_ENCODER,
+ G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL);
+ G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL));
static void
gst_speex_enc_class_init (GstSpeexEncClass * klass)
{
GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
GstAudioEncoderClass *base_class;
gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
base_class = (GstAudioEncoderClass *) 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;
@@ -225,7 +207,15 @@ 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;
+ 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
@@ -241,7 +231,7 @@ gst_speex_enc_finalize (GObject * object)
}
static void
-gst_speex_enc_init (GstSpeexEnc * enc, GstSpeexEncClass * klass)
+gst_speex_enc_init (GstSpeexEnc * enc)
{
GstAudioEncoder *benc = GST_AUDIO_ENCODER (enc);
@@ -257,7 +247,7 @@ gst_speex_enc_start (GstAudioEncoder * benc)
GST_DEBUG_OBJECT (enc, "start");
speex_bits_init (&enc->bits);
- enc->tags = gst_tag_list_new ();
+ enc->tags = gst_tag_list_new_empty ();
enc->header_sent = FALSE;
return TRUE;
@@ -353,7 +343,7 @@ gst_speex_enc_create_metadata_buffer (GstSpeexEnc * enc)
gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (enc)));
if (merged_tags == NULL)
- merged_tags = gst_tag_list_new ();
+ merged_tags = gst_tag_list_new_empty ();
GST_DEBUG_OBJECT (enc, "merged tags = %" GST_PTR_FORMAT, merged_tags);
comments = gst_tag_list_to_vorbiscomment_buffer (merged_tags, NULL,
@@ -501,12 +491,9 @@ gst_speex_enc_setup (GstSpeexEnc * enc)
static GstFlowReturn
gst_speex_enc_push_buffer (GstSpeexEnc * enc, GstBuffer * buffer)
{
- guint size;
-
- size = GST_BUFFER_SIZE (buffer);
- GST_DEBUG_OBJECT (enc, "pushing output buffer of size %u", size);
+ GST_DEBUG_OBJECT (enc, "pushing output buffer of size %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (buffer));
- gst_buffer_set_caps (buffer, GST_PAD_CAPS (GST_AUDIO_ENCODER_SRC_PAD (enc)));
return gst_pad_push (GST_AUDIO_ENCODER_SRC_PAD (enc), buffer);
}
@@ -543,21 +530,27 @@ static GstFlowReturn
gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
{
gint frame_size = enc->frame_size;
- gint bytes = frame_size * 2 * enc->channels, samples, size;
+ gint bytes = frame_size * 2 * enc->channels, samples;
gint outsize, written, dtx_ret = 0;
- guint8 *data, *data0 = NULL;
+ guint8 *data, *data0 = NULL, *bdata, *outdata;
+ gsize bsize, size;
GstBuffer *outbuf;
GstFlowReturn ret = GST_FLOW_OK;
if (G_LIKELY (buf)) {
- data = GST_BUFFER_DATA (buf);
- size = GST_BUFFER_SIZE (buf);
+ bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
- if (G_UNLIKELY (size % bytes)) {
+ if (G_UNLIKELY (bsize % bytes)) {
GST_DEBUG_OBJECT (enc, "draining; adding silence samples");
- size = ((size / bytes) + 1) * bytes;
+
+ size = ((bsize / bytes) + 1) * bytes;
data0 = data = g_malloc0 (size);
- memcpy (data, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ memcpy (data, bdata, bsize);
+ gst_buffer_unmap (buf, bdata, bsize);
+ bdata = NULL;
+ } else {
+ data = bdata;
+ size = bsize;
}
} else {
GST_DEBUG_OBJECT (enc, "nothing to drain");
@@ -584,22 +577,29 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
speex_bits_insert_terminator (&enc->bits);
outsize = speex_bits_nbytes (&enc->bits);
+ if (bdata)
+ gst_buffer_unmap (buf, bdata, bsize);
+
+#if 0
ret = gst_pad_alloc_buffer_and_set_caps (GST_AUDIO_ENCODER_SRC_PAD (enc),
GST_BUFFER_OFFSET_NONE, outsize,
GST_PAD_CAPS (GST_AUDIO_ENCODER_SRC_PAD (enc)), &outbuf);
if ((GST_FLOW_OK != ret))
goto done;
+#endif
+ outbuf = gst_buffer_new_allocate (NULL, outsize, 0);
+ outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
- written = speex_bits_write (&enc->bits,
- (gchar *) GST_BUFFER_DATA (outbuf), outsize);
+ written = speex_bits_write (&enc->bits, (gchar *) outdata, outsize);
if (G_UNLIKELY (written < outsize)) {
GST_ERROR_OBJECT (enc, "short write: %d < %d bytes", written, outsize);
- GST_BUFFER_SIZE (outbuf) = written;
} else if (G_UNLIKELY (written > outsize)) {
GST_ERROR_OBJECT (enc, "overrun: %d > %d bytes", written, outsize);
+ written = outsize;
}
+ gst_buffer_unmap (outbuf, outdata, written);
if (!dtx_ret)
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
@@ -647,7 +647,7 @@ _gst_caps_set_buffer_array (GstCaps * caps, const gchar * field,
va_start (va, buf);
/* put buffers in a fixed list */
while (buf) {
- g_assert (gst_buffer_is_metadata_writable (buf));
+ g_assert (gst_buffer_is_writable (buf));
/* mark buffer */
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
@@ -691,9 +691,7 @@ gst_speex_enc_handle_frame (GstAudioEncoder * benc, GstBuffer * buf)
/* create header buffer */
data = (guint8 *) speex_header_to_packet (&enc->header, &data_len);
- buf1 = gst_buffer_new ();
- GST_BUFFER_DATA (buf1) = GST_BUFFER_MALLOCDATA (buf1) = data;
- GST_BUFFER_SIZE (buf1) = data_len;
+ buf1 = gst_buffer_new_wrapped (data, data_len);
GST_BUFFER_OFFSET_END (buf1) = 0;
GST_BUFFER_OFFSET (buf1) = 0;
@@ -708,8 +706,6 @@ gst_speex_enc_handle_frame (GstAudioEncoder * benc, GstBuffer * buf)
/* negotiate with these caps */
GST_DEBUG_OBJECT (enc, "here are the caps: %" GST_PTR_FORMAT, caps);
- gst_buffer_set_caps (buf1, caps);
- gst_buffer_set_caps (buf2, caps);
gst_pad_set_caps (GST_AUDIO_ENCODER_SRC_PAD (enc), caps);
gst_caps_unref (caps);
@@ -724,8 +720,8 @@ gst_speex_enc_handle_frame (GstAudioEncoder * benc, GstBuffer * buf)
enc->header_sent = TRUE;
}
- GST_DEBUG_OBJECT (enc, "received buffer %p of %u bytes", buf,
- buf ? GST_BUFFER_SIZE (buf) : 0);
+ GST_DEBUG_OBJECT (enc, "received buffer %p of %" G_GSIZE_FORMAT " bytes", buf,
+ buf ? gst_buffer_get_size (buf) : 0);
ret = gst_speex_enc_encode (enc, buf);
diff --git a/ext/taglib/gstapev2mux.cc b/ext/taglib/gstapev2mux.cc
index c99a31f9a..58206e61e 100644
--- a/ext/taglib/gstapev2mux.cc
+++ b/ext/taglib/gstapev2mux.cc
@@ -75,7 +75,8 @@ gst_apev2_mux_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class, &src_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_template));
gst_element_class_set_details_simple (element_class,
"TagLib-based APEv2 Muxer", "Formatter/Metadata",
diff --git a/ext/taglib/gstid3v2mux.cc b/ext/taglib/gstid3v2mux.cc
index 2b5042ef8..cc307aa0f 100644
--- a/ext/taglib/gstid3v2mux.cc
+++ b/ext/taglib/gstid3v2mux.cc
@@ -84,7 +84,8 @@ gst_id3v2_mux_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class, &src_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_template));
gst_element_class_set_details_simple (element_class,
"TagLib-based ID3v2 Muxer", "Formatter/Metadata",
@@ -367,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;
@@ -402,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/ext/taglib/gsttaglibmux.c b/ext/taglib/gsttaglibmux.c
index 094bec12a..7e8cf6e25 100644
--- a/ext/taglib/gsttaglibmux.c
+++ b/ext/taglib/gsttaglibmux.c
@@ -83,8 +83,8 @@ gst_tag_lib_mux_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class,
- &gst_tag_lib_mux_sink_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_tag_lib_mux_sink_template));
GST_DEBUG_CATEGORY_INIT (gst_tag_lib_mux_debug, "taglibmux", 0,
"taglib-based muxer");
diff --git a/ext/wavpack/gstwavpackdec.c b/ext/wavpack/gstwavpackdec.c
index 4ba242d87..f7c96ba14 100644
--- a/ext/wavpack/gstwavpackdec.c
+++ b/ext/wavpack/gstwavpackdec.c
@@ -95,8 +95,10 @@ gst_wavpack_dec_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &sink_factory);
+ 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, "Wavpack audio decoder",
"Codec/Decoder/Audio",
"Decodes Wavpack audio data",
diff --git a/ext/wavpack/gstwavpackenc.c b/ext/wavpack/gstwavpackenc.c
index a22dd23a3..91af97c1e 100644
--- a/ext/wavpack/gstwavpackenc.c
+++ b/ext/wavpack/gstwavpackenc.c
@@ -218,10 +218,12 @@ gst_wavpack_enc_base_init (gpointer klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
/* add pad templates */
- gst_element_class_add_static_pad_template (element_class, &sink_factory);
- gst_element_class_add_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &wvcsrc_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_factory));
+ 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 (&wvcsrc_factory));
/* set element details */
gst_element_class_set_details_simple (element_class, "Wavpack audio encoder",
diff --git a/ext/wavpack/gstwavpackparse.c b/ext/wavpack/gstwavpackparse.c
index 8734e625d..2d9fac42e 100644
--- a/ext/wavpack/gstwavpackparse.c
+++ b/ext/wavpack/gstwavpackparse.c
@@ -115,10 +115,12 @@ gst_wavpack_parse_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &wvc_src_factory);
- gst_element_class_add_static_pad_template (element_class, &sink_factory);
+ 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 (&wvc_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, "Wavpack parser",
"Codec/Demuxer/Audio",
diff --git a/gconf/.gitignore b/gconf/.gitignore
deleted file mode 100644
index 57ec96782..000000000
--- a/gconf/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-gstreamer-*.schemas
-gstreamer.schemas
diff --git a/gconf/Makefile.am b/gconf/Makefile.am
deleted file mode 100644
index 5129c0069..000000000
--- a/gconf/Makefile.am
+++ /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
index bc1ff44f1..000000000
--- a/gconf/gstreamer.schemas.in
+++ /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>
diff --git a/gst-plugins-good.spec.in b/gst-plugins-good.spec.in
index 2dfc0eb43..af7769fca 100644
--- a/gst-plugins-good.spec.in
+++ b/gst-plugins-good.spec.in
@@ -1,7 +1,7 @@
%define majorminor @GST_MAJORMINOR@
-%define gstreamer gstreamer
+%define gstreamer gstreamer011
-%define gst_minver 0.10.0
+%define gst_minver 0.11.0
Name: %{gstreamer}-plugins-good
Version: @VERSION@
@@ -20,20 +20,13 @@ 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
@USE_LIBPNG_TRUE@BuildRequires: libpng-devel >= 1.2.0
@USE_OSS_TRUE@BuildRequires: glibc-devel
@USE_SPEEX_TRUE@BuildRequires: speex-devel
-@USE_HAL_TRUE@BuildRequires: hal-devel
@USE_SHOUT2_TRUE@BuildRequires: libshout-devel >= 2.0
@USE_AALIB_TRUE@BuildRequires: aalib-devel >= 1.3
@USE_AALIB_TRUE@Provides: gstreamer-aasink = %{version}-%{release}
@@ -63,9 +56,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 +70,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)
@@ -96,15 +85,14 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/gstreamer-%{majorminor}/libgsteffectv.so
%{_libdir}/gstreamer-%{majorminor}/libgstgoom.so
%{_libdir}/gstreamer-%{majorminor}/libgstlevel.so
-%{_libdir}/gstreamer-%{majorminor}/libgstefence.so
%{_libdir}/gstreamer-%{majorminor}/libgstmulaw.so
%{_libdir}/gstreamer-%{majorminor}/libgstisomp4.so
%{_libdir}/gstreamer-%{majorminor}/libgstrtp.so
%{_libdir}/gstreamer-%{majorminor}/libgstrtpmanager.so
%{_libdir}/gstreamer-%{majorminor}/libgstrtsp.so
-%{_libdir}/gstreamer-%{majorminor}/libgstsmpte.so
+# %{_libdir}/gstreamer-%{majorminor}/libgstsmpte.so
%{_libdir}/gstreamer-%{majorminor}/libgstudp.so
-%{_libdir}/gstreamer-%{majorminor}/libgstvideobox.so
+# %{_libdir}/gstreamer-%{majorminor}/libgstvideobox.so
%{_libdir}/gstreamer-%{majorminor}/libgstwavenc.so
%{_libdir}/gstreamer-%{majorminor}/libgstwavparse.so
%{_libdir}/gstreamer-%{majorminor}/libgstauparse.so
@@ -112,31 +100,31 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/gstreamer-%{majorminor}/libgstnavigationtest.so
%{_libdir}/gstreamer-%{majorminor}/libgstalphacolor.so
@USE_CAIRO_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstcairo.so
-%{_libdir}/gstreamer-%{majorminor}/libgstflxdec.so
-%{_libdir}/gstreamer-%{majorminor}/libgstmatroska.so
-%{_libdir}/gstreamer-%{majorminor}/libgstvideomixer.so
+# %{_libdir}/gstreamer-%{majorminor}/libgstflxdec.so
+# %{_libdir}/gstreamer-%{majorminor}/libgstmatroska.so
+# %{_libdir}/gstreamer-%{majorminor}/libgstvideomixer.so
%{_libdir}/gstreamer-%{majorminor}/libgstcutter.so
%{_libdir}/gstreamer-%{majorminor}/libgstmultipart.so
%{_libdir}/gstreamer-%{majorminor}/libgstid3demux.so
@USE_GDK_PIXBUF_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstgdkpixbuf.so
-%{_libdir}/gstreamer-%{majorminor}/libgstapetag.so
+# %{_libdir}/gstreamer-%{majorminor}/libgstapetag.so
%{_libdir}/gstreamer-%{majorminor}/libgstannodex.so
%{_libdir}/gstreamer-%{majorminor}/libgstvideocrop.so
%{_libdir}/gstreamer-%{majorminor}/libgsticydemux.so
-%{_libdir}/gstreamer-%{majorminor}/libgsttaglib.so
+# %{_libdir}/gstreamer-%{majorminor}/libgsttaglib.so
%{_libdir}/gstreamer-%{majorminor}/libgstximagesrc.so
%{_libdir}/gstreamer-%{majorminor}/libgstaudiofx.so
%{_libdir}/gstreamer-%{majorminor}/libgstequalizer.so
%{_libdir}/gstreamer-%{majorminor}/libgstmultifile.so
%{_libdir}/gstreamer-%{majorminor}/libgstspectrum.so
-%{_libdir}/gstreamer-%{majorminor}/libgstgoom2k1.so
-%{_libdir}/gstreamer-%{majorminor}/libgstinterleave.so
+# %{_libdir}/gstreamer-%{majorminor}/libgstgoom2k1.so
+# %{_libdir}/gstreamer-%{majorminor}/libgstinterleave.so
%{_libdir}/gstreamer-%{majorminor}/libgstreplaygain.so
-%{_libdir}/gstreamer-%{majorminor}/libgstdeinterlace.so
+# %{_libdir}/gstreamer-%{majorminor}/libgstdeinterlace.so
%{_libdir}/gstreamer-%{majorminor}/libgstflv.so
%{_libdir}/gstreamer-%{majorminor}/libgsty4menc.so
-%{_libdir}/gstreamer-%{majorminor}/libgstoss4audio.so
-%{_libdir}/gstreamer-%{majorminor}/libgstimagefreeze.so
+# %{_libdir}/gstreamer-%{majorminor}/libgstoss4audio.so
+# %{_libdir}/gstreamer-%{majorminor}/libgstimagefreeze.so
%{_libdir}/gstreamer-%{majorminor}/libgstshapewipe.so
%{_libdir}/gstreamer-%{majorminor}/libgstvideofilter.so
%{_libdir}/gstreamer-%{majorminor}/libgstaudioparsers.so
@@ -146,15 +134,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
@USE_LIBDV_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstdv.so
@@ -163,9 +148,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
diff --git a/gst/alpha/Makefile.am b/gst/alpha/Makefile.am
index dcd88ae04..b17fb41b1 100644
--- a/gst/alpha/Makefile.am
+++ b/gst/alpha/Makefile.am
@@ -2,9 +2,9 @@ plugin_LTLIBRARIES = libgstalpha.la libgstalphacolor.la
libgstalpha_la_SOURCES = gstalpha.c
libgstalpha_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_CONTROLLER_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
+ $(GST_BASE_CFLAGS) $(GST_CFLAGS)
libgstalpha_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) \
- $(GST_CONTROLLER_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM)
+ $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM)
libgstalpha_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstalpha_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/gst/alpha/gstalpha.c b/gst/alpha/gstalpha.c
index 65aae69b2..a97c6812a 100644
--- a/gst/alpha/gstalpha.c
+++ b/gst/alpha/gstalpha.c
@@ -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 ()); \
@@ -172,11 +156,10 @@ static GstStaticCaps gst_alpha_alpha_caps =
g_static_mutex_unlock (&alpha->lock); \
} G_STMT_END
-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 +176,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 +199,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_static_pad_template (element_class,
- &gst_alpha_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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,7 +257,18 @@ gst_alpha_class_init (GstAlphaClass * klass)
DEFAULT_PREFER_PASSTHROUGH,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
- btrans_class->start = GST_DEBUG_FUNCPTR (gst_alpha_start);
+ 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->transform = GST_DEBUG_FUNCPTR (gst_alpha_transform);
btrans_class->before_transform =
GST_DEBUG_FUNCPTR (gst_alpha_before_transform);
@@ -300,7 +278,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 +436,26 @@ 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 = %" G_GSIZE_FORMAT " 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 +469,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 +500,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 +522,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_info_from_caps (&in_info, incaps) ||
+ !gst_video_info_from_caps (&out_info, outcaps))
+ goto invalid_format;
- 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;
- }
-
- 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 +653,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 +699,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 +720,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 +768,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 +809,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 +830,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 +886,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 +932,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 +953,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 +1001,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 +1050,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 +1068,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 +1135,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 +1148,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);
+
+ 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);
memcpy (matrix,
alpha->out_sdtv ? cog_rgb_to_ycbcr_matrix_8bit_sdtv :
@@ -1185,9 +1182,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 +1204,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 +1253,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 +1296,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 +1318,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 +1375,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 +1389,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 +1489,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 +1513,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 +1628,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 +1646,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 +1724,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 +1751,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 +1836,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 +1849,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);
- 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);
if (alpha->in_sdtv != alpha->out_sdtv) {
gint matrix[12];
@@ -1961,9 +1958,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 +1979,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);
+
+ 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);
smin = 128 - alpha->black_sensitivity;
smax = 128 + alpha->white_sensitivity;
@@ -2113,9 +2113,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 +2127,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);
- o[0] =
- gst_video_format_get_component_offset (alpha->in_format, 0, width,
- height);
+ src_stride = GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 0);
+
+ 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 +2193,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 +2216,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 +2322,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 +2394,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 +2434,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 +2476,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 +2516,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;
@@ -2567,18 +2561,6 @@ gst_alpha_set_process_function (GstAlpha * alpha)
return alpha->process != NULL;
}
-static gboolean
-gst_alpha_start (GstBaseTransform * btrans)
-{
- GstAlpha *alpha = GST_ALPHA (btrans);
-
- GST_ALPHA_LOCK (alpha);
- gst_alpha_init_params (alpha);
- GST_ALPHA_UNLOCK (alpha);
-
- return TRUE;
-}
-
static void
gst_alpha_before_transform (GstBaseTransform * btrans, GstBuffer * buf)
{
@@ -2589,39 +2571,60 @@ gst_alpha_before_transform (GstBaseTransform * btrans, GstBuffer * buf)
GST_BUFFER_TIMESTAMP (buf));
GST_LOG ("Got stream time of %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (timestamp))
- gst_object_sync_values (G_OBJECT (alpha), timestamp);
+ gst_object_sync_values (GST_OBJECT (alpha), timestamp);
}
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;
- width = alpha->width;
- height = alpha->height;
+ if (!gst_video_frame_map (&out_frame, &alpha->out_info, out, GST_MAP_WRITE))
+ goto invalid_out;
- alpha->process (GST_BUFFER_DATA (in),
- GST_BUFFER_DATA (out), width, height, alpha);
+ alpha->process (&in_frame, &out_frame, 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
plugin_init (GstPlugin * plugin)
{
- gst_controller_init (NULL, NULL);
-
return gst_element_register (plugin, "alpha", GST_RANK_NONE, GST_TYPE_ALPHA);
}
diff --git a/gst/alpha/gstalpha.h b/gst/alpha/gstalpha.h
index 44025572c..3e15c14a9 100644
--- a/gst/alpha/gstalpha.h
+++ b/gst/alpha/gstalpha.h
@@ -26,7 +26,6 @@
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/gstvideofilter.h>
-#include <gst/controller/gstcontroller.h>
G_BEGIN_DECLS
@@ -72,8 +71,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 +91,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;
diff --git a/gst/alpha/gstalphacolor.c b/gst/alpha/gstalphacolor.c
index 48e6a5a10..66e2c330d 100644
--- a/gst/alpha/gstalphacolor.c
+++ b/gst/alpha/gstalphacolor.c
@@ -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,49 +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_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &src_template);
-}
-
-static void
-gst_alpha_color_class_init (GstAlphaColorClass * klass)
-{
- GstBaseTransformClass *gstbasetransform_class =
- (GstBaseTransformClass *) klass;
+ 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));
gstbasetransform_class->transform_caps =
GST_DEBUG_FUNCPTR (gst_alpha_color_transform_caps);
@@ -99,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);
@@ -114,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;
@@ -160,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;
}
@@ -202,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)); \
@@ -229,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)); \
@@ -261,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];
@@ -271,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));
@@ -291,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];
@@ -313,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];
@@ -335,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];
@@ -357,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];
@@ -379,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];
@@ -401,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];
@@ -428,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;
@@ -487,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;
@@ -517,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;
@@ -547,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;
@@ -577,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;
@@ -625,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
diff --git a/gst/alpha/gstalphacolor.h b/gst/alpha/gstalphacolor.h
index 636d83289..11f8674ce 100644
--- a/gst/alpha/gstalphacolor.h
+++ b/gst/alpha/gstalphacolor.h
@@ -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;
};
diff --git a/gst/apetag/gstapedemux.c b/gst/apetag/gstapedemux.c
index c139eadab..838e393f2 100644
--- a/gst/apetag/gstapedemux.c
+++ b/gst/apetag/gstapedemux.c
@@ -72,30 +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_DEBUG_CATEGORY_INIT (apedemux_debug, "apedemux", 0,
+ "GStreamer APE tag demuxer");
- gst_element_class_add_static_pad_template (element_class, &sink_factory);
+ 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);
@@ -109,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 */
}
@@ -165,7 +162,7 @@ ape_demux_get_gst_tag_from_tag (const gchar * ape_tag,
static GstTagList *
ape_demux_parse_tags (const guint8 * data, gint size)
{
- GstTagList *taglist = gst_tag_list_new ();
+ GstTagList *taglist = gst_tag_list_new_empty ();
GST_LOG ("Reading tags from chunk of size %u bytes", size);
@@ -332,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;
}
@@ -350,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;
- GST_LOG_OBJECT (demux, "Parsing buffer of size %u", GST_BUFFER_SIZE (buffer));
+ data_start = data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
- data = GST_BUFFER_DATA (buffer);
- footer = GST_BUFFER_DATA (buffer) + GST_BUFFER_SIZE (buffer) - 32;
+ GST_LOG_OBJECT (demux, "Parsing buffer of size %" G_GSIZE_FORMAT, size);
+
+ footer = data + size - 32;
GST_LOG_OBJECT (demux, "Checking for footer at offset 0x%04x",
(guint) (footer - data));
@@ -419,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;
}
diff --git a/gst/audiofx/Makefile.am b/gst/audiofx/Makefile.am
index c943e20f2..b7f22d693 100644
--- a/gst/audiofx/Makefile.am
+++ b/gst/audiofx/Makefile.am
@@ -22,11 +22,9 @@ libgstaudiofx_la_SOURCES = audiofx.c\
# flags used to compile this plugin
libgstaudiofx_la_CFLAGS = $(GST_CFLAGS) \
$(GST_BASE_CFLAGS) \
- $(GST_CONTROLLER_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS)
libgstaudiofx_la_LIBADD = $(GST_LIBS) \
$(GST_BASE_LIBS) \
- $(GST_CONTROLLER_LIBS) \
$(GST_PLUGINS_BASE_LIBS) \
-lgstaudio-$(GST_MAJORMINOR) \
-lgstfft-$(GST_MAJORMINOR) \
diff --git a/gst/audiofx/audioamplify.c b/gst/audiofx/audioamplify.c
index 5316c9632..f8dbb21d6 100644
--- a/gst/audiofx/audioamplify.c
+++ b/gst/audiofx/audioamplify.c
@@ -43,7 +43,6 @@
#include <gst/base/gstbasetransform.h>
#include <gst/audio/audio.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include "audioamplify.h"
@@ -90,56 +89,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 +251,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 +286,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 +303,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 +385,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 +403,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 +432,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 +447,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 =
@@ -489,16 +458,18 @@ gst_audio_amplify_transform_ip (GstBaseTransform * base, GstBuffer * buf)
GST_TIME_ARGS (timestamp));
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);
+ gst_object_sync_values (GST_OBJECT (filter), stream_time);
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;
}
diff --git a/gst/audiofx/audioamplify.h b/gst/audiofx/audioamplify.h
index b28f38b3c..2f5fc413f 100644
--- a/gst/audiofx/audioamplify.h
+++ b/gst/audiofx/audioamplify.h
@@ -48,8 +48,7 @@ struct _GstAudioAmplify
/* < private > */
GstAudioAmplifyProcessFunc process;
gint clipping_method;
- gint format;
- gint width;
+ GstAudioFormat format;
};
struct _GstAudioAmplifyClass
diff --git a/gst/audiofx/audiochebband.c b/gst/audiofx/audiochebband.c
index 89a950c23..f0d2e34f0 100644
--- a/gst/audiofx/audiochebband.c
+++ b/gst/audiofx/audiochebband.c
@@ -70,11 +70,12 @@
#include "config.h"
#endif
+#include <string.h>
+
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
#include <gst/audio/audio.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include <math.h>
@@ -96,11 +97,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 +108,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 +139,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 +185,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 +212,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 +335,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 +389,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 +412,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 +492,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 +520,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 +544,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 +642,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);
}
diff --git a/gst/audiofx/audiocheblimit.c b/gst/audiofx/audiocheblimit.c
index 8d51fbbf6..250857ec0 100644
--- a/gst/audiofx/audiocheblimit.c
+++ b/gst/audiofx/audiocheblimit.c
@@ -66,11 +66,12 @@
#include "config.h"
#endif
+#include <string.h>
+
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
#include <gst/audio/audio.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include <math.h>
@@ -91,12 +92,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 +103,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 +134,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 +176,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 +319,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 +343,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 +354,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 +451,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 +462,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 +551,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);
}
diff --git a/gst/audiofx/audiodynamic.c b/gst/audiofx/audiodynamic.c
index 33871d284..564dd7f2d 100644
--- a/gst/audiofx/audiodynamic.c
+++ b/gst/audiofx/audiodynamic.c
@@ -46,7 +46,6 @@
#include <gst/base/gstbasetransform.h>
#include <gst/audio/audio.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include "audiodynamic.h"
@@ -70,24 +69,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 +82,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);
@@ -197,10 +184,13 @@ gst_audio_dynamic_set_process_function (GstAudioDynamic * filter)
{
gint func_index;
+ if (GST_AUDIO_FILTER_FORMAT (filter) == GST_AUDIO_FORMAT_UNKNOWN)
+ return FALSE;
+
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 +203,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 +244,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 +260,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 +325,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 +574,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 +604,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 +635,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 +661,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 +690,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 =
@@ -705,16 +701,18 @@ gst_audio_dynamic_transform_ip (GstBaseTransform * base, GstBuffer * buf)
GST_TIME_ARGS (timestamp));
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);
+ gst_object_sync_values (GST_OBJECT (filter), stream_time);
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;
}
diff --git a/gst/audiofx/audioecho.c b/gst/audiofx/audioecho.c
index 90646199d..38cafd244 100644
--- a/gst/audiofx/audioecho.c
+++ b/gst/audiofx/audioecho.c
@@ -50,7 +50,6 @@
#include <gst/base/gstbasetransform.h>
#include <gst/audio/audio.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include "audioecho.h"
@@ -67,17 +66,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 +81,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 +94,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 +135,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 +152,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 +270,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 +318,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 +358,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 =
@@ -369,24 +369,20 @@ gst_audio_echo_transform_ip (GstBaseTransform * base, GstBuffer * buf)
GST_TIME_ARGS (timestamp));
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);
+ gst_object_sync_values (GST_OBJECT (self), stream_time);
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_BPF (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 +392,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;
}
diff --git a/gst/audiofx/audiofirfilter.c b/gst/audiofx/audiofirfilter.c
index b6102ae78..414768920 100644
--- a/gst/audiofx/audiofirfilter.c
+++ b/gst/audiofx/audiofirfilter.c
@@ -53,7 +53,6 @@
#include <math.h>
#include <gst/gst.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include "audiofirfilter.h"
@@ -75,12 +74,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 +85,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 +129,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 +161,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 +182,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
diff --git a/gst/audiofx/audiofirfilter.h b/gst/audiofx/audiofirfilter.h
index d1d896c0a..8b2488512 100644
--- a/gst/audiofx/audiofirfilter.h
+++ b/gst/audiofx/audiofirfilter.h
@@ -56,7 +56,6 @@ struct _GstAudioFIRFilter {
/* < private > */
GMutex *lock;
- gint rate;
};
struct _GstAudioFIRFilterClass {
diff --git a/gst/audiofx/audiofx.c b/gst/audiofx/audiofx.c
index a268724d5..098e44258 100644
--- a/gst/audiofx/audiofx.c
+++ b/gst/audiofx/audiofx.c
@@ -23,7 +23,6 @@
#endif
#include <gst/gst.h>
-#include <gst/controller/gstcontroller.h>
#include "audiopanorama.h"
#include "audioinvert.h"
@@ -46,9 +45,6 @@
static gboolean
plugin_init (GstPlugin * plugin)
{
- /* initialize gst controller library */
- gst_controller_init (NULL, NULL);
-
return (gst_element_register (plugin, "audiopanorama", GST_RANK_NONE,
GST_TYPE_AUDIO_PANORAMA) &&
gst_element_register (plugin, "audioinvert", GST_RANK_NONE,
diff --git a/gst/audiofx/audiofxbasefirfilter.c b/gst/audiofx/audiofxbasefirfilter.c
index ac1b14858..5022af534 100644
--- a/gst/audiofx/audiofxbasefirfilter.c
+++ b/gst/audiofx/audiofxbasefirfilter.c
@@ -30,12 +30,6 @@
#include <math.h>
#include <gst/gst.h>
#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"
@@ -43,16 +37,11 @@
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,25 +55,24 @@ 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);
-static const GstQueryType *gst_audio_fx_base_fir_filter_query_type (GstPad *
- pad);
+ GstObject * parent, GstQuery * query);
/*
* The code below calculates the linear convolution:
@@ -102,7 +90,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 +229,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 +407,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 +499,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 +536,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 +581,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;
@@ -621,8 +614,6 @@ gst_audio_fx_base_fir_filter_init (GstAudioFXBaseFIRFilter * self,
gst_pad_set_query_function (GST_BASE_TRANSFORM (self)->srcpad,
gst_audio_fx_base_fir_filter_query);
- gst_pad_set_query_type_function (GST_BASE_TRANSFORM (self)->srcpad,
- gst_audio_fx_base_fir_filter_query_type);
}
void
@@ -630,11 +621,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 +644,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 +655,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 +663,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
@@ -731,10 +717,12 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
GST_BUFFER_OFFSET_END (outbuf) = GST_BUFFER_OFFSET (outbuf) + outsamples;
}
- GST_DEBUG_OBJECT (self, "Pushing residue buffer of size %d with timestamp: %"
+ GST_DEBUG_OBJECT (self,
+ "Pushing residue buffer of size %" G_GSIZE_FORMAT " 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 +740,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 +756,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 +766,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 +798,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;
@@ -839,7 +825,7 @@ gst_audio_fx_base_fir_filter_transform (GstBaseTransform * base,
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (self), stream_time);
+ gst_object_sync_values (GST_OBJECT (self), stream_time);
g_return_val_if_fail (self->kernel != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (channels != 0, GST_FLOW_ERROR);
@@ -871,11 +857,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 +884,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) =
@@ -910,10 +903,12 @@ gst_audio_fx_base_fir_filter_transform (GstBaseTransform * base,
GST_BUFFER_OFFSET_END (outbuf) = GST_BUFFER_OFFSET_NONE;
}
- GST_DEBUG_OBJECT (self, "Pushing buffer of size %d with timestamp: %"
+ GST_DEBUG_OBJECT (self,
+ "Pushing buffer of size %" G_GSIZE_FORMAT " 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);
@@ -949,10 +944,10 @@ gst_audio_fx_base_fir_filter_stop (GstBaseTransform * base)
}
static gboolean
-gst_audio_fx_base_fir_filter_query (GstPad * pad, GstQuery * query)
+gst_audio_fx_base_fir_filter_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
- GstAudioFXBaseFIRFilter *self =
- GST_AUDIO_FX_BASE_FIR_FILTER (gst_pad_get_parent (pad));
+ GstAudioFXBaseFIRFilter *self = GST_AUDIO_FX_BASE_FIR_FILTER (parent);
gboolean res = TRUE;
switch (GST_QUERY_TYPE (query)) {
@@ -961,65 +956,51 @@ gst_audio_fx_base_fir_filter_query (GstPad * pad, GstQuery * query)
GstClockTime min, max;
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;
- } else if ((peer = gst_pad_get_peer (GST_BASE_TRANSFORM (self)->sinkpad))) {
- if ((res = gst_pad_query (peer, query))) {
- gst_query_parse_latency (query, &live, &min, &max);
+ } else if ((res =
+ gst_pad_peer_query (GST_BASE_TRANSFORM (self)->sinkpad, query))) {
+ gst_query_parse_latency (query, &live, &min, &max);
- GST_DEBUG_OBJECT (self, "Peer latency: min %"
- GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
- GST_TIME_ARGS (min), GST_TIME_ARGS (max));
+ GST_DEBUG_OBJECT (self, "Peer latency: min %"
+ GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (min), GST_TIME_ARGS (max));
- if (self->fft && !self->low_latency)
- latency = self->block_length - self->kernel_length + 1;
- else
- latency = self->latency;
+ if (self->fft && !self->low_latency)
+ latency = self->block_length - self->kernel_length + 1;
+ else
+ latency = self->latency;
- /* add our own latency */
- latency = gst_util_uint64_scale_round (latency, GST_SECOND, rate);
+ /* add our own latency */
+ latency = gst_util_uint64_scale_round (latency, GST_SECOND, rate);
- GST_DEBUG_OBJECT (self, "Our latency: %"
- GST_TIME_FORMAT, GST_TIME_ARGS (latency));
+ GST_DEBUG_OBJECT (self, "Our latency: %"
+ GST_TIME_FORMAT, GST_TIME_ARGS (latency));
- min += latency;
- if (max != GST_CLOCK_TIME_NONE)
- max += latency;
+ min += latency;
+ if (max != GST_CLOCK_TIME_NONE)
+ max += latency;
- GST_DEBUG_OBJECT (self, "Calculated total latency : min %"
- GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
- GST_TIME_ARGS (min), GST_TIME_ARGS (max));
+ GST_DEBUG_OBJECT (self, "Calculated total latency : min %"
+ GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (min), GST_TIME_ARGS (max));
- gst_query_set_latency (query, live, min, max);
- }
- gst_object_unref (peer);
+ gst_query_set_latency (query, live, min, max);
}
break;
}
default:
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, parent, query);
break;
}
- gst_object_unref (self);
return res;
}
-static const GstQueryType *
-gst_audio_fx_base_fir_filter_query_type (GstPad * pad)
-{
- static const GstQueryType types[] = {
- GST_QUERY_LATENCY,
- 0
- };
-
- return types;
-}
-
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 +1016,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 +1060,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;
diff --git a/gst/audiofx/audiofxbaseiirfilter.c b/gst/audiofx/audiofxbaseiirfilter.c
index 0b0fc3464..ee2f88dff 100644
--- a/gst/audiofx/audiofxbaseiirfilter.c
+++ b/gst/audiofx/audiofxbaseiirfilter.c
@@ -22,11 +22,12 @@
#include "config.h"
#endif
+#include <string.h>
+
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
#include <gst/audio/audio.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include <math.h>
@@ -36,21 +37,17 @@
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 +61,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 +98,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 +118,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 +238,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);
- for (i = 0; i < filter->nchannels; i++) {
+ filter->channels = g_new0 (GstAudioFXBaseIIRFilterChannelCtx, channels);
+ for (i = 0; i < channels; 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 +330,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 +354,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 =
@@ -366,17 +365,19 @@ gst_audio_fx_base_iir_filter_transform_ip (GstBaseTransform * base,
GST_TIME_ARGS (timestamp));
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);
+ gst_object_sync_values (GST_OBJECT (filter), stream_time);
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 +387,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 +402,7 @@ gst_audio_fx_base_iir_filter_stop (GstBaseTransform * base)
g_free (filter->channels);
}
filter->channels = NULL;
+ filter->nchannels = 0;
return TRUE;
}
diff --git a/gst/audiofx/audioiirfilter.c b/gst/audiofx/audioiirfilter.c
index bac16b295..f411d8871 100644
--- a/gst/audiofx/audioiirfilter.c
+++ b/gst/audiofx/audioiirfilter.c
@@ -49,7 +49,6 @@
#include <math.h>
#include <gst/gst.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include "audioiirfilter.h"
@@ -71,12 +70,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 +81,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 +127,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 +177,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 +199,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
diff --git a/gst/audiofx/audioiirfilter.h b/gst/audiofx/audioiirfilter.h
index 607edf27d..2a80c09bb 100644
--- a/gst/audiofx/audioiirfilter.h
+++ b/gst/audiofx/audioiirfilter.h
@@ -55,7 +55,6 @@ struct _GstAudioIIRFilter {
/* < private > */
GMutex *lock;
- gint rate;
};
struct _GstAudioIIRFilterClass {
diff --git a/gst/audiofx/audioinvert.c b/gst/audiofx/audioinvert.c
index c0a7da496..dc61b2663 100644
--- a/gst/audiofx/audioinvert.c
+++ b/gst/audiofx/audioinvert.c
@@ -44,7 +44,6 @@
#include <gst/base/gstbasetransform.h>
#include <gst/audio/audio.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include "audioinvert.h"
@@ -65,24 +64,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 +77,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 +89,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 +110,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 +127,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 +171,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 +227,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 =
@@ -245,16 +238,18 @@ gst_audio_invert_transform_ip (GstBaseTransform * base, GstBuffer * buf)
GST_TIME_ARGS (timestamp));
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);
+ gst_object_sync_values (GST_OBJECT (filter), stream_time);
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;
}
diff --git a/gst/audiofx/audiokaraoke.c b/gst/audiofx/audiokaraoke.c
index c6fb93ee4..4d09eed62 100644
--- a/gst/audiofx/audiokaraoke.c
+++ b/gst/audiofx/audiokaraoke.c
@@ -42,7 +42,6 @@
#include <gst/base/gstbasetransform.h>
#include <gst/audio/audio.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include "audiokaraoke.h"
@@ -72,24 +71,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 +84,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 +96,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 +131,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 +147,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 +159,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 +196,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 +238,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 +270,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 +303,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 +329,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 =
@@ -348,16 +340,18 @@ gst_audio_karaoke_transform_ip (GstBaseTransform * base, GstBuffer * buf)
GST_TIME_ARGS (timestamp));
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);
+ gst_object_sync_values (GST_OBJECT (filter), stream_time);
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;
}
diff --git a/gst/audiofx/audiokaraoke.h b/gst/audiofx/audiokaraoke.h
index 727fafaee..a299b8878 100644
--- a/gst/audiofx/audiokaraoke.h
+++ b/gst/audiofx/audiokaraoke.h
@@ -42,9 +42,6 @@ struct _GstAudioKaraoke
{
GstAudioFilter audiofilter;
- gint channels;
- gint rate;
-
/* properties */
gfloat level;
gfloat mono_level;
diff --git a/gst/audiofx/audiopanorama.c b/gst/audiofx/audiopanorama.c
index f64eaa468..0802c4c2e 100644
--- a/gst/audiofx/audiopanorama.c
+++ b/gst/audiofx/audiopanorama.c
@@ -40,9 +40,10 @@
#include "config.h"
#endif
+#include <string.h>
+
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
-#include <gst/controller/gstcontroller.h>
#include "audiopanorama.h"
@@ -92,36 +93,20 @@ gst_audio_panorama_method_get_type (void)
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, 2 ], "
- "endianness = (int) BYTE_ORDER, " "width = (int) 32; "
- "audio/x-raw-int, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, 2 ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
+ GST_STATIC_CAPS ("audio/x-raw, "
+ "format = (string) { " GST_AUDIO_NE (S32) ", " GST_AUDIO_NE (S16) "}, "
+ "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
);
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) 2, "
- "endianness = (int) BYTE_ORDER, " "width = (int) 32; "
- "audio/x-raw-int, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) 2, "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
+ GST_STATIC_CAPS ("audio/x-raw, "
+ "format = (string) { " GST_AUDIO_NE (S32) ", " GST_AUDIO_NE (S16) "}, "
+ "rate = (int) [ 1, MAX ], " "channels = (int) 2")
);
-#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 +114,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,25 +165,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_static_pad_template (element_class, &src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
@@ -223,6 +200,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 =
@@ -234,33 +221,32 @@ 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;
filter->method = METHOD_PSYCHOACOUSTIC;
- filter->width = 0;
- filter->channels = 0;
- filter->format_float = FALSE;
+ gst_audio_info_init (&filter->info);
filter->process = NULL;
gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (filter), TRUE);
}
static gboolean
-gst_audio_panorama_set_process_function (GstAudioPanorama * filter)
+gst_audio_panorama_set_process_function (GstAudioPanorama * filter,
+ GstAudioInfo * info)
{
gint channel_index, format_index, method_index;
+ const GstAudioFormatInfo *finfo = info->finfo;
/* set processing function */
- channel_index = filter->channels - 1;
+ channel_index = GST_AUDIO_INFO_CHANNELS (info) - 1;
if (channel_index > 1 || channel_index < 0) {
filter->process = NULL;
return FALSE;
}
- format_index = (filter->format_float) ? 1 : 0;
+ format_index = GST_AUDIO_FORMAT_INFO_IS_FLOAT (finfo) ? 1 : 0;
method_index = filter->method;
if (method_index >= NUM_METHODS || method_index < 0)
@@ -283,7 +269,7 @@ gst_audio_panorama_set_property (GObject * object, guint prop_id,
break;
case PROP_METHOD:
filter->method = g_value_get_enum (value);
- gst_audio_panorama_set_process_function (filter);
+ gst_audio_panorama_set_process_function (filter, &filter->info);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -314,27 +300,23 @@ 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;
- gboolean ret;
+ GstAudioInfo info;
g_assert (size);
- /* this works for both float and int */
- structure = gst_caps_get_structure (caps, 0);
- ret = gst_structure_get_int (structure, "width", &width);
- ret &= gst_structure_get_int (structure, "channels", &channels);
+ if (!gst_audio_info_from_caps (&info, caps))
+ return FALSE;
- *size = width * channels / 8;
+ *size = GST_AUDIO_INFO_BPF (&info);
- return ret;
+ return TRUE;
}
static GstCaps *
gst_audio_panorama_transform_caps (GstBaseTransform * base,
- GstPadDirection direction, GstCaps * caps)
+ GstPadDirection direction, GstCaps * caps, GstCaps * filter)
{
GstCaps *res;
GstStructure *structure;
@@ -359,44 +341,27 @@ gst_audio_panorama_set_caps (GstBaseTransform * base, GstCaps * incaps,
GstCaps * outcaps)
{
GstAudioPanorama *filter = GST_AUDIO_PANORAMA (base);
- const GstStructure *structure;
- gboolean ret;
- gint width;
- const gchar *fmt;
+ GstAudioInfo info;
/*GST_INFO ("incaps are %" GST_PTR_FORMAT, incaps); */
+ if (!gst_audio_info_from_caps (&info, incaps))
+ goto no_format;
- structure = gst_caps_get_structure (incaps, 0);
- ret = gst_structure_get_int (structure, "channels", &filter->channels);
- if (!ret)
- goto no_channels;
-
- ret = gst_structure_get_int (structure, "width", &width);
- if (!ret)
- goto no_width;
- filter->width = width / 8;
-
- fmt = gst_structure_get_name (structure);
- if (!strcmp (fmt, "audio/x-raw-int"))
- filter->format_float = FALSE;
- else
- filter->format_float = TRUE;
-
- GST_DEBUG ("try to process %s input with %d channels", fmt, filter->channels);
+ GST_DEBUG ("try to process %d input with %d channels",
+ GST_AUDIO_INFO_FORMAT (&info), GST_AUDIO_INFO_CHANNELS (&info));
- ret = gst_audio_panorama_set_process_function (filter);
+ if (!gst_audio_panorama_set_process_function (filter, &info))
+ goto no_format;
- if (!ret)
- GST_WARNING ("can't process input with %d channels", filter->channels);
+ filter->info = info;
- return ret;
+ return TRUE;
-no_channels:
- GST_DEBUG ("no channels in caps");
- return ret;
-no_width:
- GST_DEBUG ("no width in caps");
- return ret;
+no_format:
+ {
+ GST_DEBUG ("invalid caps");
+ return FALSE;
+ }
}
/* psychoacoustic processing functions */
@@ -654,8 +619,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 =
@@ -665,16 +631,22 @@ gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (filter), stream_time);
+ gst_object_sync_values (GST_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 / GST_AUDIO_INFO_BPF (&filter->info);
+
+ 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;
}
diff --git a/gst/audiofx/audiopanorama.h b/gst/audiofx/audiopanorama.h
index b3cd18300..e445f4dd6 100644
--- a/gst/audiofx/audiopanorama.h
+++ b/gst/audiofx/audiopanorama.h
@@ -22,6 +22,7 @@
#define __GST_AUDIO_PANORAMA_H__
#include <gst/gst.h>
+#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
G_BEGIN_DECLS
@@ -42,12 +43,11 @@ struct _GstAudioPanorama {
GstBaseTransform element;
gfloat panorama;
-
+
/* < private > */
GstAudioPanoramaProcessFunc process;
- gint channels;
- gboolean format_float;
- gint width;
+
+ GstAudioInfo info;
gint method;
};
diff --git a/gst/audiofx/audiowsincband.c b/gst/audiofx/audiowsincband.c
index 07356e240..3f23b561a 100644
--- a/gst/audiofx/audiowsincband.c
+++ b/gst/audiofx/audiowsincband.c
@@ -60,7 +60,6 @@
#include <math.h>
#include <gst/gst.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include "audiowsincband.h"
@@ -138,12 +137,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 +148,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 +194,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 +226,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 +261,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 +298,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 +370,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
diff --git a/gst/audiofx/audiowsincband.h b/gst/audiofx/audiowsincband.h
index b0dea007f..2ade91c54 100644
--- a/gst/audiofx/audiowsincband.h
+++ b/gst/audiofx/audiowsincband.h
@@ -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
diff --git a/gst/audiofx/audiowsinclimit.c b/gst/audiofx/audiowsinclimit.c
index aa0cf4b0f..f13d2d020 100644
--- a/gst/audiofx/audiowsinclimit.c
+++ b/gst/audiofx/audiowsinclimit.c
@@ -60,7 +60,6 @@
#include <math.h>
#include <gst/gst.h>
#include <gst/audio/gstaudiofilter.h>
-#include <gst/controller/gstcontroller.h>
#include "audiowsinclimit.h"
@@ -137,12 +136,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 +147,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 +190,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 +220,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 +247,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 +305,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
diff --git a/gst/audioparsers/gstaacparse.c b/gst/audioparsers/gstaacparse.c
index d8c0995c1..5c0d88a06 100644
--- a/gst/audioparsers/gstaacparse.c
+++ b/gst/audioparsers/gstaacparse.c
@@ -74,7 +74,8 @@ static gboolean gst_aac_parse_stop (GstBaseParse * parse);
static gboolean gst_aac_parse_sink_setcaps (GstBaseParse * parse,
GstCaps * caps);
-static GstCaps *gst_aac_parse_sink_getcaps (GstBaseParse * parse);
+static GstCaps *gst_aac_parse_sink_getcaps (GstBaseParse * parse,
+ GstCaps * filter);
static gboolean gst_aac_parse_check_valid_frame (GstBaseParse * parse,
GstBaseParseFrame * frame, guint * size, gint * skipsize);
@@ -82,12 +83,16 @@ static gboolean gst_aac_parse_check_valid_frame (GstBaseParse * parse,
static GstFlowReturn gst_aac_parse_parse_frame (GstBaseParse * parse,
GstBaseParseFrame * frame);
-#define _do_init(bla) \
- GST_DEBUG_CATEGORY_INIT (aacparse_debug, "aacparse", 0, \
- "AAC audio stream parser");
+gboolean gst_aac_parse_convert (GstBaseParse * parse,
+ GstFormat src_format,
+ gint64 src_value, GstFormat dest_format, gint64 * dest_value);
-GST_BOILERPLATE_FULL (GstAacParse, gst_aac_parse, GstBaseParse,
- GST_TYPE_BASE_PARSE, _do_init);
+gint gst_aac_parse_get_frame_overhead (GstBaseParse * parse,
+ GstBuffer * buffer);
+
+gboolean gst_aac_parse_event (GstBaseParse * parse, GstEvent * event);
+
+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)
@@ -103,34 +108,27 @@ 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_element_class_add_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &src_template);
+ 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));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_template));
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);
@@ -149,7 +147,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");
}
@@ -177,7 +175,7 @@ gst_aac_parse_set_src_caps (GstAacParse * aacparse, GstCaps * sink_caps)
if (sink_caps)
src_caps = gst_caps_copy (sink_caps);
else
- src_caps = gst_caps_new_simple ("audio/mpeg", NULL);
+ src_caps = gst_caps_new_empty_simple ("audio/mpeg");
gst_caps_set_simple (src_caps, "framed", G_TYPE_BOOLEAN, TRUE,
"mpegversion", G_TYPE_INT, aacparse->mpegversion, NULL);
@@ -244,16 +242,20 @@ 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;
- aacparse->frame_samples = (buffer[1] & 4) ? 960 : 1024;
+ aacparse->frame_samples = (data[1] & 4) ? 960 : 1024;
+ gst_buffer_unmap (buf, data, size);
GST_DEBUG ("codec_data: object_type=%d, sample_rate=%d, channels=%d, "
"samples=%d", aacparse->object_type, aacparse->sample_rate,
@@ -476,6 +478,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;
@@ -538,8 +541,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);
@@ -571,7 +575,8 @@ static 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;
@@ -579,27 +584,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");
@@ -612,6 +617,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;
}
@@ -647,6 +653,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;
@@ -657,20 +665,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, aacparse->frame_samples, 2, 2);
@@ -717,11 +732,13 @@ gst_aac_parse_stop (GstBaseParse * parse)
}
static GstCaps *
-gst_aac_parse_sink_getcaps (GstBaseParse * parse)
+gst_aac_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter)
{
GstCaps *peercaps;
GstCaps *res;
+ /* FIXME: handle filter caps */
+
peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
if (peercaps) {
guint i, n;
diff --git a/gst/audioparsers/gstac3parse.c b/gst/audioparsers/gstac3parse.c
index 65c958cd9..26b619585 100644
--- a/gst/audioparsers/gstac3parse.c
+++ b/gst/audioparsers/gstac3parse.c
@@ -165,35 +165,33 @@ static GstFlowReturn gst_ac3_parse_parse_frame (GstBaseParse * parse,
GstBaseParseFrame * frame);
static gboolean gst_ac3_parse_src_event (GstBaseParse * parse,
GstEvent * event);
-static GstCaps *gst_ac3_parse_get_sink_caps (GstBaseParse * parse);
+static GstCaps *gst_ac3_parse_get_sink_caps (GstBaseParse * parse,
+ GstCaps * filter);
-GST_BOILERPLATE (GstAc3Parse, gst_ac3_parse, GstBaseParse, GST_TYPE_BASE_PARSE);
-
-static void
-gst_ac3_parse_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &src_template);
-
- gst_element_class_set_details_simple (element_class,
- "AC3 audio stream parser", "Codec/Parser/Converter/Audio",
- "AC3 parser", "Tim-Philipp Müller <tim centricular net>");
-}
+#define gst_ac3_parse_parent_class parent_class
+G_DEFINE_TYPE (GstAc3Parse, gst_ac3_parse, GST_TYPE_BASE_PARSE);
static void
gst_ac3_parse_class_init (GstAc3ParseClass * klass)
{
- GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (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));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_template));
+
+ gst_element_class_set_details_simple (element_class,
+ "AC3 audio stream parser", "Codec/Parser/Converter/Audio",
+ "AC3 parser", "Tim-Philipp Müller <tim centricular net>");
+
parse_class->start = GST_DEBUG_FUNCPTR (gst_ac3_parse_start);
parse_class->stop = GST_DEBUG_FUNCPTR (gst_ac3_parse_stop);
parse_class->check_valid_frame =
@@ -214,7 +212,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 +297,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, rate_scale;
+ 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 +315,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 +326,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);
}
@@ -352,7 +355,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
@@ -360,19 +368,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 */
@@ -382,7 +395,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;
@@ -408,7 +421,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
@@ -416,11 +434,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;
- GST_MEMDUMP_OBJECT (parse, "AC3 frame sync", GST_BUFFER_DATA (buf), 16);
+ data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_bit_reader_init (&bits, data, size);
+
+ GST_MEMDUMP_OBJECT (parse, "AC3 frame sync", data, MIN (size, 16));
gst_bit_reader_skip_unchecked (&bits, skip * 8);
@@ -429,24 +453,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
@@ -455,37 +488,43 @@ 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;
+ gst_byte_reader_init (&reader, data, size);
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;
@@ -521,8 +560,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;
}
@@ -549,12 +587,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);
@@ -562,7 +600,12 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
}
}
- return TRUE;
+ ret = TRUE;
+
+cleanup:
+ gst_buffer_unmap (buf, data, size);
+
+ return ret;
}
static GstFlowReturn
@@ -602,7 +645,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);
@@ -664,11 +706,13 @@ gst_ac3_parse_src_event (GstBaseParse * parse, GstEvent * event)
}
static GstCaps *
-gst_ac3_parse_get_sink_caps (GstBaseParse * parse)
+gst_ac3_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
{
GstCaps *peercaps;
GstCaps *res;
+ /* FIXME: handle filter */
+
peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
if (peercaps) {
guint i, n;
diff --git a/gst/audioparsers/gstamrparse.c b/gst/audioparsers/gstamrparse.c
index 8f6ef9451..eacce78d0 100644
--- a/gst/audioparsers/gstamrparse.c
+++ b/gst/audioparsers/gstamrparse.c
@@ -76,7 +76,8 @@ static gboolean gst_amr_parse_stop (GstBaseParse * parse);
static gboolean gst_amr_parse_sink_setcaps (GstBaseParse * parse,
GstCaps * caps);
-static GstCaps *gst_amr_parse_sink_getcaps (GstBaseParse * parse);
+static GstCaps *gst_amr_parse_sink_getcaps (GstBaseParse * parse,
+ GstCaps * filter);
static gboolean gst_amr_parse_check_valid_frame (GstBaseParse * parse,
GstBaseParseFrame * frame, guint * framesize, gint * skipsize);
@@ -84,43 +85,31 @@ static gboolean gst_amr_parse_check_valid_frame (GstBaseParse * parse,
static 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_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &src_template);
+ 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,
"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 +128,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 +259,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 +283,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? */
@@ -331,9 +323,12 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
}
}
}
-
GST_LOG ("sync lost");
- return FALSE;
+
+done:
+ gst_buffer_unmap (buffer, data, size);
+
+ return ret;
}
@@ -395,11 +390,13 @@ gst_amr_parse_stop (GstBaseParse * parse)
}
static GstCaps *
-gst_amr_parse_sink_getcaps (GstBaseParse * parse)
+gst_amr_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter)
{
GstCaps *peercaps;
GstCaps *res;
+ /* FIXME: handle filter caps */
+
peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
if (peercaps) {
guint i, n;
diff --git a/gst/audioparsers/gstdcaparse.c b/gst/audioparsers/gstdcaparse.c
index c34d83e81..7c11e0b73 100644
--- a/gst/audioparsers/gstdcaparse.c
+++ b/gst/audioparsers/gstdcaparse.c
@@ -78,28 +78,17 @@ static gboolean gst_dca_parse_check_valid_frame (GstBaseParse * parse,
GstBaseParseFrame * frame, guint * size, gint * skipsize);
static GstFlowReturn gst_dca_parse_parse_frame (GstBaseParse * parse,
GstBaseParseFrame * frame);
-static GstCaps *gst_dca_parse_get_sink_caps (GstBaseParse * parse);
+static GstCaps *gst_dca_parse_get_sink_caps (GstBaseParse * parse,
+ GstCaps * filter);
-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_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &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,
@@ -113,6 +102,15 @@ gst_dca_parse_class_init (GstDcaParseClass * klass)
GST_DEBUG_FUNCPTR (gst_dca_parse_check_valid_frame);
parse_class->parse_frame = GST_DEBUG_FUNCPTR (gst_dca_parse_parse_frame);
parse_class->get_sink_caps = GST_DEBUG_FUNCPTR (gst_dca_parse_get_sink_caps);
+
+ 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
@@ -128,7 +126,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);
@@ -257,7 +255,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;
@@ -267,7 +265,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;
@@ -275,7 +273,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;
@@ -286,7 +284,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;
@@ -294,7 +292,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;
@@ -313,33 +311,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);
@@ -347,14 +352,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",
@@ -369,19 +374,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 */
@@ -389,14 +394,19 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
} else {
/* 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);
+ GST_LOG_OBJECT (dcaparse,
+ "next sync out of reach (%" G_GSIZE_FORMAT " < %u)", bufsize,
+ size + 16);
/* *skipsize = 0; */
/* return FALSE; */
}
}
- return TRUE;
+ ret = TRUE;
+
+cleanup:
+ gst_buffer_unmap (buf, data, bufsize);
+ return ret;
}
static GstFlowReturn
@@ -404,10 +414,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))
@@ -427,7 +442,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);
@@ -441,6 +455,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 */
@@ -448,16 +463,19 @@ 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;
}
}
static GstCaps *
-gst_dca_parse_get_sink_caps (GstBaseParse * parse)
+gst_dca_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
{
GstCaps *peercaps;
GstCaps *res;
+ /* FIXME: handle filter caps */
+
peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
if (peercaps) {
guint i, n;
diff --git a/gst/audioparsers/gstflacparse.c b/gst/audioparsers/gstflacparse.c
index 9cfdb9810..67ce51361 100644
--- a/gst/audioparsers/gstflacparse.c
+++ b/gst/audioparsers/gstflacparse.c
@@ -201,34 +201,22 @@ static GstFlowReturn gst_flac_parse_pre_push_frame (GstBaseParse * parse,
static gboolean gst_flac_parse_convert (GstBaseParse * parse,
GstFormat src_format, gint64 src_value, GstFormat dest_format,
gint64 * dest_value);
-static GstCaps *gst_flac_parse_get_sink_caps (GstBaseParse * parse);
+static GstCaps *gst_flac_parse_get_sink_caps (GstBaseParse * parse,
+ GstCaps * filter);
-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_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &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;
@@ -249,10 +237,20 @@ gst_flac_parse_class_init (GstFlacParseClass * klass)
baseparse_class->convert = GST_DEBUG_FUNCPTR (gst_flac_parse_convert);
baseparse_class->get_sink_caps =
GST_DEBUG_FUNCPTR (gst_flac_parse_get_sink_caps);
+
+ 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;
}
@@ -618,15 +616,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;
@@ -636,10 +635,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);
@@ -666,7 +665,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;
}
@@ -682,12 +682,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;
}
}
@@ -696,7 +698,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
@@ -705,99 +711,123 @@ 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->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->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 (%" G_GSIZE_FORMAT " 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) {
- GST_ERROR_OBJECT (flacparse, "Invalid metablock size for STREAMINFO: %u",
- GST_BUFFER_SIZE (buffer));
- return FALSE;
+ if (size != 4 + 34) {
+ GST_ERROR_OBJECT (flacparse,
+ "Invalid metablock size for STREAMINFO: %" G_GSIZE_FORMAT "", size);
+ goto failure;
}
/* Skip metadata block header */
@@ -826,7 +856,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))
@@ -835,7 +865,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))
@@ -849,6 +879,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"
@@ -865,6 +897,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;
}
@@ -872,8 +906,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");
@@ -888,11 +927,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;
@@ -916,7 +959,7 @@ gst_flac_parse_handle_picture (GstFlacParse * flacparse, GstBuffer * buffer)
goto error;
if (!flacparse->tags)
- flacparse->tags = gst_tag_list_new ();
+ flacparse->tags = gst_tag_list_new_empty ();
gst_tag_list_add_id3_image (flacparse->tags,
data + gst_byte_reader_get_pos (&reader), img_len, img_type);
@@ -926,10 +969,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;
}
@@ -950,14 +995,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;
@@ -983,6 +1032,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;
}
@@ -1024,8 +1075,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);
@@ -1036,6 +1089,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) {
@@ -1051,21 +1106,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);
}
@@ -1099,9 +1162,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);
@@ -1125,9 +1186,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;
@@ -1135,7 +1199,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 */
@@ -1169,10 +1233,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_peer_query_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;
@@ -1184,6 +1247,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;
@@ -1192,7 +1256,7 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
/* empty vorbiscomment */
{
- GstTagList *taglist = gst_tag_list_new ();
+ GstTagList *taglist = gst_tag_list_new_empty ();
guchar header[4];
guint size;
@@ -1203,23 +1267,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;
@@ -1235,7 +1303,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;
@@ -1250,14 +1322,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);
@@ -1265,19 +1338,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 */
@@ -1296,7 +1369,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,
@@ -1305,7 +1378,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;
@@ -1313,17 +1386,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)
@@ -1335,15 +1408,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;
}
@@ -1381,8 +1454,14 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
flacparse->offset = -1;
flacparse->blocking_strategy = 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
@@ -1392,7 +1471,8 @@ gst_flac_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
/* Push tags */
if (flacparse->tags) {
- gst_element_found_tags (GST_ELEMENT (flacparse), flacparse->tags);
+ gst_pad_push_event (GST_BASE_PARSE_SRC_PAD (flacparse),
+ gst_event_new_tag (flacparse->tags));
flacparse->tags = NULL;
}
@@ -1434,11 +1514,13 @@ gst_flac_parse_convert (GstBaseParse * parse,
}
static GstCaps *
-gst_flac_parse_get_sink_caps (GstBaseParse * parse)
+gst_flac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
{
GstCaps *peercaps;
GstCaps *res;
+ /* FIXME: handle filter caps */
+
peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
if (peercaps) {
guint i, n;
diff --git a/gst/audioparsers/gstmpegaudioparse.c b/gst/audioparsers/gstmpegaudioparse.c
index 2381fc36d..d09990d9e 100644
--- a/gst/audioparsers/gstmpegaudioparse.c
+++ b/gst/audioparsers/gstmpegaudioparse.c
@@ -100,10 +100,11 @@ static GstFlowReturn gst_mpeg_audio_parse_pre_push_frame (GstBaseParse * parse,
static gboolean gst_mpeg_audio_parse_convert (GstBaseParse * parse,
GstFormat src_format, gint64 src_value,
GstFormat dest_format, gint64 * dest_value);
-static GstCaps *gst_mpeg_audio_parse_get_sink_caps (GstBaseParse * parse);
+static GstCaps *gst_mpeg_audio_parse_get_sink_caps (GstBaseParse * parse,
+ GstCaps * filter);
-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())
@@ -142,25 +143,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_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &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,
@@ -190,6 +176,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
@@ -225,8 +222,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);
}
@@ -379,13 +375,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
@@ -394,10 +390,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;
}
}
@@ -418,14 +415,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,
@@ -436,7 +433,10 @@ gst_mp3parse_validate_extended (GstMpegAudioParse * mp3parse, GstBuffer * buf,
}
*valid = TRUE;
- return TRUE;
+
+cleanup:
+ gst_buffer_unmap (buf, data, available);
+ return res;
}
static gboolean
@@ -492,37 +492,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");
@@ -546,24 +552,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
@@ -577,9 +587,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)
@@ -606,8 +616,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);
@@ -617,9 +627,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_peer_query_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) {
@@ -647,7 +656,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");
@@ -803,7 +812,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");
@@ -814,7 +823,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;
@@ -887,10 +896,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 */
@@ -964,6 +973,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
@@ -972,12 +984,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;
@@ -989,7 +1005,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);
@@ -1033,15 +1048,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
@@ -1213,9 +1236,7 @@ gst_mpeg_audio_parse_pre_push_frame (GstBaseParse * parse,
codec = g_strdup_printf ("MPEG %d Audio, Layer %d",
mp3parse->version, mp3parse->layer);
}
- taglist = gst_tag_list_new ();
- gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE,
- GST_TAG_AUDIO_CODEC, codec, NULL);
+ taglist = gst_tag_list_new (GST_TAG_AUDIO_CODEC, codec, NULL);
if (mp3parse->hdr_bitrate > 0 && mp3parse->xing_bitrate == 0 &&
mp3parse->vbri_bitrate == 0) {
/* We don't have a VBR bitrate, so post the available bitrate as
@@ -1223,8 +1244,8 @@ gst_mpeg_audio_parse_pre_push_frame (GstBaseParse * parse,
gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_NOMINAL_BITRATE, mp3parse->hdr_bitrate, NULL);
}
- gst_element_found_tags_for_pad (GST_ELEMENT (mp3parse),
- GST_BASE_PARSE_SRC_PAD (mp3parse), taglist);
+ gst_pad_push_event (GST_BASE_PARSE_SRC_PAD (mp3parse),
+ gst_event_new_tag (taglist));
g_free (codec);
/* also signals the end of first-frame processing */
@@ -1238,7 +1259,7 @@ gst_mpeg_audio_parse_pre_push_frame (GstBaseParse * parse,
gboolean using_crc;
if (!taglist) {
- taglist = gst_tag_list_new ();
+ taglist = gst_tag_list_new_empty ();
}
mp3parse->last_posted_crc = mp3parse->last_crc;
if (mp3parse->last_posted_crc == CRC_PROTECTED) {
@@ -1252,7 +1273,7 @@ gst_mpeg_audio_parse_pre_push_frame (GstBaseParse * parse,
if (mp3parse->last_posted_channel_mode != mp3parse->last_mode) {
if (!taglist) {
- taglist = gst_tag_list_new ();
+ taglist = gst_tag_list_new_empty ();
}
mp3parse->last_posted_channel_mode = mp3parse->last_mode;
@@ -1262,8 +1283,8 @@ gst_mpeg_audio_parse_pre_push_frame (GstBaseParse * parse,
/* if the taglist exists, we need to send it */
if (taglist) {
- gst_element_found_tags_for_pad (GST_ELEMENT (mp3parse),
- GST_BASE_PARSE_SRC_PAD (mp3parse), taglist);
+ gst_pad_push_event (GST_BASE_PARSE_SRC_PAD (mp3parse),
+ gst_event_new_tag (taglist));
}
/* usual clipping applies */
@@ -1273,11 +1294,13 @@ gst_mpeg_audio_parse_pre_push_frame (GstBaseParse * parse,
}
static GstCaps *
-gst_mpeg_audio_parse_get_sink_caps (GstBaseParse * parse)
+gst_mpeg_audio_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
{
GstCaps *peercaps;
GstCaps *res;
+ /* FIXME: handle filter caps */
+
peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
if (peercaps) {
guint i, n;
diff --git a/gst/auparse/Makefile.am b/gst/auparse/Makefile.am
index a79fb7b5b..3f103b02e 100644
--- a/gst/auparse/Makefile.am
+++ b/gst/auparse/Makefile.am
@@ -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
diff --git a/gst/auparse/gstauparse.c b/gst/auparse/gstauparse.c
index e0cdc8234..7c1734bcd 100644
--- a/gst/auparse/gstauparse.c
+++ b/gst/auparse/gstauparse.c
@@ -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, S16LE, S16BE, S24LE, S24BE, " \
+ "S32LE, S32BE, F32LE, F32BE, " \
+ "F64LE, F64BE }, " \
+ "rate = (int) [ 8000, 192000 ], " \
+ "channels = (int) [ 1, 2 ]"
+
#define GST_AU_PARSE_ALAW_PAD_TEMPLATE_CAPS \
"audio/x-alaw, " \
"rate = (int) [ 8000, 192000 ], " \
@@ -60,45 +68,31 @@ 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));
static void gst_au_parse_dispose (GObject * object);
-static GstFlowReturn gst_au_parse_chain (GstPad * pad, GstBuffer * buf);
+static GstFlowReturn gst_au_parse_chain (GstPad * pad, GstObject * parent,
+ 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);
+static gboolean gst_au_parse_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
+static gboolean gst_au_parse_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static gboolean gst_au_parse_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
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_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &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)
@@ -106,6 +100,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;
@@ -113,10 +109,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,
@@ -125,7 +130,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);
}
@@ -145,8 +157,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;
@@ -158,66 +168,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);
+ 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->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;
- }
-
- return res;
+ return;
}
static GstFlowReturn
@@ -227,9 +191,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]);
@@ -237,14 +203,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:{
@@ -284,33 +250,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_S16LE;
+ else
+ format = GST_AUDIO_FORMAT_S16BE;
+ auparse->sample_size = auparse->channels * 2;
break;
case 4: /* 24-bit linear PCM */
- depth = 24;
+ if (endianness == G_LITTLE_ENDIAN)
+ format = GST_AUDIO_FORMAT_S24LE;
+ else
+ format = GST_AUDIO_FORMAT_S24BE;
+ auparse->sample_size = auparse->channels * 3;
break;
case 5: /* 32-bit linear PCM */
- depth = 32;
+ if (endianness == G_LITTLE_ENDIAN)
+ format = GST_AUDIO_FORMAT_S32LE;
+ else
+ format = GST_AUDIO_FORMAT_S32BE;
+ 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_F32LE;
+ else
+ format = GST_AUDIO_FORMAT_F32BE;
+ 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_F64LE;
+ else
+ format = GST_AUDIO_FORMAT_F64BE;
+ auparse->sample_size = auparse->channels * 8;
break;
case 23: /* 4-bit CCITT G.721 ADPCM 32kbps -> modplug/libsndfile (compressed 8-bit mu-law) */
@@ -355,34 +338,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_unmap (auparse->adapter);
gst_adapter_flush (auparse->adapter, auparse->offset);
gst_caps_unref (tempcaps);
@@ -391,40 +364,37 @@ gst_au_parse_parse_header (GstAuParse * auparse)
/* ERRORS */
unknown_header:
{
+ gst_adapter_unmap (auparse->adapter);
GST_ELEMENT_ERROR (auparse, STREAM, WRONG_TYPE, (NULL), (NULL));
return GST_FLOW_ERROR;
}
unsupported_sample_rate:
{
+ gst_adapter_unmap (auparse->adapter);
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);
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);
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
static GstFlowReturn
-gst_au_parse_chain (GstPad * pad, GstBuffer * buf)
+gst_au_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstFlowReturn ret = GST_FLOW_OK;
GstAuParse *auparse;
@@ -432,16 +402,18 @@ 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));
+ auparse = GST_AU_PARSE (parent);
- GST_LOG_OBJECT (auparse, "got buffer of size %u", GST_BUFFER_SIZE (buf));
+ GST_LOG_OBJECT (auparse, "got buffer of size %" G_GSIZE_FORMAT,
+ 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;
@@ -452,9 +424,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);
@@ -470,21 +441,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);
@@ -509,7 +469,6 @@ gst_au_parse_chain (GstPad * pad, GstBuffer * buf)
out:
- gst_object_unref (auparse);
return ret;
}
@@ -586,21 +545,21 @@ gst_au_parse_src_convert (GstAuParse * auparse, GstFormat src_format,
}
static gboolean
-gst_au_parse_src_query (GstPad * pad, GstQuery * query)
+gst_au_parse_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
GstAuParse *auparse;
gboolean ret = FALSE;
- auparse = GST_AU_PARSE (gst_pad_get_parent (pad));
+ auparse = GST_AU_PARSE (parent);
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_peer_query_duration (auparse->sinkpad, GST_FORMAT_BYTES,
+ &len)) {
GST_DEBUG_OBJECT (auparse, "failed to query upstream length");
break;
}
@@ -608,7 +567,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);
@@ -616,12 +577,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_peer_query_position (auparse->sinkpad, GST_FORMAT_BYTES,
+ &pos)) {
GST_DEBUG_OBJECT (auparse, "failed to query upstream position");
break;
}
@@ -649,11 +610,10 @@ gst_au_parse_src_query (GstPad * pad, GstQuery * query)
break;
}
default:
- ret = gst_pad_query_default (pad, query);
+ ret = gst_pad_query_default (pad, parent, query);
break;
}
- gst_object_unref (auparse);
return ret;
}
@@ -693,29 +653,33 @@ gst_au_parse_handle_seek (GstAuParse * auparse, GstEvent * event)
}
static gboolean
-gst_au_parse_sink_event (GstPad * pad, GstEvent * event)
+gst_au_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstAuParse *auparse;
gboolean ret = TRUE;
- auparse = GST_AU_PARSE (gst_pad_get_parent (pad));
+ auparse = GST_AU_PARSE (parent);
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;
@@ -732,16 +696,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;
@@ -755,32 +719,30 @@ gst_au_parse_sink_event (GstPad * pad, GstEvent * event)
}
/* fall-through */
default:
- ret = gst_pad_event_default (pad, event);
+ ret = gst_pad_event_default (pad, parent, event);
break;
}
- gst_object_unref (auparse);
return ret;
}
static gboolean
-gst_au_parse_src_event (GstPad * pad, GstEvent * event)
+gst_au_parse_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstAuParse *auparse;
gboolean ret;
- auparse = GST_AU_PARSE (gst_pad_get_parent (pad));
+ auparse = GST_AU_PARSE (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
ret = gst_au_parse_handle_seek (auparse, event);
break;
default:
- ret = gst_pad_event_default (pad, event);
+ ret = gst_pad_event_default (pad, parent, event);
break;
}
- gst_object_unref (auparse);
return ret;
}
@@ -790,7 +752,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;
diff --git a/gst/auparse/gstauparse.h b/gst/auparse/gstauparse.h
index 55d13e21b..5744d2687 100644
--- a/gst/auparse/gstauparse.h
+++ b/gst/auparse/gstauparse.h
@@ -60,7 +60,6 @@ struct _GstAuParse {
guint sample_size;
guint encoding;
guint samplerate;
- guint endianness;
guint channels;
};
diff --git a/gst/autodetect/gstautoaudiosink.c b/gst/autodetect/gstautoaudiosink.c
index 535f294f0..9f5aad19f 100644
--- a/gst/autodetect/gstautoaudiosink.c
+++ b/gst/autodetect/gstautoaudiosink.c
@@ -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,19 +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_static_pad_template (eklass, &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;
@@ -111,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
@@ -133,7 +129,7 @@ gst_auto_audio_sink_clear_kid (GstAutoAudioSink * sink)
gst_bin_remove (GST_BIN (sink), sink->kid);
sink->kid = NULL;
/* Don't lose the SINK flag */
- GST_OBJECT_FLAG_SET (sink, GST_ELEMENT_IS_SINK);
+ GST_OBJECT_FLAG_SET (sink, GST_ELEMENT_FLAG_SINK);
}
}
@@ -158,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);
@@ -174,7 +168,7 @@ gst_auto_audio_sink_init (GstAutoAudioSink * sink,
sink->filter_caps = gst_static_caps_get (&raw_caps);
/* mark as sink */
- GST_OBJECT_FLAG_SET (sink, GST_ELEMENT_IS_SINK);
+ GST_OBJECT_FLAG_SET (sink, GST_ELEMENT_FLAG_SINK);
}
static gboolean
@@ -219,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"))
@@ -261,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_query_caps (el_pad, NULL);
gst_object_unref (el_pad);
GST_DEBUG_OBJECT (sink,
"Checking caps: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
diff --git a/gst/autodetect/gstautoaudiosrc.c b/gst/autodetect/gstautoaudiosrc.c
index 87ba27f31..f62f60b74 100644
--- a/gst/autodetect/gstautoaudiosrc.c
+++ b/gst/autodetect/gstautoaudiosrc.c
@@ -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,20 +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_static_pad_template (eklass, &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;
@@ -113,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
@@ -136,7 +132,7 @@ gst_auto_audio_src_clear_kid (GstAutoAudioSrc * src)
src->kid = NULL;
/* Don't lose SOURCE flag */
- GST_OBJECT_FLAG_SET (src, GST_ELEMENT_IS_SOURCE);
+ GST_OBJECT_FLAG_SET (src, GST_ELEMENT_FLAG_SOURCE);
}
}
@@ -161,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);
@@ -176,7 +171,7 @@ gst_auto_audio_src_init (GstAutoAudioSrc * src, GstAutoAudioSrcClass * g_class)
src->filter_caps = gst_static_caps_get (&raw_caps);
/* mark as source */
- GST_OBJECT_FLAG_SET (src, GST_ELEMENT_IS_SOURCE);
+ GST_OBJECT_FLAG_SET (src, GST_ELEMENT_FLAG_SOURCE);
}
static gboolean
@@ -221,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"))
@@ -263,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_query_caps (el_pad, NULL);
gst_object_unref (el_pad);
GST_DEBUG_OBJECT (src,
"Checking caps: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
diff --git a/gst/autodetect/gstautovideosink.c b/gst/autodetect/gstautovideosink.c
index d4e041953..9921c7972 100644
--- a/gst/autodetect/gstautovideosink.c
+++ b/gst/autodetect/gstautovideosink.c
@@ -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,18 +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_static_pad_template (eklass, &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;
@@ -108,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
@@ -130,7 +126,7 @@ gst_auto_video_sink_clear_kid (GstAutoVideoSink * sink)
gst_bin_remove (GST_BIN (sink), sink->kid);
sink->kid = NULL;
/* Don't lose the SINK flag */
- GST_OBJECT_FLAG_SET (sink, GST_ELEMENT_IS_SINK);
+ GST_OBJECT_FLAG_SET (sink, GST_ELEMENT_FLAG_SINK);
}
}
@@ -157,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);
@@ -173,7 +167,7 @@ gst_auto_video_sink_init (GstAutoVideoSink * sink,
sink->filter_caps = gst_static_caps_get (&raw_caps);
/* mark as sink */
- GST_OBJECT_FLAG_SET (sink, GST_ELEMENT_IS_SINK);
+ GST_OBJECT_FLAG_SET (sink, GST_ELEMENT_FLAG_SINK);
}
static gboolean
@@ -218,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"))
@@ -257,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_query_caps (el_pad, NULL);
gst_object_unref (el_pad);
GST_DEBUG_OBJECT (sink,
"Checking caps: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
diff --git a/gst/autodetect/gstautovideosrc.c b/gst/autodetect/gstautovideosrc.c
index fb7bd8ada..350410a10 100644
--- a/gst/autodetect/gstautovideosrc.c
+++ b/gst/autodetect/gstautovideosrc.c
@@ -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,19 +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_static_pad_template (eklass, &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;
@@ -111,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
@@ -133,7 +129,7 @@ gst_auto_video_src_clear_kid (GstAutoVideoSrc * src)
gst_bin_remove (GST_BIN (src), src->kid);
src->kid = NULL;
/* Don't loose SOURCE flag */
- GST_OBJECT_FLAG_SET (src, GST_ELEMENT_IS_SOURCE);
+ GST_OBJECT_FLAG_SET (src, GST_ELEMENT_FLAG_SOURCE);
}
}
@@ -160,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);
@@ -175,7 +170,7 @@ gst_auto_video_src_init (GstAutoVideoSrc * src, GstAutoVideoSrcClass * g_class)
src->filter_caps = gst_static_caps_get (&raw_caps);
/* mark as source */
- GST_OBJECT_FLAG_SET (src, GST_ELEMENT_IS_SOURCE);
+ GST_OBJECT_FLAG_SET (src, GST_ELEMENT_FLAG_SOURCE);
}
static gboolean
@@ -220,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"))
@@ -259,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_query_caps (el_pad, NULL);
gst_object_unref (el_pad);
GST_DEBUG_OBJECT (src,
"Checking caps: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
diff --git a/gst/avi/Makefile.am b/gst/avi/Makefile.am
index 90ea0ed49..d9d9ba2b3 100644
--- a/gst/avi/Makefile.am
+++ b/gst/avi/Makefile.am
@@ -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
diff --git a/gst/avi/gstavidemux.c b/gst/avi/gstavidemux.c
index 83a054799..3d8a50333 100644
--- a/gst/avi/gstavidemux.c
+++ b/gst/avi/gstavidemux.c
@@ -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);
@@ -82,16 +79,17 @@ static void gst_avi_demux_reset (GstAviDemux * avi);
#if 0
static const GstEventMask *gst_avi_demux_get_event_mask (GstPad * pad);
#endif
-static gboolean gst_avi_demux_handle_src_event (GstPad * pad, GstEvent * event);
+static gboolean gst_avi_demux_handle_src_event (GstPad * pad,
+ GstObject * parent, GstEvent * event);
static gboolean gst_avi_demux_handle_sink_event (GstPad * pad,
- GstEvent * event);
+ GstObject * parent, GstEvent * event);
static gboolean gst_avi_demux_push_event (GstAviDemux * avi, GstEvent * event);
#if 0
static const GstFormat *gst_avi_demux_get_src_formats (GstPad * pad);
#endif
-static const GstQueryType *gst_avi_demux_get_src_query_types (GstPad * pad);
-static gboolean gst_avi_demux_handle_src_query (GstPad * pad, GstQuery * query);
+static gboolean gst_avi_demux_handle_src_query (GstPad * pad,
+ GstObject * parent, GstQuery * query);
static gboolean gst_avi_demux_src_convert (GstPad * pad, GstFormat src_format,
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
@@ -101,11 +99,12 @@ static gboolean gst_avi_demux_handle_seek (GstAviDemux * avi, GstPad * pad,
static gboolean gst_avi_demux_handle_seek_push (GstAviDemux * avi, GstPad * pad,
GstEvent * event);
static void gst_avi_demux_loop (GstPad * pad);
-static gboolean gst_avi_demux_sink_activate (GstPad * sinkpad);
-static gboolean gst_avi_demux_sink_activate_pull (GstPad * sinkpad,
- gboolean active);
-static gboolean gst_avi_demux_activate_push (GstPad * pad, gboolean active);
-static GstFlowReturn gst_avi_demux_chain (GstPad * pad, GstBuffer * buf);
+static gboolean gst_avi_demux_sink_activate (GstPad * sinkpad,
+ GstObject * parent);
+static gboolean gst_avi_demux_sink_activate_mode (GstPad * sinkpad,
+ GstObject * parent, GstPadMode mode, gboolean active);
+static GstFlowReturn gst_avi_demux_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buf);
static void gst_avi_demux_set_index (GstElement * element, GstIndex * index);
static GstIndex *gst_avi_demux_get_index (GstElement * element);
@@ -118,65 +117,50 @@ 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",
+ gst_caps_append (audcaps, gst_caps_new_empty_simple ("audio/x-avi-unknown"));
+ audiosrctempl = gst_pad_template_new ("audio_%u",
GST_PAD_SRC, GST_PAD_SOMETIMES, audcaps);
vidcaps = gst_riff_create_video_template_caps ();
gst_caps_append (vidcaps, gst_riff_create_iavs_template_caps ());
- gst_caps_append (vidcaps, gst_caps_new_simple ("video/x-avi-unknown", NULL));
- videosrctempl = gst_pad_template_new ("video_%02d",
+ gst_caps_append (vidcaps, gst_caps_new_empty_simple ("video/x-avi-unknown"));
+ videosrctempl = gst_pad_template_new ("video_%u",
GST_PAD_SRC, GST_PAD_SOMETIMES, vidcaps);
- subcaps = gst_caps_new_simple ("application/x-subtitle-avi", NULL);
- subsrctempl = gst_pad_template_new ("subtitle_%02d",
+ subcaps = gst_caps_new_empty_simple ("application/x-subtitle-avi");
+ subsrctempl = gst_pad_template_new ("subtitle_%u",
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_static_pad_template (element_class, &sink_templ);
- gst_object_unref (audiosrctempl);
- gst_object_unref (videosrctempl);
- gst_object_unref (subsrctempl);
- gst_element_class_set_details_simple (element_class, "Avi demuxer",
+ 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 (gstelement_class, "Avi demuxer",
"Codec/Demuxer",
"Demultiplex an avi file into audio and video",
"Erik Walthinsen <omega@cse.ogi.edu>, "
@@ -185,34 +169,13 @@ 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");
gst_pad_set_activate_function (avi->sinkpad,
GST_DEBUG_FUNCPTR (gst_avi_demux_sink_activate));
- gst_pad_set_activatepull_function (avi->sinkpad,
- GST_DEBUG_FUNCPTR (gst_avi_demux_sink_activate_pull));
- gst_pad_set_activatepush_function (avi->sinkpad,
- GST_DEBUG_FUNCPTR (gst_avi_demux_activate_push));
+ gst_pad_set_activatemode_function (avi->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_avi_demux_sink_activate_mode));
gst_pad_set_chain_function (avi->sinkpad,
GST_DEBUG_FUNCPTR (gst_avi_demux_chain));
gst_pad_set_event_function (avi->sinkpad,
@@ -222,6 +185,8 @@ gst_avi_demux_init (GstAviDemux * avi)
avi->adapter = gst_adapter_new ();
gst_avi_demux_reset (avi);
+
+ GST_OBJECT_FLAG_SET (avi, GST_ELEMENT_FLAG_INDEXABLE);
}
static void
@@ -291,10 +256,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;
@@ -458,30 +419,17 @@ done:
return res;
}
-static const GstQueryType *
-gst_avi_demux_get_src_query_types (GstPad * pad)
-{
- static const GstQueryType src_types[] = {
- GST_QUERY_POSITION,
- GST_QUERY_DURATION,
- GST_QUERY_SEEKING,
- GST_QUERY_CONVERT,
- 0
- };
-
- return src_types;
-}
-
static gboolean
-gst_avi_demux_handle_src_query (GstPad * pad, GstQuery * query)
+gst_avi_demux_handle_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
gboolean res = TRUE;
- GstAviDemux *avi = GST_AVI_DEMUX (gst_pad_get_parent (pad));
+ GstAviDemux *avi = GST_AVI_DEMUX (parent);
GstAviStream *stream = gst_pad_get_element_private (pad);
if (!stream->strh || !stream->strf.data)
- return gst_pad_query_default (pad, query);
+ return gst_pad_query_default (pad, parent, query);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:{
@@ -572,7 +520,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;
}
@@ -608,15 +556,14 @@ gst_avi_demux_handle_src_query (GstPad * pad, GstQuery * query)
&dest_val)))
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
else
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, parent, query);
break;
}
default:
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, parent, query);
break;
}
- gst_object_unref (avi);
return res;
}
@@ -747,31 +694,24 @@ gst_avi_demux_seek_streams_index (GstAviDemux * avi, guint64 offset,
#define GST_AVI_SEEK_PUSH_DISPLACE (4 * GST_SECOND)
static gboolean
-gst_avi_demux_handle_sink_event (GstPad * pad, GstEvent * event)
+gst_avi_demux_handle_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
gboolean res = TRUE;
- GstAviDemux *avi = GST_AVI_DEMUX (gst_pad_get_parent (pad));
+ GstAviDemux *avi = GST_AVI_DEMUX (parent);
GST_DEBUG_OBJECT (avi,
"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 */
@@ -781,7 +721,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;
}
@@ -792,7 +732,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];
@@ -801,7 +741,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;
@@ -813,10 +753,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];
@@ -828,14 +768,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) {
@@ -843,27 +783,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)
@@ -872,9 +815,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);
@@ -910,20 +853,19 @@ gst_avi_demux_handle_sink_event (GstPad * pad, GstEvent * event)
/* fall through to default case so that the event gets passed downstream */
}
default:
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, event);
break;
}
- gst_object_unref (avi);
-
return res;
}
static gboolean
-gst_avi_demux_handle_src_event (GstPad * pad, GstEvent * event)
+gst_avi_demux_handle_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
gboolean res = TRUE;
- GstAviDemux *avi = GST_AVI_DEMUX (gst_pad_get_parent (pad));
+ GstAviDemux *avi = GST_AVI_DEMUX (parent);
GST_DEBUG_OBJECT (avi,
"have event type %s: %p on src pad", GST_EVENT_TYPE_NAME (event), event);
@@ -943,12 +885,10 @@ gst_avi_demux_handle_src_event (GstPad * pad, GstEvent * event)
gst_event_unref (event);
break;
default:
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, event);
break;
}
- gst_object_unref (avi);
-
return res;
}
@@ -972,9 +912,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);
return TRUE;
}
@@ -1153,14 +1094,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);
@@ -1219,8 +1163,8 @@ no_buffer:
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)));
+ ("Too small avih (%" G_GSIZE_FORMAT " available, %d needed)",
+ size, (int) sizeof (gst_riff_avih)));
gst_buffer_unref (buf);
return FALSE;
}
@@ -1247,16 +1191,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). */
@@ -1287,6 +1235,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;
@@ -1295,17 +1244,20 @@ gst_avi_demux_parse_superindex (GstAviDemux * avi,
too_small:
{
GST_ERROR_OBJECT (avi,
- "Not enough data to parse superindex (%d available, 24 needed)", size);
- if (buf)
+ "Not enough data to parse superindex (%" G_GSIZE_FORMAT
+ " available, 24 needed)", size);
+ 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;
}
}
@@ -1510,19 +1462,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;
@@ -1572,6 +1521,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;
@@ -1580,22 +1531,22 @@ gst_avi_demux_parse_subindex (GstAviDemux * avi, GstAviStream * stream,
too_small:
{
GST_ERROR_OBJECT (avi,
- "Not enough data to parse subindex (%d available, 24 needed)", size);
- gst_buffer_unref (buf);
- return TRUE; /* continue */
+ "Not enough data to parse subindex (%" G_GSIZE_FORMAT
+ " available, 24 needed)", size);
+ 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:
{
@@ -1603,6 +1554,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;
}
@@ -1756,14 +1708,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);
@@ -1779,8 +1735,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);
@@ -1851,9 +1806,8 @@ gst_avi_demux_riff_parse_vprp (GstElement * element,
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));
+ "Too small vprp (%" G_GSIZE_FORMAT " available, at least %d needed)",
+ size, (int) G_STRUCT_OFFSET (gst_riff_vprp, field_info));
gst_buffer_unref (buf);
return FALSE;
}
@@ -1870,8 +1824,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)
@@ -1895,16 +1849,23 @@ 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);
+ GST_DEBUG_OBJECT (avi, "rounding up dubious list size %" G_GSIZE_FORMAT,
+ 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);
}
}
@@ -2129,9 +2090,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 {
@@ -2187,13 +2151,13 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
fourcc = (stream->strf.vids->compression) ?
stream->strf.vids->compression : stream->strh->fcc_handler;
- padname = g_strdup_printf ("video_%02d", avi->num_v_streams);
- templ = gst_element_class_get_pad_template (klass, "video_%02d");
+ padname = g_strdup_printf ("video_%u", avi->num_v_streams);
+ templ = gst_element_class_get_pad_template (klass, "video_%u");
caps = gst_riff_create_video_caps (fourcc, stream->strh,
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;
@@ -2215,8 +2179,8 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
break;
}
case GST_RIFF_FCC_auds:{
- padname = g_strdup_printf ("audio_%02d", avi->num_a_streams);
- templ = gst_element_class_get_pad_template (klass, "audio_%02d");
+ padname = g_strdup_printf ("audio_%u", avi->num_a_streams);
+ templ = gst_element_class_get_pad_template (klass, "audio_%u");
caps = gst_riff_create_audio_caps (stream->strf.auds->format,
stream->strh, stream->strf.auds, stream->extradata,
stream->initdata, &codec_name);
@@ -2231,22 +2195,22 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
case GST_RIFF_FCC_iavs:{
guint32 fourcc = stream->strh->fcc_handler;
- padname = g_strdup_printf ("video_%02d", avi->num_v_streams);
- templ = gst_element_class_get_pad_template (klass, "video_%02d");
+ padname = g_strdup_printf ("video_%u", avi->num_v_streams);
+ templ = gst_element_class_get_pad_template (klass, "video_%u");
caps = gst_riff_create_iavs_caps (fourcc, stream->strh,
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++;
break;
}
case GST_RIFF_FCC_txts:{
- padname = g_strdup_printf ("subtitle_%02d", avi->num_t_streams);
- templ = gst_element_class_get_pad_template (klass, "subtitle_%02d");
- caps = gst_caps_new_simple ("application/x-subtitle-avi", NULL);
+ padname = g_strdup_printf ("subtitle_%u", avi->num_t_streams);
+ templ = gst_element_class_get_pad_template (klass, "subtitle_%u");
+ caps = gst_caps_new_empty_simple ("application/x-subtitle-avi");
tag_name = NULL;
avi->num_t_streams++;
break;
@@ -2280,8 +2244,6 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
#endif
gst_pad_set_event_function (pad,
GST_DEBUG_FUNCPTR (gst_avi_demux_handle_src_event));
- gst_pad_set_query_type_function (pad,
- GST_DEBUG_FUNCPTR (gst_avi_demux_get_src_query_types));
gst_pad_set_query_function (pad,
GST_DEBUG_FUNCPTR (gst_avi_demux_handle_src_query));
#if 0
@@ -2311,14 +2273,14 @@ 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 */
if (codec_name) {
if (!stream->taglist)
- stream->taglist = gst_tag_list_new ();
+ stream->taglist = gst_tag_list_new_empty ();
avi->got_tags = TRUE;
@@ -2367,20 +2329,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)",
+ "DMLH entry is too small (%" G_GSIZE_FORMAT " 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);
@@ -2558,7 +2526,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;
@@ -2569,8 +2537,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 ();
@@ -2632,6 +2599,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 */
@@ -2647,6 +2615,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;
}
@@ -2656,6 +2625,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;
}
@@ -2675,6 +2645,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);
@@ -2682,34 +2654,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 */
@@ -2717,8 +2696,8 @@ gst_avi_demux_stream_index (GstAviDemux * avi)
avi->sinkpad, &offset, &tag, &buf) != GST_FLOW_OK)
return;
- GST_DEBUG ("will parse index chunk size %u for tag %"
- GST_FOURCC_FORMAT, GST_BUFFER_SIZE (buf), GST_FOURCC_ARGS (tag));
+ GST_DEBUG ("will parse index chunk size %" G_GSIZE_FORMAT " for tag %"
+ GST_FOURCC_FORMAT, gst_buffer_get_size (buf), GST_FOURCC_ARGS (tag));
gst_avi_demux_parse_index (avi, buf);
@@ -2747,6 +2726,7 @@ pull_failed:
too_small:
{
GST_DEBUG_OBJECT (avi, "Buffer is too small");
+ gst_buffer_unmap (buf, bdata, bsize);
gst_buffer_unref (buf);
return;
}
@@ -2755,13 +2735,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;
}
}
@@ -2811,8 +2789,8 @@ gst_avi_demux_stream_index_push (GstAviDemux * avi)
/* advance offset */
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_DEBUG ("will parse index chunk size %" G_GSIZE_FORMAT " for 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);
@@ -2860,19 +2838,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);
@@ -2881,6 +2857,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;
@@ -2893,7 +2870,8 @@ pull_failed:
}
wrong_size:
{
- GST_DEBUG_OBJECT (avi, "got %d bytes which is <> 8 bytes", bufsize);
+ GST_DEBUG_OBJECT (avi, "got %" G_GSIZE_FORMAT " bytes which is <> 8 bytes",
+ bufsize);
res = GST_FLOW_ERROR;
goto done;
}
@@ -2941,7 +2919,6 @@ gst_avi_demux_stream_scan (GstAviDemux * avi)
{
GstFlowReturn res;
GstAviStream *stream;
- GstFormat format;
guint64 pos = 0;
guint64 length;
gint64 tmplength;
@@ -2954,8 +2931,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_peer_query_duration (avi->sinkpad, GST_FORMAT_BYTES, &tmplength))
return FALSE;
length = tmplength;
@@ -3073,7 +3049,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,
@@ -3117,10 +3093,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_peer_query_duration (avi->sinkpad, GST_FORMAT_BYTES, &stop);
}
/* if upstream doesn't know the size, it's likely that it's not seekable in
@@ -3151,9 +3125,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);
@@ -3169,7 +3143,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 */
@@ -3202,10 +3178,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;
@@ -3222,14 +3200,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;
@@ -3272,10 +3249,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);
if (tag == GST_RIFF_TAG_LIST) {
switch (ltag) {
@@ -3363,16 +3341,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);
@@ -3440,7 +3411,7 @@ gst_avi_demux_add_date_tag (GstAviDemux * avi, gint y, gint m, gint d,
dt = gst_date_time_new_local_time (y, m, d, h, min, s);
if (avi->globaltags == NULL)
- avi->globaltags = gst_tag_list_new ();
+ avi->globaltags = gst_tag_list_new_empty ();
gst_tag_list_add (avi->globaltags, GST_TAG_MERGE_REPLACE, GST_TAG_DATE, date,
NULL);
@@ -3527,10 +3498,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
@@ -3544,24 +3516,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;
@@ -3571,6 +3546,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);
}
/*
@@ -3583,10 +3559,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 ();
@@ -3596,15 +3572,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);
@@ -3615,8 +3592,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");
@@ -3635,23 +3613,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),
@@ -3665,8 +3641,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) {
@@ -3681,16 +3656,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;
@@ -3698,14 +3671,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;
}
@@ -3728,6 +3702,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;
@@ -3735,22 +3710,23 @@ 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) {
- GST_DEBUG_OBJECT (avi, "got %d bytes which is less than 12 bytes",
- GST_BUFFER_SIZE (buf));
+ } else if (gst_buffer_get_size (buf) < 12) {
+ GST_DEBUG_OBJECT (avi,
+ "got %" G_GSIZE_FORMAT " bytes which is less than 12 bytes",
+ 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) {
@@ -3768,7 +3744,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 %" G_GSIZE_FORMAT, gst_buffer_get_size (buf));
if (size < 4) {
GST_DEBUG ("skipping INFO LIST prefix");
avi->offset += (4 - GST_ROUND_UP_2 (size));
@@ -3776,7 +3752,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) {
@@ -3816,7 +3792,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);
@@ -3853,21 +3831,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,
@@ -3997,8 +3967,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);
@@ -4031,9 +4001,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;
@@ -4085,17 +4055,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 %"
@@ -4136,28 +4105,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 */
@@ -4167,30 +4127,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);
}
@@ -4243,29 +4188,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
@@ -4452,7 +4396,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;
@@ -4461,7 +4407,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;
@@ -4477,20 +4426,24 @@ gst_avi_demux_invert (GstAviStream * stream, GstBuffer * buf)
stride = GST_ROUND_UP_4 (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;
}
@@ -4744,7 +4697,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 */
@@ -4770,15 +4723,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_DEBUG_OBJECT (avi, "Pushing buffer of size %" G_GSIZE_FORMAT ", 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);
@@ -4832,8 +4783,8 @@ pull_failed:
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);
+ ", only got %" G_GSIZE_FORMAT "/%" G_GUINT64_FORMAT
+ " bytes (truncated file?)", offset, gst_buffer_get_size (buf), size);
gst_buffer_unref (buf);
ret = GST_FLOW_UNEXPECTED;
goto beach;
@@ -4851,7 +4802,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 */
@@ -4978,7 +4928,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;
}
@@ -5007,9 +4957,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);
@@ -5018,7 +4967,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;
@@ -5026,9 +4975,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;
@@ -5040,7 +4988,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
@@ -5068,17 +5015,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;
- }
}
/*
@@ -5104,19 +5041,19 @@ push_tag_lists (GstAviDemux * avi)
if (pad && tags) {
GST_DEBUG_OBJECT (pad, "Tags: %" GST_PTR_FORMAT, tags);
- gst_element_found_tags_for_pad (GST_ELEMENT_CAST (avi), pad, tags);
+ gst_pad_push_event (pad, gst_event_new_tag (tags));
stream->taglist = NULL;
}
}
if (!(tags = avi->globaltags))
- tags = gst_tag_list_new ();
+ tags = gst_tag_list_new_empty ();
gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE,
GST_TAG_CONTAINER_FORMAT, "AVI", NULL);
GST_DEBUG_OBJECT (avi, "Global tags: %" GST_PTR_FORMAT, tags);
- gst_element_found_tags (GST_ELEMENT_CAST (avi), tags);
+ gst_avi_demux_push_event (avi, gst_event_new_tag (tags));
avi->globaltags = NULL;
avi->got_tags = FALSE;
}
@@ -5145,10 +5082,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;
@@ -5178,12 +5111,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;
@@ -5221,10 +5159,10 @@ pause:{
static GstFlowReturn
-gst_avi_demux_chain (GstPad * pad, GstBuffer * buf)
+gst_avi_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstFlowReturn res;
- GstAviDemux *avi = GST_AVI_DEMUX (GST_PAD_PARENT (pad));
+ GstAviDemux *avi = GST_AVI_DEMUX (parent);
gint i;
if (GST_BUFFER_IS_DISCONT (buf)) {
@@ -5235,7 +5173,8 @@ 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 %" G_GSIZE_FORMAT " bytes in adapter",
+ gst_buffer_get_size (buf));
gst_adapter_push (avi->adapter, buf);
switch (avi->state) {
@@ -5252,10 +5191,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,58 +5271,65 @@ abort_buffering:
}
static gboolean
-gst_avi_demux_sink_activate (GstPad * sinkpad)
+gst_avi_demux_sink_activate (GstPad * sinkpad, GstObject * parent)
{
- 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");
- return gst_pad_activate_push (sinkpad, TRUE);
+ GstQuery *query;
+ gboolean pull_mode;
+
+ query = gst_query_new_scheduling ();
+
+ if (!gst_pad_peer_query (sinkpad, query)) {
+ gst_query_unref (query);
+ goto activate_push;
}
-}
-static gboolean
-gst_avi_demux_sink_activate_pull (GstPad * sinkpad, gboolean active)
-{
- GstAviDemux *avi = GST_AVI_DEMUX (GST_OBJECT_PARENT (sinkpad));
+ pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL);
+ gst_query_unref (query);
- 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);
+ if (!pull_mode)
+ goto activate_push;
+
+ GST_DEBUG_OBJECT (sinkpad, "activating pull");
+ return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
+
+activate_push:
+ {
+ GST_DEBUG_OBJECT (sinkpad, "activating push");
+ return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
}
}
static gboolean
-gst_avi_demux_activate_push (GstPad * pad, gboolean active)
+gst_avi_demux_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
+ GstPadMode mode, gboolean active)
{
- GstAviDemux *avi = GST_AVI_DEMUX (GST_OBJECT_PARENT (pad));
-
- if (active) {
- GST_DEBUG ("avi: activating push/chain function");
- avi->streaming = TRUE;
-#if 0
- /* create index for some push based seeking if not provided */
- GST_OBJECT_LOCK (avi);
- if (!avi->element_index) {
- GST_DEBUG_OBJECT (avi, "creating index");
- avi->element_index = gst_index_factory_make ("memindex");
- }
- GST_OBJECT_UNLOCK (avi);
- /* object lock might be taken again */
- gst_index_get_writer_id (avi->element_index, GST_OBJECT_CAST (avi),
- &avi->index_id);
-#endif
- } else {
- GST_DEBUG ("avi: deactivating push/chain function");
+ gboolean res;
+ GstAviDemux *avi = GST_AVI_DEMUX (parent);
+
+ switch (mode) {
+ case GST_PAD_MODE_PULL:
+ if (active) {
+ avi->streaming = FALSE;
+ res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_avi_demux_loop,
+ sinkpad);
+ } else {
+ res = gst_pad_stop_task (sinkpad);
+ }
+ break;
+ case GST_PAD_MODE_PUSH:
+ if (active) {
+ GST_DEBUG ("avi: activating push/chain function");
+ avi->streaming = TRUE;
+ } else {
+ GST_DEBUG ("avi: deactivating push/chain function");
+ }
+ res = TRUE;
+ break;
+ default:
+ res = FALSE;
+ break;
}
-
- return TRUE;
+ return res;
}
static void
diff --git a/gst/avi/gstavidemux.h b/gst/avi/gstavidemux.h
index cdd99d0a3..fe3dd5893 100644
--- a/gst/avi/gstavidemux.h
+++ b/gst/avi/gstavidemux.h
@@ -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;
diff --git a/gst/avi/gstavimux.c b/gst/avi/gstavimux.c
index fe50cef9e..9561bd7f3 100644
--- a/gst/avi/gstavimux.c
+++ b/gst/avi/gstavimux.c
@@ -35,19 +35,19 @@
* <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. \
+ * ! 'audio/x-raw,rate=44100,channels=2' ! queue ! mux. \
* avimux name=mux ! filesink location=test.avi
* ]| This will create an .AVI file containing an uncompressed video stream
* with a test picture and an uncompressed audio stream containing a
* 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' \
+ * audiotestsrc num-buffers=440 ! audioconvert ! 'audio/x-raw,rate=44100,channels=2' \
* ! lame ! queue ! mux. \
* avimux name=mux ! filesink location=test.avi
* ]| This will create an .AVI file containing the same test video and sound
@@ -66,6 +66,7 @@
#include <string.h>
#include <gst/video/video.h>
+#include <gst/audio/audio.h>
#include <gst/base/gstbytewriter.h>
#include "gstavimux.h"
@@ -88,11 +89,11 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
);
static GstStaticPadTemplate video_sink_factory =
- GST_STATIC_PAD_TEMPLATE ("video_%d",
+ GST_STATIC_PAD_TEMPLATE ("video_%u",
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 ]; "
@@ -157,14 +158,11 @@ static GstStaticPadTemplate video_sink_factory =
);
static GstStaticPadTemplate audio_sink_factory =
- GST_STATIC_PAD_TEMPLATE ("audio_%d",
+ GST_STATIC_PAD_TEMPLATE ("audio_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) LITTLE_ENDIAN, "
- "signed = (boolean) { TRUE, FALSE }, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
+ GST_STATIC_CAPS ("audio/x-raw, "
+ "format = (string) { U8, S16LE }, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2 ]; "
"audio/mpeg, "
@@ -190,16 +188,14 @@ 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 gboolean gst_avi_mux_handle_event (GstPad * pad, GstObject * parent,
+ 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,57 +204,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_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &audio_sink_factory);
- gst_element_class_add_static_pad_template (element_class,
- &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)
@@ -296,7 +244,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;
@@ -311,6 +259,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
@@ -505,18 +465,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;
- gst_structure_get_fourcc (structure, "format", &format);
- avipad->vids.compression = format;
- switch (format) {
- case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ format = gst_structure_get_string (structure, "format");
+ fmt = gst_video_format_from_string (format);
+
+ 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;
@@ -630,7 +596,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));
@@ -661,16 +627,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;
@@ -709,6 +673,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;
@@ -724,7 +690,7 @@ cbr_fallback:
avipad->hdr.scale = 1;
/* no need to check further */
avipad->hook = NULL;
- return GST_FLOW_OK;
+ goto done;
}
}
@@ -788,39 +754,30 @@ 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")) {
- gint width, depth;
- gboolean signedness;
-
- avipad->auds.format = GST_RIFF_WAVE_FORMAT_PCM;
+ if (!strcmp (mimetype, "audio/x-raw")) {
+ const gchar *format;
+ GstAudioFormat fmt;
- if (!gst_structure_get_int (structure, "width", &width) ||
- !gst_structure_get_int (structure, "depth", &depth) ||
- !gst_structure_get_boolean (structure, "signed", &signedness)) {
- GST_DEBUG_OBJECT (avimux,
- "broken caps, width/depth/signed field missing");
- goto refuse_caps;
- }
+ format = gst_structure_get_string (structure, "format");
+ fmt = gst_audio_format_from_string (format);
- /* no clear place to put different values for these while keeping to spec */
- if (width != depth) {
- GST_DEBUG_OBJECT (avimux, "width must be same as depth!");
- goto refuse_caps;
- }
-
- /* because that's the way the caps will be recreated from riff data */
- if ((width == 8 && signedness) || (width == 16 && !signedness)) {
- GST_DEBUG_OBJECT (avimux,
- "8-bit PCM must be unsigned, 16-bit PCM signed");
- goto refuse_caps;
+ switch (fmt) {
+ case GST_AUDIO_FORMAT_U8:
+ avipad->auds.blockalign = 8;
+ avipad->auds.size = 8;
+ break;
+ case GST_AUDIO_FORMAT_S16:
+ avipad->auds.blockalign = 16;
+ avipad->auds.size = 16;
+ break;
+ default:
+ goto refuse_caps;
}
- avipad->auds.blockalign = width;
- avipad->auds.size = (width == 8) ? 8 : depth;
-
+ avipad->auds.format = GST_RIFF_WAVE_FORMAT_PCM;
/* set some more info straight */
avipad->auds.blockalign /= 8;
avipad->auds.blockalign *= avipad->auds.channels;
@@ -867,6 +824,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) {
@@ -881,13 +839,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;
}
@@ -955,7 +914,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;
@@ -963,7 +922,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);
@@ -979,18 +937,15 @@ gst_avi_mux_request_new_pad (GstElement * element,
klass = GST_ELEMENT_GET_CLASS (element);
- /* FIXME-0.11: use %d instead of %02d for pad_names */
-
- if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
+ if (templ == gst_element_class_get_pad_template (klass, "audio_%u")) {
/* don't mix named and unnamed pads, if the pad already exists we fail when
* trying to add it */
- if (req_name != NULL && sscanf (req_name, "audio_%02d", &pad_id) == 1) {
+ if (req_name != NULL && sscanf (req_name, "audio_%u", &pad_id) == 1) {
pad_name = req_name;
} else {
- name = g_strdup_printf ("audio_%02d", avimux->audio_pads++);
+ name = g_strdup_printf ("audio_%u", 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));
@@ -998,7 +953,7 @@ gst_avi_mux_request_new_pad (GstElement * element,
avipad->hdr.type = GST_MAKE_FOURCC ('a', 'u', 'd', 's');
/* audio goes last */
avimux->sinkpads = g_slist_append (avimux->sinkpads, avipad);
- } else if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
+ } else if (templ == gst_element_class_get_pad_template (klass, "video_%u")) {
/* though streams are pretty generic and relatively self-contained,
* some video info goes in a single avi header -and therefore mux struct-
* so video restricted to one stream */
@@ -1006,9 +961,8 @@ gst_avi_mux_request_new_pad (GstElement * element,
goto too_many_video_pads;
/* setup pad */
- pad_name = "video_00";
+ pad_name = "video_0";
avimux->video_pads++;
- setcapsfunc = GST_DEBUG_FUNCPTR (gst_avi_mux_vidsink_set_caps);
/* init pad specific data */
avipad = g_malloc0 (sizeof (GstAviVideoPad));
@@ -1020,17 +974,16 @@ 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);
avipad->collect = gst_collect_pads_add_pad (avimux->collect,
- newpad, sizeof (GstAviCollectData));
+ newpad, sizeof (GstAviCollectData), NULL);
((GstAviCollectData *) (avipad->collect))->avipad = avipad;
/* FIXME: hacked way to override/extend the event function of
* GstCollectPads; because it sets its own event function giving the
* element no access to events */
- avimux->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (newpad);
+ avimux->collect_event = GST_PAD_EVENTFUNC (newpad);
gst_pad_set_event_function (newpad,
GST_DEBUG_FUNCPTR (gst_avi_mux_handle_event));
@@ -1186,6 +1139,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);
@@ -1261,7 +1216,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 */
@@ -1277,9 +1232,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);
@@ -1321,7 +1278,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 */
@@ -1333,9 +1290,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);
}
@@ -1406,12 +1365,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;
}
@@ -1420,17 +1380,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;
}
@@ -1439,12 +1401,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;
}
@@ -1457,12 +1422,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) {
@@ -1475,19 +1442,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;
@@ -1495,26 +1464,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;
@@ -1579,26 +1547,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;
@@ -1615,7 +1588,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 */
@@ -1632,21 +1604,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;
@@ -1678,10 +1652,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);
}
@@ -1694,6 +1668,7 @@ gst_avi_mux_start_file (GstAviMux * avimux)
GstBuffer *header;
GSList *node;
GstCaps *caps;
+ GstSegment segment;
avimux->total_data = 0;
avimux->total_frames = 0;
@@ -1741,17 +1716,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;
@@ -1763,9 +1737,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 */
@@ -1825,21 +1799,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;
@@ -1861,14 +1833,35 @@ gst_avi_mux_restart_file (GstAviMux * avimux)
/* handle events (search) */
static gboolean
-gst_avi_mux_handle_event (GstPad * pad, GstEvent * event)
+gst_avi_mux_handle_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstAviMux *avimux;
- gboolean ret;
+ gboolean ret = TRUE;
- avimux = GST_AVI_MUX (gst_pad_get_parent (pad));
+ avimux = GST_AVI_MUX (parent);
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);
@@ -1883,9 +1876,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);
-
- gst_object_unref (avimux);
+ if (ret)
+ ret = avimux->collect_event (pad, parent, event);
return ret;
}
@@ -1895,10 +1887,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);
}
@@ -1910,10 +1907,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));
@@ -1924,7 +1922,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);
@@ -1938,9 +1936,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;
@@ -1951,11 +1951,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;
@@ -1967,8 +1967,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++;
@@ -1986,17 +1986,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)
diff --git a/gst/avi/gstavisubtitle.c b/gst/avi/gstavisubtitle.c
index ad1cd9062..d7b894627 100644
--- a/gst/avi/gstavisubtitle.c
+++ b/gst/avi/gstavisubtitle.c
@@ -75,14 +75,15 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
);
static void gst_avi_subtitle_title_tag (GstAviSubtitle * sub, gchar * title);
-static GstFlowReturn gst_avi_subtitle_chain (GstPad * pad, GstBuffer * buffer);
+static GstFlowReturn gst_avi_subtitle_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
static GstStateChangeReturn gst_avi_subtitle_change_state (GstElement * element,
GstStateChange transition);
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 +97,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 +126,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 +139,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 +147,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;
}
@@ -165,24 +176,20 @@ gst_avi_subtitle_extract_file (GstAviSubtitle * sub, GstBuffer * buffer,
static void
gst_avi_subtitle_title_tag (GstAviSubtitle * sub, gchar * title)
{
- GstTagList *temp_list = gst_tag_list_new ();
-
- gst_tag_list_add (temp_list, GST_TAG_MERGE_APPEND, GST_TAG_TITLE, title,
- NULL);
- gst_pad_push_event (sub->src, gst_event_new_tag (temp_list));
+ gst_pad_push_event (sub->src,
+ gst_event_new_tag (gst_tag_list_new (GST_TAG_TITLE, title, NULL)));
}
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 +229,23 @@ 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));
+ ("name doesn't fit in buffer (%" G_GSIZE_FORMAT " < %d)", size,
+ 17 + name_length));
+ gst_buffer_unmap (buf, data, size);
return GST_FLOW_ERROR;
}
wrong_fixed_word_2:
@@ -241,27 +253,30 @@ 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:
{
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
- ("buffer size is wrong: need %d bytes, have %d bytes",
+ ("buffer size is wrong: need %d bytes, have %" G_GSIZE_FORMAT " 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;
}
}
static GstFlowReturn
-gst_avi_subtitle_chain (GstPad * pad, GstBuffer * buffer)
+gst_avi_subtitle_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
- GstAviSubtitle *sub = GST_AVI_SUBTITLE (GST_PAD_PARENT (pad));
+ GstAviSubtitle *sub = GST_AVI_SUBTITLE (parent);
GstFlowReturn ret;
if (sub->subfile != NULL) {
@@ -302,35 +317,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_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &src_template);
-
- gst_element_class_set_details_simple (element_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);
+
+ 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,
+ "Avi subtitle parser", "Codec/Parser/Subtitle",
+ "Parse avi subtitle stream", "Thijs Vermeir <thijsvermeir@gmail.com>");
}
static void
-gst_avi_subtitle_init (GstAviSubtitle * self, GstAviSubtitleClass * klass)
+gst_avi_subtitle_init (GstAviSubtitle * self)
{
GstCaps *caps;
diff --git a/gst/cutter/gstcutter.c b/gst/cutter/gstcutter.c
index 72b90db12..c1d7c47f1 100644
--- a/gst/cutter/gstcutter.c
+++ b/gst/cutter/gstcutter.c
@@ -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,27 @@ 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 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_static_pad_template (element_class,
- &cutter_src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &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 gboolean gst_cutter_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static GstFlowReturn gst_cutter_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
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 +141,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 +177,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 +224,105 @@ 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, GstObject * parent, GstEvent * event)
+{
+ gboolean ret;
+ GstCutter *filter;
+
+ filter = GST_CUTTER (parent);
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ ret = gst_cutter_setcaps (filter, caps);
+ gst_event_unref (event);
+ break;
+ }
+ default:
+ ret = gst_pad_event_default (pad, parent, event);
+ break;
+ }
+ return ret;
+}
static GstFlowReturn
-gst_cutter_chain (GstPad * pad, GstBuffer * buf)
+gst_cutter_chain (GstPad * pad, GstObject * parent, 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 */
+ GstClockTime duration;
- 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);
+ filter = GST_CUTTER (parent);
- 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 (GST_AUDIO_INFO_FORMAT (&filter->info) == GST_AUDIO_FORMAT_UNKNOWN)
+ goto not_negotiated;
- if (!filter->have_caps) {
- if (!(gst_cutter_get_caps (pad, filter)))
- return GST_FLOW_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 +351,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 +366,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);
+ ret = gst_pad_push (filter->srcpad, buf);
- return GST_FLOW_OK;
-}
+ 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)
diff --git a/gst/cutter/gstcutter.h b/gst/cutter/gstcutter.h
index d64c30174..47c1750db 100644
--- a/gst/cutter/gstcutter.h
+++ b/gst/cutter/gstcutter.h
@@ -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
diff --git a/gst/debugutils/Makefile.am b/gst/debugutils/Makefile.am
index 7f3edf0ad..4361795f9 100644
--- a/gst/debugutils/Makefile.am
+++ b/gst/debugutils/Makefile.am
@@ -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)
diff --git a/gst/debugutils/breakmydata.c b/gst/debugutils/breakmydata.c
index d04256a4c..0c790f3cd 100644
--- a/gst/debugutils/breakmydata.c
+++ b/gst/debugutils/breakmydata.c
@@ -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_static_pad_template (gstelement_class,
- &bmd_sink_template);
- gst_element_class_add_static_pad_template (gstelement_class,
- &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,11 +234,11 @@ 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 %"
- G_GUINT64_FORMAT "", buf, size, GST_BUFFER_TIMESTAMP (buf),
+ "got buffer %p (size %" G_GSIZE_FORMAT ", timestamp %" G_GUINT64_FORMAT
+ ", offset %" G_GUINT64_FORMAT "", buf, size, GST_BUFFER_TIMESTAMP (buf),
GST_BUFFER_OFFSET (buf));
for (; i < size; i++) {
@@ -254,14 +250,16 @@ gst_break_my_data_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
} else {
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;
+ GST_INFO_OBJECT (bmd,
+ "changing byte %" G_GSIZE_FORMAT " from 0x%02X to 0x%02X", i,
+ (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);
diff --git a/gst/debugutils/cpureport.c b/gst/debugutils/cpureport.c
index b2b6808d7..8ddaf8313 100644
--- a/gst/debugutils/cpureport.c
+++ b/gst/debugutils/cpureport.c
@@ -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_static_pad_template (element_class,
- &cpu_report_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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);
diff --git a/gst/debugutils/efence.c b/gst/debugutils/efence.c
index a26b31f28..9aa9d2d21 100644
--- a/gst/debugutils/efence.c
+++ b/gst/debugutils/efence.c
@@ -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)
@@ -134,10 +148,10 @@ gst_efence_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class,
- &gst_efence_sink_factory);
- gst_element_class_add_static_pad_template (element_class,
- &gst_efence_src_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_efence_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_efence_src_factory));
gst_element_class_set_details_simple (element_class, "Electric Fence",
"Testing",
"This element converts a stream of normal GStreamer buffers into a "
@@ -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;
-}
diff --git a/gst/debugutils/gstcapsdebug.c b/gst/debugutils/gstcapsdebug.c
index 6bdc109b8..6a15d3fed 100644
--- a/gst/debugutils/gstcapsdebug.c
+++ b/gst/debugutils/gstcapsdebug.c
@@ -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_static_pad_template (element_class,
- &gst_caps_debug_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 =
diff --git a/gst/debugutils/gstcapssetter.c b/gst/debugutils/gstcapssetter.c
index 061da4786..977a502b4 100644
--- a/gst/debugutils/gstcapssetter.c
+++ b/gst/debugutils/gstcapssetter.c
@@ -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_static_pad_template (element_class,
- &gst_caps_setter_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
diff --git a/gst/debugutils/gstdebug.c b/gst/debugutils/gstdebug.c
index de5728503..dacad5ac1 100644
--- a/gst/debugutils/gstdebug.c
+++ b/gst/debugutils/gstdebug.c
@@ -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 ()))
diff --git a/gst/debugutils/gstnavigationtest.c b/gst/debugutils/gstnavigationtest.c
index 6f6daea6f..7ee945e25 100644
--- a/gst/debugutils/gstnavigationtest.c
+++ b/gst/debugutils/gstnavigationtest.c
@@ -39,25 +39,26 @@ 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;
+#define gst_navigationtest_parent_class parent_class
+G_DEFINE_TYPE (GstNavigationtest, gst_navigationtest, GST_TYPE_VIDEO_FILTER);
static gboolean
-gst_navigationtest_handle_src_event (GstPad * pad, GstEvent * event)
+gst_navigationtest_src_event (GstBaseTransform * trans, GstEvent * event)
{
GstNavigationtest *navtest;
const gchar *type;
- navtest = GST_NAVIGATIONTEST (GST_PAD_PARENT (pad));
+ navtest = GST_NAVIGATIONTEST (trans);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NAVIGATION:
@@ -65,8 +66,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")) {
@@ -100,7 +101,7 @@ gst_navigationtest_handle_src_event (GstPad * pad, GstEvent * event)
default:
break;
}
- return gst_pad_event_default (pad, event);
+ return GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans, event);
}
/* Useful macros */
@@ -116,7 +117,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;
@@ -131,8 +132,9 @@ gst_navigationtest_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
gst_structure_get_int (structure, "height", &height)) {
*size = GST_VIDEO_I420_SIZE (width, height);
ret = TRUE;
- GST_DEBUG_OBJECT (navtest, "our frame size is %d bytes (%dx%d)", *size,
- width, height);
+ GST_DEBUG_OBJECT (navtest,
+ "our frame size is %" G_GSIZE_FORMAT " bytes (%dx%d)", *size, width,
+ height);
}
return ret;
@@ -143,31 +145,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 +182,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 +220,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;
+
+ if (!gst_video_frame_map (&in_frame, &navtest->info, in, GST_MAP_READ))
+ goto invalid_in;
- /* 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 (&out_frame, &navtest->info, out, GST_MAP_WRITE))
+ goto invalid_out;
- memcpy (GST_BUFFER_DATA (out), GST_BUFFER_DATA (in),
- MIN (GST_BUFFER_SIZE (in), GST_BUFFER_SIZE (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
@@ -262,23 +291,7 @@ gst_navigationtest_change_state (GstElement * element,
}
static void
-gst_navigationtest_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details_simple (element_class, "Video navigation test",
- "Filter/Effect/Video",
- "Handle navigation events showing a black square following mouse pointer",
- "David Schleef <ds@schleef.org>");
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_navigationtest_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_navigationtest_src_template);
-}
-
-static void
-gst_navigationtest_class_init (gpointer klass, gpointer class_data)
+gst_navigationtest_class_init (GstNavigationtestClass * klass)
{
GstElementClass *element_class;
GstBaseTransformClass *trans_class;
@@ -291,48 +304,28 @@ gst_navigationtest_class_init (gpointer klass, gpointer class_data)
element_class->change_state =
GST_DEBUG_FUNCPTR (gst_navigationtest_change_state);
+ gst_element_class_set_details_simple (element_class, "Video navigation test",
+ "Filter/Effect/Video",
+ "Handle navigation events showing a black square following mouse pointer",
+ "David Schleef <ds@schleef.org>");
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_navigationtest_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_navigationtest_src_template));
+
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_navigationtest_set_caps);
trans_class->get_unit_size =
GST_DEBUG_FUNCPTR (gst_navigationtest_get_unit_size);
trans_class->transform = GST_DEBUG_FUNCPTR (gst_navigationtest_transform);
+ trans_class->src_event = GST_DEBUG_FUNCPTR (gst_navigationtest_src_event);
}
static void
-gst_navigationtest_init (GTypeInstance * instance, gpointer g_class)
+gst_navigationtest_init (GstNavigationtest * navtest)
{
- GstNavigationtest *navtest = GST_NAVIGATIONTEST (instance);
- GstBaseTransform *btrans = GST_BASE_TRANSFORM (instance);
-
- gst_pad_set_event_function (btrans->srcpad,
- GST_DEBUG_FUNCPTR (gst_navigationtest_handle_src_event));
-
navtest->x = -1;
navtest->y = -1;
- g_value_init (&navtest->framerate, GST_TYPE_FRACTION);
-}
-
-GType
-gst_navigationtest_get_type (void)
-{
- static GType navigationtest_type = 0;
-
- if (!navigationtest_type) {
- static const GTypeInfo navigationtest_info = {
- sizeof (GstNavigationtestClass),
- gst_navigationtest_base_init,
- NULL,
- gst_navigationtest_class_init,
- NULL,
- NULL,
- sizeof (GstNavigationtest),
- 0,
- gst_navigationtest_init,
- };
-
- navigationtest_type = g_type_register_static (GST_TYPE_VIDEO_FILTER,
- "GstNavigationtest", &navigationtest_info, 0);
- }
- return navigationtest_type;
}
static gboolean
diff --git a/gst/debugutils/gstnavigationtest.h b/gst/debugutils/gstnavigationtest.h
index efdbb228d..6ff9ef45d 100644
--- a/gst/debugutils/gstnavigationtest.h
+++ b/gst/debugutils/gstnavigationtest.h
@@ -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;
};
diff --git a/gst/debugutils/gstnavseek.c b/gst/debugutils/gstnavseek.c
index 4ee934380..13f2b7284 100644
--- a/gst/debugutils/gstnavseek.c
+++ b/gst/debugutils/gstnavseek.c
@@ -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_static_pad_template (element_class,
- &navseek_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
@@ -229,17 +223,17 @@ gst_navseek_toggle_play_pause (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;
@@ -288,18 +282,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;
}
@@ -341,7 +331,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);
@@ -355,7 +345,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
diff --git a/gst/debugutils/gstpushfilesrc.c b/gst/debugutils/gstpushfilesrc.c
index 012ad9f21..de27e238d 100644
--- a/gst/debugutils/gstpushfilesrc.c
+++ b/gst/debugutils/gstpushfilesrc.c
@@ -55,37 +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_static_pad_template (element_class, &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)
@@ -108,20 +82,46 @@ 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, GstObject * parent,
+ GstQuery * query)
{
- return FALSE;
+ gboolean res;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_SCHEDULING:
+ gst_query_set_scheduling (query, GST_SCHEDULING_FLAG_SEEKABLE, 1, -1, 0);
+ gst_query_add_scheduling_mode (query, GST_PAD_MODE_PUSH);
+ res = TRUE;
+ break;
+ default:
+ res = gst_proxy_pad_query_default (pad, parent, 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) {
@@ -133,8 +133,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);
}
@@ -143,40 +143,52 @@ 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)
+static const gchar *const *
+gst_push_file_src_uri_get_protocols (GType type)
{
- static gchar *protocols[] = { (char *) "pushfile", NULL };
+ static const gchar *protocols[] = { "pushfile", NULL };
return protocols;
}
-static const gchar *
+static gchar *
gst_push_file_src_uri_get_uri (GstURIHandler * handler)
{
GstPushFileSrc *src = GST_PUSH_FILE_SRC (handler);
+ gchar *fileuri, *pushfileuri;
if (src->filesrc == NULL)
return NULL;
- return gst_uri_handler_get_uri (GST_URI_HANDLER (src->filesrc));
+ fileuri = gst_uri_handler_get_uri (GST_URI_HANDLER (src->filesrc));;
+ if (fileuri == NULL)
+ return NULL;
+ pushfileuri = g_strconcat ("push", fileuri, NULL);
+ g_free (fileuri);
+
+ return pushfileuri;
}
static gboolean
-gst_push_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_push_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
GstPushFileSrc *src = GST_PUSH_FILE_SRC (handler);
- if (src->filesrc == NULL || !g_str_has_prefix (uri, "pushfile://"))
+ if (src->filesrc == NULL) {
+ g_set_error_literal (error, GST_URI_ERROR, GST_URI_ERROR_BAD_STATE,
+ "Could not create file source element");
return FALSE;
+ }
/* skip 'push' bit */
- return gst_uri_handler_set_uri (GST_URI_HANDLER (src->filesrc), uri + 4);
+ return gst_uri_handler_set_uri (GST_URI_HANDLER (src->filesrc), uri + 4,
+ error);
}
static void
diff --git a/gst/debugutils/gsttaginject.c b/gst/debugutils/gsttaginject.c
index 20a88a5a7..f3d40d26e 100644
--- a/gst/debugutils/gsttaginject.c
+++ b/gst/debugutils/gsttaginject.c
@@ -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_static_pad_template (gstelement_class,
- &srctemplate);
- gst_element_class_add_static_pad_template (gstelement_class,
- &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)
{
GstBaseTransform *trans = GST_BASE_TRANSFORM (self);
@@ -151,8 +147,8 @@ gst_tag_inject_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
/* send tags */
if (self->tags && !gst_tag_list_is_empty (self->tags)) {
GST_DEBUG ("tag event :%" GST_PTR_FORMAT, self->tags);
- gst_element_found_tags (GST_ELEMENT (trans),
- gst_tag_list_copy (self->tags));
+ gst_pad_push_event (GST_BASE_TRANSFORM_SRC_PAD (trans),
+ gst_event_new_tag (gst_tag_list_copy (self->tags)));
}
}
@@ -169,7 +165,7 @@ gst_tag_inject_set_property (GObject * object, guint prop_id,
case PROP_TAGS:{
gchar *structure =
g_strdup_printf ("taglist,%s", g_value_get_string (value));
- if (!(self->tags = gst_structure_from_string (structure, NULL))) {
+ if (!(self->tags = gst_tag_list_new_from_string (structure))) {
GST_WARNING ("unparsable taglist = '%s'", structure);
}
diff --git a/gst/debugutils/progressreport.c b/gst/debugutils/progressreport.c
index 2ef30a1e2..82f4d7d95 100644
--- a/gst/debugutils/progressreport.c
+++ b/gst/debugutils/progressreport.c
@@ -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_static_pad_template (element_class,
- &progress_report_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_peer_query_position (sink_pad, format, &cur) ||
+ !gst_pad_peer_query_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
diff --git a/gst/debugutils/rndbuffersize.c b/gst/debugutils/rndbuffersize.c
index e6ddd1f47..4967d16e6 100644
--- a/gst/debugutils/rndbuffersize.c
+++ b/gst/debugutils/rndbuffersize.c
@@ -85,37 +85,16 @@ static void gst_rnd_buffer_size_set_property (GObject * object, guint prop_id,
static void gst_rnd_buffer_size_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static gboolean gst_rnd_buffer_size_activate (GstPad * pad);
-static gboolean gst_rnd_buffer_size_activate_pull (GstPad * pad,
- gboolean active);
+static gboolean gst_rnd_buffer_size_activate (GstPad * pad, GstObject * parent);
+static gboolean gst_rnd_buffer_size_activate_mode (GstPad * pad,
+ GstObject * parent, GstPadMode mode, gboolean active);
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);
-
-
-static void
-gst_rnd_buffer_size_base_init (gpointer g_class)
-{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_static_pad_template (gstelement_class,
- &sink_template);
- gst_element_class_add_static_pad_template (gstelement_class,
- &src_template);
-
- gst_element_class_set_details_simple (gstelement_class, "Random buffer size",
- "Testing", "pull random sized buffers",
- "Stefan Kost <stefan.kost@nokia.com>");
-}
-
+#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_class_init (GstRndBufferSizeClass * klass)
@@ -123,10 +102,22 @@ gst_rnd_buffer_size_class_init (GstRndBufferSizeClass * klass)
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));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&src_template));
+
+ gst_element_class_set_details_simple (gstelement_class, "Random buffer size",
+ "Testing", "pull random sized buffers",
+ "Stefan Kost <stefan.kost@nokia.com>");
+
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_change_state);
@@ -149,14 +140,13 @@ 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,
GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate));
- gst_pad_set_activatepull_function (self->sinkpad,
- GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate_pull));
+ gst_pad_set_activatemode_function (self->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate_mode));
gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
self->srcpad = gst_pad_new_from_static_template (&src_template, "src");
@@ -225,30 +215,60 @@ gst_rnd_buffer_size_get_property (GObject * object, guint prop_id,
static gboolean
-gst_rnd_buffer_size_activate (GstPad * pad)
+gst_rnd_buffer_size_activate (GstPad * pad, GstObject * parent)
{
- 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;
+ }
+
+ pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL);
+ gst_query_unref (query);
+
+ if (!pull_mode)
+ goto no_pull;
+
+ GST_DEBUG_OBJECT (pad, "activating pull");
+ return gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE);
+
+ /* ERRORS */
+no_pull:
+ {
+ GST_DEBUG_OBJECT (pad, "pull mode not supported");
return FALSE;
}
}
static gboolean
-gst_rnd_buffer_size_activate_pull (GstPad * pad, gboolean active)
+gst_rnd_buffer_size_activate_mode (GstPad * pad, GstObject * parent,
+ GstPadMode mode, gboolean active)
{
- GstRndBufferSize *self = GST_RND_BUFFER_SIZE (GST_OBJECT_PARENT (pad));
-
- if (active) {
- GST_INFO_OBJECT (self, "starting pull");
- return gst_pad_start_task (pad, (GstTaskFunction) gst_rnd_buffer_size_loop,
- self);
- } else {
- GST_INFO_OBJECT (self, "stopping pull");
- return gst_pad_stop_task (pad);
+ gboolean res;
+ GstRndBufferSize *self = GST_RND_BUFFER_SIZE (parent);
+
+ switch (mode) {
+ case GST_PAD_MODE_PULL:
+ if (active) {
+ GST_INFO_OBJECT (self, "starting pull");
+ res =
+ gst_pad_start_task (pad, (GstTaskFunction) gst_rnd_buffer_size_loop,
+ self);
+ } else {
+ GST_INFO_OBJECT (self, "stopping pull");
+ res = gst_pad_stop_task (pad);
+ }
+ break;
+ default:
+ res = FALSE;
+ break;
}
+ return res;
}
@@ -257,7 +277,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 +296,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);
diff --git a/gst/debugutils/testplugin.c b/gst/debugutils/testplugin.c
index df0be9310..e8c1d1e69 100644
--- a/gst/debugutils/testplugin.c
+++ b/gst/debugutils/testplugin.c
@@ -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_static_pad_template (gstelement_class,
- &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;
@@ -186,7 +180,6 @@ gst_test_sink_event (GstBaseSink * basesink, GstEvent * event)
{
GstTestClass *klass = GST_TEST_GET_CLASS (basesink);
GstTest *test = GST_TEST (basesink);
- gboolean ret = FALSE;
switch (GST_EVENT_TYPE (event)) {
/*
@@ -223,14 +216,13 @@ gst_test_sink_event (GstBaseSink * basesink, GstEvent * event)
}
}
g_object_thaw_notify (G_OBJECT (test));
- ret = TRUE;
break;
}
default:
break;
}
- return ret;
+ return GST_BASE_SINK_CLASS (parent_class)->event (basesink, event);
}
static GstFlowReturn
diff --git a/gst/debugutils/tests.c b/gst/debugutils/tests.c
index 93afd0eb4..9a20f7487 100644
--- a/gst/debugutils/tests.c
+++ b/gst/debugutils/tests.c
@@ -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
diff --git a/gst/deinterlace/gstdeinterlace.c b/gst/deinterlace/gstdeinterlace.c
index 6e71bce22..e1210d1f7 100644
--- a/gst/deinterlace/gstdeinterlace.c
+++ b/gst/deinterlace/gstdeinterlace.c
@@ -450,8 +450,10 @@ gst_deinterlace_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class, &src_templ);
- gst_element_class_add_static_pad_template (element_class, &sink_templ);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_templ));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_templ));
gst_element_class_set_details_simple (element_class,
"Deinterlacer",
diff --git a/gst/effectv/Makefile.am b/gst/effectv/Makefile.am
index 2fe3152b1..fb5d3f210 100644
--- a/gst/effectv/Makefile.am
+++ b/gst/effectv/Makefile.am
@@ -6,13 +6,11 @@ libgsteffectv_la_SOURCES = \
gstradioac.c gststreak.c gstripple.c
libgsteffectv_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_CONTROLLER_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS) \
-I$(top_srcdir)/gst/videofilter
libgsteffectv_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) -lgstvideo-@GST_MAJORMINOR@ \
- $(GST_CONTROLLER_LIBS) \
$(GST_BASE_LIBS) \
$(GST_LIBS) \
$(LIBM)
diff --git a/gst/effectv/gstaging.c b/gst/effectv/gstaging.c
index 0661d02c7..d3c9da5ad 100644
--- a/gst/effectv/gstaging.c
+++ b/gst/effectv/gstaging.c
@@ -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,9 +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 };
static const gint dy[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
@@ -69,9 +66,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 +85,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 +325,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 =
@@ -342,12 +339,22 @@ gst_agingtv_transform (GstBaseTransform * trans, GstBuffer * in,
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (agingtv), stream_time);
+ gst_object_sync_values (GST_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 +363,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;
-}
+ gst_video_frame_unmap (&in_frame);
+ gst_video_frame_unmap (&out_frame);
-static void
-gst_agingtv_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- 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_static_pad_template (element_class,
- &gst_agingtv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +420,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;
diff --git a/gst/effectv/gstaging.h b/gst/effectv/gstaging.h
index 0ac6c8e98..ec02f6672 100644
--- a/gst/effectv/gstaging.h
+++ b/gst/effectv/gstaging.h
@@ -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;
diff --git a/gst/effectv/gstdice.c b/gst/effectv/gstdice.c
index a29714764..ca803b059 100644
--- a/gst/effectv/gstdice.c
+++ b/gst/effectv/gstdice.c
@@ -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,9 +53,6 @@
#include "gstdice.h"
#include "gsteffectv.h"
-#include <gst/video/video.h>
-#include <gst/controller/gstcontroller.h>
-
#define DEFAULT_CUBE_BITS 4
#define MAX_CUBE_BITS 5
#define MIN_CUBE_BITS 0
@@ -68,24 +65,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 +95,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);
+
+ filter->info = info;
+
+ return TRUE;
- return ret;
+ /* 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);
@@ -140,10 +138,16 @@ gst_dicetv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (filter), stream_time);
+ gst_object_sync_values (GST_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 +158,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 +172,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 +183,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 +194,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 +211,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;
+
+ width = GST_VIDEO_INFO_WIDTH (&filter->info);
+ height = GST_VIDEO_INFO_HEIGHT (&filter->info);
- if (filter->height <= 0 || filter->width <= 0)
+ 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 +291,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_static_pad_template (element_class,
- &gst_dicetv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +306,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;
diff --git a/gst/effectv/gstdice.h b/gst/effectv/gstdice.h
index 856e995db..0a5c3e613 100644
--- a/gst/effectv/gstdice.h
+++ b/gst/effectv/gstdice.h
@@ -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;
diff --git a/gst/effectv/gstedge.c b/gst/effectv/gstedge.c
index e41e99fbf..5ba182e45 100644
--- a/gst/effectv/gstedge.c
+++ b/gst/effectv/gstedge.c
@@ -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>
*/
@@ -46,14 +46,13 @@
#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;
@@ -202,7 +212,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;
}
@@ -230,34 +239,29 @@ gst_edgetv_finalize (GObject * object)
}
static void
-gst_edgetv_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details_simple (element_class, "EdgeTV effect",
- "Filter/Effect/Video",
- "Apply edge detect on video", "Wim Taymans <wim.taymans@chello.be>");
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_edgetv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_edgetv_src_template);
-}
-
-static void
gst_edgetv_class_init (GstEdgeTVClass * klass)
{
- GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
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 (gstelement_class, "EdgeTV effect",
+ "Filter/Effect/Video",
+ "Apply edge detect on video", "Wim Taymans <wim.taymans@chello.be>");
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_edgetv_sink_template));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_edgetv_src_template));
+
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_edgetv_set_caps);
trans_class->transform = GST_DEBUG_FUNCPTR (gst_edgetv_transform);
trans_class->start = GST_DEBUG_FUNCPTR (gst_edgetv_start);
}
static void
-gst_edgetv_init (GstEdgeTV * edgetv, GstEdgeTVClass * klass)
+gst_edgetv_init (GstEdgeTV * edgetv)
{
}
diff --git a/gst/effectv/gstedge.h b/gst/effectv/gstedge.h
index 172d5978f..469dc68c0 100644
--- a/gst/effectv/gstedge.h
+++ b/gst/effectv/gstedge.h
@@ -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;
diff --git a/gst/effectv/gstop.c b/gst/effectv/gstop.c
index 29f41f6cc..7d89ea1c4 100644
--- a/gst/effectv/gstop.c
+++ b/gst/effectv/gstop.c
@@ -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>
*/
@@ -50,7 +50,6 @@
#include "gsteffectv.h"
#include <gst/video/video.h>
-#include <gst/controller/gstcontroller.h>
enum
{
@@ -95,12 +94,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 +203,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;
@@ -218,14 +218,23 @@ gst_optv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
GST_TIME_ARGS (timestamp));
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);
+ gst_object_sync_values (GST_OBJECT (filter), stream_time);
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 +255,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 +266,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 +290,36 @@ gst_optv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
GstCaps * outcaps)
{
GstOpTV *filter = GST_OPTV (btrans);
- GstStructure *structure;
- gboolean ret = FALSE;
-
- structure = gst_caps_get_structure (incaps, 0);
+ GstVideoInfo info;
+ gint i, width, height;
- 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 ret;
+ return TRUE;
+
+ /* ERRORS */
+invalid_caps:
+ {
+ GST_DEBUG_OBJECT (filter, "invalid caps received");
+ return FALSE;
+ }
}
static gboolean
@@ -374,26 +401,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_static_pad_template (element_class,
- &gst_optv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +427,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 +446,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;
diff --git a/gst/effectv/gstop.h b/gst/effectv/gstop.h
index e79460302..d5e0fec85 100644
--- a/gst/effectv/gstop.h
+++ b/gst/effectv/gstop.h
@@ -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;
diff --git a/gst/effectv/gstquark.c b/gst/effectv/gstquark.c
index 59f4f2cc6..4ae7ecb19 100644
--- a/gst/effectv/gstquark.c
+++ b/gst/effectv/gstquark.c
@@ -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>
*/
@@ -48,9 +48,6 @@
#include "gstquark.h"
#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. */
#define PLANES 16
@@ -61,25 +58,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 +82,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);
- return ret;
+ gst_quarktv_planetable_clear (filter);
+ filter->area = width * height;
+
+ return TRUE;
+
+ /* ERRORS */
+invalid_caps:
+ {
+ GST_DEBUG_OBJECT (filter, "invalid caps received");
+ return FALSE;
+ }
}
static GstFlowReturn
@@ -111,10 +113,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 =
@@ -124,15 +126,22 @@ gst_quarktv_transform (GstBaseTransform * trans, GstBuffer * in,
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (timestamp))
- gst_object_sync_values (G_OBJECT (filter), timestamp);
+ gst_object_sync_values (GST_OBJECT (filter), timestamp);
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 +157,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 +169,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 +293,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_static_pad_template (element_class,
- &gst_quarktv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +309,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;
diff --git a/gst/effectv/gstquark.h b/gst/effectv/gstquark.h
index 79a6107c0..e3fd17d9b 100644
--- a/gst/effectv/gstquark.h
+++ b/gst/effectv/gstquark.h
@@ -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;
diff --git a/gst/effectv/gstradioac.c b/gst/effectv/gstradioac.c
index f417c93d3..57b6d5db3 100644
--- a/gst/effectv/gstradioac.c
+++ b/gst/effectv/gstradioac.c
@@ -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,9 +55,6 @@
#include "gstradioac.h"
#include "gsteffectv.h"
-#include <gst/video/video.h>
-#include <gst/controller/gstcontroller.h>
-
enum
{
RADIOAC_NORMAL = 0,
@@ -136,13 +133,13 @@ enum
static guint32 palettes[COLORS * PATTERN];
static gint swap_tab[] = { 2, 1, 0, 3 };
-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 "; " GST_VIDEO_CAPS_BGRx
+#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ RGBx, BGRx }")
#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_radioactv_src_template =
@@ -238,7 +235,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--) {
@@ -323,9 +320,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;
@@ -338,20 +335,29 @@ gst_radioactv_transform (GstBaseTransform * trans, GstBuffer * in,
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (filter), stream_time);
+ gst_object_sync_values (GST_OBJECT (filter), stream_time);
+
+ if (!gst_video_frame_map (&in_frame, &filter->info, in, GST_MAP_READ))
+ goto invalid_in;
- src = (guint32 *) GST_BUFFER_DATA (in);
- dest = (guint32 *) GST_BUFFER_DATA (out);
+ 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);
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- if (filter->format == GST_VIDEO_FORMAT_RGBx) {
+ if (GST_VIDEO_FRAME_FORMAT (&in_frame) == GST_VIDEO_FORMAT_RGBx) {
palette = &palettes[COLORS * filter->color];
} else {
palette = &palettes[COLORS * swap_tab[filter->color]];
}
#else
- if (filter->format == GST_VIDEO_FORMAT_xBGR) {
+ if (GST_VIDEO_FRAME_FORMAT (&in_frame) == GST_VIDEO_FORMAT_xBGR) {
palette = &palettes[COLORS * filter->color];
} else {
palette = &palettes[COLORS * swap_tab[filter->color]];
@@ -366,7 +372,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;
@@ -374,11 +380,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);
}
}
}
@@ -388,7 +394,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++;
}
@@ -412,7 +418,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
@@ -420,55 +442,67 @@ gst_radioactv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
GstCaps * outcaps)
{
GstRadioacTV *filter = GST_RADIOACTV (btrans);
- gboolean ret = FALSE;
+ GstVideoInfo info;
+ gint width, height;
- GST_OBJECT_LOCK (filter);
+ if (!gst_video_info_from_caps (&info, incaps))
+ goto invalid_caps;
- if (gst_video_format_parse_caps (incaps, &filter->format, &filter->width,
- &filter->height)) {
- filter->buf_width_blocks = filter->width / 32;
- if (filter->buf_width_blocks > 255)
- goto out;
+ filter->info = info;
- 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;
+ width = GST_VIDEO_INFO_WIDTH (&info);
+ height = GST_VIDEO_INFO_HEIGHT (&info);
- if (filter->blurzoombuf)
- g_free (filter->blurzoombuf);
- filter->blurzoombuf = g_new0 (guint8, filter->buf_area * 2);
+ filter->buf_width_blocks = width / 32;
+ if (filter->buf_width_blocks > 255)
+ goto too_wide;
- if (filter->blurzoomx)
- g_free (filter->blurzoomx);
- filter->blurzoomx = g_new0 (gint, filter->buf_width);
+ 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->blurzoomy)
- g_free (filter->blurzoomy);
- filter->blurzoomy = g_new0 (gint, filter->buf_height);
+ if (filter->blurzoombuf)
+ g_free (filter->blurzoombuf);
+ filter->blurzoombuf = g_new0 (guint8, filter->buf_area * 2);
- if (filter->snapframe)
- g_free (filter->snapframe);
- filter->snapframe = g_new (guint32, filter->width * filter->height);
+ if (filter->blurzoomx)
+ g_free (filter->blurzoomx);
+ filter->blurzoomx = g_new0 (gint, filter->buf_width);
- if (filter->diff)
- g_free (filter->diff);
- filter->diff = g_new (guint8, filter->width * filter->height);
+ if (filter->blurzoomy)
+ g_free (filter->blurzoomy);
+ filter->blurzoomy = g_new0 (gint, filter->buf_height);
- if (filter->background)
- g_free (filter->background);
- filter->background = g_new0 (gint16, filter->width * filter->height);
+ if (filter->snapframe)
+ g_free (filter->snapframe);
+ filter->snapframe = g_new (guint32, width * height);
- setTable (filter);
+ if (filter->diff)
+ g_free (filter->diff);
+ filter->diff = g_new (guint8, width * height);
- ret = TRUE;
- }
-out:
- GST_OBJECT_UNLOCK (filter);
+ if (filter->background)
+ g_free (filter->background);
+ filter->background = g_new0 (gint16, width * height);
+
+ setTable (filter);
- return ret;
+ 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
@@ -568,26 +602,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_static_pad_template (element_class,
- &gst_radioactv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
@@ -615,6 +633,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);
@@ -623,7 +652,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;
diff --git a/gst/effectv/gstradioac.h b/gst/effectv/gstradioac.h
index 64a425d11..a7a787a2f 100644
--- a/gst/effectv/gstradioac.h
+++ b/gst/effectv/gstradioac.h
@@ -53,8 +53,7 @@ struct _GstRadioacTV
GstVideoFilter element;
/* < private > */
- gint width, height;
- GstVideoFormat format;
+ GstVideoInfo info;
gint mode;
gint color;
diff --git a/gst/effectv/gstrev.c b/gst/effectv/gstrev.c
index a5cc4ddc8..6dce8877f 100644
--- a/gst/effectv/gstrev.c
+++ b/gst/effectv/gstrev.c
@@ -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,9 +64,6 @@
#include "gstrev.h"
-#include <gst/video/video.h>
-#include <gst/controller/gstcontroller.h>
-
#define THE_COLOR 0xffffffff
enum
@@ -77,12 +74,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 +102,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 ret;
+ return TRUE;
+
+ /* ERRORS */
+invalid_caps:
+ {
+ GST_DEBUG_OBJECT (filter, "invalid caps received");
+ return FALSE;
+ }
}
static GstFlowReturn
@@ -124,12 +124,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 =
@@ -139,25 +139,33 @@ gst_revtv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (filter), stream_time);
+ gst_object_sync_values (GST_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 +175,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 +247,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_static_pad_template (element_class,
- &gst_revtv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +268,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;
diff --git a/gst/effectv/gstrev.h b/gst/effectv/gstrev.h
index 867f49ac4..deb8dd13f 100644
--- a/gst/effectv/gstrev.h
+++ b/gst/effectv/gstrev.h
@@ -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;
diff --git a/gst/effectv/gstripple.c b/gst/effectv/gstripple.c
index 49ed75ce2..170fd3a65 100644
--- a/gst/effectv/gstripple.c
+++ b/gst/effectv/gstripple.c
@@ -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,9 +52,6 @@
#include "gstripple.h"
#include "gsteffectv.h"
-#include <gst/video/video.h>
-#include <gst/controller/gstcontroller.h>
-
#define DEFAULT_MODE 0
enum
@@ -84,24 +81,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 +139,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 +179,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 +309,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, o_dx;
gint h, v;
@@ -327,10 +326,16 @@ gst_rippletv_transform (GstBaseTransform * trans, GstBuffer * in,
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (filter), stream_time);
+ gst_object_sync_values (GST_OBJECT (filter), stream_time);
+
+ 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 = (guint32 *) GST_BUFFER_DATA (in);
- dest = (guint32 *) GST_BUFFER_DATA (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 */
@@ -341,8 +346,8 @@ gst_rippletv_transform (GstBaseTransform * trans, GstBuffer * in,
m_w = filter->map_w;
m_h = filter->map_h;
- v_w = filter->width;
- v_h = filter->height;
+ v_w = GST_VIDEO_FRAME_WIDTH (&in_frame);
+ v_h = GST_VIDEO_FRAME_HEIGHT (&in_frame);
/* simulate surface wave */
@@ -436,7 +441,24 @@ gst_rippletv_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
@@ -444,45 +466,52 @@ 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);
- /* we over allocate the buffers, as the render code does not handle clipping
- * very well */
- if (filter->map)
- g_free (filter->map);
- filter->map = g_new0 (gint, (1 + 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;
+ /* we over allocate the buffers, as the render code does not handle clipping
+ * very well */
+ if (filter->map)
+ g_free (filter->map);
+ filter->map = g_new0 (gint, (1 + filter->map_h) * filter->map_w * 3);
- if (filter->vtable)
- g_free (filter->vtable);
- filter->vtable = g_new0 (gint8, (1 + 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 + 1));
+ if (filter->vtable)
+ g_free (filter->vtable);
+ filter->vtable = g_new0 (gint8, (1 + filter->map_h) * filter->map_w * 2);
- if (filter->diff)
- g_free (filter->diff);
- filter->diff = g_new0 (guint8, filter->width * (filter->height + 1));
+ if (filter->background)
+ g_free (filter->background);
+ filter->background = g_new0 (gint16, width * (height + 1));
- ret = TRUE;
- }
+ if (filter->diff)
+ g_free (filter->diff);
+ filter->diff = g_new0 (guint8, width * (height + 1));
GST_OBJECT_UNLOCK (filter);
- return ret;
+ return TRUE;
+
+ /* ERRORS */
+invalid_caps:
+ {
+ GST_DEBUG_OBJECT (filter, "invalid caps received");
+ return FALSE;
+ }
}
static gboolean
@@ -567,26 +596,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_static_pad_template (element_class,
- &gst_rippletv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
@@ -604,6 +617,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);
@@ -612,7 +636,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;
diff --git a/gst/effectv/gstripple.h b/gst/effectv/gstripple.h
index 388ba5664..571db51d2 100644
--- a/gst/effectv/gstripple.h
+++ b/gst/effectv/gstripple.h
@@ -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;
diff --git a/gst/effectv/gstshagadelic.c b/gst/effectv/gstshagadelic.c
index f2cb6e7af..6e56430c6 100644
--- a/gst/effectv/gstshagadelic.c
+++ b/gst/effectv/gstshagadelic.c
@@ -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>
*/
@@ -45,21 +45,19 @@
#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)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details_simple (element_class, "ShagadelicTV",
- "Filter/Effect/Video",
- "Oh behave, ShagedelicTV makes images shagadelic!",
- "Wim Taymans <wim.taymans@chello.be>");
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_shagadelictv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_shagadelictv_src_template);
-}
-
-static void
gst_shagadelictv_class_init (GstShagadelicTVClass * klass)
{
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 (gstelement_class, "ShagadelicTV",
+ "Filter/Effect/Video",
+ "Oh behave, ShagedelicTV makes images shagadelic!",
+ "Wim Taymans <wim.taymans@chello.be>");
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_shagadelictv_sink_template));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_shagadelictv_src_template));
+
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;
diff --git a/gst/effectv/gstshagadelic.h b/gst/effectv/gstshagadelic.h
index d44faa7df..b2731a261 100644
--- a/gst/effectv/gstshagadelic.h
+++ b/gst/effectv/gstshagadelic.h
@@ -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;
diff --git a/gst/effectv/gststreak.c b/gst/effectv/gststreak.c
index 3feb1f4a9..9ae451aee 100644
--- a/gst/effectv/gststreak.c
+++ b/gst/effectv/gststreak.c
@@ -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 TRUE;
- return ret;
+ /* 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_static_pad_template (element_class,
- &gst_streaktv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
}
diff --git a/gst/effectv/gststreak.h b/gst/effectv/gststreak.h
index 0e49a002b..fb96cade9 100644
--- a/gst/effectv/gststreak.h
+++ b/gst/effectv/gststreak.h
@@ -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;
diff --git a/gst/effectv/gstvertigo.c b/gst/effectv/gstvertigo.c
index 51b1f9052..592231990 100644
--- a/gst/effectv/gstvertigo.c
+++ b/gst/effectv/gstvertigo.c
@@ -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>
*/
@@ -43,11 +43,8 @@
#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 +55,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 +79,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 TRUE;
- return ret;
+ /* ERRORS */
+invalid_caps:
+ {
+ GST_DEBUG_OBJECT (filter, "invalid caps received");
+ return FALSE;
+ }
}
static void
@@ -113,15 +116,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 +168,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 =
@@ -173,25 +180,35 @@ gst_vertigotv_transform (GstBaseTransform * trans, GstBuffer * in,
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (filter), stream_time);
+ gst_object_sync_values (GST_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 +216,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 +311,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_static_pad_template (element_class,
- &gst_vertigotv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +329,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;
diff --git a/gst/effectv/gstvertigo.h b/gst/effectv/gstvertigo.h
index efc63ecb5..8e03da2e3 100644
--- a/gst/effectv/gstvertigo.h
+++ b/gst/effectv/gstvertigo.h
@@ -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;
diff --git a/gst/effectv/gstwarp.c b/gst/effectv/gstwarp.c
index fff0d4e28..80161a7b1 100644
--- a/gst/effectv/gstwarp.c
+++ b/gst/effectv/gstwarp.c
@@ -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>
*/
@@ -54,33 +54,31 @@
#include <math.h>
#include "gstwarp.h"
-
-#include <gst/video/video.h>
+#include <gst/video/gstvideometa.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,24 +129,14 @@ 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;
float m;
- halfw = filter->width >> 1;
- halfh = filter->height >> 1;
+ halfw = width >> 1;
+ halfh = height >> 1;
distptr = filter->disttable;
@@ -167,18 +156,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);
@@ -189,7 +187,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++) {
@@ -216,15 +213,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
@@ -237,52 +238,67 @@ gst_warptv_start (GstBaseTransform * trans)
return TRUE;
}
-static void
-gst_warptv_finalize (GObject * object)
+static gboolean
+gst_wraptv_decide_allocation (GstBaseTransform * trans, GstQuery * query)
{
- GstWarpTV *warptv = GST_WARPTV (object);
+ GstBufferPool *pool = NULL;
+ guint size, min, max, prefix, alignment;
- g_free (warptv->offstable);
- warptv->offstable = NULL;
- g_free (warptv->disttable);
- warptv->disttable = NULL;
+ gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
+ &alignment, &pool);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ if (pool) {
+ GstStructure *config;
+
+ config = gst_buffer_pool_get_config (pool);
+ gst_buffer_pool_config_add_option (config,
+ GST_BUFFER_POOL_OPTION_VIDEO_META);
+ gst_buffer_pool_set_config (pool, config);
+ }
+ return TRUE;
}
static void
-gst_warptv_base_init (gpointer g_class)
+gst_warptv_finalize (GObject * object)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+ GstWarpTV *warptv = GST_WARPTV (object);
- gst_element_class_set_details_simple (element_class, "WarpTV effect",
- "Filter/Effect/Video",
- "WarpTV does realtime goo'ing of the video input",
- "Sam Lantinga <slouken@devolution.com>");
+ g_free (warptv->disttable);
+ warptv->disttable = NULL;
- gst_element_class_add_static_pad_template (element_class,
- &gst_warptv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_warptv_src_template);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gst_warptv_class_init (GstWarpTVClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
+ GstElementClass *gstelement_class = (GstElementClass *) klass;
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
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 (gstelement_class,
+ gst_static_pad_template_get (&gst_warptv_sink_template));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_warptv_src_template));
+
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)
{
/* nothing to do */
}
diff --git a/gst/effectv/gstwarp.h b/gst/effectv/gstwarp.h
index a9879604b..4c53499d0 100644
--- a/gst/effectv/gstwarp.h
+++ b/gst/effectv/gstwarp.h
@@ -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;
diff --git a/gst/equalizer/Makefile.am b/gst/equalizer/Makefile.am
index b3b86633e..760698fcb 100644
--- a/gst/equalizer/Makefile.am
+++ b/gst/equalizer/Makefile.am
@@ -7,9 +7,9 @@ libgstequalizer_la_SOURCES = \
gstiirequalizer10bands.c gstiirequalizer10bands.h
libgstequalizer_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \
- $(GST_CONTROLLER_CFLAGS) $(GST_CFLAGS)
+ $(GST_CFLAGS)
libgstequalizer_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
- -lgstaudio-$(GST_MAJORMINOR) $(GST_BASE_LIBS) $(GST_CONTROLLER_LIBS) \
+ -lgstaudio-$(GST_MAJORMINOR) $(GST_BASE_LIBS) \
$(GST_LIBS) $(LIBM)
libgstequalizer_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstequalizer_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/gst/equalizer/gstiirequalizer.c b/gst/equalizer/gstiirequalizer.c
index c640124de..8c6d90d20 100644
--- a/gst/equalizer/gstiirequalizer.c
+++ b/gst/equalizer/gstiirequalizer.c
@@ -24,6 +24,7 @@
#endif
#include <math.h>
+#include <stdio.h>
#include <string.h>
#include "gstiirequalizer.h"
@@ -43,39 +44,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 +349,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 +459,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 +497,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 +507,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 +537,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 +547,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 +614,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 +817,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;
if (gst_base_transform_is_passthrough (btrans))
@@ -847,10 +835,10 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
GstIirEqualizerBand **filters = equ->bands;
guint f, nf = equ->freq_band_count;
- gst_object_sync_values (G_OBJECT (equ), timestamp);
+ gst_object_sync_values (GST_OBJECT (equ), timestamp);
/* sync values for bands too */
for (f = 0; f < nf; f++) {
- gst_object_sync_values (G_OBJECT (filters[f]), timestamp);
+ gst_object_sync_values (GST_OBJECT (filters[f]), timestamp);
}
}
@@ -861,41 +849,30 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
}
BANDS_UNLOCK (equ);
- 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;
diff --git a/gst/equalizer/gstiirequalizer.h b/gst/equalizer/gstiirequalizer.h
index 2254ddc92..f4bb10f0f 100644
--- a/gst/equalizer/gstiirequalizer.h
+++ b/gst/equalizer/gstiirequalizer.h
@@ -22,8 +22,6 @@
#define __GST_IIR_EQUALIZER__
#include <gst/audio/gstaudiofilter.h>
-#include <gst/audio/gstringbuffer.h>
-#include <gst/controller/gstcontroller.h>
typedef struct _GstIirEqualizer GstIirEqualizer;
typedef struct _GstIirEqualizerClass GstIirEqualizerClass;
diff --git a/gst/equalizer/gstiirequalizer10bands.c b/gst/equalizer/gstiirequalizer10bands.c
index b39515c8a..5dc790b85 100644
--- a/gst/equalizer/gstiirequalizer10bands.c
+++ b/gst/equalizer/gstiirequalizer10bands.c
@@ -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);
diff --git a/gst/equalizer/gstiirequalizer3bands.c b/gst/equalizer/gstiirequalizer3bands.c
index 733c5b883..513b9204d 100644
--- a/gst/equalizer/gstiirequalizer3bands.c
+++ b/gst/equalizer/gstiirequalizer3bands.c
@@ -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);
diff --git a/gst/equalizer/gstiirequalizernbands.c b/gst/equalizer/gstiirequalizernbands.c
index b5071953a..3ea40a292 100644
--- a/gst/equalizer/gstiirequalizernbands.c
+++ b/gst/equalizer/gstiirequalizernbands.c
@@ -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);
diff --git a/gst/flv/gstflvdemux.c b/gst/flv/gstflvdemux.c
index 00a68e47b..b4e5669dd 100644
--- a/gst/flv/gstflvdemux.c
+++ b/gst/flv/gstflvdemux.c
@@ -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
@@ -92,8 +93,10 @@ static gboolean flv_demux_handle_seek_push (GstFlvDemux * demux,
static gboolean gst_flv_demux_handle_seek_pull (GstFlvDemux * demux,
GstEvent * event, gboolean seeking);
-static gboolean gst_flv_demux_query (GstPad * pad, GstQuery * query);
-static gboolean gst_flv_demux_src_event (GstPad * pad, GstEvent * event);
+static gboolean gst_flv_demux_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
+static gboolean gst_flv_demux_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static void
@@ -181,19 +184,6 @@ FLV_GET_STRING (GstByteReader * reader)
return string;
}
-static const GstQueryType *
-gst_flv_demux_query_types (GstPad * pad)
-{
- static const GstQueryType query_types[] = {
- GST_QUERY_DURATION,
- GST_QUERY_POSITION,
- GST_QUERY_SEEKING,
- 0
- };
-
- return query_types;
-}
-
static void
gst_flv_demux_check_seekability (GstFlvDemux * demux)
{
@@ -216,10 +206,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_peer_query_duration (demux->sinkpad, GST_FORMAT_BYTES, &stop);
}
/* if upstream doesn't know the size, it's likely that it's not seekable in
@@ -530,17 +518,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) {
@@ -557,7 +550,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) {
@@ -568,7 +561,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
@@ -594,7 +587,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;
@@ -619,6 +612,9 @@ gst_flv_demux_parse_tag_script (GstFlvDemux * demux, GstBuffer * buffer)
}
}
+cleanup:
+ gst_buffer_unmap (buffer, data, -1);
+
return ret;
}
@@ -655,17 +651,21 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
case 4:
case 5:
case 6:
- caps = gst_caps_new_simple ("audio/x-nellymoser", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-nellymoser");
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);
@@ -677,19 +677,21 @@ 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);
break;
}
case 7:
- caps = gst_caps_new_simple ("audio/x-alaw", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-alaw");
break;
case 8:
- caps = gst_caps_new_simple ("audio/x-mulaw", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-mulaw");
break;
case 11:
- caps = gst_caps_new_simple ("audio/x-speex", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-speex");
break;
default:
GST_WARNING_OBJECT (demux, "unsupported audio codec tag %u", codec_tag);
@@ -721,7 +723,7 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
if (codec_name) {
if (demux->taglist == NULL)
- demux->taglist = gst_tag_list_new ();
+ demux->taglist = gst_tag_list_new_empty ();
gst_tag_list_add (demux->taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_AUDIO_CODEC, codec_name, NULL);
g_free (codec_name);
@@ -740,6 +742,22 @@ beach:
return ret;
}
+static gboolean
+gst_flv_demux_push_src_event (GstFlvDemux * demux, GstEvent * event)
+{
+ gboolean ret = TRUE;
+
+ if (demux->audio_pad)
+ ret |= gst_pad_push_event (demux->audio_pad, gst_event_ref (event));
+
+ if (demux->video_pad)
+ ret |= gst_pad_push_event (demux->video_pad, gst_event_ref (event));
+
+ gst_event_unref (event);
+
+ return ret;
+}
+
static void
gst_flv_demux_push_tags (GstFlvDemux * demux)
{
@@ -756,8 +774,8 @@ gst_flv_demux_push_tags (GstFlvDemux * demux)
if (demux->taglist) {
GST_DEBUG_OBJECT (demux, "pushing tags out %" GST_PTR_FORMAT,
demux->taglist);
- gst_element_found_tags (GST_ELEMENT (demux), demux->taglist);
- demux->taglist = gst_tag_list_new ();
+ gst_flv_demux_push_src_event (demux, gst_event_new_tag (demux->taglist));
+ demux->taglist = gst_tag_list_new_empty ();
demux->push_tags = FALSE;
}
}
@@ -786,20 +804,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 (%" G_GSIZE_FORMAT ")",
+ 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 */
@@ -810,20 +838,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;
@@ -878,13 +899,19 @@ 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,
- GST_DEBUG_FUNCPTR (gst_flv_demux_query_types));
gst_pad_set_query_function (demux->audio_pad,
GST_DEBUG_FUNCPTR (gst_flv_demux_query));
gst_pad_set_event_function (demux->audio_pad,
@@ -934,9 +961,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);
@@ -974,7 +1000,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))
@@ -992,24 +1017,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");
}
@@ -1019,9 +1038,11 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
demux->audio_need_segment = FALSE;
}
- GST_LOG_OBJECT (demux, "pushing %d bytes buffer at pts %" GST_TIME_FORMAT
+ GST_LOG_OBJECT (demux,
+ "pushing %" G_GSIZE_FORMAT " 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)) {
@@ -1046,7 +1067,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. */
@@ -1067,6 +1088,8 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
demux->audio_linked = TRUE;
beach:
+ gst_buffer_unmap (buffer, data, -1);
+
return ret;
}
@@ -1080,16 +1103,16 @@ gst_flv_demux_video_negotiate (GstFlvDemux * demux, guint32 codec_tag)
/* Generate caps for that pad */
switch (codec_tag) {
case 2:
- caps = gst_caps_new_simple ("video/x-flash-video", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-flash-video");
break;
case 3:
- caps = gst_caps_new_simple ("video/x-flash-screen", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-flash-screen");
break;
case 4:
- caps = gst_caps_new_simple ("video/x-vp6-flash", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-vp6-flash");
break;
case 5:
- caps = gst_caps_new_simple ("video/x-vp6-alpha", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-vp6-alpha");
break;
case 7:
caps =
@@ -1142,7 +1165,7 @@ gst_flv_demux_video_negotiate (GstFlvDemux * demux, guint32 codec_tag)
if (codec_name) {
if (demux->taglist == NULL)
- demux->taglist = gst_tag_list_new ();
+ demux->taglist = gst_tag_list_new_empty ();
gst_tag_list_add (demux->taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_VIDEO_CODEC, codec_name, NULL);
g_free (codec_name);
@@ -1168,21 +1191,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 */
@@ -1193,11 +1223,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);
@@ -1249,12 +1274,19 @@ 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,
- GST_DEBUG_FUNCPTR (gst_flv_demux_query_types));
gst_pad_set_query_function (demux->video_pad,
GST_DEBUG_FUNCPTR (gst_flv_demux_query));
gst_pad_set_event_function (demux->video_pad,
@@ -1306,9 +1338,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);
@@ -1346,7 +1377,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))
@@ -1365,24 +1395,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");
}
@@ -1392,9 +1416,10 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
demux->video_need_segment = FALSE;
}
- GST_LOG_OBJECT (demux, "pushing %d bytes buffer at pts %" GST_TIME_FORMAT
+ GST_LOG_OBJECT (demux,
+ "pushing %" G_GSIZE_FORMAT " 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);
@@ -1422,7 +1447,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. */
@@ -1443,6 +1468,7 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
demux->video_linked = TRUE;
beach:
+ gst_buffer_unmap (buffer, data, -1);
return ret;
}
@@ -1454,16 +1480,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_get_size (buffer) >= 12,
+ GST_CLOCK_TIME_NONE);
- g_return_val_if_fail (GST_BUFFER_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)
@@ -1473,10 +1503,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;
}
}
@@ -1513,6 +1543,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;
}
@@ -1521,9 +1553,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_SIZE (buffer) >= 4, GST_FLOW_ERROR);
+ g_return_val_if_fail (gst_buffer_get_size (buffer) >= 4, GST_FLOW_ERROR);
+
+ data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
tag_type = data[0];
@@ -1551,6 +1585,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;
}
@@ -1558,9 +1594,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') {
@@ -1573,12 +1611,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;
@@ -1599,6 +1634,7 @@ gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer)
demux->need_header = FALSE;
beach:
+ gst_buffer_unmap (buffer, data, -1);
return ret;
}
@@ -1676,11 +1712,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) {
@@ -1740,15 +1771,17 @@ flv_demux_seek_to_offset (GstFlvDemux * demux, guint64 offset)
}
static GstFlowReturn
-gst_flv_demux_chain (GstPad * pad, GstBuffer * buffer)
+gst_flv_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstFlowReturn ret = GST_FLOW_OK;
GstFlvDemux *demux = NULL;
- demux = GST_FLV_DEMUX (gst_pad_get_parent (pad));
+ demux = GST_FLV_DEMUX (parent);
- GST_LOG_OBJECT (demux, "received buffer of %d bytes at offset %"
- G_GUINT64_FORMAT, GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer));
+ GST_LOG_OBJECT (demux,
+ "received buffer of %" G_GSIZE_FORMAT " bytes at offset %"
+ 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");
@@ -1908,20 +1941,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,
@@ -1958,8 +1987,6 @@ beach:
}
}
- gst_object_unref (demux);
-
return ret;
/* ERRORS */
@@ -1998,10 +2025,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);
+ "partial pull got %" G_GSIZE_FORMAT " when expecting %d from offset %"
+ G_GUINT64_FORMAT, gst_buffer_get_size (*buffer), size, offset);
gst_buffer_unref (*buffer);
ret = GST_FLOW_UNEXPECTED;
*buffer = NULL;
@@ -2179,35 +2206,17 @@ done:
return ret;
}
-static gboolean
-gst_flv_demux_push_src_event (GstFlvDemux * demux, GstEvent * event)
-{
- gboolean ret = TRUE;
-
- if (demux->audio_pad)
- ret |= gst_pad_push_event (demux->audio_pad, gst_event_ref (event));
-
- if (demux->video_pad)
- ret |= gst_pad_push_event (demux->video_pad, gst_event_ref (event));
-
- gst_event_unref (event);
-
- return ret;
-}
-
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_peer_query_duration (demux->sinkpad, GST_FORMAT_BYTES, &size))
return GST_FLOW_OK;
GST_DEBUG_OBJECT (demux, "building index at %" G_GINT64_FORMAT
@@ -2245,12 +2254,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_peer_query_duration (demux->sinkpad, GST_FORMAT_BYTES, &offset))
goto exit;
ret = offset;
@@ -2263,7 +2271,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;
@@ -2274,8 +2284,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);
@@ -2286,7 +2298,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");
@@ -2294,6 +2307,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:
@@ -2351,13 +2366,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;
}
}
@@ -2378,6 +2393,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));
@@ -2435,7 +2459,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 */
@@ -2449,7 +2473,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) {
@@ -2457,7 +2481,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,
@@ -2495,13 +2519,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);
@@ -2574,7 +2598,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 */
@@ -2591,13 +2614,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_peer_query_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;
}
@@ -2668,7 +2688,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. */
@@ -2678,29 +2698,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;
@@ -2714,35 +2734,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) {
@@ -2753,7 +2747,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 */
@@ -2772,10 +2766,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);
}
}
@@ -2811,60 +2802,72 @@ wrong_format:
/* If we can pull that's prefered */
static gboolean
-gst_flv_demux_sink_activate (GstPad * sinkpad)
+gst_flv_demux_sink_activate (GstPad * sinkpad, GstObject * parent)
{
- if (gst_pad_check_pull_range (sinkpad)) {
- return gst_pad_activate_pull (sinkpad, TRUE);
- } else {
- return gst_pad_activate_push (sinkpad, TRUE);
- }
-}
+ GstQuery *query;
+ gboolean pull_mode;
-/* This function gets called when we activate ourselves in push mode.
- * We cannot seek (ourselves) in the stream */
-static gboolean
-gst_flv_demux_sink_activate_push (GstPad * sinkpad, gboolean active)
-{
- GstFlvDemux *demux;
+ query = gst_query_new_scheduling ();
+
+ if (!gst_pad_peer_query (sinkpad, query)) {
+ gst_query_unref (query);
+ goto activate_push;
+ }
- demux = GST_FLV_DEMUX (gst_pad_get_parent (sinkpad));
+ pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL);
+ gst_query_unref (query);
- demux->random_access = FALSE;
+ if (!pull_mode)
+ goto activate_push;
- gst_object_unref (demux);
+ GST_DEBUG_OBJECT (sinkpad, "activating pull");
+ return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
- return TRUE;
+activate_push:
+ {
+ GST_DEBUG_OBJECT (sinkpad, "activating push");
+ return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
+ }
}
-/* this function gets called when we activate ourselves in pull mode.
- * We can perform random access to the resource and we start a task
- * to start reading */
static gboolean
-gst_flv_demux_sink_activate_pull (GstPad * sinkpad, gboolean active)
+gst_flv_demux_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
+ GstPadMode mode, gboolean active)
{
+ gboolean res;
GstFlvDemux *demux;
- demux = GST_FLV_DEMUX (gst_pad_get_parent (sinkpad));
+ demux = GST_FLV_DEMUX (parent);
- if (active) {
- demux->random_access = TRUE;
- gst_object_unref (demux);
- return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_flv_demux_loop,
- sinkpad);
- } else {
- demux->random_access = FALSE;
- gst_object_unref (demux);
- return gst_pad_stop_task (sinkpad);
+ switch (mode) {
+ case GST_PAD_MODE_PUSH:
+ demux->random_access = FALSE;
+ res = TRUE;
+ break;
+ case GST_PAD_MODE_PULL:
+ if (active) {
+ demux->random_access = TRUE;
+ res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_flv_demux_loop,
+ sinkpad);
+ } else {
+ demux->random_access = FALSE;
+ res = gst_pad_stop_task (sinkpad);
+ }
+ break;
+ default:
+ res = FALSE;
+ break;
}
+ return res;
}
static gboolean
-gst_flv_demux_sink_event (GstPad * pad, GstEvent * event)
+gst_flv_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstFlvDemux *demux;
gboolean ret = FALSE;
- demux = GST_FLV_DEMUX (gst_pad_get_parent (pad));
+ demux = GST_FLV_DEMUX (parent);
GST_DEBUG_OBJECT (demux, "handling event %s", GST_EVENT_TYPE_NAME (event));
@@ -2894,22 +2897,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);
@@ -2930,18 +2928,16 @@ gst_flv_demux_sink_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (demux);
-
return ret;
}
static gboolean
-gst_flv_demux_src_event (GstPad * pad, GstEvent * event)
+gst_flv_demux_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstFlvDemux *demux;
gboolean ret = FALSE;
- demux = GST_FLV_DEMUX (gst_pad_get_parent (pad));
+ demux = GST_FLV_DEMUX (parent);
GST_DEBUG_OBJECT (demux, "handling event %s", GST_EVENT_TYPE_NAME (event));
@@ -2958,18 +2954,16 @@ gst_flv_demux_src_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (demux);
-
return ret;
}
static gboolean
-gst_flv_demux_query (GstPad * pad, GstQuery * query)
+gst_flv_demux_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
gboolean res = TRUE;
GstFlvDemux *demux;
- demux = GST_FLV_DEMUX (gst_pad_get_parent (pad));
+ demux = GST_FLV_DEMUX (parent);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_DURATION:
@@ -3008,9 +3002,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;
}
@@ -3054,23 +3048,11 @@ gst_flv_demux_query (GstPad * pad, GstQuery * query)
}
case GST_QUERY_LATENCY:
default:
- {
- GstPad *peer;
-
- if ((peer = gst_pad_get_peer (demux->sinkpad))) {
- /* query latency on peer pad */
- res = gst_pad_query (peer, query);
- gst_object_unref (peer);
- } else {
- /* no peer, we don't know */
- res = FALSE;
- }
+ res = gst_pad_peer_query (demux->sinkpad, query);
break;
- }
}
beach:
- gst_object_unref (demux);
return res;
}
@@ -3184,11 +3166,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;
@@ -3228,23 +3205,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_static_pad_template (element_class,
- &flv_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &audio_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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);
@@ -3256,10 +3216,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");
@@ -3270,19 +3241,19 @@ gst_flv_demux_init (GstFlvDemux * demux, GstFlvDemuxClass * g_class)
GST_DEBUG_FUNCPTR (gst_flv_demux_chain));
gst_pad_set_activate_function (demux->sinkpad,
GST_DEBUG_FUNCPTR (gst_flv_demux_sink_activate));
- gst_pad_set_activatepull_function (demux->sinkpad,
- GST_DEBUG_FUNCPTR (gst_flv_demux_sink_activate_pull));
- gst_pad_set_activatepush_function (demux->sinkpad,
- GST_DEBUG_FUNCPTR (gst_flv_demux_sink_activate_push));
+ gst_pad_set_activatemode_function (demux->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_flv_demux_sink_activate_mode));
gst_element_add_pad (GST_ELEMENT (demux), demux->sinkpad);
demux->adapter = gst_adapter_new ();
- demux->taglist = gst_tag_list_new ();
+ demux->taglist = gst_tag_list_new_empty ();
gst_segment_init (&demux->segment, GST_FORMAT_TIME);
demux->own_index = FALSE;
+ GST_OBJECT_FLAG_SET (demux, GST_ELEMENT_FLAG_INDEXABLE);
+
gst_flv_demux_cleanup (demux);
}
diff --git a/gst/flv/gstflvdemux.h b/gst/flv/gstflvdemux.h
index 07559a520..efbed316c 100644
--- a/gst/flv/gstflvdemux.h
+++ b/gst/flv/gstflvdemux.h
@@ -71,7 +71,6 @@ struct _GstFlvDemux
GstSegment segment;
- GstEvent *close_seg_event;
GstEvent *new_seg_event;
GstTagList *taglist;
diff --git a/gst/flv/gstflvmux.c b/gst/flv/gstflvmux.c
index d4c5cb5fb..e002f9ec9 100644
--- a/gst/flv/gstflvmux.c
+++ b/gst/flv/gstflvmux.c
@@ -83,29 +83,23 @@ 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
gst_flv_mux_collected (GstCollectPads * pads, gpointer user_data);
-static gboolean gst_flv_mux_handle_src_event (GstPad * pad, GstEvent * event);
+static gboolean gst_flv_mux_handle_src_event (GstPad * pad, GstObject * parent,
+ 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,
@@ -130,22 +124,27 @@ gst_flv_mux_index_entry_free (GstFlvMuxIndexEntry * entry)
g_slice_free (GstFlvMuxIndexEntry, entry);
}
+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 void
-gst_flv_mux_base_init (gpointer g_class)
+_gst_buffer_new_and_alloc (gsize size, GstBuffer ** buffer, guint8 ** data)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_static_pad_template (element_class,
- &videosink_templ);
- gst_element_class_add_static_pad_template (element_class,
- &audiosink_templ);
- gst_element_class_add_static_pad_template (element_class, &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>");
+ g_return_if_fail (data != NULL);
+ g_return_if_fail (buffer != NULL);
- GST_DEBUG_CATEGORY_INIT (flvmux_debug, "flvmux", 0, "FLV muxer");
+ *data = g_malloc (size);
+ *buffer = _gst_buffer_new_wrapped (*data, size, g_free);
}
static void
@@ -183,10 +182,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);
@@ -242,7 +254,8 @@ gst_flv_mux_reset (GstElement * element)
}
static gboolean
-gst_flv_mux_handle_src_event (GstPad * pad, GstEvent * event)
+gst_flv_mux_handle_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstEventType type;
@@ -256,16 +269,38 @@ gst_flv_mux_handle_src_event (GstPad * pad, GstEvent * event)
break;
}
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
}
static gboolean
-gst_flv_mux_handle_sink_event (GstPad * pad, GstEvent * event)
+gst_flv_mux_handle_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
- GstFlvMux *mux = GST_FLV_MUX (gst_pad_get_parent (pad));
+ GstFlvMux *mux = GST_FLV_MUX (parent);
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);
@@ -282,8 +317,7 @@ gst_flv_mux_handle_sink_event (GstPad * pad, GstEvent * event)
/* now GstCollectPads can take care of the rest, e.g. EOS */
if (ret)
- ret = mux->collect_event (pad, event);
- gst_object_unref (mux);
+ ret = mux->collect_event (pad, parent, event);
return ret;
}
@@ -496,14 +530,13 @@ gst_flv_mux_reset_pad (GstFlvMux * mux, GstFlvPad * cpad, gboolean video)
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) {
@@ -519,7 +552,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");
@@ -528,7 +560,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;
@@ -536,7 +567,7 @@ gst_flv_mux_request_new_pad (GstElement * element,
pad = gst_pad_new_from_template (templ, name);
cpad = (GstFlvPad *)
- gst_collect_pads_add_pad (mux->collect, pad, sizeof (GstFlvPad));
+ gst_collect_pads_add_pad (mux->collect, pad, sizeof (GstFlvPad), NULL);
cpad->audio_codec_data = NULL;
cpad->video_codec_data = NULL;
@@ -550,7 +581,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);
@@ -571,10 +601,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);
}
@@ -585,8 +614,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';
@@ -618,8 +646,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 */
@@ -633,10 +660,12 @@ 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;
gsize len = strlen (name);
+ _gst_buffer_new_and_alloc (2 + len + 1 + 8, &tmp, &data);
+
GST_WRITE_UINT16_BE (data, len);
data += 2; /* name length */
memcpy (data, name, len);
@@ -659,8 +688,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;
@@ -675,8 +705,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] = AMF0_STRING_MARKER; /* string */
data[1] = 0;
data[2] = 10; /* length 10 */
@@ -685,8 +714,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);
@@ -733,8 +761,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));
@@ -751,17 +779,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_peer_query_duration (cdata->pad, GST_FORMAT_TIME,
+ (gint64 *) & dur) && dur != GST_CLOCK_TIME_NONE) {
if (mux->duration == GST_CLOCK_TIME_NONE)
mux->duration = dur;
else
@@ -776,8 +800,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) {
@@ -793,8 +818,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;
@@ -806,6 +832,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);
@@ -880,8 +910,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);
@@ -915,8 +944,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);
@@ -930,25 +958,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;
}
@@ -963,26 +990,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;
@@ -1014,11 +1044,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;
@@ -1029,17 +1057,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) ||
@@ -1143,13 +1175,12 @@ gst_flv_mux_write_header (GstFlvMux * mux)
gst_flv_mux_put_buffer_in_streamheader (&streamheader, audio_codec_data);
/* create the caps and put the streamheader in them */
- caps = gst_caps_new_simple ("video/x-flv", NULL);
- caps = gst_caps_make_writable (caps);
+ caps = gst_caps_new_empty_simple ("video/x-flv");
structure = gst_caps_get_structure (caps, 0);
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);
@@ -1205,7 +1236,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));
@@ -1264,13 +1295,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;
@@ -1317,8 +1350,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);
@@ -1367,8 +1399,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 */
@@ -1385,7 +1416,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);
}
@@ -1400,14 +1430,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;
diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c
index 501768408..627aad1e6 100644
--- a/gst/flx/gstflxdec.c
+++ b/gst/flx/gstflxdec.c
@@ -111,10 +111,10 @@ gst_flxdec_base_init (GstFlxDecClass * klass)
"Codec/Decoder/Video",
"FLC/FLI/FLX video decoder",
"Sepp Wijnands <mrrazz@garbage-coderz.net>, Zeeshan Ali <zeenix@gmail.com>");
- gst_element_class_add_static_pad_template (gstelement_class,
- &sink_factory);
- gst_element_class_add_static_pad_template (gstelement_class,
- &src_video_factory);
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&sink_factory));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&src_video_factory));
}
static void
diff --git a/gst/goom/gstgoom.c b/gst/goom/gstgoom.c
index b05b8f370..86528355d 100644
--- a/gst/goom/gstgoom.c
+++ b/gst/goom/gstgoom.c
@@ -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
@@ -28,7 +29,7 @@
* <refsect2>
* <title>Example launch line</title>
* |[
- * gst-launch -v audiotestsrc ! goom ! ffmpegcolorspace ! xvimagesink
+ * gst-launch -v audiotestsrc ! goom ! videoconvert ! xvimagesink
* ]|
* </refsect2>
*/
@@ -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,76 +73,39 @@ 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,
GstStateChange transition);
-static GstFlowReturn gst_goom_chain (GstPad * pad, GstBuffer * buffer);
-static gboolean gst_goom_src_event (GstPad * pad, GstEvent * event);
-static gboolean gst_goom_sink_event (GstPad * pad, GstEvent * event);
-
-static gboolean gst_goom_src_query (GstPad * pad, GstQuery * query);
+static GstFlowReturn gst_goom_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
+static gboolean gst_goom_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static gboolean gst_goom_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
-static gboolean gst_goom_sink_setcaps (GstPad * pad, GstCaps * caps);
-static gboolean gst_goom_src_setcaps (GstPad * pad, GstCaps * caps);
+static gboolean gst_goom_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
-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_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &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)
@@ -151,10 +116,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);
}
@@ -167,13 +139,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,
@@ -202,6 +170,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);
}
@@ -219,39 +189,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);
@@ -265,7 +228,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
@@ -273,24 +245,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_query_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);
@@ -299,7 +275,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;
@@ -312,12 +323,12 @@ no_format:
}
static gboolean
-gst_goom_src_event (GstPad * pad, GstEvent * event)
+gst_goom_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
gboolean res;
GstGoom *goom;
- goom = GST_GOOM (gst_pad_get_parent (pad));
+ goom = GST_GOOM (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_QOS:
@@ -326,7 +337,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);
@@ -346,20 +357,27 @@ gst_goom_src_event (GstPad * pad, GstEvent * event)
res = gst_pad_push_event (goom->sinkpad, event);
break;
}
- gst_object_unref (goom);
return res;
}
static gboolean
-gst_goom_sink_event (GstPad * pad, GstEvent * event)
+gst_goom_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
gboolean res;
GstGoom *goom;
- goom = GST_GOOM (gst_pad_get_parent (pad));
+ goom = GST_GOOM (parent);
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;
@@ -367,22 +385,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;
@@ -391,18 +399,17 @@ gst_goom_sink_event (GstPad * pad, GstEvent * event)
res = gst_pad_push_event (goom->srcpad, event);
break;
}
- gst_object_unref (goom);
return res;
}
static gboolean
-gst_goom_src_query (GstPad * pad, GstQuery * query)
+gst_goom_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
gboolean res = FALSE;
GstGoom *goom;
- goom = GST_GOOM (gst_pad_get_parent (pad));
+ goom = GST_GOOM (parent);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_LATENCY:
@@ -447,59 +454,48 @@ gst_goom_src_query (GstPad * pad, GstQuery * query)
break;
}
default:
- res = gst_pad_peer_query (goom->sinkpad, query);
+ res = gst_pad_query_default (pad, parent, query);
break;
}
- gst_object_unref (goom);
-
return res;
}
+/* make sure we are negotiated */
static GstFlowReturn
-get_buffer (GstGoom * goom, GstBuffer ** outbuf)
+ensure_negotiated (GstGoom * goom)
{
- GstFlowReturn ret;
+ gboolean reconfigure;
- if (GST_PAD_CAPS (goom->srcpad) == NULL) {
+ reconfigure = gst_pad_check_reconfigure (goom->srcpad);
+
+ /* 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)
+gst_goom_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstGoom *goom;
GstFlowReturn ret;
GstBuffer *outbuf = NULL;
- goom = GST_GOOM (gst_pad_get_parent (pad));
+ goom = GST_GOOM (parent);
if (goom->bps == 0) {
ret = GST_FLOW_NOT_NEGOTIATED;
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 */
@@ -508,8 +504,8 @@ 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));
+ "Input buffer has %" G_GSIZE_FORMAT " samples, time=%" G_GUINT64_FORMAT,
+ 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);
@@ -518,7 +514,6 @@ gst_goom_chain (GstPad * pad, GstBuffer * buffer)
while (TRUE) {
const guint16 *data;
- gboolean need_skip;
guchar *out_frame;
gint i;
guint avail, to_flush;
@@ -545,12 +540,12 @@ gst_goom_chain (GstPad * pad, GstBuffer * buffer)
timestamp += gst_util_uint64_scale_int (dist, GST_SECOND, goom->rate);
}
- if (timestamp != -1) {
+ if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
gint64 qostime;
+ gboolean need_skip;
qostime = gst_segment_to_running_time (&goom->segment, GST_FORMAT_TIME,
- timestamp);
- qostime += goom->duration;
+ timestamp) + goom->duration;
GST_OBJECT_LOCK (goom);
/* check for QoS, don't compute buffers that are known to be late */
@@ -567,7 +562,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) {
@@ -585,18 +580,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);
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);
GST_DEBUG ("Pushing frame with time=%" GST_TIME_FORMAT ", duration=%"
GST_TIME_FORMAT, GST_TIME_ARGS (timestamp),
@@ -622,7 +620,6 @@ gst_goom_chain (GstPad * pad, GstBuffer * buffer)
gst_buffer_unref (outbuf);
beach:
- gst_object_unref (goom);
return ret;
}
@@ -647,6 +644,10 @@ 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_replace ((GstObject **) & goom->pool, NULL);
+ }
break;
case GST_STATE_CHANGE_READY_TO_NULL:
break;
diff --git a/gst/goom/gstgoom.h b/gst/goom/gstgoom.h
index 382d05315..16e745d93 100644
--- a/gst/goom/gstgoom.h
+++ b/gst/goom/gstgoom.h
@@ -57,6 +57,7 @@ struct _GstGoom
gint height;
GstClockTime duration;
guint outsize;
+ GstBufferPool *pool;
/* samples per frame */
guint spf;
diff --git a/gst/goom2k1/gstgoom.c b/gst/goom2k1/gstgoom.c
index 7c273942d..08b7bc5c5 100644
--- a/gst/goom2k1/gstgoom.c
+++ b/gst/goom2k1/gstgoom.c
@@ -134,9 +134,10 @@ gst_goom_base_init (GstGoomClass * klass)
"GOOM: what a GOOM! 2k1 edition", "Visualization",
"Takes frames of data and outputs video frames using the GOOM 2k1 filter",
"Wim Taymans <wim@fluendo.com>");
- gst_element_class_add_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &src_template);
+ 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));
}
static void
diff --git a/gst/icydemux/gsticydemux.c b/gst/icydemux/gsticydemux.c
index 4a533b921..ccde6480e 100644
--- a/gst/icydemux/gsticydemux.c
+++ b/gst/icydemux/gsticydemux.c
@@ -66,13 +66,12 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("ANY")
);
-static void gst_icydemux_class_init (GstICYDemuxClass * klass);
-static void gst_icydemux_base_init (GstICYDemuxClass * klass);
-static void gst_icydemux_init (GstICYDemux * icydemux);
static void gst_icydemux_dispose (GObject * object);
-static GstFlowReturn gst_icydemux_chain (GstPad * pad, GstBuffer * buf);
-static gboolean gst_icydemux_handle_event (GstPad * pad, GstEvent * event);
+static GstFlowReturn gst_icydemux_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buf);
+static gboolean gst_icydemux_handle_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static gboolean gst_icydemux_add_srcpad (GstICYDemux * icydemux,
GstCaps * new_caps);
@@ -85,44 +84,9 @@ static gboolean gst_icydemux_sink_setcaps (GstPad * pad, GstCaps * caps);
static gboolean gst_icydemux_send_tag_event (GstICYDemux * icydemux,
GstTagList * taglist);
-static GstElementClass *parent_class = NULL;
-GType
-gst_icydemux_get_type (void)
-{
- static GType plugin_type = 0;
-
- if (!plugin_type) {
- static const GTypeInfo plugin_info = {
- sizeof (GstICYDemuxClass),
- (GBaseInitFunc) gst_icydemux_base_init,
- NULL,
- (GClassInitFunc) gst_icydemux_class_init,
- NULL,
- NULL,
- sizeof (GstICYDemux),
- 0,
- (GInstanceInitFunc) gst_icydemux_init,
- };
- plugin_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstICYDemux", &plugin_info, 0);
- }
- return plugin_type;
-}
-
-static void
-gst_icydemux_base_init (GstICYDemuxClass * klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &sink_factory);
- gst_element_class_set_details_simple (element_class, "ICY tag demuxer",
- "Codec/Demuxer/Metadata",
- "Read and output ICY tags while demuxing the contents",
- "Jan Schmidt <thaytan@mad.scientist.com>, "
- "Michael Smith <msmith@fluendo.com>");
-}
+#define gst_icydemux_parent_class parent_class
+G_DEFINE_TYPE (GstICYDemux, gst_icydemux, GST_TYPE_ELEMENT);
static void
gst_icydemux_class_init (GstICYDemuxClass * klass)
@@ -139,6 +103,16 @@ gst_icydemux_class_init (GstICYDemuxClass * klass)
gstelement_class->change_state = gst_icydemux_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, "ICY tag demuxer",
+ "Codec/Demuxer/Metadata",
+ "Read and output ICY tags while demuxing the contents",
+ "Jan Schmidt <thaytan@mad.scientist.com>, "
+ "Michael Smith <msmith@fluendo.com>");
}
static void
@@ -197,8 +171,6 @@ gst_icydemux_init (GstICYDemux * icydemux)
GST_DEBUG_FUNCPTR (gst_icydemux_chain));
gst_pad_set_event_function (icydemux->sinkpad,
GST_DEBUG_FUNCPTR (gst_icydemux_handle_event));
- gst_pad_set_setcaps_function (icydemux->sinkpad,
- GST_DEBUG_FUNCPTR (gst_icydemux_sink_setcaps));
gst_element_add_pad (GST_ELEMENT (icydemux), icydemux->sinkpad);
gst_icydemux_reset (icydemux);
@@ -330,13 +302,13 @@ gst_icydemux_parse_and_send_tags (GstICYDemux * icydemux)
length = gst_adapter_available (icydemux->meta_adapter);
- data = gst_adapter_peek (icydemux->meta_adapter, length);
+ data = gst_adapter_map (icydemux->meta_adapter, length);
/* Now, copy this to a buffer where we can NULL-terminate it to make things
* a bit easier, then do that parsing. */
buffer = g_strndup ((const gchar *) data, length);
- tags = gst_tag_list_new ();
+ tags = gst_tag_list_new_empty ();
strings = g_strsplit (buffer, "';", 0);
for (i = 0; strings[i]; i++) {
@@ -361,7 +333,8 @@ gst_icydemux_parse_and_send_tags (GstICYDemux * icydemux)
g_strfreev (strings);
g_free (buffer);
- gst_adapter_clear (icydemux->meta_adapter);
+ gst_adapter_unmap (icydemux->meta_adapter);
+ gst_adapter_flush (icydemux->meta_adapter, length);
if (!gst_tag_list_is_empty (tags))
gst_icydemux_tag_found (icydemux, tags);
@@ -370,18 +343,32 @@ gst_icydemux_parse_and_send_tags (GstICYDemux * icydemux)
}
static gboolean
-gst_icydemux_handle_event (GstPad * pad, GstEvent * event)
+gst_icydemux_handle_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
- GstICYDemux *icydemux = GST_ICYDEMUX (GST_PAD_PARENT (pad));
+ GstICYDemux *icydemux = GST_ICYDEMUX (parent);
gboolean result;
- if (GST_EVENT_TYPE (event) == GST_EVENT_TAG) {
- GstTagList *tags;
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_TAG:
+ {
+ GstTagList *tags;
- gst_event_parse_tag (event, &tags);
- result = gst_icydemux_tag_found (icydemux, gst_tag_list_copy (tags));
- gst_event_unref (event);
- return result;
+ gst_event_parse_tag (event, &tags);
+ result = gst_icydemux_tag_found (icydemux, gst_tag_list_copy (tags));
+ gst_event_unref (event);
+ return result;
+ }
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ result = gst_icydemux_sink_setcaps (pad, caps);
+ gst_event_unref (event);
+ return result;
+ }
+ default:
+ break;
}
if (icydemux->typefinding) {
@@ -392,14 +379,14 @@ gst_icydemux_handle_event (GstPad * pad, GstEvent * event)
g_list_free (icydemux->cached_events);
icydemux->cached_events = NULL;
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
default:
icydemux->cached_events = g_list_append (icydemux->cached_events,
event);
return TRUE;
}
} else {
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
}
}
@@ -430,7 +417,7 @@ gst_icydemux_typefind_or_forward (GstICYDemux * icydemux, GstBuffer * buf)
if (G_UNLIKELY (icydemux->content_type)) {
if (!g_ascii_strcasecmp (icydemux->content_type, "video/nsv")) {
GST_DEBUG ("We have a NSV stream");
- caps = gst_caps_new_simple ("video/x-nsv", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-nsv");
} else {
GST_DEBUG ("Upstream Content-Type isn't supported");
g_free (icydemux->content_type);
@@ -450,7 +437,8 @@ gst_icydemux_typefind_or_forward (GstICYDemux * icydemux, GstBuffer * buf)
icydemux->typefind_buf, &prob);
if (caps == NULL) {
- if (GST_BUFFER_SIZE (icydemux->typefind_buf) < ICY_TYPE_FIND_MAX_SIZE) {
+ if (gst_buffer_get_size (icydemux->typefind_buf) <
+ ICY_TYPE_FIND_MAX_SIZE) {
/* Just break for more data */
return GST_FLOW_OK;
}
@@ -495,8 +483,7 @@ gst_icydemux_typefind_or_forward (GstICYDemux * icydemux, GstBuffer * buf)
return GST_FLOW_ERROR;
}
- buf = gst_buffer_make_metadata_writable (buf);
- gst_buffer_set_caps (buf, icydemux->src_caps);
+ buf = gst_buffer_make_writable (buf);
/* Most things don't care, and it's a pain to track (we should preserve a
* 0 offset on the first buffer though if it's there, for id3demux etc.) */
@@ -518,14 +505,14 @@ gst_icydemux_add_meta (GstICYDemux * icydemux, GstBuffer * buf)
}
static GstFlowReturn
-gst_icydemux_chain (GstPad * pad, GstBuffer * buf)
+gst_icydemux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstICYDemux *icydemux;
guint size, chunk, offset;
GstBuffer *sub;
GstFlowReturn ret = GST_FLOW_OK;
- icydemux = GST_ICYDEMUX (GST_PAD_PARENT (pad));
+ icydemux = GST_ICYDEMUX (parent);
if (G_UNLIKELY (icydemux->meta_interval < 0))
goto not_negotiated;
@@ -538,12 +525,12 @@ gst_icydemux_chain (GstPad * pad, GstBuffer * buf)
/* Go through the buffer, chopping it into appropriate chunks. Forward as
* tags or buffers, as appropriate
*/
- size = GST_BUFFER_SIZE (buf);
+ size = gst_buffer_get_size (buf);
offset = 0;
while (size) {
if (icydemux->remaining) {
chunk = (size <= icydemux->remaining) ? size : icydemux->remaining;
- sub = gst_buffer_create_sub (buf, offset, chunk);
+ sub = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, offset, chunk);
offset += chunk;
icydemux->remaining -= chunk;
size -= chunk;
@@ -555,7 +542,7 @@ gst_icydemux_chain (GstPad * pad, GstBuffer * buf)
} else if (icydemux->meta_remaining) {
chunk = (size <= icydemux->meta_remaining) ?
size : icydemux->meta_remaining;
- sub = gst_buffer_create_sub (buf, offset, chunk);
+ sub = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, offset, chunk);
gst_icydemux_add_meta (icydemux, sub);
offset += chunk;
@@ -570,12 +557,14 @@ gst_icydemux_chain (GstPad * pad, GstBuffer * buf)
icydemux->remaining = icydemux->meta_interval;
}
} else {
+ guint8 byte;
/* We need to read a single byte (always safe at this point in the loop)
* to figure out how many bytes of metadata exist.
* The 'spec' tells us to read 16 * (byte_value) bytes of metadata after
* this (zero is common, and means the metadata hasn't changed).
*/
- icydemux->meta_remaining = 16 * GST_BUFFER_DATA (buf)[offset];
+ gst_buffer_extract (buf, offset, &byte, 1);
+ icydemux->meta_remaining = 16 * byte;
if (icydemux->meta_remaining == 0)
icydemux->remaining = icydemux->meta_interval;
diff --git a/gst/id3demux/gstid3demux.c b/gst/id3demux/gstid3demux.c
index 414b574e8..333850654 100644
--- a/gst/id3demux/gstid3demux.c
+++ b/gst/id3demux/gstid3demux.c
@@ -89,26 +89,15 @@ static void gst_id3demux_set_property (GObject * object, guint prop_id,
static void gst_id3demux_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-GST_BOILERPLATE (GstID3Demux, gst_id3demux, GstTagDemux, GST_TYPE_TAG_DEMUX);
-
-static void
-gst_id3demux_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class, &sink_factory);
-
- gst_element_class_set_details_simple (element_class, "ID3 tag demuxer",
- "Codec/Demuxer/Metadata",
- "Read and output ID3v1 and ID3v2 tags while demuxing the contents",
- "Jan Schmidt <thaytan@mad.scientist.com>");
-}
+#define gst_id3demux_parent_class parent_class
+G_DEFINE_TYPE (GstID3Demux, gst_id3demux, GST_TYPE_TAG_DEMUX);
static void
gst_id3demux_class_init (GstID3DemuxClass * klass)
{
- GstTagDemuxClass *tagdemux_class = (GstTagDemuxClass *) klass;
GObjectClass *gobject_class = (GObjectClass *) klass;
+ GstElementClass *gstelement_class = (GstElementClass *) klass;
+ GstTagDemuxClass *tagdemux_class = (GstTagDemuxClass *) klass;
gobject_class->set_property = gst_id3demux_set_property;
gobject_class->get_property = gst_id3demux_get_property;
@@ -119,6 +108,14 @@ gst_id3demux_class_init (GstID3DemuxClass * klass)
"and ID3v2 tags are present", DEFAULT_PREFER_V1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&sink_factory));
+
+ gst_element_class_set_details_simple (gstelement_class, "ID3 tag demuxer",
+ "Codec/Demuxer/Metadata",
+ "Read and output ID3v1 and ID3v2 tags while demuxing the contents",
+ "Jan Schmidt <thaytan@mad.scientist.com>");
+
tagdemux_class->identify_tag = GST_DEBUG_FUNCPTR (gst_id3demux_identify_tag);
tagdemux_class->parse_tag = GST_DEBUG_FUNCPTR (gst_id3demux_parse_tag);
tagdemux_class->merge_tags = GST_DEBUG_FUNCPTR (gst_id3demux_merge_tags);
@@ -128,7 +125,7 @@ gst_id3demux_class_init (GstID3DemuxClass * klass)
}
static void
-gst_id3demux_init (GstID3Demux * id3demux, GstID3DemuxClass * klass)
+gst_id3demux_init (GstID3Demux * id3demux)
{
id3demux->prefer_v1 = DEFAULT_PREFER_V1;
}
@@ -137,7 +134,9 @@ static gboolean
gst_id3demux_identify_tag (GstTagDemux * demux, GstBuffer * buf,
gboolean start_tag, guint * tag_size)
{
- const guint8 *data = GST_BUFFER_DATA (buf);
+ guint8 data[3];
+
+ gst_buffer_extract (buf, 0, data, 3);
if (start_tag) {
if (data[0] != 'I' || data[1] != 'D' || data[2] != '3')
@@ -189,7 +188,11 @@ gst_id3demux_parse_tag (GstTagDemux * demux, GstBuffer * buffer,
return GST_TAG_DEMUX_RESULT_BROKEN_TAG;
}
} else {
- *tags = gst_tag_list_new_from_id3v1 (GST_BUFFER_DATA (buffer));
+ guint8 *data;
+
+ data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
+ *tags = gst_tag_list_new_from_id3v1 (data);
+ gst_buffer_unmap (buffer, data, -1);
if (G_UNLIKELY (*tags == NULL))
return GST_TAG_DEMUX_RESULT_BROKEN_TAG;
diff --git a/gst/imagefreeze/gstimagefreeze.c b/gst/imagefreeze/gstimagefreeze.c
index 77785caae..3e122adca 100644
--- a/gst/imagefreeze/gstimagefreeze.c
+++ b/gst/imagefreeze/gstimagefreeze.c
@@ -89,10 +89,10 @@ gst_image_freeze_base_init (gpointer g_class)
"Generates a still frame stream from an image",
"Sebastian Dröge <sebastian.droege@collabora.co.uk>");
- gst_element_class_add_static_pad_template (gstelement_class,
- &sink_pad_template);
- gst_element_class_add_static_pad_template (gstelement_class,
- &src_pad_template);
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&sink_pad_template));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&src_pad_template));
}
static void
@@ -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",
diff --git a/gst/interleave/deinterleave.c b/gst/interleave/deinterleave.c
index ad88c4e8e..53ad10ace 100644
--- a/gst/interleave/deinterleave.c
+++ b/gst/interleave/deinterleave.c
@@ -69,7 +69,7 @@
GST_DEBUG_CATEGORY_STATIC (gst_deinterleave_debug);
#define GST_CAT_DEFAULT gst_deinterleave_debug
-static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src%d",
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("audio/x-raw-int, "
@@ -190,10 +190,10 @@ gst_deinterleave_base_init (gpointer g_class)
"Iain <iain@prettypeople.org>, "
"Sebastian Dröge <slomo@circular-chaos.org>");
- gst_element_class_add_static_pad_template (gstelement_class,
- &sink_template);
- gst_element_class_add_static_pad_template (gstelement_class,
- &src_template);
+ 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));
}
static void
@@ -255,7 +255,7 @@ gst_deinterleave_add_new_pads (GstDeinterleave * self, GstCaps * caps)
guint i;
for (i = 0; i < self->channels; i++) {
- gchar *name = g_strdup_printf ("src%d", i);
+ gchar *name = g_strdup_printf ("src_%u", i);
GstCaps *srccaps;
diff --git a/gst/interleave/interleave.c b/gst/interleave/interleave.c
index bc672d10c..f5d600497 100644
--- a/gst/interleave/interleave.c
+++ b/gst/interleave/interleave.c
@@ -70,7 +70,7 @@
GST_DEBUG_CATEGORY_STATIC (gst_interleave_debug);
#define GST_CAT_DEFAULT gst_interleave_debug
-static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink%d",
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("audio/x-raw-int, "
@@ -320,8 +320,10 @@ gst_interleave_base_init (gpointer g_class)
"Andy Wingo <wingo at pobox.com>, "
"Sebastian Dröge <slomo@circular-chaos.org>");
- gst_element_class_add_static_pad_template (g_class, &sink_template);
- gst_element_class_add_static_pad_template (g_class, &src_template);
+ gst_element_class_add_pad_template (g_class,
+ gst_static_pad_template_get (&sink_template));
+ gst_element_class_add_pad_template (g_class,
+ gst_static_pad_template_get (&src_template));
}
static void
@@ -485,7 +487,7 @@ gst_interleave_request_new_pad (GstElement * element, GstPadTemplate * templ,
padnumber = g_atomic_int_exchange_and_add (&self->padcounter, 1);
#endif
- pad_name = g_strdup_printf ("sink%d", padnumber);
+ pad_name = g_strdup_printf ("sink_%u", padnumber);
new_pad = GST_PAD_CAST (g_object_new (GST_TYPE_INTERLEAVE_PAD,
"name", pad_name, "direction", templ->direction,
"template", templ, NULL));
@@ -498,7 +500,8 @@ gst_interleave_request_new_pad (GstElement * element, GstPadTemplate * templ,
gst_pad_set_getcaps_function (new_pad,
GST_DEBUG_FUNCPTR (gst_interleave_sink_getcaps));
- gst_collect_pads_add_pad (self->collect, new_pad, sizeof (GstCollectData));
+ gst_collect_pads_add_pad (self->collect, new_pad, sizeof (GstCollectData),
+ NULL);
/* FIXME: hacked way to override/extend the event function of
* GstCollectPads; because it sets its own event function giving the
diff --git a/gst/isomp4/Makefile.am b/gst/isomp4/Makefile.am
index 010e09ca0..f3f3718f6 100644
--- a/gst/isomp4/Makefile.am
+++ b/gst/isomp4/Makefile.am
@@ -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@ \
diff --git a/gst/isomp4/atoms.c b/gst/isomp4/atoms.c
index 5bd6cb73c..dc4eea0d7 100644
--- a/gst/isomp4/atoms.c
+++ b/gst/isomp4/atoms.c
@@ -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;
}
@@ -2900,6 +2901,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)
{
@@ -2918,10 +2932,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);
@@ -2939,12 +2950,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);
@@ -3263,13 +3274,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);
@@ -4017,13 +4027,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,
@@ -4036,13 +4046,14 @@ build_btrt_extension (guint32 buffer_size_db, guint32 avg_bitrate,
{
AtomData *atom_data;
GstBuffer *buf;
+ guint8 *data;
- 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 (FOURCC_btrt, buf);
gst_buffer_unref (buf);
@@ -4093,6 +4104,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,
@@ -4100,8 +4112,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);
@@ -4123,14 +4134,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);
@@ -4157,8 +4167,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;
@@ -4176,15 +4187,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;
@@ -4200,9 +4211,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);
@@ -4286,6 +4296,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);
@@ -4316,10 +4327,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 */
@@ -4331,6 +4338,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;
@@ -4343,10 +4351,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 */
@@ -4356,6 +4360,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;
@@ -4371,8 +4376,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;
@@ -4383,14 +4388,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;
@@ -4412,8 +4420,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. */
@@ -4430,6 +4437,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);
@@ -4473,6 +4481,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,
@@ -4485,9 +4494,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);
diff --git a/gst/isomp4/atoms.h b/gst/isomp4/atoms.h
index 20ea14172..0998c7364 100644
--- a/gst/isomp4/atoms.h
+++ b/gst/isomp4/atoms.h
@@ -919,7 +919,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);
diff --git a/gst/isomp4/atomsrecovery.c b/gst/isomp4/atomsrecovery.c
index 1190ec1ca..8383b6654 100644
--- a/gst/isomp4/atomsrecovery.c
+++ b/gst/isomp4/atomsrecovery.c
@@ -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;
diff --git a/gst/isomp4/gstqtmoovrecover.c b/gst/isomp4/gstqtmoovrecover.c
index 80799724c..678ab3bb4 100644
--- a/gst/isomp4/gstqtmoovrecover.c
+++ b/gst/isomp4/gstqtmoovrecover.c
@@ -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)
{
}
@@ -352,7 +343,7 @@ gst_qt_moov_recover_change_state (GstElement * element,
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
- qtmr->task = gst_task_create (gst_qt_moov_recover_run, qtmr);
+ qtmr->task = gst_task_new (gst_qt_moov_recover_run, qtmr);
g_static_rec_mutex_init (&qtmr->task_mutex);
gst_task_set_lock (qtmr->task, &qtmr->task_mutex);
break;
diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c
index a83835c18..b18ed9783 100644
--- a/gst/isomp4/gstqtmux.c
+++ b/gst/isomp4/gstqtmux.c
@@ -97,7 +97,7 @@
* <refsect2>
* <title>Example pipelines</title>
* |[
- * gst-launch v4l2src num-buffers=500 ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! qtmux ! filesink location=video.mov
+ * gst-launch v4l2src num-buffers=500 ! video/x-raw,width=320,height=240 ! ffmpegcolorspace ! qtmux ! filesink location=video.mov
* ]|
* Records a video stream captured from a v4l2 device and muxes it into a qt file.
* </refsect2>
@@ -117,6 +117,7 @@
#include <gst/gst.h>
#include <gst/base/gstcollectpads.h>
+#include <gst/video/video.h>
#include <gst/tag/xmpwriter.h>
#include <sys/types.h>
@@ -220,11 +221,12 @@ 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 */
-static gboolean gst_qt_mux_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_qt_mux_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static GstFlowReturn gst_qt_mux_collected (GstCollectPads * pads,
gpointer user_data);
@@ -262,20 +264,17 @@ gst_qt_mux_base_init (gpointer g_class)
srctempl = gst_pad_template_new ("src", GST_PAD_SRC,
GST_PAD_ALWAYS, params->src_caps);
gst_element_class_add_pad_template (element_class, srctempl);
- gst_object_unref (srctempl);
if (params->audio_sink_caps) {
- audiosinktempl = gst_pad_template_new ("audio_%d",
+ audiosinktempl = gst_pad_template_new ("audio_%u",
GST_PAD_SINK, GST_PAD_REQUEST, params->audio_sink_caps);
gst_element_class_add_pad_template (element_class, audiosinktempl);
- gst_object_unref (audiosinktempl);
}
if (params->video_sink_caps) {
- videosinktempl = gst_pad_template_new ("video_%d",
+ videosinktempl = gst_pad_template_new ("video_%u",
GST_PAD_SINK, GST_PAD_REQUEST, params->video_sink_caps);
gst_element_class_add_pad_template (element_class, videosinktempl);
- gst_object_unref (videosinktempl);
}
klass->format = params->prop->format;
@@ -520,20 +519,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;
@@ -644,6 +646,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);
@@ -654,7 +658,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;
@@ -674,10 +680,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 %" G_GSIZE_FORMAT "", 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);
}
@@ -1104,14 +1111,19 @@ 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;
- GST_DEBUG_OBJECT (qtmux, "Found private tag %d/%d; size %d, caps %"
- GST_PTR_FORMAT, i, num_tags, GST_BUFFER_SIZE (buf), caps);
+ data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ GST_DEBUG_OBJECT (qtmux,
+ "Found private tag %d/%d; size %" G_GSIZE_FORMAT ", 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
@@ -1121,10 +1133,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);
}
}
@@ -1171,8 +1183,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;
}
@@ -1182,21 +1194,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);
-
- GST_LOG_OBJECT (qtmux, "sending buffer size %d", size);
+ size = gst_buffer_get_size (buf);
+ GST_LOG_OBJECT (qtmux, "sending buffer size %" G_GSIZE_FORMAT, 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;
@@ -1204,9 +1216,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);
}
@@ -1257,16 +1266,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;
}
@@ -1363,9 +1375,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);
@@ -1373,23 +1387,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);
}
@@ -1476,9 +1490,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);
@@ -1598,6 +1615,7 @@ gst_qt_mux_start_file (GstQTMux * qtmux)
{
GstFlowReturn ret = GST_FLOW_OK;
GstCaps *caps;
+ GstSegment segment;
GST_DEBUG_OBJECT (qtmux, "starting file");
@@ -1609,8 +1627,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);
@@ -1793,7 +1811,7 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
}
if (qtmux->fragment_sequence) {
- GstEvent *event;
+ GstSegment segment;
if (qtmux->mfra) {
guint8 *data = NULL;
@@ -1813,7 +1831,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
@@ -1823,9 +1840,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);
}
@@ -1981,14 +1998,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 %" G_GSIZE_FORMAT,
+ 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",
@@ -2112,7 +2130,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;
@@ -2151,7 +2169,7 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
if (G_LIKELY (buf != NULL && GST_CLOCK_TIME_IS_VALID (pad->first_ts) &&
pad->first_ts != 0)) {
- buf = gst_buffer_make_metadata_writable (buf);
+ buf = gst_buffer_make_writable (buf);
check_and_subtract_ts (qtmux, &GST_BUFFER_TIMESTAMP (buf), pad->first_ts);
}
/* when we obtain the first_ts we subtract from all stored buffers we have,
@@ -2314,7 +2332,7 @@ again:
/* for computing the avg bitrate */
if (G_LIKELY (last_buf)) {
- pad->total_bytes += GST_BUFFER_SIZE (last_buf);
+ pad->total_bytes += gst_buffer_get_size (last_buf);
pad->total_duration += duration;
}
@@ -2329,7 +2347,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 */
@@ -2337,7 +2355,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;
@@ -2346,7 +2364,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);
@@ -2564,7 +2582,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 {
@@ -2619,7 +2637,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);
@@ -2631,15 +2648,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,
@@ -2716,11 +2737,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)
@@ -2847,19 +2869,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");
@@ -2869,9 +2897,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);
}
@@ -2941,7 +2970,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);
@@ -2953,15 +2981,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,
@@ -3016,24 +3048,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) {
@@ -3171,7 +3208,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;
@@ -3189,9 +3226,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);
@@ -3215,13 +3254,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;
}
@@ -3249,22 +3288,38 @@ 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;
}
}
static gboolean
-gst_qt_mux_sink_event (GstPad * pad, GstEvent * event)
+gst_qt_mux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
gboolean ret;
GstQTMux *qtmux;
guint32 avg_bitrate = 0, max_bitrate = 0;
- qtmux = GST_QT_MUX_CAST (gst_pad_get_parent (pad));
+ qtmux = GST_QT_MUX_CAST (parent);
+
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);
@@ -3296,8 +3351,7 @@ gst_qt_mux_sink_event (GstPad * pad, GstEvent * event)
break;
}
- ret = qtmux->collect_event (pad, event);
- gst_object_unref (qtmux);
+ ret = qtmux->collect_event (pad, parent, event);
return ret;
}
@@ -3326,7 +3380,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);
@@ -3334,6 +3388,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;
@@ -3341,12 +3396,20 @@ gst_qt_mux_request_new_pad (GstElement * element,
if (qtmux->state > GST_QT_MUX_STATE_STARTED)
goto too_late;
- if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
+ if (templ == gst_element_class_get_pad_template (klass, "audio_%u")) {
audio = TRUE;
- name = g_strdup_printf ("audio_%02d", qtmux->audio_pads++);
- } else if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
+ if (req_name != NULL && sscanf (req_name, "audio_%u", &pad_id) == 1) {
+ name = g_strdup (req_name);
+ } else {
+ name = g_strdup_printf ("audio_%u", qtmux->audio_pads++);
+ }
+ } else if (templ == gst_element_class_get_pad_template (klass, "video_%u")) {
audio = FALSE;
- name = g_strdup_printf ("video_%02d", qtmux->video_pads++);
+ if (req_name != NULL && sscanf (req_name, "video_%u", &pad_id) == 1) {
+ name = g_strdup (req_name);
+ } else {
+ name = g_strdup_printf ("video_%u", qtmux->video_pads++);
+ }
} else
goto wrong_template;
@@ -3356,7 +3419,7 @@ gst_qt_mux_request_new_pad (GstElement * element,
newpad = gst_pad_new_from_template (templ, name);
g_free (name);
collect_pad = (GstQTPad *)
- gst_collect_pads_add_pad_full (qtmux->collect, newpad, sizeof (GstQTPad),
+ gst_collect_pads_add_pad (qtmux->collect, newpad, sizeof (GstQTPad),
(GstCollectDataDestroyNotify) (gst_qt_mux_pad_reset));
/* set up pad */
gst_qt_mux_pad_reset (collect_pad);
@@ -3367,11 +3430,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
diff --git a/gst/isomp4/gstqtmux.h b/gst/isomp4/gstqtmux.h
index 1851973e5..fdbbb5a54 100644
--- a/gst/isomp4/gstqtmux.h
+++ b/gst/isomp4/gstqtmux.h
@@ -129,6 +129,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
diff --git a/gst/isomp4/gstqtmuxmap.c b/gst/isomp4/gstqtmuxmap.c
index e0fb78bf1..eb376aaec 100644
--- a/gst/isomp4/gstqtmuxmap.c
+++ b/gst/isomp4/gstqtmuxmap.c
@@ -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;
diff --git a/gst/isomp4/gstrtpxqtdepay.c b/gst/isomp4/gstrtpxqtdepay.c
index ce0778bc6..0df90106f 100644
--- a/gst/isomp4/gstrtpxqtdepay.c
+++ b/gst/isomp4/gstrtpxqtdepay.c
@@ -91,45 +91,30 @@ 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_RTP_BASE_DEPAYLOAD);
static void gst_rtp_xqt_depay_finalize (GObject * object);
-static gboolean gst_rtp_xqt_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_xqt_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_xqt_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_xqt_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
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_static_pad_template (element_class,
- &gst_rtp_xqt_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
parent_class = g_type_class_peek_parent (klass);
@@ -137,16 +122,25 @@ gst_rtp_xqt_depay_class_init (GstRtpXQTDepayClass * klass)
gstelement_class->change_state = gst_rtp_xqt_depay_change_state;
- gstbasertpdepayload_class->set_caps = gst_rtp_xqt_depay_setcaps;
- gstbasertpdepayload_class->process = gst_rtp_xqt_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_xqt_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_xqt_depay_process;
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,11 +207,13 @@ 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);
- gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD (rtpxqtdepay)->srcpad, caps);
+ gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD (rtpxqtdepay)->srcpad, caps);
gst_caps_unref (caps);
break;
}
@@ -238,7 +235,7 @@ too_short:
}
static gboolean
-gst_rtp_xqt_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_xqt_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
gint clock_rate = 90000; /* default */
@@ -252,14 +249,17 @@ gst_rtp_xqt_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
}
static GstBuffer *
-gst_rtp_xqt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_xqt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpXQTDepay *rtpxqtdepay;
- GstBuffer *outbuf;
+ GstBuffer *outbuf = NULL;
gboolean m;
+ GstRTPBuffer rtp = { NULL };
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,11 +591,13 @@ 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);
- gst_base_rtp_depayload_push (depayload, outbuf);
+ gst_rtp_base_depayload_push (depayload, outbuf);
/* aligned on 32 bit boundary */
slen = GST_ROUND_UP_4 (slen);
@@ -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;
}
}
diff --git a/gst/isomp4/gstrtpxqtdepay.h b/gst/isomp4/gstrtpxqtdepay.h
index 4b8a6df8b..a26ad6512 100644
--- a/gst/isomp4/gstrtpxqtdepay.h
+++ b/gst/isomp4/gstrtpxqtdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpXQTDepayClass GstRtpXQTDepayClass;
struct _GstRtpXQTDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
GstAdapter *adapter;
@@ -54,7 +54,7 @@ struct _GstRtpXQTDepay
struct _GstRtpXQTDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_xqt_depay_get_type (void);
diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c
index b91b4b3ba..b3653b432 100644
--- a/gst/isomp4/qtdemux.c
+++ b/gst/isomp4/qtdemux.c
@@ -33,7 +33,7 @@
* <refsect2>
* <title>Example launch line</title>
* |[
- * gst-launch filesrc location=test.mov ! qtdemux name=demux demux.audio_00 ! decodebin ! audioconvert ! audioresample ! autoaudiosink demux.video_00 ! queue ! decodebin ! ffmpegcolorspace ! videoscale ! autovideosink
+ * gst-launch filesrc location=test.mov ! qtdemux name=demux demux.audio_0 ! decodebin ! audioconvert ! audioresample ! autoaudiosink demux.video_0 ! queue ! decodebin ! ffmpegcolorspace ! videoscale ! autovideosink
* ]| Play (parse and decode) a .mov file and try to output it to
* an automatically detected soundcard and videosink. If the MOV file contains
* compressed audio or video data, this will only work if you have the
@@ -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"
@@ -366,24 +367,25 @@ static GstStaticPadTemplate gst_qtdemux_sink_template =
);
static GstStaticPadTemplate gst_qtdemux_videosrc_template =
-GST_STATIC_PAD_TEMPLATE ("video_%02d",
+GST_STATIC_PAD_TEMPLATE ("video_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate gst_qtdemux_audiosrc_template =
-GST_STATIC_PAD_TEMPLATE ("audio_%02d",
+GST_STATIC_PAD_TEMPLATE ("audio_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate gst_qtdemux_subsrc_template =
-GST_STATIC_PAD_TEMPLATE ("subtitle_%02d",
+GST_STATIC_PAD_TEMPLATE ("subtitle_%u",
GST_PAD_SRC,
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);
@@ -398,13 +400,15 @@ static void gst_qtdemux_set_index (GstElement * element, GstIndex * index);
static GstIndex *gst_qtdemux_get_index (GstElement * element);
static GstStateChangeReturn gst_qtdemux_change_state (GstElement * element,
GstStateChange transition);
-static gboolean qtdemux_sink_activate (GstPad * sinkpad);
-static gboolean qtdemux_sink_activate_pull (GstPad * sinkpad, gboolean active);
-static gboolean qtdemux_sink_activate_push (GstPad * sinkpad, gboolean active);
+static gboolean qtdemux_sink_activate (GstPad * sinkpad, GstObject * parent);
+static gboolean qtdemux_sink_activate_mode (GstPad * sinkpad,
+ GstObject * parent, GstPadMode mode, gboolean active);
static void gst_qtdemux_loop (GstPad * pad);
-static GstFlowReturn gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf);
-static gboolean gst_qtdemux_handle_sink_event (GstPad * pad, GstEvent * event);
+static GstFlowReturn gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent,
+ GstBuffer * inbuf);
+static gboolean gst_qtdemux_handle_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static gboolean qtdemux_parse_moov (GstQTDemux * qtdemux,
const guint8 * buffer, guint length);
@@ -428,27 +432,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_static_pad_template (element_class,
- &gst_qtdemux_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_qtdemux_videosrc_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_qtdemux_audiosrc_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
@@ -462,23 +445,36 @@ gst_qtdemux_class_init (GstQTDemuxClass * klass)
gobject_class->dispose = gst_qtdemux_dispose;
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_qtdemux_change_state);
-
gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_qtdemux_set_index);
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");
gst_pad_set_activate_function (qtdemux->sinkpad, qtdemux_sink_activate);
- gst_pad_set_activatepull_function (qtdemux->sinkpad,
- qtdemux_sink_activate_pull);
- gst_pad_set_activatepush_function (qtdemux->sinkpad,
- qtdemux_sink_activate_push);
+ gst_pad_set_activatemode_function (qtdemux->sinkpad,
+ qtdemux_sink_activate_mode);
gst_pad_set_chain_function (qtdemux->sinkpad, gst_qtdemux_chain);
gst_pad_set_event_function (qtdemux->sinkpad, gst_qtdemux_handle_sink_event);
gst_element_add_pad (GST_ELEMENT_CAST (qtdemux), qtdemux->sinkpad);
@@ -495,6 +491,8 @@ gst_qtdemux_init (GstQTDemux * qtdemux, GstQTDemuxClass * klass)
qtdemux->mdatoffset = GST_CLOCK_TIME_NONE;
qtdemux->mdatbuffer = NULL;
gst_segment_init (&qtdemux->segment, GST_FORMAT_TIME);
+
+ GST_OBJECT_FLAG_SET (qtdemux, GST_ELEMENT_FLAG_INDEXABLE);
}
static void
@@ -524,11 +522,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 +568,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 +597,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)) {
- GST_WARNING_OBJECT (qtdemux, "short read: %u < %" G_GUINT64_FORMAT,
- GST_BUFFER_SIZE (*buf), size);
+ if (G_UNLIKELY (bsize < size)) {
+ GST_WARNING_OBJECT (qtdemux,
+ "short read: %" G_GSIZE_FORMAT " < %" G_GUINT64_FORMAT, bsize, size);
gst_buffer_unref (*buf);
*buf = NULL;
return GST_FLOW_UNEXPECTED;
@@ -646,21 +679,6 @@ done:
}
#endif
-static const GstQueryType *
-gst_qtdemux_get_src_query_types (GstPad * pad)
-{
- static const GstQueryType src_types[] = {
- GST_QUERY_POSITION,
- GST_QUERY_DURATION,
- GST_QUERY_CONVERT,
- GST_QUERY_FORMATS,
- GST_QUERY_SEEKING,
- 0
- };
-
- return src_types;
-}
-
static gboolean
gst_qtdemux_get_duration (GstQTDemux * qtdemux, gint64 * duration)
{
@@ -678,18 +696,19 @@ gst_qtdemux_get_duration (GstQTDemux * qtdemux, gint64 * duration)
}
static gboolean
-gst_qtdemux_handle_src_query (GstPad * pad, GstQuery * query)
+gst_qtdemux_handle_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
gboolean res = FALSE;
- GstQTDemux *qtdemux = GST_QTDEMUX (gst_pad_get_parent (pad));
+ GstQTDemux *qtdemux = GST_QTDEMUX (parent);
GST_LOG_OBJECT (pad, "%s query", GST_QUERY_TYPE_NAME (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;
@@ -754,12 +773,10 @@ gst_qtdemux_handle_src_query (GstPad * pad, GstQuery * query)
break;
}
default:
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, parent, query);
break;
}
- gst_object_unref (qtdemux);
-
return res;
}
@@ -1155,7 +1172,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);
@@ -1164,12 +1180,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;
@@ -1278,7 +1293,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));
@@ -1304,8 +1319,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 */
@@ -1370,7 +1388,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);
}
@@ -1379,32 +1397,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 */
@@ -1413,12 +1407,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;
@@ -1463,10 +1455,11 @@ parse_error:
}
static gboolean
-gst_qtdemux_handle_src_event (GstPad * pad, GstEvent * event)
+gst_qtdemux_handle_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
gboolean res = TRUE;
- GstQTDemux *qtdemux = GST_QTDEMUX (gst_pad_get_parent (pad));
+ GstQTDemux *qtdemux = GST_QTDEMUX (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
@@ -1503,12 +1496,10 @@ gst_qtdemux_handle_src_event (GstPad * pad, GstEvent * event)
gst_event_unref (event);
break;
default:
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, event);
break;
}
- gst_object_unref (qtdemux);
-
done:
return res;
@@ -1595,32 +1586,25 @@ gst_qtdemux_find_sample (GstQTDemux * qtdemux, gint64 byte_pos, gboolean fw,
}
static gboolean
-gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
+gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstObject * parent,
+ GstEvent * event)
{
- GstQTDemux *demux = GST_QTDEMUX (GST_PAD_PARENT (sinkpad));
+ GstQTDemux *demux = GST_QTDEMUX (parent);
gboolean res;
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 */
@@ -1630,12 +1614,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;
@@ -1645,19 +1629,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");
@@ -1665,16 +1650,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);
@@ -1698,6 +1681,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);
@@ -1708,6 +1692,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:
@@ -1730,7 +1717,7 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
break;
}
- res = gst_pad_event_default (demux->sinkpad, event);
+ res = gst_pad_event_default (demux->sinkpad, parent, event);
drop:
return res;
@@ -1906,7 +1893,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);
}
}
@@ -1952,10 +1939,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);
@@ -2591,7 +2576,7 @@ qtdemux_parse_mfro (GstQTDemux * qtdemux, guint64 * mfra_offset,
gint64 len;
GstFormat fmt = GST_FORMAT_BYTES;
- if (!gst_pad_query_peer_duration (qtdemux->sinkpad, &fmt, &len)) {
+ if (!gst_pad_peer_query_duration (qtdemux->sinkpad, &fmt, &len)) {
GST_DEBUG_OBJECT (qtdemux, "upstream size not available; "
"can not locate mfro");
goto exit;
@@ -2653,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 */
@@ -2704,51 +2692,49 @@ 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));
+ ("We got less than expected (received %" G_GSIZE_FORMAT
+ ", wanted %u, 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;
@@ -2764,8 +2750,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;
}
@@ -2778,8 +2765,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;
}
@@ -2794,8 +2782,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;
@@ -2840,7 +2829,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)
@@ -2916,7 +2905,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));
@@ -3080,13 +3069,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;
@@ -3348,8 +3342,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;
@@ -3410,16 +3404,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) {
@@ -3469,7 +3463,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;
}
}
@@ -3488,10 +3482,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;
@@ -3521,12 +3514,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 */
@@ -3541,25 +3532,26 @@ 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);
}
- GST_LOG_OBJECT (qtdemux, "3GPP timed text subtitle: %d/%d", nsize, size);
+ GST_LOG_OBJECT (qtdemux, "3GPP timed text subtitle: %d/%" G_GSIZE_FORMAT "",
+ nsize, size);
/* 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 */
@@ -3581,8 +3573,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),
@@ -3599,7 +3595,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);
}
@@ -3618,7 +3614,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);
@@ -3626,7 +3621,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);
@@ -3637,8 +3632,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)) {
@@ -3674,8 +3668,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)),
@@ -3834,7 +3826,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;
@@ -3845,7 +3836,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 */
@@ -3858,11 +3848,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;
@@ -4009,10 +3994,8 @@ gst_qtdemux_check_seekability (GstQTDemux * demux)
/* 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 (demux, "doing duration query to fix up unset stop");
- gst_pad_query_peer_duration (demux->sinkpad, &fmt, &stop);
+ gst_pad_peer_query_duration (demux->sinkpad, GST_FORMAT_BYTES, &stop);
}
/* if upstream doesn't know the size, it's likely that it's not seekable in
@@ -4033,12 +4016,12 @@ done:
/* FIXME, unverified after edit list updates */
static GstFlowReturn
-gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
+gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf)
{
GstQTDemux *demux;
GstFlowReturn ret = GST_FLOW_OK;
- demux = GST_QTDEMUX (gst_pad_get_parent (sinkpad));
+ demux = GST_QTDEMUX (parent);
gst_adapter_push (demux->adapter, inbuf);
@@ -4046,8 +4029,9 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
if (demux->neededbytes == -1)
goto eos;
- GST_DEBUG_OBJECT (demux, "pushing in inbuf %p, neededbytes:%u, available:%u",
- inbuf, demux->neededbytes, gst_adapter_available (demux->adapter));
+ GST_DEBUG_OBJECT (demux,
+ "pushing in inbuf %p, neededbytes:%u, available:%" G_GSIZE_FORMAT, inbuf,
+ demux->neededbytes, gst_adapter_available (demux->adapter));
while (((gst_adapter_available (demux->adapter)) >= demux->neededbytes) &&
(ret == GST_FLOW_OK)) {
@@ -4064,11 +4048,13 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
gst_qtdemux_check_seekability (demux);
- 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);
+ data = NULL;
GST_DEBUG_OBJECT (demux, "Peeking found [%" GST_FOURCC_FORMAT "] "
"size: %" G_GUINT64_FORMAT, GST_FOURCC_ARGS (fourcc), size);
if (size == 0) {
@@ -4130,7 +4116,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))
@@ -4164,7 +4150,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,
@@ -4175,11 +4161,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);
@@ -4194,6 +4177,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);
ret = GST_FLOW_ERROR;
goto done;
}
@@ -4212,6 +4196,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);
+ data = NULL;
if (demux->mdatbuffer && demux->n_streams) {
/* the mdat was before the header */
@@ -4256,12 +4242,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
@@ -4401,7 +4389,6 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
demux->neededbytes);
}
done:
- gst_object_unref (demux);
return ret;
@@ -4435,38 +4422,60 @@ no_moov:
}
static gboolean
-qtdemux_sink_activate (GstPad * sinkpad)
+qtdemux_sink_activate (GstPad * sinkpad, GstObject * parent)
{
- if (gst_pad_check_pull_range (sinkpad))
- return gst_pad_activate_pull (sinkpad, TRUE);
- else
- return gst_pad_activate_push (sinkpad, TRUE);
-}
+ GstQuery *query;
+ gboolean pull_mode;
-static gboolean
-qtdemux_sink_activate_pull (GstPad * sinkpad, gboolean active)
-{
- GstQTDemux *demux = GST_QTDEMUX (GST_PAD_PARENT (sinkpad));
+ query = gst_query_new_scheduling ();
- 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);
+ if (!gst_pad_peer_query (sinkpad, query)) {
+ gst_query_unref (query);
+ goto activate_push;
+ }
+
+ pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL);
+ gst_query_unref (query);
+
+ if (!pull_mode)
+ goto activate_push;
+
+ GST_DEBUG_OBJECT (sinkpad, "activating pull");
+ return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
+
+activate_push:
+ {
+ GST_DEBUG_OBJECT (sinkpad, "activating push");
+ return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
}
}
static gboolean
-qtdemux_sink_activate_push (GstPad * sinkpad, gboolean active)
+qtdemux_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
+ GstPadMode mode, gboolean active)
{
- GstQTDemux *demux = GST_QTDEMUX (GST_PAD_PARENT (sinkpad));
-
- demux->pullbased = FALSE;
+ gboolean res;
+ GstQTDemux *demux = GST_QTDEMUX (parent);
- return TRUE;
+ switch (mode) {
+ case GST_PAD_MODE_PUSH:
+ demux->pullbased = FALSE;
+ res = TRUE;
+ break;
+ case GST_PAD_MODE_PULL:
+ if (active) {
+ demux->pullbased = TRUE;
+ res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_qtdemux_loop,
+ sinkpad);
+ } else {
+ res = gst_pad_stop_task (sinkpad);
+ }
+ break;
+ default:
+ res = FALSE;
+ break;
+ }
+ return res;
}
#ifdef HAVE_ZLIB
@@ -4654,19 +4663,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;
@@ -4975,11 +4984,9 @@ 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);
+ gchar *name = g_strdup_printf ("video_%u", qtdemux->n_video_streams);
stream->pad =
gst_pad_new_from_static_template (&gst_qtdemux_videosrc_template, name);
@@ -5079,10 +5086,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);
@@ -5097,7 +5102,7 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux,
}
qtdemux->n_video_streams++;
} else if (stream->subtype == FOURCC_soun) {
- gchar *name = g_strdup_printf ("audio_%02d", qtdemux->n_audio_streams);
+ gchar *name = g_strdup_printf ("audio_%u", qtdemux->n_audio_streams);
stream->pad =
gst_pad_new_from_static_template (&gst_qtdemux_audiosrc_template, name);
@@ -5111,7 +5116,7 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux,
} else if (stream->subtype == FOURCC_strm) {
GST_DEBUG_OBJECT (qtdemux, "stream type, not creating pad");
} else if (stream->subtype == FOURCC_subp || stream->subtype == FOURCC_text) {
- gchar *name = g_strdup_printf ("subtitle_%02d", qtdemux->n_sub_streams);
+ gchar *name = g_strdup_printf ("subtitle_%u", qtdemux->n_sub_streams);
stream->pad =
gst_pad_new_from_static_template (&gst_qtdemux_subsrc_template, name);
@@ -5127,27 +5132,19 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux,
gst_pad_use_fixed_caps (stream->pad);
gst_pad_set_event_function (stream->pad, gst_qtdemux_handle_src_event);
- gst_pad_set_query_type_function (stream->pad,
- gst_qtdemux_get_src_query_types);
gst_pad_set_query_function (stream->pad, gst_qtdemux_handle_src_query);
+ gst_pad_set_active (stream->pad, TRUE);
GST_DEBUG_OBJECT (qtdemux, "setting caps %" GST_PTR_FORMAT, stream->caps);
gst_pad_set_caps (stream->pad, stream->caps);
GST_DEBUG_OBJECT (qtdemux, "adding pad %s %p to qtdemux %p",
GST_OBJECT_NAME (stream->pad), stream->pad, qtdemux);
- gst_pad_set_active (stream->pad, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (qtdemux), stream->pad);
+
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;
}
@@ -5168,17 +5165,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)) {
@@ -5218,6 +5219,8 @@ qtdemux_add_fragmented_samples (GstQTDemux * qtdemux)
GstBuffer *buf = NULL;
GstFlowReturn ret = GST_FLOW_OK;
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);
@@ -5237,13 +5240,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;
@@ -6082,7 +6087,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);
}
}
}
@@ -6239,12 +6244,14 @@ 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) {
- GST_DEBUG ("Atom should have size 0x11, not %u", size);
+ data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+
+ if (size != 0x11) {
+ GST_DEBUG ("Atom should have size 0x11, not %" G_GSIZE_FORMAT, size);
goto bad_data;
}
@@ -6268,9 +6275,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;
}
@@ -6475,7 +6484,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
stream->caps =
qtdemux_video_caps (qtdemux, stream, fourcc, stsd_data, &codec);
if (codec) {
- list = gst_tag_list_new ();
+ list = gst_tag_list_new_empty ();
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_VIDEO_CODEC, codec, NULL);
g_free (codec);
@@ -6538,7 +6547,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);
@@ -6569,7 +6578,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
}
if (!list)
- list = gst_tag_list_new ();
+ list = gst_tag_list_new_empty ();
if (max_bitrate > 0 && max_bitrate < G_MAXUINT32) {
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
@@ -6617,7 +6626,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);
@@ -6630,7 +6639,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;
@@ -6661,21 +6670,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 */
@@ -6742,7 +6752,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, };
@@ -6800,7 +6810,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);
@@ -6830,7 +6840,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);
@@ -6864,7 +6874,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
case FOURCC_ovc1:
{
GNode *ovc1;
- gchar *ovc1_data;
+ guint8 *ovc1_data;
guint ovc1_len;
GstBuffer *buf;
@@ -6879,7 +6889,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);
@@ -7054,14 +7064,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;
@@ -7092,7 +7103,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;
@@ -7130,7 +7141,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
GstStructure *s;
gint bitrate = 0;
- list = gst_tag_list_new ();
+ list = gst_tag_list_new_empty ();
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_AUDIO_CODEC, codec, NULL);
g_free (codec);
@@ -7190,9 +7201,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)) {
@@ -7230,7 +7240,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);
@@ -7265,7 +7275,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);
@@ -7286,14 +7296,14 @@ 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. */
if ((len - 0x34) > 8 &&
(bitrate = qtdemux_parse_amr_bitrate (buf, amrwb))) {
if (!list)
- list = gst_tag_list_new ();
+ list = gst_tag_list_new_empty ();
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_MAXIMUM_BITRATE, bitrate, NULL);
}
@@ -7330,7 +7340,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
stream->caps =
qtdemux_sub_caps (qtdemux, stream, fourcc, stsd_data, &codec);
if (codec) {
- list = gst_tag_list_new ();
+ list = gst_tag_list_new_empty ();
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_SUBTITLE_CODEC, codec, NULL);
g_free (codec);
@@ -7442,7 +7452,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
const gchar *lang_code;
if (!list)
- list = gst_tag_list_new ();
+ list = gst_tag_list_new_empty ();
/* convert ISO 639-2 code to ISO 639-1 */
lang_code = gst_tag_get_language_code (stream->lang_id);
@@ -7508,7 +7518,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;
@@ -7519,8 +7528,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_peer_query_duration (qtdemux->sinkpad, GST_FORMAT_BYTES, &size)) {
GST_DEBUG_OBJECT (qtdemux,
"Size in bytes of the stream not known - bailing");
return;
@@ -7587,7 +7595,7 @@ gst_qtdemux_guess_bitrate (GstQTDemux * qtdemux)
", Stream bitrate = %u", sys_bitrate, bitrate);
if (!stream->pending_tags)
- stream->pending_tags = gst_tag_list_new ();
+ stream->pending_tags = gst_tag_list_new_empty ();
gst_tag_list_add (stream->pending_tags, GST_TAG_MERGE_REPLACE,
GST_TAG_BITRATE, bitrate, NULL);
@@ -7700,16 +7708,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;
@@ -8122,7 +8132,7 @@ qtdemux_tag_add_covr (GstQTDemux * qtdemux, const char *tag1, const char *dummy,
GNode *data;
int len;
int type;
- GstBuffer *buf;
+ GstSample *sample;
data = qtdemux_tree_get_child_by_type (node, FOURCC_data);
if (data) {
@@ -8130,12 +8140,13 @@ qtdemux_tag_add_covr (GstQTDemux * qtdemux, const char *tag1, const char *dummy,
type = QT_UINT32 ((guint8 *) data->data + 8);
GST_DEBUG_OBJECT (qtdemux, "have covr tag, type=%d,len=%d", type, len);
if ((type == 0x0000000d || type == 0x0000000e) && len > 16) {
- if ((buf = gst_tag_image_data_to_image_buffer ((guint8 *) data->data + 16,
+ if ((sample =
+ gst_tag_image_data_to_image_sample ((guint8 *) data->data + 16,
len - 16, GST_TAG_IMAGE_TYPE_NONE))) {
GST_DEBUG_OBJECT (qtdemux, "adding tag size %d", len - 16);
gst_tag_list_add (qtdemux->tag_list, GST_TAG_MERGE_REPLACE,
- tag1, buf, NULL);
- gst_buffer_unref (buf);
+ tag1, sample, NULL);
+ gst_sample_unref (sample);
}
}
}
@@ -8381,9 +8392,8 @@ qtdemux_tag_add_id32 (GstQTDemux * demux, const char *tag,
if (len < 12 + 2)
return;
- buf = gst_buffer_new ();
- GST_BUFFER_DATA (buf) = data + 14;
- GST_BUFFER_SIZE (buf) = len - 14;
+ buf = gst_buffer_new_allocate (NULL, len - 14, 0);
+ gst_buffer_fill (buf, 0, data + 14, len - 14);
taglist = gst_tag_list_from_id3v2_tag (buf);
if (taglist) {
@@ -8488,7 +8498,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_____ ||
@@ -8514,12 +8524,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);
@@ -8549,7 +8560,7 @@ qtdemux_parse_udta (GstQTDemux * qtdemux, GNode * udta)
GST_DEBUG_OBJECT (qtdemux, "new tag list");
if (!qtdemux->tag_list)
- qtdemux->tag_list = gst_tag_list_new ();
+ qtdemux->tag_list = gst_tag_list_new_empty ();
i = 0;
while (i < G_N_ELEMENTS (add_funcs)) {
@@ -8581,10 +8592,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);
@@ -8769,7 +8778,7 @@ qtdemux_add_container_format (GstQTDemux * qtdemux, GstTagList * tags)
const gchar *fmt;
if (tags == NULL)
- tags = gst_tag_list_new ();
+ tags = gst_tag_list_new_empty ();
if (qtdemux->major_brand == FOURCC_mjp2)
fmt = "Motion JPEG 2000";
@@ -8847,7 +8856,7 @@ qtdemux_parse_tree (GstQTDemux * qtdemux)
}
if (datetime) {
if (!qtdemux->tag_list)
- qtdemux->tag_list = gst_tag_list_new ();
+ qtdemux->tag_list = gst_tag_list_new_empty ();
/* Use KEEP as explicit tags should have a higher priority than mvhd tag */
gst_tag_list_add (qtdemux->tag_list, GST_TAG_MERGE_KEEP, GST_TAG_DATE_TIME,
@@ -8876,7 +8885,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;
/* also do not exceed duration; stop is set that way post seek anyway,
* and segment activation falls back to duration,
* whereas loop only checks stop, so let's align this here as well */
@@ -9081,11 +9090,11 @@ gst_qtdemux_handle_esds (GstQTDemux * qtdemux, QtDemuxStream * stream,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
break;
case 0x6C: /* MJPEG */
- caps = gst_caps_new_simple ("image/jpeg", NULL);
+ caps = gst_caps_new_empty_simple ("image/jpeg");
codec_name = "Motion-JPEG";
break;
case 0x6D: /* PNG */
- caps = gst_caps_new_simple ("image/png", NULL);
+ caps = gst_caps_new_empty_simple ("image/png");
codec_name = "PNG still images";
break;
case 0x6E: /* JPEG2000 */
@@ -9094,7 +9103,7 @@ gst_qtdemux_handle_esds (GstQTDemux * qtdemux, QtDemuxStream * stream,
break;
case 0xA4: /* Dirac */
codec_name = "Dirac";
- caps = gst_caps_new_simple ("video/x-dirac", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-dirac");
break;
case 0xA5: /* AC3 */
codec_name = "AC-3 audio";
@@ -9104,7 +9113,7 @@ gst_qtdemux_handle_esds (GstQTDemux * qtdemux, QtDemuxStream * stream,
case 0xE1: /* QCELP */
/* QCELP, the codec_data is a riff tag (little endian) with
* more info (http://ftp.3gpp2.org/TSGC/Working/2003/2003-05-SanDiego/TSG-C-2003-05-San%20Diego/WG1/SWG12/C12-20030512-006%20=%20C12-20030217-015_Draft_Baseline%20Text%20of%20FFMS_R2.doc). */
- caps = gst_caps_new_simple ("audio/qcelp", NULL);
+ caps = gst_caps_new_empty_simple ("audio/qcelp");
codec_name = "QCELP";
break;
default:
@@ -9126,7 +9135,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);
@@ -9156,22 +9165,22 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
switch (fourcc) {
case GST_MAKE_FOURCC ('p', 'n', 'g', ' '):
_codec ("PNG still images");
- caps = gst_caps_new_simple ("image/png", NULL);
+ caps = gst_caps_new_empty_simple ("image/png");
break;
case GST_MAKE_FOURCC ('j', 'p', 'e', 'g'):
_codec ("JPEG still images");
- caps = gst_caps_new_simple ("image/jpeg", NULL);
+ caps = gst_caps_new_empty_simple ("image/jpeg");
break;
case GST_MAKE_FOURCC ('m', 'j', 'p', 'a'):
case GST_MAKE_FOURCC ('A', 'V', 'D', 'J'):
case GST_MAKE_FOURCC ('M', 'J', 'P', 'G'):
case GST_MAKE_FOURCC ('d', 'm', 'b', '1'):
_codec ("Motion-JPEG");
- caps = gst_caps_new_simple ("image/jpeg", NULL);
+ caps = gst_caps_new_empty_simple ("image/jpeg");
break;
case GST_MAKE_FOURCC ('m', 'j', 'p', 'b'):
_codec ("Motion-JPEG format B");
- caps = gst_caps_new_simple ("video/x-mjpeg-b", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-mjpeg-b");
break;
case GST_MAKE_FOURCC ('m', 'j', 'p', '2'):
_codec ("JPEG-2000");
@@ -9197,43 +9206,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_empty_simple ("video/x-raw");
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 */
@@ -9243,39 +9229,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'):
@@ -9303,7 +9280,7 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
break;
case GST_MAKE_FOURCC ('g', 'i', 'f', ' '):
_codec ("GIF still images");
- caps = gst_caps_new_simple ("image/gif", NULL);
+ caps = gst_caps_new_empty_simple ("image/gif");
break;
case GST_MAKE_FOURCC ('h', '2', '6', '3'):
case GST_MAKE_FOURCC ('H', '2', '6', '3'):
@@ -9311,7 +9288,7 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
case GST_MAKE_FOURCC ('U', '2', '6', '3'):
_codec ("H.263");
/* ffmpeg uses the height/width props, don't know why */
- caps = gst_caps_new_simple ("video/x-h263", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-h263");
break;
case GST_MAKE_FOURCC ('m', 'p', '4', 'v'):
case GST_MAKE_FOURCC ('M', 'P', '4', 'V'):
@@ -9328,7 +9305,7 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
case GST_MAKE_FOURCC ('3', 'I', 'V', '1'):
case GST_MAKE_FOURCC ('3', 'I', 'V', '2'):
_codec ("3ivX video");
- caps = gst_caps_new_simple ("video/x-3ivx", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-3ivx");
break;
case GST_MAKE_FOURCC ('D', 'I', 'V', '3'):
_codec ("DivX 3");
@@ -9349,7 +9326,7 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
case GST_MAKE_FOURCC ('X', 'V', 'I', 'D'):
case GST_MAKE_FOURCC ('x', 'v', 'i', 'd'):
_codec ("XVID MPEG-4");
- caps = gst_caps_new_simple ("video/x-xvid", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-xvid");
break;
case GST_MAKE_FOURCC ('F', 'M', 'P', '4'):
@@ -9362,15 +9339,15 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
case GST_MAKE_FOURCC ('c', 'v', 'i', 'd'):
_codec ("Cinepak");
- caps = gst_caps_new_simple ("video/x-cinepak", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-cinepak");
break;
case GST_MAKE_FOURCC ('q', 'd', 'r', 'w'):
_codec ("Apple QuickDraw");
- caps = gst_caps_new_simple ("video/x-qdrw", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-qdrw");
break;
case GST_MAKE_FOURCC ('r', 'p', 'z', 'a'):
_codec ("Apple video");
- caps = gst_caps_new_simple ("video/x-apple-video", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-apple-video");
break;
case GST_MAKE_FOURCC ('a', 'v', 'c', '1'):
_codec ("H.264 / AVC");
@@ -9421,26 +9398,26 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
break;
case GST_MAKE_FOURCC ('s', 'm', 'c', ' '):
_codec ("Apple Graphics (SMC)");
- caps = gst_caps_new_simple ("video/x-smc", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-smc");
break;
case GST_MAKE_FOURCC ('V', 'P', '3', '1'):
_codec ("VP3");
- caps = gst_caps_new_simple ("video/x-vp3", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-vp3");
break;
case GST_MAKE_FOURCC ('X', 'i', 'T', 'h'):
_codec ("Theora");
- caps = gst_caps_new_simple ("video/x-theora", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-theora");
/* theora uses one byte of padding in the data stream because it does not
* allow 0 sized packets while theora does */
stream->padding = 1;
break;
case GST_MAKE_FOURCC ('d', 'r', 'a', 'c'):
_codec ("Dirac");
- caps = gst_caps_new_simple ("video/x-dirac", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-dirac");
break;
case GST_MAKE_FOURCC ('t', 'i', 'f', 'f'):
_codec ("TIFF still images");
- caps = gst_caps_new_simple ("image/tiff", NULL);
+ caps = gst_caps_new_empty_simple ("image/tiff");
break;
case GST_MAKE_FOURCC ('i', 'c', 'o', 'd'):
_codec ("Apple Intermediate Codec");
@@ -9457,9 +9434,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:
@@ -9468,7 +9443,7 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
s = g_strdup_printf ("video/x-gst-fourcc-%" GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (fourcc));
- caps = gst_caps_new_simple (s, NULL);
+ caps = gst_caps_new_empty_simple (s);
break;
}
}
@@ -9476,7 +9451,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;
@@ -9497,8 +9472,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;
@@ -9507,53 +9482,51 @@ 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, "F64BE", 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, "F32BE", 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, "S24BE", 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, "S32BE", NULL);
break;
case GST_MAKE_FOURCC ('u', 'l', 'a', 'w'):
_codec ("Mu-law audio");
- caps = gst_caps_new_simple ("audio/x-mulaw", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-mulaw");
break;
case GST_MAKE_FOURCC ('a', 'l', 'a', 'w'):
_codec ("A-law audio");
- caps = gst_caps_new_simple ("audio/x-alaw", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-alaw");
break;
case 0x0200736d:
case 0x6d730002:
@@ -9609,11 +9582,11 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
break;
case GST_MAKE_FOURCC ('O', 'g', 'g', 'V'):
/* ogg/vorbis */
- caps = gst_caps_new_simple ("application/ogg", NULL);
+ caps = gst_caps_new_empty_simple ("application/ogg");
break;
case GST_MAKE_FOURCC ('d', 'v', 'c', 'a'):
_codec ("DV audio");
- caps = gst_caps_new_simple ("audio/x-dv", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-dv");
break;
case GST_MAKE_FOURCC ('m', 'p', '4', 'a'):
_codec ("MPEG-4 AAC audio");
@@ -9623,7 +9596,7 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
break;
case GST_MAKE_FOURCC ('Q', 'D', 'M', 'C'):
_codec ("QDesign Music");
- caps = gst_caps_new_simple ("audio/x-qdm", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-qdm");
break;
case GST_MAKE_FOURCC ('Q', 'D', 'M', '2'):
_codec ("QDesign Music v.2");
@@ -9634,20 +9607,20 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
"bitrate", G_TYPE_INT, QT_UINT32 (data + 40),
"blocksize", G_TYPE_INT, QT_UINT32 (data + 44), NULL);
} else {
- caps = gst_caps_new_simple ("audio/x-qdm2", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-qdm2");
}
break;
case GST_MAKE_FOURCC ('a', 'g', 's', 'm'):
_codec ("GSM audio");
- caps = gst_caps_new_simple ("audio/x-gsm", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-gsm");
break;
case GST_MAKE_FOURCC ('s', 'a', 'm', 'r'):
_codec ("AMR audio");
- caps = gst_caps_new_simple ("audio/AMR", NULL);
+ caps = gst_caps_new_empty_simple ("audio/AMR");
break;
case GST_MAKE_FOURCC ('s', 'a', 'w', 'b'):
_codec ("AMR-WB audio");
- caps = gst_caps_new_simple ("audio/AMR-WB", NULL);
+ caps = gst_caps_new_empty_simple ("audio/AMR-WB");
break;
case GST_MAKE_FOURCC ('i', 'm', 'a', '4'):
_codec ("Quicktime IMA ADPCM");
@@ -9656,7 +9629,7 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
break;
case GST_MAKE_FOURCC ('a', 'l', 'a', 'c'):
_codec ("Apple lossless audio");
- caps = gst_caps_new_simple ("audio/x-alac", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-alac");
break;
case GST_MAKE_FOURCC ('Q', 'c', 'l', 'p'):
_codec ("QualComm PureVoice");
@@ -9664,7 +9637,7 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
break;
case FOURCC_owma:
_codec ("WMA");
- caps = gst_caps_new_simple ("audio/x-wma", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-wma");
break;
case GST_MAKE_FOURCC ('q', 't', 'v', 'r'):
/* ? */
@@ -9674,7 +9647,7 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
s = g_strdup_printf ("audio/x-gst-fourcc-%" GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (fourcc));
- caps = gst_caps_new_simple (s, NULL);
+ caps = gst_caps_new_empty_simple (s);
break;
}
}
@@ -9682,7 +9655,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;
@@ -9699,7 +9672,7 @@ qtdemux_sub_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
switch (fourcc) {
case GST_MAKE_FOURCC ('m', 'p', '4', 's'):
_codec ("DVD subtitle");
- caps = gst_caps_new_simple ("video/x-dvd-subpicture", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-dvd-subpicture");
break;
case GST_MAKE_FOURCC ('t', 'e', 'x', 't'):
_codec ("Quicktime timed text");
@@ -9707,7 +9680,7 @@ qtdemux_sub_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
case GST_MAKE_FOURCC ('t', 'x', '3', 'g'):
_codec ("3GPP timed text");
text:
- caps = gst_caps_new_simple ("text/plain", NULL);
+ caps = gst_caps_new_empty_simple ("text/plain");
/* actual text piece needs to be extracted */
stream->need_process = TRUE;
break;
@@ -9717,7 +9690,7 @@ qtdemux_sub_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
s = g_strdup_printf ("text/x-gst-fourcc-%" GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (fourcc));
- caps = gst_caps_new_simple (s, NULL);
+ caps = gst_caps_new_empty_simple (s);
break;
}
}
diff --git a/gst/isomp4/qtdemux.h b/gst/isomp4/qtdemux.h
index 8d35ead0a..17fe8817b 100644
--- a/gst/isomp4/qtdemux.h
+++ b/gst/isomp4/qtdemux.h
@@ -100,7 +100,6 @@ struct _GstQTDemux {
/* configured playback region */
GstSegment segment;
- gboolean segment_running;
GstEvent *pending_newsegment;
/* gst index support */
diff --git a/gst/isomp4/qtdemux_dump.c b/gst/isomp4/qtdemux_dump.c
index fa6676758..9a8a704db 100644
--- a/gst/isomp4/qtdemux_dump.c
+++ b/gst/isomp4/qtdemux_dump.c
@@ -800,7 +800,7 @@ qtdemux_node_dump_foreach (GNode * node, gpointer qtdemux)
gboolean
qtdemux_node_dump (GstQTDemux * qtdemux, GNode * node)
{
- if (__gst_debug_min < GST_LEVEL_LOG)
+ if (_gst_debug_min < GST_LEVEL_LOG)
return TRUE;
g_node_traverse (node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
diff --git a/gst/law/alaw-decode.c b/gst/law/alaw-decode.c
index 2fa6a5da9..4d7d7bd6c 100644
--- a/gst/law/alaw-decode.c
+++ b/gst/law/alaw-decode.c
@@ -36,9 +36,14 @@ GST_DEBUG_CATEGORY_STATIC (alaw_dec_debug);
static GstStateChangeReturn
gst_alaw_dec_change_state (GstElement * element, GstStateChange transition);
-static GstFlowReturn gst_alaw_dec_chain (GstPad * pad, GstBuffer * buffer);
-GST_BOILERPLATE (GstALawDec, gst_alaw_dec, GstElement, GST_TYPE_ELEMENT);
+static gboolean gst_alaw_dec_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static GstFlowReturn gst_alaw_dec_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
+
+#define gst_alaw_dec_parent_class parent_class
+G_DEFINE_TYPE (GstALawDec, gst_alaw_dec, GST_TYPE_ELEMENT);
/* some day we might have defines in gstconfig.h that tell us about the
* desired cpu/memory/binary size trade-offs */
@@ -110,16 +115,13 @@ alaw_to_s16 (guint8 a_val)
#endif /* GST_ALAW_DEC_USE_TABLE */
static gboolean
-gst_alaw_dec_sink_setcaps (GstPad * pad, GstCaps * caps)
+gst_alaw_dec_setcaps (GstALawDec * alawdec, GstCaps * caps)
{
- GstALawDec *alawdec;
GstStructure *structure;
int rate, channels;
gboolean ret;
GstCaps *outcaps;
- alawdec = GST_ALAW_DEC (GST_PAD_PARENT (pad));
-
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "rate", &rate);
@@ -146,7 +148,7 @@ gst_alaw_dec_sink_setcaps (GstPad * pad, GstCaps * caps)
}
static GstCaps *
-gst_alaw_dec_getcaps (GstPad * pad)
+gst_alaw_dec_getcaps (GstPad * pad, GstCaps * filter)
{
GstALawDec *alawdec;
GstPad *otherpad;
@@ -166,7 +168,7 @@ gst_alaw_dec_getcaps (GstPad * pad)
otherpad = alawdec->srcpad;
}
/* get caps from the peer, this can return NULL when there is no peer */
- othercaps = gst_pad_peer_get_caps (otherpad);
+ othercaps = gst_pad_peer_query_caps (otherpad, filter);
/* get the template caps to make sure we return something acceptable */
templ = gst_pad_get_pad_template_caps (pad);
@@ -207,40 +209,59 @@ gst_alaw_dec_getcaps (GstPad * pad)
return result;
}
-static void
-gst_alaw_dec_base_init (gpointer klass)
+static gboolean
+gst_alaw_dec_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ gboolean res;
- gst_element_class_add_static_pad_template (element_class,
- &alaw_dec_src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &alaw_dec_sink_factory);
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
- gst_element_class_set_details_simple (element_class, "A Law audio decoder",
- "Codec/Decoder/Audio", "Convert 8bit A law to 16bit PCM",
- "Zaheer Abbas Merali <zaheerabbas at merali dot org>");
+ gst_query_parse_caps (query, &filter);
+ caps = gst_alaw_dec_getcaps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
- GST_DEBUG_CATEGORY_INIT (alaw_dec_debug, "alawdec", 0, "A Law audio decoder");
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_query_default (pad, parent, query);
+ break;
+ }
+ return res;
}
static void
gst_alaw_dec_class_init (GstALawDecClass * klass)
{
- GstElementClass *element_class = (GstElementClass *) klass;
+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&alaw_dec_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&alaw_dec_sink_factory));
+
+ gst_element_class_set_details_simple (element_class, "A Law audio decoder",
+ "Codec/Decoder/Audio", "Convert 8bit A law to 16bit PCM",
+ "Zaheer Abbas Merali <zaheerabbas at merali dot org>");
element_class->change_state = GST_DEBUG_FUNCPTR (gst_alaw_dec_change_state);
+
+ GST_DEBUG_CATEGORY_INIT (alaw_dec_debug, "alawdec", 0, "A Law audio decoder");
}
static void
-gst_alaw_dec_init (GstALawDec * alawdec, GstALawDecClass * klass)
+gst_alaw_dec_init (GstALawDec * alawdec)
{
alawdec->sinkpad =
gst_pad_new_from_static_template (&alaw_dec_sink_factory, "sink");
- gst_pad_set_setcaps_function (alawdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_alaw_dec_sink_setcaps));
- gst_pad_set_getcaps_function (alawdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_alaw_dec_getcaps));
+ gst_pad_set_query_function (alawdec->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_alaw_dec_query));
+ gst_pad_set_event_function (alawdec->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_alaw_dec_event));
gst_pad_set_chain_function (alawdec->sinkpad,
GST_DEBUG_FUNCPTR (gst_alaw_dec_chain));
gst_element_add_pad (GST_ELEMENT (alawdec), alawdec->sinkpad);
@@ -248,23 +269,50 @@ gst_alaw_dec_init (GstALawDec * alawdec, GstALawDecClass * klass)
alawdec->srcpad =
gst_pad_new_from_static_template (&alaw_dec_src_factory, "src");
gst_pad_use_fixed_caps (alawdec->srcpad);
- gst_pad_set_getcaps_function (alawdec->srcpad,
- GST_DEBUG_FUNCPTR (gst_alaw_dec_getcaps));
+ gst_pad_set_query_function (alawdec->srcpad,
+ GST_DEBUG_FUNCPTR (gst_alaw_dec_query));
gst_element_add_pad (GST_ELEMENT (alawdec), alawdec->srcpad);
}
+static gboolean
+gst_alaw_dec_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+ GstALawDec *alawdec;
+ gboolean res;
+
+ alawdec = GST_ALAW_DEC (parent);
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ gst_alaw_dec_setcaps (alawdec, caps);
+ gst_event_unref (event);
+
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_event_default (pad, parent, event);
+ break;
+ }
+ return res;
+}
+
static GstFlowReturn
-gst_alaw_dec_chain (GstPad * pad, GstBuffer * buffer)
+gst_alaw_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstALawDec *alawdec;
gint16 *linear_data;
guint8 *alaw_data;
- guint alaw_size;
+ gsize alaw_size;
GstBuffer *outbuf;
gint i;
GstFlowReturn ret;
- alawdec = GST_ALAW_DEC (GST_PAD_PARENT (pad));
+ alawdec = GST_ALAW_DEC (parent);
if (G_UNLIKELY (alawdec->rate == 0))
goto not_negotiated;
@@ -272,17 +320,11 @@ gst_alaw_dec_chain (GstPad * pad, GstBuffer * buffer)
GST_LOG_OBJECT (alawdec, "buffer with ts=%" GST_TIME_FORMAT,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
- alaw_data = GST_BUFFER_DATA (buffer);
- alaw_size = GST_BUFFER_SIZE (buffer);
+ alaw_data = gst_buffer_map (buffer, &alaw_size, NULL, GST_MAP_READ);
- ret =
- gst_pad_alloc_buffer_and_set_caps (alawdec->srcpad,
- GST_BUFFER_OFFSET_NONE, alaw_size * 2, GST_PAD_CAPS (alawdec->srcpad),
- &outbuf);
- if (ret != GST_FLOW_OK)
- goto alloc_failed;
+ outbuf = gst_buffer_new_allocate (NULL, alaw_size, 0);
- linear_data = (gint16 *) GST_BUFFER_DATA (outbuf);
+ linear_data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
/* copy discont flag */
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
@@ -290,11 +332,13 @@ gst_alaw_dec_chain (GstPad * pad, GstBuffer * buffer)
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
- gst_buffer_set_caps (outbuf, GST_PAD_CAPS (alawdec->srcpad));
for (i = 0; i < alaw_size; i++) {
linear_data[i] = alaw_to_s16 (alaw_data[i]);
}
+
+ gst_buffer_unmap (outbuf, linear_data, -1);
+ gst_buffer_unmap (buffer, alaw_data, -1);
gst_buffer_unref (buffer);
ret = gst_pad_push (alawdec->srcpad, outbuf);
@@ -307,13 +351,6 @@ not_negotiated:
GST_WARNING_OBJECT (alawdec, "no input format set: not-negotiated");
return GST_FLOW_NOT_NEGOTIATED;
}
-alloc_failed:
- {
- gst_buffer_unref (buffer);
- GST_DEBUG_OBJECT (alawdec, "pad alloc failed, flow: %s",
- gst_flow_get_name (ret));
- return ret;
- }
}
static GstStateChangeReturn
diff --git a/gst/law/alaw-encode.c b/gst/law/alaw-encode.c
index b12c23efe..a115534f3 100644
--- a/gst/law/alaw-encode.c
+++ b/gst/law/alaw-encode.c
@@ -34,9 +34,12 @@ GST_DEBUG_CATEGORY_STATIC (alaw_enc_debug);
extern GstStaticPadTemplate alaw_enc_src_factory;
extern GstStaticPadTemplate alaw_enc_sink_factory;
-static GstFlowReturn gst_alaw_enc_chain (GstPad * pad, GstBuffer * buffer);
+static gboolean gst_alaw_enc_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static GstFlowReturn gst_alaw_enc_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
-GST_BOILERPLATE (GstALawEnc, gst_alaw_enc, GstElement, GST_TYPE_ELEMENT);
+G_DEFINE_TYPE (GstALawEnc, gst_alaw_enc, GST_TYPE_ELEMENT);
/* some day we might have defines in gstconfig.h that tell us about the
* desired cpu/memory/binary size trade-offs */
@@ -297,7 +300,7 @@ s16_to_alaw (gint pcm_val)
#endif /* GST_ALAW_ENC_USE_TABLE */
static GstCaps *
-gst_alaw_enc_getcaps (GstPad * pad)
+gst_alaw_enc_getcaps (GstPad * pad, GstCaps * filter)
{
GstALawEnc *alawenc;
GstPad *otherpad;
@@ -317,7 +320,7 @@ gst_alaw_enc_getcaps (GstPad * pad)
otherpad = alawenc->srcpad;
}
/* get caps from the peer, this can return NULL when there is no peer */
- othercaps = gst_pad_peer_get_caps (otherpad);
+ othercaps = gst_pad_peer_query_caps (otherpad, filter);
/* get the template caps to make sure we return something acceptable */
templ = gst_pad_get_pad_template_caps (pad);
@@ -359,27 +362,42 @@ gst_alaw_enc_getcaps (GstPad * pad)
}
static gboolean
-gst_alaw_enc_setcaps (GstPad * pad, GstCaps * caps)
+gst_alaw_enc_query (GstPad * pad, GstObject * parent, GstQuery * query)
+{
+ gboolean res;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = gst_alaw_enc_getcaps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_query_default (pad, parent, query);
+ break;
+ }
+ return res;
+}
+
+static gboolean
+gst_alaw_enc_setcaps (GstALawEnc * alawenc, GstCaps * caps)
{
- GstALawEnc *alawenc;
- GstPad *otherpad;
GstStructure *structure;
gboolean ret;
GstCaps *base_caps;
- alawenc = GST_ALAW_ENC (GST_PAD_PARENT (pad));
-
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "channels", &alawenc->channels);
gst_structure_get_int (structure, "rate", &alawenc->rate);
- if (pad == alawenc->sinkpad) {
- otherpad = alawenc->srcpad;
- } else {
- otherpad = alawenc->sinkpad;
- }
-
- base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (otherpad));
+ base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (alawenc->srcpad));
structure = gst_caps_get_structure (base_caps, 0);
gst_structure_set (structure, "rate", G_TYPE_INT, alawenc->rate, NULL);
gst_structure_set (structure, "channels", G_TYPE_INT, alawenc->channels,
@@ -388,7 +406,7 @@ gst_alaw_enc_setcaps (GstPad * pad, GstCaps * caps)
GST_DEBUG_OBJECT (alawenc, "rate=%d, channels=%d", alawenc->rate,
alawenc->channels);
- ret = gst_pad_set_caps (otherpad, base_caps);
+ ret = gst_pad_set_caps (alawenc->srcpad, base_caps);
gst_caps_unref (base_caps);
@@ -396,14 +414,14 @@ gst_alaw_enc_setcaps (GstPad * pad, GstCaps * caps)
}
static void
-gst_alaw_enc_base_init (gpointer klass)
+gst_alaw_enc_class_init (GstALawEncClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class,
- &alaw_enc_src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &alaw_enc_sink_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&alaw_enc_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&alaw_enc_sink_factory));
gst_element_class_set_details_simple (element_class,
"A Law audio encoder", "Codec/Encoder/Audio",
@@ -414,30 +432,22 @@ gst_alaw_enc_base_init (gpointer klass)
}
static void
-gst_alaw_enc_class_init (GstALawEncClass * klass)
-{
- /* nothing to do here for now */
-}
-
-static void
-gst_alaw_enc_init (GstALawEnc * alawenc, GstALawEncClass * klass)
+gst_alaw_enc_init (GstALawEnc * alawenc)
{
alawenc->sinkpad =
gst_pad_new_from_static_template (&alaw_enc_sink_factory, "sink");
- gst_pad_set_setcaps_function (alawenc->sinkpad,
- GST_DEBUG_FUNCPTR (gst_alaw_enc_setcaps));
- gst_pad_set_getcaps_function (alawenc->sinkpad,
- GST_DEBUG_FUNCPTR (gst_alaw_enc_getcaps));
+ gst_pad_set_query_function (alawenc->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_alaw_enc_query));
+ gst_pad_set_event_function (alawenc->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_alaw_enc_event));
gst_pad_set_chain_function (alawenc->sinkpad,
GST_DEBUG_FUNCPTR (gst_alaw_enc_chain));
gst_element_add_pad (GST_ELEMENT (alawenc), alawenc->sinkpad);
alawenc->srcpad =
gst_pad_new_from_static_template (&alaw_enc_src_factory, "src");
- gst_pad_set_setcaps_function (alawenc->srcpad,
- GST_DEBUG_FUNCPTR (gst_alaw_enc_setcaps));
- gst_pad_set_getcaps_function (alawenc->srcpad,
- GST_DEBUG_FUNCPTR (gst_alaw_enc_getcaps));
+ gst_pad_set_query_function (alawenc->srcpad,
+ GST_DEBUG_FUNCPTR (gst_alaw_enc_query));
gst_pad_use_fixed_caps (alawenc->srcpad);
gst_element_add_pad (GST_ELEMENT (alawenc), alawenc->srcpad);
@@ -446,12 +456,39 @@ gst_alaw_enc_init (GstALawEnc * alawenc, GstALawEncClass * klass)
alawenc->rate = 0;
}
+static gboolean
+gst_alaw_enc_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+ GstALawEnc *alawenc;
+ gboolean res;
+
+ alawenc = GST_ALAW_ENC (parent);
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ gst_alaw_enc_setcaps (alawenc, caps);
+ gst_event_unref (event);
+
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_event_default (pad, parent, event);
+ break;
+ }
+ return res;
+}
+
static GstFlowReturn
-gst_alaw_enc_chain (GstPad * pad, GstBuffer * buffer)
+gst_alaw_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstALawEnc *alawenc;
gint16 *linear_data;
- guint linear_size;
+ gsize linear_size;
guint8 *alaw_data;
guint alaw_size;
GstBuffer *outbuf;
@@ -459,13 +496,12 @@ gst_alaw_enc_chain (GstPad * pad, GstBuffer * buffer)
GstFlowReturn ret;
GstClockTime timestamp, duration;
- alawenc = GST_ALAW_ENC (GST_PAD_PARENT (pad));
+ alawenc = GST_ALAW_ENC (parent);
if (G_UNLIKELY (alawenc->rate == 0 || alawenc->channels == 0))
goto not_negotiated;
- linear_data = (gint16 *) GST_BUFFER_DATA (buffer);
- linear_size = GST_BUFFER_SIZE (buffer);
+ linear_data = gst_buffer_map (buffer, &linear_size, NULL, GST_MAP_READ);
alaw_size = linear_size / 2;
@@ -475,25 +511,14 @@ gst_alaw_enc_chain (GstPad * pad, GstBuffer * buffer)
GST_LOG_OBJECT (alawenc, "buffer with ts=%" GST_TIME_FORMAT,
GST_TIME_ARGS (timestamp));
- ret =
- gst_pad_alloc_buffer_and_set_caps (alawenc->srcpad,
- GST_BUFFER_OFFSET_NONE, alaw_size, GST_PAD_CAPS (alawenc->srcpad),
- &outbuf);
- if (ret != GST_FLOW_OK)
- goto done;
+ outbuf = gst_buffer_new_allocate (NULL, alaw_size, 0);
if (duration == GST_CLOCK_TIME_NONE) {
duration = gst_util_uint64_scale_int (alaw_size,
GST_SECOND, alawenc->rate * alawenc->channels);
}
- if (GST_BUFFER_SIZE (outbuf) < alaw_size) {
- /* pad-alloc can return a smaller buffer */
- gst_buffer_unref (outbuf);
- outbuf = gst_buffer_new_and_alloc (alaw_size);
- }
-
- alaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
+ alaw_data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
/* copy discont flag */
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
@@ -502,23 +527,21 @@ gst_alaw_enc_chain (GstPad * pad, GstBuffer * buffer)
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
GST_BUFFER_DURATION (outbuf) = duration;
- gst_buffer_set_caps (outbuf, GST_PAD_CAPS (alawenc->srcpad));
-
for (i = 0; i < alaw_size; i++) {
alaw_data[i] = s16_to_alaw (linear_data[i]);
}
- ret = gst_pad_push (alawenc->srcpad, outbuf);
-
-done:
-
+ gst_buffer_unmap (outbuf, alaw_data, -1);
+ gst_buffer_unmap (buffer, linear_data, -1);
gst_buffer_unref (buffer);
+ ret = gst_pad_push (alawenc->srcpad, outbuf);
+
return ret;
not_negotiated:
{
- ret = GST_FLOW_NOT_NEGOTIATED;
- goto done;
+ gst_buffer_unref (buffer);
+ return GST_FLOW_NOT_NEGOTIATED;
}
}
diff --git a/gst/law/alaw.c b/gst/law/alaw.c
index 04429353f..9e342055e 100644
--- a/gst/law/alaw.c
+++ b/gst/law/alaw.c
@@ -23,14 +23,18 @@
#include "alaw-encode.h"
#include "alaw-decode.h"
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define INT_FORMAT "S16LE"
+#else
+#define INT_FORMAT "S16BE"
+#endif
+
GstStaticPadTemplate alaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "rate = (int) [ 8000, 192000 ], "
- "channels = (int) [ 1, 2 ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
+ GST_STATIC_CAPS ("audio/x-raw, "
+ "format = (string) " INT_FORMAT ", "
+ "rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate alaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
@@ -43,11 +47,9 @@ GstStaticPadTemplate alaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GstStaticPadTemplate alaw_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "rate = (int) [ 8000, 192000 ], "
- "channels = (int) [ 1, 2 ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
+ GST_STATIC_CAPS ("audio/x-raw, "
+ "format = (string) " INT_FORMAT ", "
+ "rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate alaw_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
diff --git a/gst/law/mulaw-decode.c b/gst/law/mulaw-decode.c
index b8a0d6556..e5fb33daf 100644
--- a/gst/law/mulaw-decode.c
+++ b/gst/law/mulaw-decode.c
@@ -26,9 +26,16 @@
#include "config.h"
#endif
#include <gst/gst.h>
+
#include "mulaw-decode.h"
#include "mulaw-conversion.h"
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define INT_FORMAT "S16LE"
+#else
+#define INT_FORMAT "S16BE"
+#endif
+
extern GstStaticPadTemplate mulaw_dec_src_factory;
extern GstStaticPadTemplate mulaw_dec_sink_factory;
@@ -44,38 +51,33 @@ enum
ARG_0
};
-static void gst_mulawdec_class_init (GstMuLawDecClass * klass);
-static void gst_mulawdec_base_init (GstMuLawDecClass * klass);
-static void gst_mulawdec_init (GstMuLawDec * mulawdec);
static GstStateChangeReturn
gst_mulawdec_change_state (GstElement * element, GstStateChange transition);
-static GstFlowReturn gst_mulawdec_chain (GstPad * pad, GstBuffer * buffer);
+static gboolean gst_mulawdec_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static GstFlowReturn gst_mulawdec_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
-static GstElementClass *parent_class = NULL;
+#define gst_mulawdec_parent_class parent_class
+G_DEFINE_TYPE (GstMuLawDec, gst_mulawdec, GST_TYPE_ELEMENT);
static gboolean
-mulawdec_sink_setcaps (GstPad * pad, GstCaps * caps)
+mulawdec_setcaps (GstMuLawDec * mulawdec, GstCaps * caps)
{
- GstMuLawDec *mulawdec;
GstStructure *structure;
int rate, channels;
gboolean ret;
GstCaps *outcaps;
- mulawdec = GST_MULAWDEC (GST_PAD_PARENT (pad));
-
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "rate", &rate);
ret = ret && gst_structure_get_int (structure, "channels", &channels);
if (!ret)
return FALSE;
- outcaps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "signed", G_TYPE_BOOLEAN, TRUE,
+ outcaps = gst_caps_new_simple ("audio/x-raw",
+ "format", G_TYPE_STRING, INT_FORMAT,
"rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL);
ret = gst_pad_set_caps (mulawdec->srcpad, outcaps);
gst_caps_unref (outcaps);
@@ -89,7 +91,7 @@ mulawdec_sink_setcaps (GstPad * pad, GstCaps * caps)
}
static GstCaps *
-mulawdec_getcaps (GstPad * pad)
+mulawdec_getcaps (GstPad * pad, GstCaps * filter)
{
GstMuLawDec *mulawdec;
GstPad *otherpad;
@@ -102,14 +104,14 @@ mulawdec_getcaps (GstPad * pad)
/* figure out the name of the caps we are going to return */
if (pad == mulawdec->srcpad) {
- name = "audio/x-raw-int";
+ name = "audio/x-raw";
otherpad = mulawdec->sinkpad;
} else {
name = "audio/x-mulaw";
otherpad = mulawdec->srcpad;
}
/* get caps from the peer, this can return NULL when there is no peer */
- othercaps = gst_pad_peer_get_caps (otherpad);
+ othercaps = gst_pad_peer_query_caps (otherpad, filter);
/* get the template caps to make sure we return something acceptable */
templ = gst_pad_get_pad_template_caps (pad);
@@ -129,14 +131,11 @@ mulawdec_getcaps (GstPad * pad)
if (pad == mulawdec->sinkpad) {
/* remove the fields we don't want */
- gst_structure_remove_fields (structure, "width", "depth", "endianness",
- "signed", NULL);
+ gst_structure_remove_fields (structure, "format", NULL);
} else {
/* add fixed fields */
- gst_structure_set (structure, "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+ gst_structure_set (structure, "format", G_TYPE_STRING, INT_FORMAT,
+ NULL);
}
}
/* filter against the allowed caps of the pad to return our result */
@@ -149,52 +148,45 @@ mulawdec_getcaps (GstPad * pad)
return result;
}
-GType
-gst_mulawdec_get_type (void)
+static gboolean
+gst_mulawdec_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
- static GType mulawdec_type = 0;
-
- if (!mulawdec_type) {
- static const GTypeInfo mulawdec_info = {
- sizeof (GstMuLawDecClass),
- (GBaseInitFunc) gst_mulawdec_base_init,
- NULL,
- (GClassInitFunc) gst_mulawdec_class_init,
- NULL,
- NULL,
- sizeof (GstMuLawDec),
- 0,
- (GInstanceInitFunc) gst_mulawdec_init,
- };
-
- mulawdec_type =
- g_type_register_static (GST_TYPE_ELEMENT, "GstMuLawDec", &mulawdec_info,
- 0);
+ gboolean res;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = mulawdec_getcaps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_query_default (pad, parent, query);
+ break;
}
- return mulawdec_type;
+ return res;
}
static void
-gst_mulawdec_base_init (GstMuLawDecClass * klass)
+gst_mulawdec_class_init (GstMuLawDecClass * klass)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *element_class = (GstElementClass *) klass;
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&mulaw_dec_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&mulaw_dec_sink_factory));
- gst_element_class_add_static_pad_template (element_class,
- &mulaw_dec_src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &mulaw_dec_sink_factory);
gst_element_class_set_details_simple (element_class, "Mu Law audio decoder",
"Codec/Decoder/Audio",
"Convert 8bit mu law to 16bit PCM",
"Zaheer Abbas Merali <zaheerabbas at merali dot org>");
-}
-
-static void
-gst_mulawdec_class_init (GstMuLawDecClass * klass)
-{
- GstElementClass *element_class = (GstElementClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
element_class->change_state = GST_DEBUG_FUNCPTR (gst_mulawdec_change_state);
}
@@ -204,44 +196,65 @@ gst_mulawdec_init (GstMuLawDec * mulawdec)
{
mulawdec->sinkpad =
gst_pad_new_from_static_template (&mulaw_dec_sink_factory, "sink");
- gst_pad_set_setcaps_function (mulawdec->sinkpad, mulawdec_sink_setcaps);
- gst_pad_set_getcaps_function (mulawdec->sinkpad, mulawdec_getcaps);
+ gst_pad_set_query_function (mulawdec->sinkpad, gst_mulawdec_query);
+ gst_pad_set_event_function (mulawdec->sinkpad, gst_mulawdec_event);
gst_pad_set_chain_function (mulawdec->sinkpad, gst_mulawdec_chain);
gst_element_add_pad (GST_ELEMENT (mulawdec), mulawdec->sinkpad);
mulawdec->srcpad =
gst_pad_new_from_static_template (&mulaw_dec_src_factory, "src");
- gst_pad_use_fixed_caps (mulawdec->srcpad);
- gst_pad_set_getcaps_function (mulawdec->srcpad, mulawdec_getcaps);
+ gst_pad_set_query_function (mulawdec->srcpad, gst_mulawdec_query);
gst_element_add_pad (GST_ELEMENT (mulawdec), mulawdec->srcpad);
}
+static gboolean
+gst_mulawdec_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+ GstMuLawDec *mulawdec;
+ gboolean res;
+
+ mulawdec = GST_MULAWDEC (parent);
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ mulawdec_setcaps (mulawdec, caps);
+ gst_event_unref (event);
+
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_event_default (pad, parent, event);
+ break;
+ }
+ return res;
+}
+
static GstFlowReturn
-gst_mulawdec_chain (GstPad * pad, GstBuffer * buffer)
+gst_mulawdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstMuLawDec *mulawdec;
gint16 *linear_data;
guint8 *mulaw_data;
- guint mulaw_size;
+ gsize mulaw_size, linear_size;
GstBuffer *outbuf;
GstFlowReturn ret;
- mulawdec = GST_MULAWDEC (GST_PAD_PARENT (pad));
+ mulawdec = GST_MULAWDEC (parent);
if (G_UNLIKELY (mulawdec->rate == 0))
goto not_negotiated;
- mulaw_data = (guint8 *) GST_BUFFER_DATA (buffer);
- mulaw_size = GST_BUFFER_SIZE (buffer);
+ mulaw_data = gst_buffer_map (buffer, &mulaw_size, NULL, GST_MAP_READ);
- ret =
- gst_pad_alloc_buffer_and_set_caps (mulawdec->srcpad,
- GST_BUFFER_OFFSET_NONE, mulaw_size * 2, GST_PAD_CAPS (mulawdec->srcpad),
- &outbuf);
- if (ret != GST_FLOW_OK)
- goto alloc_failed;
+ linear_size = mulaw_size * 2;
- linear_data = (gint16 *) GST_BUFFER_DATA (outbuf);
+ outbuf = gst_buffer_new_allocate (NULL, linear_size, 0);
+ linear_data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
/* copy discont flag */
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
@@ -250,13 +263,14 @@ gst_mulawdec_chain (GstPad * pad, GstBuffer * buffer)
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
if (GST_BUFFER_DURATION (outbuf) == GST_CLOCK_TIME_NONE)
GST_BUFFER_DURATION (outbuf) = gst_util_uint64_scale_int (GST_SECOND,
- mulaw_size * 2, 2 * mulawdec->rate * mulawdec->channels);
+ linear_size, 2 * mulawdec->rate * mulawdec->channels);
else
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
- gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mulawdec->srcpad));
mulaw_decode (mulaw_data, linear_data, mulaw_size);
+ gst_buffer_unmap (outbuf, linear_data, -1);
+ gst_buffer_unmap (buffer, mulaw_data, -1);
gst_buffer_unref (buffer);
ret = gst_pad_push (mulawdec->srcpad, outbuf);
@@ -270,13 +284,6 @@ not_negotiated:
gst_buffer_unref (buffer);
return GST_FLOW_NOT_NEGOTIATED;
}
-alloc_failed:
- {
- GST_DEBUG_OBJECT (mulawdec, "pad alloc failed, flow: %s",
- gst_flow_get_name (ret));
- gst_buffer_unref (buffer);
- return ret;
- }
}
static GstStateChangeReturn
diff --git a/gst/law/mulaw-encode.c b/gst/law/mulaw-encode.c
index 15f828515..7517f624b 100644
--- a/gst/law/mulaw-encode.c
+++ b/gst/law/mulaw-encode.c
@@ -44,18 +44,18 @@ enum
ARG_0
};
-static void gst_mulawenc_class_init (GstMuLawEncClass * klass);
-static void gst_mulawenc_base_init (GstMuLawEncClass * klass);
-static void gst_mulawenc_init (GstMuLawEnc * mulawenc);
+static gboolean gst_mulawenc_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static GstFlowReturn gst_mulawenc_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
-static GstFlowReturn gst_mulawenc_chain (GstPad * pad, GstBuffer * buffer);
-
-static GstElementClass *parent_class = NULL;
+#define gst_mulawenc_parent_class parent_class
+G_DEFINE_TYPE (GstMuLawEnc, gst_mulawenc, GST_TYPE_ELEMENT);
/*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */
static GstCaps *
-mulawenc_getcaps (GstPad * pad)
+mulawenc_getcaps (GstPad * pad, GstCaps * filter)
{
GstMuLawEnc *mulawenc;
GstPad *otherpad;
@@ -75,7 +75,7 @@ mulawenc_getcaps (GstPad * pad)
otherpad = mulawenc->srcpad;
}
/* get caps from the peer, this can return NULL when there is no peer */
- othercaps = gst_pad_peer_get_caps (otherpad);
+ othercaps = gst_pad_peer_query_caps (otherpad, filter);
/* get the template caps to make sure we return something acceptable */
templ = gst_pad_get_pad_template_caps (pad);
@@ -116,73 +116,65 @@ mulawenc_getcaps (GstPad * pad)
}
static gboolean
-mulawenc_setcaps (GstPad * pad, GstCaps * caps)
+gst_mulawenc_query (GstPad * pad, GstObject * parent, GstQuery * query)
+{
+ gboolean res;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = mulawenc_getcaps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_query_default (pad, parent, query);
+ break;
+ }
+ return res;
+}
+
+
+static gboolean
+mulawenc_setcaps (GstMuLawEnc * mulawenc, GstCaps * caps)
{
- GstMuLawEnc *mulawenc;
- GstPad *otherpad;
GstStructure *structure;
GstCaps *base_caps;
- mulawenc = GST_MULAWENC (gst_pad_get_parent (pad));
-
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "channels", &mulawenc->channels);
gst_structure_get_int (structure, "rate", &mulawenc->rate);
- if (pad == mulawenc->sinkpad) {
- otherpad = mulawenc->srcpad;
- } else {
- otherpad = mulawenc->sinkpad;
- }
- base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (otherpad));
+ base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (mulawenc->srcpad));
structure = gst_caps_get_structure (base_caps, 0);
gst_structure_set (structure, "rate", G_TYPE_INT, mulawenc->rate, NULL);
gst_structure_set (structure, "channels", G_TYPE_INT, mulawenc->channels,
NULL);
- gst_pad_set_caps (otherpad, base_caps);
+ gst_pad_set_caps (mulawenc->srcpad, base_caps);
- gst_object_unref (mulawenc);
gst_caps_unref (base_caps);
return TRUE;
}
-GType
-gst_mulawenc_get_type (void)
-{
- static GType mulawenc_type = 0;
-
- if (!mulawenc_type) {
- static const GTypeInfo mulawenc_info = {
- sizeof (GstMuLawEncClass),
- (GBaseInitFunc) gst_mulawenc_base_init,
- NULL,
- (GClassInitFunc) gst_mulawenc_class_init,
- NULL,
- NULL,
- sizeof (GstMuLawEnc),
- 0,
- (GInstanceInitFunc) gst_mulawenc_init,
- };
-
- mulawenc_type =
- g_type_register_static (GST_TYPE_ELEMENT, "GstMuLawEnc", &mulawenc_info,
- 0);
- }
- return mulawenc_type;
-}
-
static void
-gst_mulawenc_base_init (GstMuLawEncClass * klass)
+gst_mulawenc_class_init (GstMuLawEncClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class,
- &mulaw_enc_src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &mulaw_enc_sink_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&mulaw_enc_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&mulaw_enc_sink_factory));
+
gst_element_class_set_details_simple (element_class, "Mu Law audio encoder",
"Codec/Encoder/Audio",
"Convert 16bit PCM to 8bit mu law",
@@ -190,26 +182,18 @@ gst_mulawenc_base_init (GstMuLawEncClass * klass)
}
static void
-gst_mulawenc_class_init (GstMuLawEncClass * klass)
-{
- parent_class = g_type_class_peek_parent (klass);
-}
-
-static void
gst_mulawenc_init (GstMuLawEnc * mulawenc)
{
mulawenc->sinkpad =
gst_pad_new_from_static_template (&mulaw_enc_sink_factory, "sink");
- gst_pad_set_setcaps_function (mulawenc->sinkpad, mulawenc_setcaps);
- gst_pad_set_getcaps_function (mulawenc->sinkpad, mulawenc_getcaps);
+ gst_pad_set_query_function (mulawenc->sinkpad, gst_mulawenc_query);
+ gst_pad_set_event_function (mulawenc->sinkpad, gst_mulawenc_event);
gst_pad_set_chain_function (mulawenc->sinkpad, gst_mulawenc_chain);
gst_element_add_pad (GST_ELEMENT (mulawenc), mulawenc->sinkpad);
mulawenc->srcpad =
gst_pad_new_from_static_template (&mulaw_enc_src_factory, "src");
- gst_pad_set_setcaps_function (mulawenc->srcpad, mulawenc_setcaps);
- gst_pad_set_getcaps_function (mulawenc->srcpad, mulawenc_getcaps);
- gst_pad_use_fixed_caps (mulawenc->srcpad);
+ gst_pad_set_query_function (mulawenc->srcpad, gst_mulawenc_query);
gst_element_add_pad (GST_ELEMENT (mulawenc), mulawenc->srcpad);
/* init rest */
@@ -217,49 +201,65 @@ gst_mulawenc_init (GstMuLawEnc * mulawenc)
mulawenc->rate = 0;
}
+static gboolean
+gst_mulawenc_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+ GstMuLawEnc *mulawenc;
+ gboolean res;
+
+ mulawenc = GST_MULAWENC (parent);
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ mulawenc_setcaps (mulawenc, caps);
+ gst_event_unref (event);
+
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_event_default (pad, parent, event);
+ break;
+ }
+ return res;
+}
+
static GstFlowReturn
-gst_mulawenc_chain (GstPad * pad, GstBuffer * buffer)
+gst_mulawenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstMuLawEnc *mulawenc;
gint16 *linear_data;
- guint linear_size;
+ gsize linear_size;
guint8 *mulaw_data;
guint mulaw_size;
GstBuffer *outbuf;
GstFlowReturn ret;
GstClockTime timestamp, duration;
- mulawenc = GST_MULAWENC (gst_pad_get_parent (pad));
+ mulawenc = GST_MULAWENC (parent);
if (!mulawenc->rate || !mulawenc->channels)
goto not_negotiated;
- linear_data = (gint16 *) GST_BUFFER_DATA (buffer);
- linear_size = GST_BUFFER_SIZE (buffer);
+ linear_data = gst_buffer_map (buffer, &linear_size, NULL, GST_MAP_READ);
mulaw_size = linear_size / 2;
timestamp = GST_BUFFER_TIMESTAMP (buffer);
duration = GST_BUFFER_DURATION (buffer);
- ret = gst_pad_alloc_buffer_and_set_caps (mulawenc->srcpad,
- GST_BUFFER_OFFSET_NONE, mulaw_size, GST_PAD_CAPS (mulawenc->srcpad),
- &outbuf);
- if (ret != GST_FLOW_OK)
- goto alloc_failed;
+ outbuf = gst_buffer_new_allocate (NULL, mulaw_size, 0);
if (duration == -1) {
duration = gst_util_uint64_scale_int (mulaw_size,
GST_SECOND, mulawenc->rate * mulawenc->channels);
}
- if (GST_BUFFER_SIZE (outbuf) < mulaw_size) {
- /* pad-alloc can suggest a smaller size */
- gst_buffer_unref (outbuf);
- outbuf = gst_buffer_new_and_alloc (mulaw_size);
- }
-
- mulaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
+ mulaw_data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
/* copy discont flag */
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
@@ -268,16 +268,15 @@ gst_mulawenc_chain (GstPad * pad, GstBuffer * buffer)
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
GST_BUFFER_DURATION (outbuf) = duration;
- gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mulawenc->srcpad));
-
mulaw_encode (linear_data, mulaw_data, mulaw_size);
+ gst_buffer_unmap (outbuf, mulaw_data, -1);
+ gst_buffer_unmap (buffer, linear_data, -1);
gst_buffer_unref (buffer);
ret = gst_pad_push (mulawenc->srcpad, outbuf);
done:
- gst_object_unref (mulawenc);
return ret;
@@ -288,10 +287,4 @@ not_negotiated:
gst_buffer_unref (buffer);
goto done;
}
-alloc_failed:
- {
- GST_DEBUG_OBJECT (mulawenc, "pad alloc failed");
- gst_buffer_unref (buffer);
- goto done;
- }
}
diff --git a/gst/law/mulaw.c b/gst/law/mulaw.c
index e8d9e72de..ba310db17 100644
--- a/gst/law/mulaw.c
+++ b/gst/law/mulaw.c
@@ -22,14 +22,18 @@
#include "mulaw-encode.h"
#include "mulaw-decode.h"
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define INT_FORMAT "S16LE"
+#else
+#define INT_FORMAT "S16BE"
+#endif
+
GstStaticPadTemplate mulaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "rate = (int) [ 8000, 192000 ], "
- "channels = (int) [ 1, 2 ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
+ GST_STATIC_CAPS ("audio/x-raw, "
+ "format = (string) " INT_FORMAT ", "
+ "rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate mulaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
@@ -42,11 +46,9 @@ GstStaticPadTemplate mulaw_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GstStaticPadTemplate mulaw_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "rate = (int) [ 8000, 192000 ], "
- "channels = (int) [ 1, 2 ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
+ GST_STATIC_CAPS ("audio/x-raw, "
+ "format = (string) " INT_FORMAT ", "
+ "rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
);
GstStaticPadTemplate mulaw_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
diff --git a/gst/level/Makefile.am b/gst/level/Makefile.am
index 047e196ad..63cdfae18 100644
--- a/gst/level/Makefile.am
+++ b/gst/level/Makefile.am
@@ -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
diff --git a/gst/level/gstlevel.c b/gst/level/gstlevel.c
index 6d89a682b..16efded8d 100644
--- a/gst/level/gstlevel.c
+++ b/gst/level/gstlevel.c
@@ -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_static_pad_template (element_class,
- &sink_template_factory);
- gst_element_class_add_static_pad_template (element_class,
- &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;
}
diff --git a/gst/level/gstlevel.h b/gst/level/gstlevel.h
index 32d4c9e98..ae9ba3a94 100644
--- a/gst/level/gstlevel.h
+++ b/gst/level/gstlevel.h
@@ -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*);
};
diff --git a/gst/matroska/ebml-read.c b/gst/matroska/ebml-read.c
index f6bf1348c..666c58567 100644
--- a/gst/matroska/ebml-read.c
+++ b/gst/matroska/ebml-read.c
@@ -164,6 +164,7 @@ gst_ebml_read_init (GstEbmlRead * ebml, GstElement * el, GstBuffer * buf,
guint64 offset)
{
GstEbmlMaster m;
+ gsize buf_size;
g_return_if_fail (el);
g_return_if_fail (buf);
@@ -171,9 +172,10 @@ gst_ebml_read_init (GstEbmlRead * ebml, GstElement * el, GstBuffer * buf,
ebml->el = el;
ebml->offset = offset;
ebml->buf = buf;
+ ebml->buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
ebml->readers = g_array_sized_new (FALSE, FALSE, sizeof (GstEbmlMaster), 10);
m.offset = ebml->offset;
- gst_byte_reader_init (&m.br, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ gst_byte_reader_init (&m.br, ebml->buf_data, buf_size);
g_array_append_val (ebml->readers, m);
}
@@ -183,8 +185,10 @@ gst_ebml_read_clear (GstEbmlRead * ebml)
if (ebml->readers)
g_array_free (ebml->readers, TRUE);
ebml->readers = NULL;
- if (ebml->buf)
+ if (ebml->buf) {
+ gst_buffer_unmap (ebml->buf, ebml->buf_data, -1);
gst_buffer_unref (ebml->buf);
+ }
ebml->buf = NULL;
ebml->el = NULL;
}
@@ -334,7 +338,8 @@ gst_ebml_read_buffer (GstEbmlRead * ebml, guint32 * id, GstBuffer ** buf)
offset = gst_ebml_read_get_pos (ebml) - ebml->offset;
if (G_LIKELY (gst_byte_reader_skip (gst_ebml_read_br (ebml), length))) {
- *buf = gst_buffer_create_sub (ebml->buf, offset, length);
+ *buf = gst_buffer_copy_region (ebml->buf, GST_BUFFER_COPY_ALL,
+ offset, length);
} else {
*buf = NULL;
return GST_FLOW_PARSE;
diff --git a/gst/matroska/ebml-read.h b/gst/matroska/ebml-read.h
index 9db38f54c..b175706fd 100644
--- a/gst/matroska/ebml-read.h
+++ b/gst/matroska/ebml-read.h
@@ -54,6 +54,7 @@ typedef struct _GstEbmlRead {
GstElement *el;
GstBuffer *buf;
+ gpointer buf_data;
guint64 offset;
GArray *readers;
diff --git a/gst/matroska/ebml-write.c b/gst/matroska/ebml-write.c
index 06f356877..bf17d6213 100644
--- a/gst/matroska/ebml-write.c
+++ b/gst/matroska/ebml-write.c
@@ -33,19 +33,15 @@
GST_DEBUG_CATEGORY_STATIC (gst_ebml_write_debug);
#define GST_CAT_DEFAULT gst_ebml_write_debug
-#define _do_init(thing) \
+#define _do_init \
GST_DEBUG_CATEGORY_INIT (gst_ebml_write_debug, "ebmlwrite", 0, "Write EBML structured data")
-GST_BOILERPLATE_FULL (GstEbmlWrite, gst_ebml_write, GstObject, GST_TYPE_OBJECT,
+#define parent_class gst_ebml_write_parent_class
+G_DEFINE_TYPE_WITH_CODE (GstEbmlWrite, gst_ebml_write, GST_TYPE_OBJECT,
_do_init);
static void gst_ebml_write_finalize (GObject * object);
static void
-gst_ebml_write_base_init (gpointer g_class)
-{
-}
-
-static void
gst_ebml_write_class_init (GstEbmlWriteClass * klass)
{
GObjectClass *object = G_OBJECT_CLASS (klass);
@@ -54,11 +50,11 @@ gst_ebml_write_class_init (GstEbmlWriteClass * klass)
}
static void
-gst_ebml_write_init (GstEbmlWrite * ebml, GstEbmlWriteClass * klass)
+gst_ebml_write_init (GstEbmlWrite * ebml)
{
ebml->srcpad = NULL;
ebml->pos = 0;
- ebml->last_pos = G_MAXUINT64; /* force newsegment event */
+ ebml->last_pos = G_MAXUINT64; /* force segment event */
ebml->cache = NULL;
ebml->streamheader = NULL;
@@ -89,7 +85,7 @@ gst_ebml_write_finalize (GObject * object)
ebml->caps = NULL;
}
- GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -126,7 +122,7 @@ void
gst_ebml_write_reset (GstEbmlWrite * ebml)
{
ebml->pos = 0;
- ebml->last_pos = G_MAXUINT64; /* force newsegment event */
+ ebml->last_pos = G_MAXUINT64; /* force segment event */
if (ebml->cache) {
gst_byte_writer_free (ebml->cache);
@@ -182,7 +178,7 @@ gst_ebml_stop_streamheader (GstEbmlWrite * ebml)
buffer = gst_byte_writer_free_and_get_buffer (ebml->streamheader);
ebml->streamheader = NULL;
- GST_DEBUG ("Streamheader was size %d", GST_BUFFER_SIZE (buffer));
+ GST_DEBUG ("Streamheader was size %d", gst_buffer_get_size (buffer));
ebml->writing_streamheader = FALSE;
return buffer;
@@ -211,14 +207,19 @@ gst_ebml_write_set_cache (GstEbmlWrite * ebml, guint size)
}
static gboolean
-gst_ebml_writer_send_new_segment_event (GstEbmlWrite * ebml, guint64 new_pos)
+gst_ebml_writer_send_segment_event (GstEbmlWrite * ebml, guint64 new_pos)
{
+ GstSegment segment;
gboolean res;
GST_INFO ("seeking to %" G_GUINT64_FORMAT, new_pos);
- res = gst_pad_push_event (ebml->srcpad,
- gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, new_pos, -1, 0));
+ gst_segment_init (&segment, GST_FORMAT_BYTES);
+ segment.start = new_pos;
+ segment.stop = -1;
+ segment.position = 0;
+
+ res = gst_pad_push_event (ebml->srcpad, gst_event_new_segment (&segment));
if (!res)
GST_WARNING ("seek to %" G_GUINT64_FORMAT "failed", new_pos);
@@ -244,14 +245,13 @@ gst_ebml_write_flush_cache (GstEbmlWrite * ebml, gboolean is_keyframe,
buffer = gst_byte_writer_free_and_get_buffer (ebml->cache);
ebml->cache = NULL;
- GST_DEBUG ("Flushing cache of size %d", GST_BUFFER_SIZE (buffer));
- gst_buffer_set_caps (buffer, ebml->caps);
+ GST_DEBUG ("Flushing cache of size %d", gst_buffer_get_size (buffer));
GST_BUFFER_TIMESTAMP (buffer) = timestamp;
- GST_BUFFER_OFFSET (buffer) = ebml->pos - GST_BUFFER_SIZE (buffer);
+ GST_BUFFER_OFFSET (buffer) = ebml->pos - gst_buffer_get_size (buffer);
GST_BUFFER_OFFSET_END (buffer) = ebml->pos;
if (ebml->last_write_result == GST_FLOW_OK) {
if (GST_BUFFER_OFFSET (buffer) != ebml->last_pos) {
- gst_ebml_writer_send_new_segment_event (ebml, GST_BUFFER_OFFSET (buffer));
+ gst_ebml_writer_send_segment_event (ebml, GST_BUFFER_OFFSET (buffer));
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
}
if (ebml->writing_streamheader) {
@@ -290,7 +290,7 @@ gst_ebml_write_element_new (GstEbmlWrite * ebml, guint8 ** data_out, guint size)
buf = gst_buffer_new_and_alloc (size);
GST_BUFFER_TIMESTAMP (buf) = ebml->timestamp;
- *data_out = GST_BUFFER_DATA (buf);
+ *data_out = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
return buf;
}
@@ -408,31 +408,33 @@ gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf,
{
guint data_size;
- if (!buf_data)
- buf_data = GST_BUFFER_DATA (buf);
-
- if (buf_data_end) {
+ if (buf_data_end)
data_size = buf_data_end - buf_data;
- GST_BUFFER_SIZE (buf) = data_size;
- } else {
- data_size = GST_BUFFER_SIZE (buf);
- }
+ else
+ data_size = gst_buffer_get_size (buf);
ebml->pos += data_size;
/* if there's no cache, then don't push it! */
if (ebml->writing_streamheader) {
+ if (!buf_data)
+ buf_data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
gst_byte_writer_put_data (ebml->streamheader, buf_data, data_size);
}
if (ebml->cache) {
+ if (!buf_data)
+ buf_data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
gst_byte_writer_put_data (ebml->cache, buf_data, data_size);
+ gst_buffer_unmap (buf, buf_data, -1);
gst_buffer_unref (buf);
return;
}
+ if (buf_data)
+ gst_buffer_unmap (buf, buf_data, -1);
+
if (ebml->last_write_result == GST_FLOW_OK) {
- buf = gst_buffer_make_metadata_writable (buf);
- gst_buffer_set_caps (buf, ebml->caps);
+ buf = gst_buffer_make_writable (buf);
GST_BUFFER_OFFSET (buf) = ebml->pos - data_size;
GST_BUFFER_OFFSET_END (buf) = ebml->pos;
if (ebml->writing_streamheader) {
@@ -441,7 +443,7 @@ gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf,
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
if (GST_BUFFER_OFFSET (buf) != ebml->last_pos) {
- gst_ebml_writer_send_new_segment_event (ebml, GST_BUFFER_OFFSET (buf));
+ gst_ebml_writer_send_segment_event (ebml, GST_BUFFER_OFFSET (buf));
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
}
ebml->last_pos = ebml->pos;
@@ -730,12 +732,12 @@ gst_ebml_write_master_finish_full (GstEbmlWrite * ebml, guint64 startpos,
guint64 extra_size)
{
guint64 pos = ebml->pos;
- GstBuffer *buf;
+ guint8 *data = g_malloc (8);
+ GstBuffer *buf = gst_buffer_new_wrapped (data, 8);
gst_ebml_write_seek (ebml, startpos);
- buf = gst_buffer_new_and_alloc (8);
- GST_WRITE_UINT64_BE (GST_BUFFER_DATA (buf),
+ GST_WRITE_UINT64_BE (data,
(G_GINT64_CONSTANT (1) << 56) | (pos - startpos - 8 + extra_size));
gst_ebml_write_element_push (ebml, buf, NULL, NULL);
@@ -835,11 +837,12 @@ void
gst_ebml_replace_uint (GstEbmlWrite * ebml, guint64 pos, guint64 num)
{
guint64 oldpos = ebml->pos;
- GstBuffer *buf = gst_buffer_new_and_alloc (8);
guint8 *data_start, *data_end;
+ GstBuffer *buf;
- data_start = GST_BUFFER_DATA (buf);
+ data_start = g_malloc (8);
data_end = data_start;
+ buf = gst_buffer_new_wrapped (data_start, 8);
gst_ebml_write_seek (ebml, pos);
gst_ebml_write_set_uint (&data_end, num, 8);
diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
index 3d5a5694c..be9456807 100644
--- a/gst/matroska/matroska-demux.c
+++ b/gst/matroska/matroska-demux.c
@@ -59,8 +59,8 @@
#include <gst/riff/riff-ids.h>
#include <gst/riff/riff-media.h>
+#include <gst/audio/audio.h>
#include <gst/tag/tag.h>
-
#include <gst/pbutils/pbutils.h>
#include "matroska-demux.h"
@@ -96,21 +96,21 @@ static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
/* TODO: fill in caps! */
static GstStaticPadTemplate audio_src_templ =
-GST_STATIC_PAD_TEMPLATE ("audio_%02d",
+GST_STATIC_PAD_TEMPLATE ("audio_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("ANY")
);
static GstStaticPadTemplate video_src_templ =
-GST_STATIC_PAD_TEMPLATE ("video_%02d",
+GST_STATIC_PAD_TEMPLATE ("video_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("ANY")
);
static GstStaticPadTemplate subtitle_src_templ =
- GST_STATIC_PAD_TEMPLATE ("subtitle_%02d",
+ GST_STATIC_PAD_TEMPLATE ("subtitle_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("text/x-pango-markup; application/x-ssa; "
@@ -130,23 +130,22 @@ static gboolean gst_matroska_demux_element_query (GstElement * element,
GstQuery * query);
/* pad functions */
-static gboolean gst_matroska_demux_sink_activate_pull (GstPad * sinkpad,
- gboolean active);
-static gboolean gst_matroska_demux_sink_activate (GstPad * sinkpad);
+static gboolean gst_matroska_demux_sink_activate (GstPad * sinkpad,
+ GstObject * parent);
+static gboolean gst_matroska_demux_sink_activate_mode (GstPad * sinkpad,
+ GstObject * parent, GstPadMode mode, gboolean active);
static gboolean gst_matroska_demux_handle_seek_event (GstMatroskaDemux * demux,
GstPad * pad, GstEvent * event);
static gboolean gst_matroska_demux_handle_src_event (GstPad * pad,
- GstEvent * event);
-static const GstQueryType *gst_matroska_demux_get_src_query_types (GstPad *
- pad);
+ GstObject * parent, GstEvent * event);
static gboolean gst_matroska_demux_handle_src_query (GstPad * pad,
- GstQuery * query);
+ GstObject * parent, GstQuery * query);
static gboolean gst_matroska_demux_handle_sink_event (GstPad * pad,
- GstEvent * event);
+ GstObject * parent, GstEvent * event);
static GstFlowReturn gst_matroska_demux_chain (GstPad * pad,
- GstBuffer * buffer);
+ GstObject * object, GstBuffer * buffer);
static GstStateChangeReturn
gst_matroska_demux_change_state (GstElement * element,
@@ -178,25 +177,8 @@ static void gst_matroska_demux_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
GType gst_matroska_demux_get_type (void);
-GST_BOILERPLATE (GstMatroskaDemux, gst_matroska_demux, GstElement,
- GST_TYPE_ELEMENT);
-
-static void
-gst_matroska_demux_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class, &video_src_templ);
- gst_element_class_add_static_pad_template (element_class, &audio_src_templ);
- gst_element_class_add_static_pad_template (element_class,
- &subtitle_src_templ);
- gst_element_class_add_static_pad_template (element_class, &sink_templ);
-
- gst_element_class_set_details_simple (element_class, "Matroska demuxer",
- "Codec/Demuxer",
- "Demuxes Matroska/WebM streams into video/audio/subtitles",
- "GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
-}
+#define parent_class gst_matroska_demux_parent_class
+G_DEFINE_TYPE (GstMatroskaDemux, gst_matroska_demux, GST_TYPE_ELEMENT);
static void
gst_matroska_demux_finalize (GObject * object)
@@ -234,7 +216,7 @@ gst_matroska_demux_class_init (GstMatroskaDemuxClass * klass)
g_object_class_install_property (gobject_class, ARG_MAX_GAP_TIME,
g_param_spec_uint64 ("max-gap-time", "Maximum gap time",
- "The demuxer sends out newsegment events for skipping "
+ "The demuxer sends out segment events for skipping "
"gaps longer than this (0 = disabled).", 0, G_MAXUINT64,
DEFAULT_MAX_GAP_TIME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
@@ -244,23 +226,35 @@ gst_matroska_demux_class_init (GstMatroskaDemuxClass * klass)
GST_DEBUG_FUNCPTR (gst_matroska_demux_element_send_event);
gstelement_class->query =
GST_DEBUG_FUNCPTR (gst_matroska_demux_element_query);
-
gstelement_class->set_index =
GST_DEBUG_FUNCPTR (gst_matroska_demux_set_index);
gstelement_class->get_index =
GST_DEBUG_FUNCPTR (gst_matroska_demux_get_index);
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&video_src_templ));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&audio_src_templ));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&subtitle_src_templ));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&sink_templ));
+
+ gst_element_class_set_details_simple (gstelement_class, "Matroska demuxer",
+ "Codec/Demuxer",
+ "Demuxes Matroska/WebM streams into video/audio/subtitles",
+ "GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
}
static void
-gst_matroska_demux_init (GstMatroskaDemux * demux,
- GstMatroskaDemuxClass * klass)
+gst_matroska_demux_init (GstMatroskaDemux * demux)
{
demux->common.sinkpad = gst_pad_new_from_static_template (&sink_templ,
"sink");
gst_pad_set_activate_function (demux->common.sinkpad,
GST_DEBUG_FUNCPTR (gst_matroska_demux_sink_activate));
- gst_pad_set_activatepull_function (demux->common.sinkpad,
- GST_DEBUG_FUNCPTR (gst_matroska_demux_sink_activate_pull));
+ gst_pad_set_activatemode_function (demux->common.sinkpad,
+ GST_DEBUG_FUNCPTR (gst_matroska_demux_sink_activate_mode));
gst_pad_set_chain_function (demux->common.sinkpad,
GST_DEBUG_FUNCPTR (gst_matroska_demux_chain));
gst_pad_set_event_function (demux->common.sinkpad,
@@ -280,6 +274,8 @@ gst_matroska_demux_init (GstMatroskaDemux * demux,
/* property defaults */
demux->max_gap_time = DEFAULT_MAX_GAP_TIME;
+ GST_OBJECT_FLAG_SET (demux, GST_ELEMENT_FLAG_INDEXABLE);
+
/* finish off */
gst_matroska_demux_reset (GST_ELEMENT (demux));
}
@@ -441,7 +437,7 @@ gst_matroska_demux_reset (GstElement * element)
demux->next_cluster_offset = 0;
demux->index_offset = 0;
demux->seekable = FALSE;
- demux->need_newsegment = FALSE;
+ demux->need_segment = FALSE;
demux->building_index = FALSE;
if (demux->seek_event) {
gst_event_unref (demux->seek_event);
@@ -470,9 +466,14 @@ gst_matroska_demux_reset (GstElement * element)
if (demux->common.global_tags) {
gst_tag_list_free (demux->common.global_tags);
}
- demux->common.global_tags = gst_tag_list_new ();
+ demux->common.global_tags = gst_tag_list_new_empty ();
if (demux->common.cached_buffer) {
+ if (demux->common.cached_data) {
+ gst_buffer_unmap (demux->common.cached_buffer,
+ demux->common.cached_data, -1);
+ demux->common.cached_data = NULL;
+ }
gst_buffer_unref (demux->common.cached_buffer);
demux->common.cached_buffer = NULL;
}
@@ -481,32 +482,28 @@ gst_matroska_demux_reset (GstElement * element)
static GstBuffer *
gst_matroska_decode_buffer (GstMatroskaTrackContext * context, GstBuffer * buf)
{
- guint8 *data;
- guint size;
- GstBuffer *new_buf;
+ gpointer data, buf_data;
+ gsize size, buf_size;
g_return_val_if_fail (GST_IS_BUFFER (buf), NULL);
GST_DEBUG ("decoding buffer %p", buf);
- data = GST_BUFFER_DATA (buf);
- size = GST_BUFFER_SIZE (buf);
+ buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
- g_return_val_if_fail (data != NULL && size > 0, buf);
+ g_return_val_if_fail (buf_size > 0, buf);
+
+ data = buf_data;
+ size = buf_size;
if (gst_matroska_decode_data (context->encodings, &data, &size,
GST_MATROSKA_TRACK_ENCODING_SCOPE_FRAME, FALSE)) {
- new_buf = gst_buffer_new ();
- GST_BUFFER_MALLOCDATA (new_buf) = (guint8 *) data;
- GST_BUFFER_DATA (new_buf) = (guint8 *) data;
- GST_BUFFER_SIZE (new_buf) = size;
-
+ gst_buffer_unmap (buf, buf_data, buf_size);
gst_buffer_unref (buf);
- buf = new_buf;
-
- return buf;
+ return gst_buffer_new_wrapped (data, size);
} else {
GST_DEBUG ("decode data failed");
+ gst_buffer_unmap (buf, buf_data, buf_size);
gst_buffer_unref (buf);
return NULL;
}
@@ -1204,16 +1201,14 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
GstMatroskaTrackVideoContext *videocontext =
(GstMatroskaTrackVideoContext *) context;
- padname = g_strdup_printf ("video_%02d", demux->num_v_streams++);
- templ = gst_element_class_get_pad_template (klass, "video_%02d");
+ padname = g_strdup_printf ("video_%u", demux->num_v_streams++);
+ templ = gst_element_class_get_pad_template (klass, "video_%u");
caps = gst_matroska_demux_video_caps (videocontext,
- context->codec_id, (guint8 *) context->codec_priv,
+ context->codec_id, context->codec_priv,
context->codec_priv_size, &codec, &riff_fourcc);
if (codec) {
- list = gst_tag_list_new ();
- gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
- GST_TAG_VIDEO_CODEC, codec, NULL);
+ list = gst_tag_list_new (GST_TAG_VIDEO_CODEC, codec, NULL);
g_free (codec);
}
break;
@@ -1223,16 +1218,14 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
GstMatroskaTrackAudioContext *audiocontext =
(GstMatroskaTrackAudioContext *) context;
- padname = g_strdup_printf ("audio_%02d", demux->num_a_streams++);
- templ = gst_element_class_get_pad_template (klass, "audio_%02d");
+ padname = g_strdup_printf ("audio_%u", demux->num_a_streams++);
+ templ = gst_element_class_get_pad_template (klass, "audio_%u");
caps = gst_matroska_demux_audio_caps (audiocontext,
context->codec_id, context->codec_priv, context->codec_priv_size,
&codec, &riff_audio_fmt);
if (codec) {
- list = gst_tag_list_new ();
- gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
- GST_TAG_AUDIO_CODEC, codec, NULL);
+ list = gst_tag_list_new (GST_TAG_AUDIO_CODEC, codec, NULL);
g_free (codec);
}
break;
@@ -1242,8 +1235,8 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
GstMatroskaTrackSubtitleContext *subtitlecontext =
(GstMatroskaTrackSubtitleContext *) context;
- padname = g_strdup_printf ("subtitle_%02d", demux->num_t_streams++);
- templ = gst_element_class_get_pad_template (klass, "subtitle_%02d");
+ padname = g_strdup_printf ("subtitle_%u", demux->num_t_streams++);
+ templ = gst_element_class_get_pad_template (klass, "subtitle_%u");
caps = gst_matroska_demux_subtitle_caps (subtitlecontext,
context->codec_id, context->codec_priv, context->codec_priv_size);
break;
@@ -1269,7 +1262,7 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
const gchar *lang;
if (!list)
- list = gst_tag_list_new ();
+ list = gst_tag_list_new_empty ();
/* Matroska contains ISO 639-2B codes, we want ISO 639-1 */
lang = gst_tag_get_language_code (context->language);
@@ -1282,17 +1275,17 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
"codec_id='%s'", context->codec_id);
switch (context->type) {
case GST_MATROSKA_TRACK_TYPE_VIDEO:
- caps = gst_caps_new_simple ("video/x-unknown", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-unknown");
break;
case GST_MATROSKA_TRACK_TYPE_AUDIO:
- caps = gst_caps_new_simple ("audio/x-unknown", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-unknown");
break;
case GST_MATROSKA_TRACK_TYPE_SUBTITLE:
- caps = gst_caps_new_simple ("application/x-subtitle-unknown", NULL);
+ caps = gst_caps_new_empty_simple ("application/x-subtitle-unknown");
break;
case GST_MATROSKA_TRACK_TYPE_COMPLEX:
default:
- caps = gst_caps_new_simple ("application/x-matroska-unknown", NULL);
+ caps = gst_caps_new_empty_simple ("application/x-matroska-unknown");
break;
}
gst_caps_set_simple (caps, "codec-id", G_TYPE_STRING, context->codec_id,
@@ -1301,8 +1294,12 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
/* add any unrecognised riff fourcc / audio format, but after codec-id */
if (context->type == GST_MATROSKA_TRACK_TYPE_AUDIO && riff_audio_fmt != 0)
gst_caps_set_simple (caps, "format", G_TYPE_INT, riff_audio_fmt, NULL);
- else if (context->type == GST_MATROSKA_TRACK_TYPE_VIDEO && riff_fourcc != 0)
- gst_caps_set_simple (caps, "fourcc", GST_TYPE_FOURCC, riff_fourcc, NULL);
+ else if (context->type == GST_MATROSKA_TRACK_TYPE_VIDEO && riff_fourcc != 0) {
+ gchar *fstr = g_strdup_printf ("%" GST_FOURCC_FORMAT,
+ GST_FOURCC_ARGS (riff_fourcc));
+ gst_caps_set_simple (caps, "fourcc", G_TYPE_STRING, fstr, NULL);
+ g_free (fstr);
+ }
}
/* the pad in here */
@@ -1311,8 +1308,6 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
gst_pad_set_event_function (context->pad,
GST_DEBUG_FUNCPTR (gst_matroska_demux_handle_src_event));
- gst_pad_set_query_type_function (context->pad,
- GST_DEBUG_FUNCPTR (gst_matroska_demux_get_src_query_types));
gst_pad_set_query_function (context->pad,
GST_DEBUG_FUNCPTR (gst_matroska_demux_handle_src_query));
@@ -1324,8 +1319,8 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
gst_pad_set_element_private (context->pad, context);
gst_pad_use_fixed_caps (context->pad);
- gst_pad_set_caps (context->pad, context->caps);
gst_pad_set_active (context->pad, TRUE);
+ gst_pad_set_caps (context->pad, context->caps);
gst_element_add_pad (GST_ELEMENT (demux), context->pad);
g_free (padname);
@@ -1334,19 +1329,6 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
return ret;
}
-static const GstQueryType *
-gst_matroska_demux_get_src_query_types (GstPad * pad)
-{
- static const GstQueryType query_types[] = {
- GST_QUERY_POSITION,
- GST_QUERY_DURATION,
- GST_QUERY_SEEKING,
- 0
- };
-
- return query_types;
-}
-
static gboolean
gst_matroska_demux_query (GstMatroskaDemux * demux, GstPad * pad,
GstQuery * query)
@@ -1372,7 +1354,7 @@ gst_matroska_demux_query (GstMatroskaDemux * demux, GstPad * pad,
context->pos - demux->stream_start_time);
else
gst_query_set_position (query, GST_FORMAT_TIME,
- demux->common.segment.last_stop - demux->stream_start_time);
+ demux->common.segment.position - demux->stream_start_time);
GST_OBJECT_UNLOCK (demux);
} else if (format == GST_FORMAT_DEFAULT && context
&& context->default_duration) {
@@ -1438,7 +1420,7 @@ gst_matroska_demux_query (GstMatroskaDemux * demux, GstPad * pad,
break;
}
default:
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, (GstObject *) demux, query);
break;
}
@@ -1452,16 +1434,12 @@ gst_matroska_demux_element_query (GstElement * element, GstQuery * query)
}
static gboolean
-gst_matroska_demux_handle_src_query (GstPad * pad, GstQuery * query)
+gst_matroska_demux_handle_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
- gboolean ret;
- GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (gst_pad_get_parent (pad));
-
- ret = gst_matroska_demux_query (demux, pad, query);
+ GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (parent);
- gst_object_unref (demux);
-
- return ret;
+ return gst_matroska_demux_query (demux, pad, query);
}
/* returns FALSE if there are no pads to deliver event to,
@@ -1470,7 +1448,7 @@ gst_matroska_demux_handle_src_query (GstPad * pad, GstQuery * query)
static gboolean
gst_matroska_demux_send_event (GstMatroskaDemux * demux, GstEvent * event)
{
- gboolean is_newsegment;
+ gboolean is_segment;
gboolean ret = FALSE;
gint i;
@@ -1479,7 +1457,7 @@ gst_matroska_demux_send_event (GstMatroskaDemux * demux, GstEvent * event)
GST_DEBUG_OBJECT (demux, "Sending event of type %s to all source pads",
GST_EVENT_TYPE_NAME (event));
- is_newsegment = (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT);
+ is_segment = (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT);
g_assert (demux->common.src->len == demux->common.num_streams);
for (i = 0; i < demux->common.src->len; i++) {
@@ -1491,22 +1469,33 @@ gst_matroska_demux_send_event (GstMatroskaDemux * demux, GstEvent * event)
ret = TRUE;
/* FIXME: send global tags before stream tags */
- if (G_UNLIKELY (is_newsegment && stream->pending_tags != NULL)) {
+ if (G_UNLIKELY (is_segment && stream->pending_tags != NULL)) {
GST_DEBUG_OBJECT (demux, "Sending pending_tags %p for pad %s:%s : %"
GST_PTR_FORMAT, stream->pending_tags,
GST_DEBUG_PAD_NAME (stream->pad), stream->pending_tags);
- gst_element_found_tags_for_pad (GST_ELEMENT (demux), stream->pad,
- stream->pending_tags);
+ gst_pad_push_event (stream->pad,
+ gst_event_new_tag (stream->pending_tags));
stream->pending_tags = NULL;
}
}
- if (G_UNLIKELY (is_newsegment && demux->common.global_tags != NULL)) {
+ if (G_UNLIKELY (is_segment && demux->common.global_tags != NULL)) {
+ GstEvent *tag_event;
gst_tag_list_add (demux->common.global_tags, GST_TAG_MERGE_REPLACE,
GST_TAG_CONTAINER_FORMAT, "Matroska", NULL);
GST_DEBUG_OBJECT (demux, "Sending global_tags %p : %" GST_PTR_FORMAT,
demux->common.global_tags, demux->common.global_tags);
- gst_element_found_tags (GST_ELEMENT (demux), demux->common.global_tags);
+
+ tag_event = gst_event_new_tag (demux->common.global_tags);
+
+ for (i = 0; i < demux->common.src->len; i++) {
+ GstMatroskaTrackContext *stream;
+
+ stream = g_ptr_array_index (demux->common.src, i);
+ gst_pad_push_event (stream->pad, gst_event_ref (tag_event));
+ }
+
+ gst_event_unref (tag_event);
demux->common.global_tags = NULL;
}
@@ -1551,7 +1540,7 @@ gst_matroska_demux_move_to_entry (GstMatroskaDemux * demux,
/* update the time */
gst_matroska_read_common_reset_streams (&demux->common, entry->time, TRUE);
- demux->common.segment.last_stop = entry->time;
+ demux->common.segment.position = entry->time;
demux->seek_block = entry->block;
demux->seek_first = TRUE;
demux->last_stop_end = GST_CLOCK_TIME_NONE;
@@ -1594,6 +1583,8 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
GstFlowReturn ret = GST_FLOW_OK;
const guint chunk = 64 * 1024;
GstBuffer *buf = NULL;
+ gpointer data = NULL;
+ gsize size;
guint64 length;
guint32 id;
guint needed;
@@ -1630,6 +1621,7 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
gint cluster_pos;
if (buf != NULL) {
+ gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
buf = NULL;
}
@@ -1637,8 +1629,9 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
if (ret != GST_FLOW_OK)
break;
GST_DEBUG_OBJECT (demux, "read buffer size %d at offset %" G_GINT64_FORMAT,
- GST_BUFFER_SIZE (buf), newpos);
- gst_byte_reader_init_from_buffer (&reader, buf);
+ gst_buffer_get_size (buf), newpos);
+ data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_byte_reader_init (&reader, data, size);
resume:
cluster_pos = gst_byte_reader_masked_scan_uint32 (&reader, 0xffffffff,
GST_MATROSKA_ID_CLUSTER, 0, gst_byte_reader_get_remaining (&reader));
@@ -1692,6 +1685,7 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
}
if (buf) {
+ gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
buf = NULL;
}
@@ -1738,7 +1732,7 @@ gst_matroska_demux_search_pos (GstMatroskaDemux * demux, GstClockTime time)
/* estimate using start and current position */
GST_OBJECT_LOCK (demux);
opos = demux->common.offset - demux->common.ebml_segment_start;
- otime = demux->common.segment.last_stop;
+ otime = demux->common.segment.position;
GST_OBJECT_UNLOCK (demux);
/* avoid division by zero in first estimation below */
@@ -1921,11 +1915,11 @@ gst_matroska_demux_handle_seek_event (GstMatroskaDemux * demux,
if (event) {
GST_DEBUG_OBJECT (demux, "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);
/* compensate for clip start time */
if (GST_CLOCK_TIME_IS_VALID (demux->stream_start_time)) {
- seeksegment.last_stop += demux->stream_start_time;
+ seeksegment.position += demux->stream_start_time;
seeksegment.start += demux->stream_start_time;
if (GST_CLOCK_TIME_IS_VALID (seeksegment.stop))
seeksegment.stop += demux->stream_start_time;
@@ -1950,7 +1944,7 @@ gst_matroska_demux_handle_seek_event (GstMatroskaDemux * demux,
GST_OBJECT_LOCK (demux);
track = gst_matroska_read_common_get_seek_track (&demux->common, track);
if ((entry = gst_matroska_read_common_do_index_seek (&demux->common, track,
- seeksegment.last_stop, &demux->seek_index, &demux->seek_entry)) ==
+ seeksegment.position, &demux->seek_index, &demux->seek_entry)) ==
NULL) {
/* pull mode without index can scan later on */
if (demux->common.index || demux->streaming) {
@@ -1965,7 +1959,7 @@ gst_matroska_demux_handle_seek_event (GstMatroskaDemux * demux,
if (demux->streaming) {
/* need to seek to cluster start to pick up cluster time */
/* upstream takes care of flushing and all that
- * ... and newsegment event handling takes care of the rest */
+ * ... and segment event handling takes care of the rest */
return perform_seek_to_offset (demux,
entry->pos + demux->common.ebml_segment_start);
}
@@ -1993,8 +1987,9 @@ next:
if (!demux->streaming && !demux->common.index) {
/* need to stop flushing upstream as we need it next */
if (flush)
- gst_pad_push_event (demux->common.sinkpad, gst_event_new_flush_stop ());
- entry = gst_matroska_demux_search_pos (demux, seeksegment.last_stop);
+ gst_pad_push_event (demux->common.sinkpad,
+ gst_event_new_flush_stop (TRUE));
+ entry = gst_matroska_demux_search_pos (demux, seeksegment.position);
/* keep local copy */
if (entry) {
scan_entry = *entry;
@@ -2003,7 +1998,7 @@ next:
} else {
GST_DEBUG_OBJECT (demux, "Scan failed to find matching position");
if (flush)
- gst_matroska_demux_send_event (demux, gst_event_new_flush_stop ());
+ gst_matroska_demux_send_event (demux, gst_event_new_flush_stop (TRUE));
goto seek_error;
}
}
@@ -2012,26 +2007,26 @@ next:
GST_DEBUG_OBJECT (demux, "seek to key unit, adjusting segment start to %"
GST_TIME_FORMAT, GST_TIME_ARGS (entry->time));
seeksegment.start = entry->time;
- seeksegment.last_stop = entry->time;
+ seeksegment.position = entry->time;
seeksegment.time = entry->time - demux->stream_start_time;
}
exit:
if (flush) {
GST_DEBUG_OBJECT (demux, "Stopping flush");
- gst_pad_push_event (demux->common.sinkpad, gst_event_new_flush_stop ());
- gst_matroska_demux_send_event (demux, gst_event_new_flush_stop ());
+ gst_pad_push_event (demux->common.sinkpad, gst_event_new_flush_stop (TRUE));
+ gst_matroska_demux_send_event (demux, gst_event_new_flush_stop (TRUE));
} else if (demux->segment_running && update) {
+ GstSegment segment;
GST_DEBUG_OBJECT (demux, "Closing currently running segment");
GST_OBJECT_LOCK (demux);
if (demux->close_segment)
gst_event_unref (demux->close_segment);
- demux->close_segment = gst_event_new_new_segment (TRUE,
- demux->common.segment.rate, GST_FORMAT_TIME,
- demux->common.segment.start, demux->common.segment.last_stop,
- demux->common.segment.time);
+ segment = demux->common.segment;
+ segment.stop = segment.position;
+ demux->close_segment = gst_event_new_segment (&segment);
GST_OBJECT_UNLOCK (demux);
}
@@ -2057,10 +2052,8 @@ exit:
GST_OBJECT_LOCK (demux);
if (demux->new_segment)
gst_event_unref (demux->new_segment);
- demux->new_segment = gst_event_new_new_segment_full (!update,
- demux->common.segment.rate, demux->common.segment.applied_rate,
- demux->common.segment.format, demux->common.segment.start,
- demux->common.segment.stop, demux->common.segment.time);
+ /* On port from 0.10, discarded !update (for segment.update) here, FIXME? */
+ demux->new_segment = gst_event_new_segment (&demux->common.segment);
GST_OBJECT_UNLOCK (demux);
/* restart our task since it might have been stopped when we did the
@@ -2167,9 +2160,10 @@ gst_matroska_demux_handle_seek_push (GstMatroskaDemux * demux, GstPad * pad,
}
static gboolean
-gst_matroska_demux_handle_src_event (GstPad * pad, GstEvent * event)
+gst_matroska_demux_handle_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
- GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (gst_pad_get_parent (pad));
+ GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (parent);
gboolean res = TRUE;
switch (GST_EVENT_TYPE (event)) {
@@ -2196,7 +2190,7 @@ gst_matroska_demux_handle_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);
GST_OBJECT_LOCK (demux);
videocontext->earliest_time = timestamp + diff;
@@ -2219,8 +2213,6 @@ gst_matroska_demux_handle_src_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (demux);
-
return res;
}
@@ -2387,7 +2379,7 @@ gst_matroska_demux_sync_streams (GstMatroskaDemux * demux)
GST_OBJECT_LOCK (demux);
GST_LOG_OBJECT (demux, "Sync to %" GST_TIME_FORMAT,
- GST_TIME_ARGS (demux->common.segment.last_stop));
+ GST_TIME_ARGS (demux->common.segment.position));
g_assert (demux->common.num_streams == demux->common.src->len);
for (stream_nr = 0; stream_nr < demux->common.src->len; stream_nr++) {
@@ -2407,13 +2399,14 @@ gst_matroska_demux_sync_streams (GstMatroskaDemux * demux)
/* does it lag? 0.5 seconds is a random threshold...
* lag need only be considered if we have advanced into requested segment */
if (GST_CLOCK_TIME_IS_VALID (context->pos) &&
- GST_CLOCK_TIME_IS_VALID (demux->common.segment.last_stop) &&
- demux->common.segment.last_stop > demux->common.segment.start &&
- context->pos + (GST_SECOND / 2) < demux->common.segment.last_stop) {
+ GST_CLOCK_TIME_IS_VALID (demux->common.segment.position) &&
+ demux->common.segment.position > demux->common.segment.start &&
+ context->pos + (GST_SECOND / 2) < demux->common.segment.position) {
gint64 new_start;
+ GstSegment segment;
GstEvent *event;
- new_start = demux->common.segment.last_stop - (GST_SECOND / 2);
+ new_start = demux->common.segment.position - (GST_SECOND / 2);
if (GST_CLOCK_TIME_IS_VALID (demux->common.segment.stop))
new_start = MIN (new_start, demux->common.segment.stop);
GST_DEBUG_OBJECT (demux,
@@ -2424,9 +2417,10 @@ gst_matroska_demux_sync_streams (GstMatroskaDemux * demux)
context->pos = new_start;
/* advance stream time */
- event = gst_event_new_new_segment (TRUE, demux->common.segment.rate,
- demux->common.segment.format, new_start, demux->common.segment.stop,
- new_start);
+ segment = demux->common.segment;
+ segment.start = new_start;
+ segment.position = new_start;
+ event = gst_event_new_segment (&segment);
GST_OBJECT_UNLOCK (demux);
gst_pad_push_event (context->pad, event);
GST_OBJECT_LOCK (demux);
@@ -2443,9 +2437,7 @@ gst_matroska_demux_push_hdr_buf (GstMatroskaDemux * demux,
GstFlowReturn ret, cret;
GstBuffer *header_buf;
- header_buf = gst_buffer_new_and_alloc (len);
- gst_buffer_set_caps (header_buf, stream->caps);
- memcpy (GST_BUFFER_DATA (header_buf), data, len);
+ header_buf = gst_buffer_new_wrapped (g_memdup (data, len), len);
if (stream->set_discont) {
GST_BUFFER_FLAG_SET (header_buf, GST_BUFFER_FLAG_DISCONT);
@@ -2510,12 +2502,10 @@ gst_matroska_demux_push_speex_codec_priv_data (GstMatroskaDemux * demux,
GstMatroskaTrackContext * stream)
{
GstFlowReturn ret;
- guint8 *pdata;
+ guint8 *pdata = stream->codec_priv;
GST_LOG_OBJECT (demux, "priv data size = %u", stream->codec_priv_size);
- pdata = (guint8 *) stream->codec_priv;
-
/* need at least 'fLaC' marker + STREAMINFO metadata block */
if (stream->codec_priv_size < 80) {
GST_WARNING_OBJECT (demux, "not enough codec priv data for speex headers");
@@ -2543,7 +2533,7 @@ gst_matroska_demux_push_xiph_codec_priv_data (GstMatroskaDemux * demux,
GstMatroskaTrackContext * stream)
{
GstFlowReturn ret;
- guint8 *p = (guint8 *) stream->codec_priv;
+ guint8 *p = stream->codec_priv;
gint i, offset, num_packets;
guint *length, last;
@@ -2610,7 +2600,7 @@ gst_matroska_demux_push_dvd_clut_change_event (GstMatroskaDemux * demux,
* elsewhere, but for now, only interested in a small part */
/* make sure we have terminating 0 */
- buf = g_strndup ((gchar *) stream->codec_priv, stream->codec_priv_size);
+ buf = g_strndup (stream->codec_priv, stream->codec_priv_size);
/* just locate and parse palette part */
start = strstr (buf, "palette:");
@@ -2668,7 +2658,7 @@ gst_matroska_demux_add_mpeg_seq_header (GstElement * element,
{
guint8 *seq_header;
guint seq_header_len;
- guint32 header;
+ guint32 header, tmp;
if (stream->codec_state) {
seq_header = stream->codec_state;
@@ -2684,23 +2674,25 @@ gst_matroska_demux_add_mpeg_seq_header (GstElement * element,
if (GST_BUFFER_FLAG_IS_SET (*buf, GST_BUFFER_FLAG_DELTA_UNIT))
return GST_FLOW_OK;
- if (GST_BUFFER_SIZE (*buf) < 4)
+ if (gst_buffer_get_size (*buf) < 4)
return GST_FLOW_OK;
- header = GST_READ_UINT32_BE (GST_BUFFER_DATA (*buf));
+ gst_buffer_extract (*buf, 0, &tmp, sizeof (guint32));
+ header = GUINT32_FROM_BE (tmp);
+
/* Sequence start code, if not found prepend */
if (header != 0x000001b3) {
GstBuffer *newbuf;
- newbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (*buf) + seq_header_len);
- gst_buffer_set_caps (newbuf, stream->caps);
-
GST_DEBUG_OBJECT (element, "Prepending MPEG sequence header");
- gst_buffer_copy_metadata (newbuf, *buf, GST_BUFFER_COPY_TIMESTAMPS |
- GST_BUFFER_COPY_FLAGS);
- g_memmove (GST_BUFFER_DATA (newbuf), seq_header, seq_header_len);
- g_memmove (GST_BUFFER_DATA (newbuf) + seq_header_len,
- GST_BUFFER_DATA (*buf), GST_BUFFER_SIZE (*buf));
+
+ newbuf = gst_buffer_new_wrapped (g_memdup (seq_header, seq_header_len),
+ seq_header_len);
+
+ gst_buffer_copy_into (newbuf, *buf, GST_BUFFER_COPY_TIMESTAMPS |
+ GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_MEMORY, 0,
+ gst_buffer_get_size (*buf));
+
gst_buffer_unref (*buf);
*buf = newbuf;
}
@@ -2715,8 +2707,7 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
GstMatroskaTrackAudioContext *audiocontext =
(GstMatroskaTrackAudioContext *) stream;
GstBuffer *newbuf = NULL;
- guint8 *data;
- guint newlen;
+ guint8 *buf_data, *data;
Wavpack4Header wvh;
wvh.ck_id[0] = 'w';
@@ -2731,22 +2722,22 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
wvh.block_index = audiocontext->wvpk_block_index;
if (audiocontext->channels <= 2) {
- guint32 block_samples;
+ guint32 block_samples, tmp;
+ gsize size = gst_buffer_get_size (*buf);
- block_samples = GST_READ_UINT32_LE (GST_BUFFER_DATA (*buf));
+ gst_buffer_extract (*buf, 0, &tmp, sizeof (guint32));
+ block_samples = GUINT32_FROM_LE (tmp);
/* we need to reconstruct the header of the wavpack block */
/* -20 because ck_size is the size of the wavpack block -8
* and lace_size is the size of the wavpack block + 12
* (the three guint32 of the header that already are in the buffer) */
- wvh.ck_size = GST_BUFFER_SIZE (*buf) + sizeof (Wavpack4Header) - 20;
+ wvh.ck_size = size + sizeof (Wavpack4Header) - 20;
/* block_samples, flags and crc are already in the buffer */
- newlen = GST_BUFFER_SIZE (*buf) + sizeof (Wavpack4Header) - 12;
- newbuf = gst_buffer_new_and_alloc (newlen);
- gst_buffer_set_caps (newbuf, stream->caps);
+ newbuf = gst_buffer_new_allocate (NULL, sizeof (Wavpack4Header) - 12, 0);
- data = GST_BUFFER_DATA (newbuf);
+ data = gst_buffer_map (newbuf, NULL, NULL, GST_MAP_WRITE);
data[0] = 'w';
data[1] = 'v';
data[2] = 'p';
@@ -2757,26 +2748,31 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
GST_WRITE_UINT8 (data + 11, wvh.index_no);
GST_WRITE_UINT32_LE (data + 12, wvh.total_samples);
GST_WRITE_UINT32_LE (data + 16, wvh.block_index);
- g_memmove (data + 20, GST_BUFFER_DATA (*buf), GST_BUFFER_SIZE (*buf));
- gst_buffer_copy_metadata (newbuf, *buf,
- GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS);
+
+ /* Append data from buf: */
+ gst_buffer_copy_into (newbuf, *buf, GST_BUFFER_COPY_TIMESTAMPS |
+ GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_MEMORY, 0, size);
+
gst_buffer_unref (*buf);
*buf = newbuf;
audiocontext->wvpk_block_index += block_samples;
} else {
- guint8 *outdata;
+ guint8 *outdata = NULL;
guint outpos = 0;
- guint size;
+ gsize buf_size, size, out_size = 0;
guint32 block_samples, flags, crc, blocksize;
- data = GST_BUFFER_DATA (*buf);
- size = GST_BUFFER_SIZE (*buf);
+ buf_data = gst_buffer_map (*buf, &buf_size, NULL, GST_MAP_READ);
- if (size < 4) {
+ if (buf_size < 4) {
GST_ERROR_OBJECT (element, "Too small wavpack buffer");
+ gst_buffer_unmap (*buf, buf_data, buf_size);
return GST_FLOW_ERROR;
}
+ data = buf_data;
+ size = buf_size;
+
block_samples = GST_READ_UINT32_LE (data);
data += 4;
size -= 4;
@@ -2795,21 +2791,22 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
if (blocksize == 0 || size < blocksize)
break;
+ g_assert ((newbuf == NULL) == (outdata == NULL));
+
if (newbuf == NULL) {
- newbuf = gst_buffer_new_and_alloc (sizeof (Wavpack4Header) + blocksize);
- gst_buffer_set_caps (newbuf, stream->caps);
+ out_size = sizeof (Wavpack4Header) + blocksize;
+ newbuf = gst_buffer_new_allocate (NULL, out_size, 0);
- gst_buffer_copy_metadata (newbuf, *buf,
- GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS);
+ gst_buffer_copy_into (newbuf, *buf,
+ GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS, 0, -1);
outpos = 0;
- outdata = GST_BUFFER_DATA (newbuf);
+ outdata = gst_buffer_map (newbuf, NULL, NULL, GST_MAP_WRITE);
} else {
- GST_BUFFER_SIZE (newbuf) += sizeof (Wavpack4Header) + blocksize;
- GST_BUFFER_DATA (newbuf) =
- g_realloc (GST_BUFFER_DATA (newbuf), GST_BUFFER_SIZE (newbuf));
- GST_BUFFER_MALLOCDATA (newbuf) = GST_BUFFER_DATA (newbuf);
- outdata = GST_BUFFER_DATA (newbuf);
+ gst_buffer_unmap (newbuf, outdata, out_size);
+ out_size += sizeof (Wavpack4Header) + blocksize;
+ gst_buffer_set_size (newbuf, out_size);
+ outdata = gst_buffer_map (newbuf, NULL, NULL, GST_MAP_WRITE);
}
outdata[outpos] = 'w';
@@ -2835,7 +2832,12 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
data += blocksize;
size -= blocksize;
}
+ gst_buffer_unmap (*buf, buf_data, buf_size);
gst_buffer_unref (*buf);
+
+ if (newbuf)
+ gst_buffer_unmap (newbuf, outdata, out_size);
+
*buf = newbuf;
audiocontext->wvpk_block_index += block_samples;
}
@@ -2880,16 +2882,16 @@ gst_matroska_demux_check_subtitle_buffer (GstElement * element,
GstMatroskaTrackContext * stream, GstBuffer ** buf)
{
GstMatroskaTrackSubtitleContext *sub_stream;
- const gchar *encoding, *data;
+ const gchar *encoding;
GError *err = NULL;
GstBuffer *newbuf;
gchar *utf8;
- guint size;
+ gpointer data;
+ gsize size;
sub_stream = (GstMatroskaTrackSubtitleContext *) stream;
- data = (const gchar *) GST_BUFFER_DATA (*buf);
- size = GST_BUFFER_SIZE (*buf);
+ data = gst_buffer_map (*buf, &size, NULL, GST_MAP_READ);
if (!sub_stream->invalid_utf8) {
if (g_utf8_validate (data, size, NULL)) {
@@ -2931,19 +2933,18 @@ gst_matroska_demux_check_subtitle_buffer (GstElement * element,
if (utf8 == NULL)
utf8 = g_strdup ("invalid subtitle");
- newbuf = gst_buffer_new ();
- GST_BUFFER_MALLOCDATA (newbuf) = (guint8 *) utf8;
- GST_BUFFER_DATA (newbuf) = (guint8 *) utf8;
- GST_BUFFER_SIZE (newbuf) = strlen (utf8);
- gst_buffer_copy_metadata (newbuf, *buf, GST_BUFFER_COPY_ALL);
+ newbuf = gst_buffer_new_wrapped (utf8, strlen (utf8));
+ gst_buffer_copy_into (newbuf, *buf,
+ GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_META,
+ 0, -1);
+ gst_buffer_unmap (*buf, data, size);
+
gst_buffer_unref (*buf);
*buf = newbuf;
- data = (const gchar *) GST_BUFFER_DATA (*buf);
- size = GST_BUFFER_SIZE (*buf);
+ data = gst_buffer_map (*buf, &size, NULL, GST_MAP_READ);
next:
-
if (sub_stream->check_markup) {
/* caps claim markup text, so we need to escape text,
* except if text is already markup and then needs no further escaping */
@@ -2953,11 +2954,11 @@ next:
if (!sub_stream->seen_markup_tag) {
utf8 = g_markup_escape_text (data, size);
- newbuf = gst_buffer_new ();
- GST_BUFFER_MALLOCDATA (newbuf) = (guint8 *) utf8;
- GST_BUFFER_DATA (newbuf) = (guint8 *) utf8;
- GST_BUFFER_SIZE (newbuf) = strlen (utf8);
- gst_buffer_copy_metadata (newbuf, *buf, GST_BUFFER_COPY_ALL);
+ newbuf = gst_buffer_new_wrapped (utf8, strlen (utf8));
+ gst_buffer_copy_into (newbuf, *buf,
+ GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS |
+ GST_BUFFER_COPY_META, 0, -1);
+ gst_buffer_unmap (*buf, data, size);
gst_buffer_unref (*buf);
*buf = newbuf;
@@ -2971,11 +2972,11 @@ static GstFlowReturn
gst_matroska_demux_check_aac (GstElement * element,
GstMatroskaTrackContext * stream, GstBuffer ** buf)
{
- const guint8 *data;
+ guint8 data[2];
guint size;
- data = GST_BUFFER_DATA (*buf);
- size = GST_BUFFER_SIZE (*buf);
+ gst_buffer_extract (*buf, 0, data, 2);
+ size = gst_buffer_get_size (*buf);
if (size > 2 && data[0] == 0xff && (data[1] >> 4 == 0x0f)) {
GstCaps *new_caps;
@@ -2989,7 +2990,6 @@ gst_matroska_demux_check_aac (GstElement * element,
gst_structure_remove_field (s, "codec_data");
gst_caps_replace (&stream->caps, new_caps);
gst_pad_set_caps (stream->pad, new_caps);
- gst_buffer_set_caps (*buf, new_caps);
GST_DEBUG_OBJECT (element, "ADTS AAC audio data; removing codec-data, "
"new caps: %" GST_PTR_FORMAT, new_caps);
gst_caps_unref (new_caps);
@@ -3001,6 +3001,44 @@ gst_matroska_demux_check_aac (GstElement * element,
return GST_FLOW_OK;
}
+static GstBuffer *
+gst_matroska_demux_align_buffer (GstMatroskaDemux * demux,
+ GstBuffer * buffer, gsize alignment)
+{
+ gpointer data;
+ gsize size;
+
+ data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
+ if (size < sizeof (guintptr)) {
+ gst_buffer_unmap (buffer, data, size);
+ return buffer;
+ }
+
+ if (((guintptr) data) & (alignment - 1)) {
+ GstBuffer *new_buffer;
+ gpointer new_data;
+
+ new_buffer = gst_buffer_new_allocate (NULL,
+ gst_buffer_get_size (buffer), alignment);
+ /* Copy data "by hand", so ensure alignment is kept: */
+ new_data = gst_buffer_map (new_buffer, NULL, NULL, GST_MAP_WRITE);
+ memcpy (new_data, data, size);
+ gst_buffer_unmap (new_buffer, new_data, -1);
+ gst_buffer_copy_into (new_buffer, buffer, GST_BUFFER_COPY_METADATA, 0, -1);
+ GST_DEBUG_OBJECT (demux, "We want output aligned on %d, reallocated",
+ alignment);
+
+ gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unref (buffer);
+
+ return new_buffer;
+ }
+
+ gst_buffer_unmap (buffer, data, size);
+ return buffer;
+}
+
static GstFlowReturn
gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
GstEbmlRead * ebml, guint64 cluster_time, guint64 cluster_offset,
@@ -3012,6 +3050,8 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
guint32 id;
guint64 block_duration = -1;
GstBuffer *buf = NULL;
+ gpointer buf_data = NULL;
+ gsize buf_size;
gint stream_num = -1, n, laces = 0;
guint size = 0;
gint *lace_size = NULL;
@@ -3042,14 +3082,16 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
guint8 *data;
if (buf) {
+ gst_buffer_unmap (buf, buf_data, buf_size);
gst_buffer_unref (buf);
buf = NULL;
}
if ((ret = gst_ebml_read_buffer (ebml, &id, &buf)) != GST_FLOW_OK)
break;
- data = GST_BUFFER_DATA (buf);
- size = GST_BUFFER_SIZE (buf);
+ buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
+ data = buf_data;
+ size = buf_size;
/* first byte(s): blocknum */
if ((n = gst_matroska_ebmlnum_uint (data, size, &num)) < 0)
@@ -3282,7 +3324,10 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
}
/* need to refresh segment info ASAP */
- if (GST_CLOCK_TIME_IS_VALID (lace_time) && demux->need_newsegment) {
+ if (GST_CLOCK_TIME_IS_VALID (lace_time) && demux->need_segment) {
+ GstSegment *segment = &demux->common.segment;
+ guint64 segment_duration = 0;
+
GST_DEBUG_OBJECT (demux,
"generating segment starting at %" GST_TIME_FORMAT,
GST_TIME_ARGS (lace_time));
@@ -3292,15 +3337,17 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
"Setting stream start time to %" GST_TIME_FORMAT,
GST_TIME_ARGS (lace_time));
}
- gst_segment_set_newsegment (&demux->common.segment, FALSE,
- demux->common.segment.rate, GST_FORMAT_TIME, lace_time,
- GST_CLOCK_TIME_NONE, lace_time - demux->stream_start_time);
+ if (GST_CLOCK_TIME_IS_VALID (segment->stop))
+ segment_duration = segment->stop - segment->start;
+ else if (GST_CLOCK_TIME_IS_VALID (segment->position))
+ segment_duration = segment->position - segment->start;
+ segment->base += segment_duration / fabs (segment->rate);
+ segment->start = lace_time;
+ segment->stop = GST_CLOCK_TIME_NONE;
+ segment->position = lace_time - demux->stream_start_time;
/* now convey our segment notion downstream */
- gst_matroska_demux_send_event (demux, gst_event_new_new_segment (FALSE,
- demux->common.segment.rate, demux->common.segment.format,
- demux->common.segment.start, demux->common.segment.stop,
- demux->common.segment.start));
- demux->need_newsegment = FALSE;
+ gst_matroska_demux_send_event (demux, gst_event_new_segment (segment));
+ demux->need_segment = FALSE;
}
if (block_duration != -1) {
@@ -3377,8 +3424,8 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
}
}
- sub = gst_buffer_create_sub (buf,
- GST_BUFFER_SIZE (buf) - size, lace_size[n]);
+ sub = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL,
+ gst_buffer_get_size (buf) - size, lace_size[n]);
GST_DEBUG_OBJECT (demux, "created subbuffer %p", sub);
if (delta_unit)
@@ -3422,9 +3469,8 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
GST_CLOCK_TIME_IS_VALID (demux->last_stop_end) &&
demux->common.segment.rate > 0.0) {
GstClockTimeDiff diff;
- GstEvent *event1, *event2;
- /* only send newsegments with increasing start times,
+ /* only send segments with increasing start times,
* otherwise if these go back and forth downstream (sinks) increase
* accumulated time and running_time */
diff = GST_CLOCK_DIFF (demux->last_stop_end, lace_time);
@@ -3432,40 +3478,43 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
&& lace_time > demux->common.segment.start
&& (!GST_CLOCK_TIME_IS_VALID (demux->common.segment.stop)
|| lace_time < demux->common.segment.stop)) {
+ GstSegment segment;
+ GstEvent *event1, *event2;
GST_DEBUG_OBJECT (demux,
"Gap of %" G_GINT64_FORMAT " ns detected in"
"stream %d (%" GST_TIME_FORMAT " -> %" GST_TIME_FORMAT "). "
- "Sending updated NEWSEGMENT events", diff,
+ "Sending updated SEGMENT events", diff,
stream->index, GST_TIME_ARGS (stream->pos),
GST_TIME_ARGS (lace_time));
- /* send newsegment events such that the gap is not accounted in
- * accum time, hence running_time */
+ /* send segment events such that the gap is not accounted in
+ * segment base time, hence running_time */
/* close ahead of gap */
- event1 = gst_event_new_new_segment (TRUE,
- demux->common.segment.rate, demux->common.segment.format,
- demux->last_stop_end, demux->last_stop_end,
- demux->last_stop_end);
+ segment = demux->common.segment;
+ segment.start = demux->last_stop_end;
+ segment.stop = demux->last_stop_end;
+ segment.position = demux->last_stop_end;
+ event1 = gst_event_new_segment (&segment);
/* skip gap */
- event2 = gst_event_new_new_segment (FALSE,
- demux->common.segment.rate,
- demux->common.segment.format, lace_time,
- demux->common.segment.stop, lace_time);
+ segment.start = lace_time;
+ segment.stop = demux->common.segment.stop;
+ segment.position = lace_time;
+ event2 = gst_event_new_segment (&segment);
GST_OBJECT_UNLOCK (demux);
gst_matroska_demux_send_event (demux, event1);
gst_matroska_demux_send_event (demux, event2);
GST_OBJECT_LOCK (demux);
/* align segment view with downstream,
- * prevents double-counting accum when closing segment */
- gst_segment_set_newsegment (&demux->common.segment, FALSE,
- demux->common.segment.rate, demux->common.segment.format,
- lace_time, demux->common.segment.stop, lace_time);
- demux->common.segment.last_stop = lace_time;
+ * prevents double-counting base time when closing segment */
+ /* FIXME: in 0.10, the segment base/accum got updated here, but
+ * maybe we don't need that because of the double accounting
+ * mentioned above? */
+ demux->common.segment = segment;
}
}
- if (!GST_CLOCK_TIME_IS_VALID (demux->common.segment.last_stop)
- || demux->common.segment.last_stop < lace_time) {
- demux->common.segment.last_stop = lace_time;
+ if (!GST_CLOCK_TIME_IS_VALID (demux->common.segment.position)
+ || demux->common.segment.position < lace_time) {
+ demux->common.segment.position = lace_time;
}
GST_OBJECT_UNLOCK (demux);
@@ -3483,8 +3532,8 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
if (demux->common.segment.duration == -1 ||
demux->common.segment.duration <
lace_time - demux->stream_start_time) {
- gst_segment_set_duration (&demux->common.segment, GST_FORMAT_TIME,
- last_stop_end - demux->stream_start_time);
+ demux->common.segment.duration =
+ last_stop_end - demux->stream_start_time;
GST_OBJECT_UNLOCK (demux);
gst_element_post_message (GST_ELEMENT_CAST (demux),
gst_message_new_duration (GST_OBJECT_CAST (demux),
@@ -3513,7 +3562,7 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
GST_DEBUG_OBJECT (demux,
"Pushing lace %d, data of size %d for stream %d, time=%"
GST_TIME_FORMAT " and duration=%" GST_TIME_FORMAT, n,
- GST_BUFFER_SIZE (sub), stream_num,
+ gst_buffer_get_size (sub), stream_num,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (sub)),
GST_TIME_ARGS (GST_BUFFER_DURATION (sub)));
@@ -3533,8 +3582,6 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
cluster_offset, NULL);
}
- gst_buffer_set_caps (sub, GST_PAD_CAPS (stream->pad));
-
/* Postprocess the buffers depending on the codec used */
if (stream->postprocess_frame) {
GST_LOG_OBJECT (demux, "running post process");
@@ -3548,16 +3595,7 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
elements typically assume minimal alignment.
Therefore, create an aligned copy if necessary. */
g_assert (stream->alignment <= G_MEM_ALIGN);
- if (((guintptr) GST_BUFFER_DATA (sub)) & (stream->alignment - 1)) {
- GstBuffer *buffer = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (sub));
- memcpy (GST_BUFFER_DATA (buffer), GST_BUFFER_DATA (sub),
- GST_BUFFER_SIZE (sub));
- gst_buffer_copy_metadata (buffer, sub, GST_BUFFER_COPY_ALL);
- GST_DEBUG_OBJECT (demux, "We want output aligned on %d, reallocated",
- stream->alignment);
- gst_buffer_unref (sub);
- sub = buffer;
- }
+ sub = gst_matroska_demux_align_buffer (demux, sub, stream->alignment);
ret = gst_pad_push (stream->pad, sub);
if (demux->common.segment.rate < 0) {
@@ -3583,8 +3621,10 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
}
done:
- if (buf)
+ if (buf) {
+ gst_buffer_unmap (buf, buf_data, buf_size);
gst_buffer_unref (buf);
+ }
g_free (lace_size);
return ret;
@@ -3964,10 +4004,9 @@ gst_matroska_demux_check_seekability (GstMatroskaDemux * demux)
/* 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 (demux, "doing duration query to fix up unset stop");
- gst_pad_query_peer_duration (demux->common.sinkpad, &fmt, &stop);
+ gst_pad_peer_query_duration (demux->common.sinkpad, GST_FORMAT_BYTES,
+ &stop);
}
/* if upstream doesn't know the size, it's likely that it's not seekable in
@@ -4139,10 +4178,10 @@ gst_matroska_demux_parse_id (GstMatroskaDemux * demux, guint32 id,
demux->first_cluster_offset = demux->common.offset;
GST_DEBUG_OBJECT (demux, "signaling no more pads");
gst_element_no_more_pads (GST_ELEMENT (demux));
- /* send initial newsegment - we wait till we know the first
+ /* send initial segment - we wait till we know the first
incoming timestamp, so we can properly set the start of
the segment. */
- demux->need_newsegment = TRUE;
+ demux->need_segment = TRUE;
}
demux->cluster_time = GST_CLOCK_TIME_NONE;
demux->cluster_offset = demux->common.offset;
@@ -4429,12 +4468,11 @@ pause:
* if no stop was set */
if (GST_CLOCK_TIME_IS_VALID (demux->last_stop_end) &&
!GST_CLOCK_TIME_IS_VALID (demux->common.segment.stop)) {
- GstEvent *event =
- gst_event_new_new_segment_full (TRUE, demux->common.segment.rate,
- demux->common.segment.applied_rate, demux->common.segment.format,
- demux->common.segment.start,
- MAX (demux->last_stop_end, demux->common.segment.start),
- demux->common.segment.time);
+ GstSegment segment = demux->common.segment;
+ GstEvent *event;
+
+ segment.stop = MAX (demux->last_stop_end, segment.start);
+ event = gst_event_new_segment (&segment);
gst_matroska_demux_send_event (demux, event);
}
@@ -4490,14 +4528,14 @@ perform_seek_to_offset (GstMatroskaDemux * demux, guint64 offset)
res = gst_pad_push_event (demux->common.sinkpad, event);
- /* newsegment event will update offset */
+ /* segment event will update offset */
return res;
}
static GstFlowReturn
-gst_matroska_demux_chain (GstPad * pad, GstBuffer * buffer)
+gst_matroska_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
- GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (GST_PAD_PARENT (pad));
+ GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (parent);
guint available;
GstFlowReturn ret = GST_FLOW_OK;
guint needed = 0;
@@ -4542,32 +4580,26 @@ next:
}
static gboolean
-gst_matroska_demux_handle_sink_event (GstPad * pad, GstEvent * event)
+gst_matroska_demux_handle_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
gboolean res = TRUE;
- GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (GST_PAD_PARENT (pad));
+ GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (parent);
GST_DEBUG_OBJECT (demux,
"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 = 0;
- gboolean update;
- GstSegment segment;
+ const 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_event_parse_segment (event, &segment);
+ /* FIXME: do we need to update segment base here (like accum in 0.10)? */
GST_DEBUG_OBJECT (demux,
- "received format %d newsegment %" GST_SEGMENT_FORMAT, format,
- &segment);
+ "received format %d segment %" GST_SEGMENT_FORMAT, segment->format,
+ segment);
if (demux->common.state < GST_MATROSKA_READ_STATE_DATA) {
GST_DEBUG_OBJECT (demux, "still starting");
@@ -4575,7 +4607,7 @@ gst_matroska_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 (demux, "unsupported segment format, ignoring");
goto exit;
}
@@ -4585,18 +4617,18 @@ gst_matroska_demux_handle_sink_event (GstPad * pad, GstEvent * event)
/* clear current segment leftover */
gst_adapter_clear (demux->common.adapter);
/* and some streaming setup */
- demux->common.offset = start;
+ demux->common.offset = segment->start;
/* do not know where we are;
- * need to come across a cluster and generate newsegment */
- demux->common.segment.last_stop = GST_CLOCK_TIME_NONE;
+ * need to come across a cluster and generate segment */
+ demux->common.segment.position = GST_CLOCK_TIME_NONE;
demux->cluster_time = GST_CLOCK_TIME_NONE;
demux->cluster_offset = 0;
- demux->need_newsegment = TRUE;
+ demux->need_segment = TRUE;
/* but keep some of the upstream segment */
- demux->common.segment.rate = rate;
+ demux->common.segment.rate = segment->rate;
GST_OBJECT_UNLOCK (demux);
exit:
- /* chain will send initial newsegment after pads have been added,
+ /* chain will send initial segment after pads have been added,
* or otherwise come up with one */
GST_DEBUG_OBJECT (demux, "eating event");
gst_event_unref (event);
@@ -4623,14 +4655,14 @@ gst_matroska_demux_handle_sink_event (GstPad * pad, GstEvent * event)
GST_OBJECT_LOCK (demux);
gst_matroska_read_common_reset_streams (&demux->common,
GST_CLOCK_TIME_NONE, TRUE);
- demux->common.segment.last_stop = GST_CLOCK_TIME_NONE;
+ demux->common.segment.position = GST_CLOCK_TIME_NONE;
demux->cluster_time = GST_CLOCK_TIME_NONE;
demux->cluster_offset = 0;
GST_OBJECT_UNLOCK (demux);
/* fall-through */
}
default:
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, event);
break;
}
@@ -4638,39 +4670,53 @@ gst_matroska_demux_handle_sink_event (GstPad * pad, GstEvent * event)
}
static gboolean
-gst_matroska_demux_sink_activate (GstPad * sinkpad)
+gst_matroska_demux_sink_activate (GstPad * sinkpad, GstObject * parent)
{
- GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (GST_PAD_PARENT (sinkpad));
+ GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (parent);
+ GstQuery *query;
+ gboolean pull_mode = FALSE;
+
+ query = gst_query_new_scheduling ();
+
+ if (gst_pad_peer_query (sinkpad, query))
+ pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL);
- if (gst_pad_check_pull_range (sinkpad)) {
+ gst_query_unref (query);
+
+ if (pull_mode) {
GST_DEBUG ("going to pull mode");
demux->streaming = FALSE;
- return gst_pad_activate_pull (sinkpad, TRUE);
+ return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
} else {
GST_DEBUG ("going to push (streaming) mode");
demux->streaming = TRUE;
- return gst_pad_activate_push (sinkpad, TRUE);
+ return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
}
-
- return FALSE;
}
static gboolean
-gst_matroska_demux_sink_activate_pull (GstPad * sinkpad, gboolean active)
+gst_matroska_demux_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
+ GstPadMode mode, gboolean active)
{
- GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (GST_PAD_PARENT (sinkpad));
-
- if (active) {
- /* if we have a scheduler we can start the task */
- demux->segment_running = TRUE;
- gst_pad_start_task (sinkpad, (GstTaskFunction) gst_matroska_demux_loop,
- sinkpad);
- } else {
- demux->segment_running = FALSE;
- gst_pad_stop_task (sinkpad);
+ GstMatroskaDemux *demux = GST_MATROSKA_DEMUX (parent);
+
+ switch (mode) {
+ case GST_PAD_MODE_PULL:
+ if (active) {
+ /* if we have a scheduler we can start the task */
+ demux->segment_running = TRUE;
+ gst_pad_start_task (sinkpad, (GstTaskFunction) gst_matroska_demux_loop,
+ sinkpad);
+ } else {
+ demux->segment_running = FALSE;
+ gst_pad_stop_task (sinkpad);
+ }
+ return TRUE;
+ case GST_PAD_MODE_PUSH:
+ return TRUE;
+ default:
+ return FALSE;
}
-
- return TRUE;
}
static void
@@ -4756,10 +4802,11 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
vids->imp_colors = GUINT32_FROM_LE (vids->imp_colors);
if (size > sizeof (gst_riff_strf_vids)) { /* some extra_data */
- buf = gst_buffer_new_and_alloc (size - sizeof (gst_riff_strf_vids));
- memcpy (GST_BUFFER_DATA (buf),
- (guint8 *) vids + sizeof (gst_riff_strf_vids),
- GST_BUFFER_SIZE (buf));
+ gsize offset = sizeof (gst_riff_strf_vids);
+
+ buf =
+ gst_buffer_new_wrapped (g_memdup ((guint8 *) vids + offset,
+ size - offset), size - offset);
}
if (riff_fourcc)
@@ -4780,28 +4827,28 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
g_free (vids);
}
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_UNCOMPRESSED)) {
- guint32 fourcc = 0;
+ const gchar *format = NULL;
switch (videocontext->fourcc) {
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
*codec_name = g_strdup ("Raw planar YUV 4:2:0");
- fourcc = videocontext->fourcc;
+ format = "I420";
break;
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
*codec_name = g_strdup ("Raw packed YUV 4:2:2");
- fourcc = videocontext->fourcc;
+ format = "YUY2";
break;
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
*codec_name = g_strdup ("Raw packed YUV 4:2:0");
- fourcc = videocontext->fourcc;
+ format = "YV12";
break;
case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
*codec_name = g_strdup ("Raw packed YUV 4:2:2");
- fourcc = videocontext->fourcc;
+ format = "UYVY";
break;
case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
*codec_name = g_strdup ("Raw packed YUV 4:4:4 with alpha channel");
- fourcc = videocontext->fourcc;
+ format = "AYUV";
break;
default:
@@ -4810,8 +4857,8 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
return NULL;
}
- caps = gst_caps_new_simple ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, fourcc, NULL);
+ caps = gst_caps_new_simple ("video/x-raw",
+ "format", G_TYPE_STRING, format, NULL);
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_SP)) {
caps = gst_caps_new_simple ("video/x-divx",
"divxversion", G_TYPE_INT, 4, NULL);
@@ -4830,9 +4877,9 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
"mpegversion", G_TYPE_INT, 4,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
if (data) {
- GstBuffer *priv = gst_buffer_new_and_alloc (size);
+ GstBuffer *priv;
- memcpy (GST_BUFFER_DATA (priv), data, size);
+ priv = gst_buffer_new_wrapped (g_memdup (data, size), size);
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, priv, NULL);
gst_buffer_unref (priv);
}
@@ -4865,12 +4912,12 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
*codec_name = g_strdup_printf ("MPEG-%d video", mpegversion);
context->postprocess_frame = gst_matroska_demux_add_mpeg_seq_header;
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MJPEG)) {
- caps = gst_caps_new_simple ("image/jpeg", NULL);
+ caps = gst_caps_new_empty_simple ("image/jpeg");
*codec_name = g_strdup ("Motion-JPEG");
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_AVC)) {
- caps = gst_caps_new_simple ("video/x-h264", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-h264");
if (data) {
- GstBuffer *priv = gst_buffer_new_and_alloc (size);
+ GstBuffer *priv;
/* First byte is the version, second is the profile indication, and third
* is the 5 contraint_set_flags and 3 reserved bits. Fourth byte is the
@@ -4878,7 +4925,7 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
gst_codec_utils_h264_caps_set_level_and_profile (caps, data + 1,
size - 1);
- memcpy (GST_BUFFER_DATA (priv), data, size);
+ priv = gst_buffer_new_wrapped (g_memdup (data, size), size);
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, priv, NULL);
gst_buffer_unref (priv);
@@ -4917,25 +4964,23 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
subformat = GST_READ_UINT32_BE (data + 0x1a);
rformat = GST_READ_UINT32_BE (data + 0x1e);
- priv = gst_buffer_new_and_alloc (size - 0x1a);
-
- memcpy (GST_BUFFER_DATA (priv), data + 0x1a, size - 0x1a);
- gst_caps_set_simple (caps,
- "codec_data", GST_TYPE_BUFFER, priv,
- "format", G_TYPE_INT, rformat,
- "subformat", G_TYPE_INT, subformat, NULL);
+ priv =
+ gst_buffer_new_wrapped (g_memdup (data + 0x1a, size - 0x1a),
+ size - 0x1a);
+ gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, priv, "format",
+ G_TYPE_INT, rformat, "subformat", G_TYPE_INT, subformat, NULL);
gst_buffer_unref (priv);
}
*codec_name = g_strdup_printf ("RealVideo %d.0", rmversion);
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_THEORA)) {
- caps = gst_caps_new_simple ("video/x-theora", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-theora");
context->send_xiph_headers = TRUE;
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_DIRAC)) {
- caps = gst_caps_new_simple ("video/x-dirac", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-dirac");
*codec_name = g_strdup_printf ("Dirac");
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_VP8)) {
- caps = gst_caps_new_simple ("video/x-vp8", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-vp8");
*codec_name = g_strdup_printf ("On2 VP8");
} else {
GST_WARNING ("Unknown codec '%s', cannot build Caps", codec_id);
@@ -5125,26 +5170,33 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
*codec_name = g_strdup_printf ("MPEG-1 layer %d", layer);
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_PCM_INT_BE) ||
!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_PCM_INT_LE)) {
+ gboolean sign;
gint endianness;
+ GstAudioFormat format;
+ sign = (audiocontext->bitdepth != 8);
if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_PCM_INT_BE))
endianness = G_BIG_ENDIAN;
else
endianness = G_LITTLE_ENDIAN;
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "width", G_TYPE_INT, audiocontext->bitdepth,
- "depth", G_TYPE_INT, audiocontext->bitdepth,
- "signed", G_TYPE_BOOLEAN, audiocontext->bitdepth != 8,
- "endianness", G_TYPE_INT, endianness, NULL);
+ format = gst_audio_format_build_integer (sign, endianness,
+ audiocontext->bitdepth, audiocontext->bitdepth);
+
+ caps = gst_caps_new_simple ("audio/x-raw",
+ "format", G_TYPE_STRING, gst_audio_format_to_string (format), NULL);
*codec_name = g_strdup_printf ("Raw %d-bit PCM audio",
audiocontext->bitdepth);
context->alignment = audiocontext->bitdepth / 8;
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_PCM_FLOAT)) {
- caps = gst_caps_new_simple ("audio/x-raw-float",
- "endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
- "width", G_TYPE_INT, audiocontext->bitdepth, NULL);
+ const gchar *format;
+ if (audiocontext->bitdepth == 32)
+ format = "F32LE";
+ else
+ format = "F64LE";
+ caps = gst_caps_new_simple ("audio/x-raw",
+ "format", G_TYPE_STRING, format, NULL);
*codec_name = g_strdup_printf ("Raw %d-bit floating-point audio",
audiocontext->bitdepth);
context->alignment = audiocontext->bitdepth / 8;
@@ -5159,23 +5211,23 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
"framed", G_TYPE_BOOLEAN, TRUE, NULL);
*codec_name = g_strdup ("E-AC-3 audio");
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_DTS)) {
- caps = gst_caps_new_simple ("audio/x-dts", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-dts");
*codec_name = g_strdup ("DTS audio");
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_VORBIS)) {
- caps = gst_caps_new_simple ("audio/x-vorbis", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-vorbis");
context->send_xiph_headers = TRUE;
/* vorbis decoder does tags */
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_FLAC)) {
- caps = gst_caps_new_simple ("audio/x-flac", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-flac");
context->send_flac_headers = TRUE;
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_SPEEX)) {
- caps = gst_caps_new_simple ("audio/x-speex", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-speex");
context->send_speex_headers = TRUE;
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_ACM)) {
gst_riff_strf_auds auds;
if (data) {
- GstBuffer *codec_data = gst_buffer_new ();
+ GstBuffer *codec_data;
/* little-endian -> byte-order */
auds.format = GST_READ_UINT16_LE (data);
@@ -5186,7 +5238,7 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
auds.size = GST_READ_UINT16_LE (data + 16);
/* 18 is the waveformatex size */
- gst_buffer_set_data (codec_data, data + 18, auds.size);
+ codec_data = gst_buffer_new_wrapped_full (data + 18, NULL, 0, auds.size);
if (riff_audio_fmt)
*riff_audio_fmt = auds.format;
@@ -5217,9 +5269,8 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
if (freq_index == 15)
explicit_freq_bytes = 3;
GST_DEBUG ("obj_type = %u, freq_index = %u", obj_type, freq_index);
- priv = gst_buffer_new_and_alloc (context->codec_priv_size);
- memcpy (GST_BUFFER_DATA (priv), context->codec_priv,
- context->codec_priv_size);
+ priv = gst_buffer_new_wrapped (g_memdup (context->codec_priv,
+ context->codec_priv_size), context->codec_priv_size);
/* assume SBR if samplerate <= 24kHz */
if (obj_type == 5 || (freq_index >= 6 && freq_index != 15) ||
(context->codec_priv_size == (5 + explicit_freq_bytes))) {
@@ -5239,18 +5290,19 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
/* make up decoder-specific data if it is not supplied */
if (priv == NULL) {
- priv = gst_buffer_new_and_alloc (5);
- data = GST_BUFFER_DATA (priv);
+ priv = gst_buffer_new_allocate (NULL, 5, 0);
+ data = gst_buffer_map (priv, NULL, NULL, GST_MAP_WRITE);
rate_idx = aac_rate_idx (audiocontext->samplerate);
profile = aac_profile_idx (codec_id);
data[0] = ((profile + 1) << 3) | ((rate_idx & 0xE) >> 1);
data[1] = ((rate_idx & 0x1) << 7) | (audiocontext->channels << 3);
- GST_BUFFER_SIZE (priv) = 2;
if (!strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG2,
strlen (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG2))) {
mpegversion = 2;
+ gst_buffer_unmap (priv, data, 5);
+ gst_buffer_set_size (priv, 2);
} else if (!strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG4,
strlen (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG4))) {
mpegversion = 4;
@@ -5262,9 +5314,13 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
data[2] = AAC_SYNC_EXTENSION_TYPE >> 3;
data[3] = ((AAC_SYNC_EXTENSION_TYPE & 0x07) << 5) | 5;
data[4] = (1 << 7) | (rate_idx << 3);
- GST_BUFFER_SIZE (priv) = 5;
+ gst_buffer_unmap (priv, data, 5);
+ } else {
+ gst_buffer_unmap (priv, data, 5);
+ gst_buffer_set_size (priv, 2);
}
} else {
+ gst_buffer_unmap (priv, data, 5);
gst_buffer_unref (priv);
priv = NULL;
GST_ERROR ("Unknown AAC profile and no codec private data");
@@ -5333,8 +5389,8 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
G_TYPE_INT, leaf_size, "width", G_TYPE_INT, sample_width, NULL);
if ((size - 78) >= extra_data_size) {
- priv = gst_buffer_new_and_alloc (extra_data_size);
- memcpy (GST_BUFFER_DATA (priv), data + 78, extra_data_size);
+ priv = gst_buffer_new_wrapped (g_memdup (data + 78, extra_data_size),
+ extra_data_size);
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, priv, NULL);
gst_buffer_unref (priv);
}
@@ -5343,13 +5399,13 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
*codec_name = g_strdup_printf ("RealAudio %d.0", raversion);
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_REAL_SIPR)) {
- caps = gst_caps_new_simple ("audio/x-sipro", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-sipro");
*codec_name = g_strdup ("Sipro/ACELP.NET Voice Codec");
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_REAL_RALF)) {
- caps = gst_caps_new_simple ("audio/x-ralf-mpeg4-generic", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-ralf-mpeg4-generic");
*codec_name = g_strdup ("Real Audio Lossless");
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_REAL_ATRC)) {
- caps = gst_caps_new_simple ("audio/x-vnd.sony.atrac3", NULL);
+ caps = gst_caps_new_empty_simple ("audio/x-vnd.sony.atrac3");
*codec_name = g_strdup ("Sony ATRAC3");
} else {
GST_WARNING ("Unknown codec '%s', cannot build Caps", codec_id);
@@ -5395,39 +5451,38 @@ gst_matroska_demux_subtitle_caps (GstMatroskaTrackSubtitleContext *
* Check if we have to do something with codec_private */
if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_SUBTITLE_UTF8)) {
/* well, plain text simply does not have a lot of markup ... */
- caps = gst_caps_new_simple ("text/x-pango-markup", NULL);
+ caps = gst_caps_new_empty_simple ("text/x-pango-markup");
context->postprocess_frame = gst_matroska_demux_check_subtitle_buffer;
subtitlecontext->check_markup = TRUE;
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_SUBTITLE_SSA)) {
- caps = gst_caps_new_simple ("application/x-ssa", NULL);
+ caps = gst_caps_new_empty_simple ("application/x-ssa");
context->postprocess_frame = gst_matroska_demux_check_subtitle_buffer;
subtitlecontext->check_markup = FALSE;
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_SUBTITLE_ASS)) {
- caps = gst_caps_new_simple ("application/x-ass", NULL);
+ caps = gst_caps_new_empty_simple ("application/x-ass");
context->postprocess_frame = gst_matroska_demux_check_subtitle_buffer;
subtitlecontext->check_markup = FALSE;
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_SUBTITLE_USF)) {
- caps = gst_caps_new_simple ("application/x-usf", NULL);
+ caps = gst_caps_new_empty_simple ("application/x-usf");
context->postprocess_frame = gst_matroska_demux_check_subtitle_buffer;
subtitlecontext->check_markup = FALSE;
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_SUBTITLE_VOBSUB)) {
- caps = gst_caps_new_simple ("video/x-dvd-subpicture", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-dvd-subpicture");
((GstMatroskaTrackContext *) subtitlecontext)->send_dvd_event = TRUE;
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_SUBTITLE_HDMVPGS)) {
- caps = gst_caps_new_simple ("subpicture/x-pgs", NULL);
+ caps = gst_caps_new_empty_simple ("subpicture/x-pgs");
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_SUBTITLE_KATE)) {
- caps = gst_caps_new_simple ("subtitle/x-kate", NULL);
+ caps = gst_caps_new_empty_simple ("subtitle/x-kate");
context->send_xiph_headers = TRUE;
} else {
GST_DEBUG ("Unknown subtitle stream: codec_id='%s'", codec_id);
- caps = gst_caps_new_simple ("application/x-subtitle-unknown", NULL);
+ caps = gst_caps_new_empty_simple ("application/x-subtitle-unknown");
}
if (data != NULL && size > 0) {
GstBuffer *buf;
- buf = gst_buffer_new_and_alloc (size);
- memcpy (GST_BUFFER_DATA (buf), data, size);
+ buf = gst_buffer_new_wrapped (g_memdup (data, size), size);
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
gst_buffer_unref (buf);
}
diff --git a/gst/matroska/matroska-demux.h b/gst/matroska/matroska-demux.h
index 2b08b2e39..65061c1d1 100644
--- a/gst/matroska/matroska-demux.h
+++ b/gst/matroska/matroska-demux.h
@@ -87,7 +87,7 @@ typedef struct _GstMatroskaDemux {
gboolean building_index;
guint64 index_offset;
GstEvent *seek_event;
- gboolean need_newsegment;
+ gboolean need_segment;
/* reverse playback */
GArray *seek_index;
diff --git a/gst/matroska/matroska-ids.h b/gst/matroska/matroska-ids.h
index e00e2491a..df93d8885 100644
--- a/gst/matroska/matroska-ids.h
+++ b/gst/matroska/matroska-ids.h
@@ -486,10 +486,10 @@ struct _GstMatroskaTrackContext {
/* some often-used info */
gchar *codec_id, *codec_name, *name, *language;
- guint8 *codec_priv;
- guint codec_priv_size;
- guint8 *codec_state;
- guint codec_state_size;
+ gpointer codec_priv;
+ gsize codec_priv_size;
+ gpointer codec_state;
+ gsize codec_state_size;
GstMatroskaTrackType type;
guint uid, num;
GstMatroskaTrackFlags flags;
diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c
index 99bcc42aa..55fd051aa 100644
--- a/gst/matroska/matroska-mux.c
+++ b/gst/matroska/matroska-mux.c
@@ -49,6 +49,7 @@
#include <stdio.h>
#include <string.h>
+#include <gst/audio/audio.h>
#include <gst/riff/riff-media.h>
#include <gst/tag/tag.h>
@@ -95,7 +96,7 @@ static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
*/
static GstStaticPadTemplate videosink_templ =
- GST_STATIC_PAD_TEMPLATE ("video_%d",
+ GST_STATIC_PAD_TEMPLATE ("video_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("video/mpeg, "
@@ -126,8 +127,8 @@ static GstStaticPadTemplate videosink_templ =
COMMON_VIDEO_CAPS "; "
"video/x-vp8, "
COMMON_VIDEO_CAPS "; "
- "video/x-raw-yuv, "
- "format = (fourcc) { YUY2, I420, YV12, UYVY, AYUV }, "
+ "video/x-raw, "
+ "format = (string) { YUY2, I420, YV12, UYVY, AYUV }, "
COMMON_VIDEO_CAPS "; "
"video/x-wmv, " "wmvversion = (int) [ 1, 3 ], " COMMON_VIDEO_CAPS)
);
@@ -140,7 +141,7 @@ static GstStaticPadTemplate videosink_templ =
* * require codec data, etc as needed
*/
static GstStaticPadTemplate audiosink_templ =
- GST_STATIC_PAD_TEMPLATE ("audio_%d",
+ GST_STATIC_PAD_TEMPLATE ("audio_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("audio/mpeg, "
@@ -163,32 +164,8 @@ static GstStaticPadTemplate audiosink_templ =
COMMON_AUDIO_CAPS "; "
"audio/x-speex, "
COMMON_AUDIO_CAPS "; "
- "audio/x-raw-int, "
- "width = (int) 8, "
- "depth = (int) 8, "
- "signed = (boolean) false, "
- COMMON_AUDIO_CAPS ";"
- "audio/x-raw-int, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, "
- "signed = (boolean) true, "
- COMMON_AUDIO_CAPS ";"
- "audio/x-raw-int, "
- "width = (int) 24, "
- "depth = (int) 24, "
- "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, "
- "signed = (boolean) true, "
- COMMON_AUDIO_CAPS ";"
- "audio/x-raw-int, "
- "width = (int) 32, "
- "depth = (int) 32, "
- "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, "
- "signed = (boolean) true, "
- COMMON_AUDIO_CAPS ";"
- "audio/x-raw-float, "
- "width = (int) [ 32, 64 ], "
- "endianness = (int) LITTLE_ENDIAN, "
+ "audio/x-raw, "
+ "format = (string) { U8, S16BE, S16LE, S24BE, S24LE, S32BE, S32LE, F32LE, F64LE }, "
COMMON_AUDIO_CAPS ";"
"audio/x-tta, "
"width = (int) { 8, 16, 24 }, "
@@ -205,7 +182,7 @@ static GstStaticPadTemplate audiosink_templ =
);
static GstStaticPadTemplate subtitlesink_templ =
-GST_STATIC_PAD_TEMPLATE ("subtitle_%d",
+GST_STATIC_PAD_TEMPLATE ("subtitle_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("subtitle/x-kate"));
@@ -213,10 +190,9 @@ GST_STATIC_PAD_TEMPLATE ("subtitle_%d",
static GArray *used_uids;
G_LOCK_DEFINE_STATIC (used_uids);
-static void gst_matroska_mux_add_interfaces (GType type);
-
-GST_BOILERPLATE_FULL (GstMatroskaMux, gst_matroska_mux, GstElement,
- GST_TYPE_ELEMENT, gst_matroska_mux_add_interfaces);
+#define parent_class gst_matroska_mux_parent_class
+G_DEFINE_TYPE_WITH_CODE (GstMatroskaMux, gst_matroska_mux, GST_TYPE_ELEMENT,
+ G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
/* Matroska muxer destructor */
static void gst_matroska_mux_finalize (GObject * object);
@@ -227,9 +203,9 @@ gst_matroska_mux_collected (GstCollectPads * pads, gpointer user_data);
/* pad functions */
static gboolean gst_matroska_mux_handle_src_event (GstPad * pad,
- GstEvent * event);
+ GstObject * parent, GstEvent * event);
static GstPad *gst_matroska_mux_request_new_pad (GstElement * element,
- GstPadTemplate * templ, const gchar * name);
+ GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
static void gst_matroska_mux_release_pad (GstElement * element, GstPad * pad);
/* gst internal change state handler */
@@ -263,19 +239,6 @@ gst_matroska_mux_write_simple_tag (const GstTagList * list, const gchar * tag,
gpointer data);
static void
-gst_matroska_mux_add_interfaces (GType type)
-{
- static const GInterfaceInfo tag_setter_info = { NULL, NULL, NULL };
-
- g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
-}
-
-static void
-gst_matroska_mux_base_init (gpointer g_class)
-{
-}
-
-static void
gst_matroska_mux_class_init (GstMatroskaMuxClass * klass)
{
GObjectClass *gobject_class;
@@ -284,13 +247,14 @@ gst_matroska_mux_class_init (GstMatroskaMuxClass * klass)
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gst_element_class_add_static_pad_template (gstelement_class,
- &videosink_templ);
- gst_element_class_add_static_pad_template (gstelement_class,
- &audiosink_templ);
- gst_element_class_add_static_pad_template (gstelement_class,
- &subtitlesink_templ);
- gst_element_class_add_static_pad_template (gstelement_class, &src_templ);
+ 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 (&subtitlesink_templ));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&src_templ));
gst_element_class_set_details_simple (gstelement_class, "Matroska muxer",
"Codec/Muxer",
"Muxes video/audio/subtitle streams into a matroska stream",
@@ -439,12 +403,12 @@ gst_matroskamux_pad_init (GstMatroskamuxPad * pad)
* Matroska muxer constructor.
*/
static void
-gst_matroska_mux_init (GstMatroskaMux * mux, GstMatroskaMuxClass * g_class)
+gst_matroska_mux_init (GstMatroskaMux * mux)
{
GstPadTemplate *templ;
templ =
- gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src");
+ gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (mux), "src");
mux->srcpad = gst_pad_new_from_template (templ, "src");
gst_pad_set_event_function (mux->srcpad, gst_matroska_mux_handle_src_event);
@@ -617,9 +581,9 @@ gst_matroska_pad_reset (GstMatroskaPad * collect_pad, gboolean full)
* Release resources of a matroska collect pad.
*/
static void
-gst_matroska_pad_free (GstMatroskaPad * collect_pad)
+gst_matroska_pad_free (GstPad * collect_pad)
{
- gst_matroska_pad_reset (collect_pad, TRUE);
+ gst_matroska_pad_reset ((GstMatroskaPad *) collect_pad, TRUE);
}
@@ -682,7 +646,8 @@ gst_matroska_mux_reset (GstElement * element)
* Returns: #TRUE on success.
*/
static gboolean
-gst_matroska_mux_handle_src_event (GstPad * pad, GstEvent * event)
+gst_matroska_mux_handle_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstEventType type;
@@ -696,7 +661,7 @@ gst_matroska_mux_handle_src_event (GstPad * pad, GstEvent * event)
break;
}
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
}
/**
@@ -709,17 +674,27 @@ gst_matroska_mux_handle_src_event (GstPad * pad, GstEvent * event)
* Returns: #TRUE on success.
*/
static gboolean
-gst_matroska_mux_handle_sink_event (GstPad * pad, GstEvent * event)
+gst_matroska_mux_handle_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstMatroskaTrackContext *context;
GstMatroskaPad *collect_pad;
- GstMatroskaMux *mux;
+ GstMatroskaMux *mux = GST_MATROSKA_MUX (parent);
GstTagList *list;
gboolean ret = TRUE;
- mux = GST_MATROSKA_MUX (gst_pad_get_parent (pad));
-
switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_CAPS:{
+ GstCaps *caps;
+
+ collect_pad = (GstMatroskaPad *) gst_pad_get_element_private (pad);
+ gst_event_parse_caps (event, &caps);
+
+ ret = collect_pad->capsfunc (pad, caps);
+ gst_event_unref (event);
+ event = NULL;
+ break;
+ }
case GST_EVENT_TAG:{
gchar *lang = NULL;
@@ -754,12 +729,11 @@ gst_matroska_mux_handle_sink_event (GstPad * pad, GstEvent * event)
event = NULL;
break;
}
- case GST_EVENT_NEWSEGMENT:{
- GstFormat format;
+ case GST_EVENT_SEGMENT:{
+ const GstSegment *segment;
- gst_event_parse_new_segment (event, NULL, NULL, &format, NULL, NULL,
- NULL);
- if (format != GST_FORMAT_TIME) {
+ gst_event_parse_segment (event, &segment);
+ if (segment->format != GST_FORMAT_TIME) {
ret = FALSE;
gst_event_unref (event);
event = NULL;
@@ -783,9 +757,7 @@ gst_matroska_mux_handle_sink_event (GstPad * pad, GstEvent * event)
/* now GstCollectPads can take care of the rest, e.g. EOS */
if (event)
- ret = mux->collect_event (pad, event);
-
- gst_object_unref (mux);
+ ret = mux->collect_event (pad, parent, event);
return ret;
}
@@ -810,7 +782,7 @@ gst_matroska_mux_video_pad_setcaps (GstPad * pad, GstCaps * caps)
GstStructure *structure;
const gchar *mimetype;
const GValue *value = NULL;
- const GstBuffer *codec_buf = NULL;
+ GstBuffer *codec_buf = NULL;
gint width, height, pixel_width, pixel_height;
gint fps_d, fps_n;
gboolean interlaced = FALSE;
@@ -894,12 +866,17 @@ skip_details:
/* extract codec_data, may turn out needed */
value = gst_structure_get_value (structure, "codec_data");
if (value)
- codec_buf = gst_value_get_buffer (value);
+ codec_buf = (GstBuffer *) gst_value_get_buffer (value);
/* find type */
- if (!strcmp (mimetype, "video/x-raw-yuv")) {
+ if (!strcmp (mimetype, "video/x-raw")) {
+ const gchar *fstr;
context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_VIDEO_UNCOMPRESSED);
- gst_structure_get_fourcc (structure, "format", &videocontext->fourcc);
+ fstr = gst_structure_get_string (structure, "format");
+ if (fstr && strlen (fstr) == 4)
+ videocontext->fourcc = GST_STR_FOURCC (fstr);
+ } else if (!strcmp (mimetype, "image/jpeg")) {
+ context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_VIDEO_MJPEG);
} else if (!strcmp (mimetype, "video/x-xvid") /* MS/VfW compatibility cases */
||!strcmp (mimetype, "video/x-huffyuv")
|| !strcmp (mimetype, "video/x-divx")
@@ -952,9 +929,11 @@ skip_details:
}
} else if (!strcmp (mimetype, "video/x-wmv")) {
gint wmvversion;
- guint32 format;
- if (gst_structure_get_fourcc (structure, "format", &format)) {
- fourcc = format;
+ const gchar *fstr;
+
+ fstr = gst_structure_get_string (structure, "format");
+ if (fstr && strlen (fstr) == 4) {
+ fourcc = GST_STR_FOURCC (fstr);
} else if (gst_structure_get_int (structure, "wmvversion", &wmvversion)) {
if (wmvversion == 2) {
fourcc = GST_MAKE_FOURCC ('W', 'M', 'V', '2');
@@ -983,11 +962,11 @@ skip_details:
/* process codec private/initialization data, if any */
if (codec_buf) {
- size += GST_BUFFER_SIZE (codec_buf);
+ size += gst_buffer_get_size (codec_buf);
bih = g_realloc (bih, size);
GST_WRITE_UINT32_LE (&bih->size, size);
- memcpy ((guint8 *) bih + sizeof (gst_riff_strf_vids),
- GST_BUFFER_DATA (codec_buf), GST_BUFFER_SIZE (codec_buf));
+ gst_buffer_extract (codec_buf, 0,
+ (guint8 *) bih + sizeof (gst_riff_strf_vids), -1);
}
context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC);
@@ -1004,10 +983,9 @@ skip_details:
/* Create avcC header */
if (codec_buf != NULL) {
- context->codec_priv_size = GST_BUFFER_SIZE (codec_buf);
+ context->codec_priv_size = gst_buffer_get_size (codec_buf);
context->codec_priv = g_malloc0 (context->codec_priv_size);
- memcpy (context->codec_priv, GST_BUFFER_DATA (codec_buf),
- context->codec_priv_size);
+ gst_buffer_extract (codec_buf, 0, context->codec_priv, -1);
}
} else if (!strcmp (mimetype, "video/x-theora")) {
const GValue *streamheader;
@@ -1050,10 +1028,9 @@ skip_details:
/* global headers may be in codec data */
if (codec_buf != NULL) {
- context->codec_priv_size = GST_BUFFER_SIZE (codec_buf);
+ context->codec_priv_size = gst_buffer_get_size (codec_buf);
context->codec_priv = g_malloc0 (context->codec_priv_size);
- memcpy (context->codec_priv, GST_BUFFER_DATA (codec_buf),
- context->codec_priv_size);
+ gst_buffer_extract (codec_buf, 0, context->codec_priv, -1);
}
} else if (!strcmp (mimetype, "video/x-msmpeg")) {
msmpeg43:
@@ -1088,10 +1065,10 @@ skip_details:
GstBuffer *codec_data_buf = g_value_peek_pointer (mdpr_data);
- priv_data_size = GST_BUFFER_SIZE (codec_data_buf);
+ priv_data_size = gst_buffer_get_size (codec_data_buf);
priv_data = g_malloc0 (priv_data_size);
- memcpy (priv_data, GST_BUFFER_DATA (codec_data_buf), priv_data_size);
+ gst_buffer_extract (codec_data_buf, 0, priv_data, -1);
context->codec_priv = priv_data;
context->codec_priv_size = priv_data_size;
@@ -1149,12 +1126,12 @@ xiphN_streamheader_to_codecdata (const GValue * streamheader,
priv_data_size = 1;
if (bufarr->len > 0) {
for (i = 0; i < bufarr->len - 1; i++) {
- priv_data_size += GST_BUFFER_SIZE (buf[i]) / 0xff + 1;
+ priv_data_size += gst_buffer_get_size (buf[i]) / 0xff + 1;
}
}
for (i = 0; i < bufarr->len; ++i) {
- priv_data_size += GST_BUFFER_SIZE (buf[i]);
+ priv_data_size += gst_buffer_get_size (buf[i]);
}
priv_data = g_malloc0 (priv_data_size);
@@ -1164,17 +1141,16 @@ xiphN_streamheader_to_codecdata (const GValue * streamheader,
if (bufarr->len > 0) {
for (bufi = 0; bufi < bufarr->len - 1; bufi++) {
- for (i = 0; i < GST_BUFFER_SIZE (buf[bufi]) / 0xff; ++i) {
+ for (i = 0; i < gst_buffer_get_size (buf[bufi]) / 0xff; ++i) {
priv_data[offset++] = 0xff;
}
- priv_data[offset++] = GST_BUFFER_SIZE (buf[bufi]) % 0xff;
+ priv_data[offset++] = gst_buffer_get_size (buf[bufi]) % 0xff;
}
}
for (i = 0; i < bufarr->len; ++i) {
- memcpy (priv_data + offset, GST_BUFFER_DATA (buf[i]),
- GST_BUFFER_SIZE (buf[i]));
- offset += GST_BUFFER_SIZE (buf[i]);
+ gst_buffer_extract (buf[i], 0, priv_data + offset, -1);
+ offset += gst_buffer_get_size (buf[i]);
}
context->codec_priv = priv_data;
@@ -1220,17 +1196,19 @@ vorbis_streamheader_to_codecdata (const GValue * streamheader,
if (!xiphN_streamheader_to_codecdata (streamheader, context, &buf0, 3))
return FALSE;
- if (buf0 == NULL || GST_BUFFER_SIZE (buf0) < 1 + 6 + 4) {
+ if (buf0 == NULL || gst_buffer_get_size (buf0) < 1 + 6 + 4) {
GST_WARNING ("First vorbis header too small, ignoring");
} else {
- if (memcmp (GST_BUFFER_DATA (buf0) + 1, "vorbis", 6) == 0) {
+ if (gst_buffer_memcmp (buf0, 1, "vorbis", 6) == 0) {
GstMatroskaTrackAudioContext *audiocontext;
- guint8 *hdr;
+ guint8 *data, *hdr;
- hdr = GST_BUFFER_DATA (buf0) + 1 + 6 + 4;
+ data = gst_buffer_map (buf0, NULL, NULL, GST_MAP_READ);
+ hdr = data + 1 + 6 + 4;
audiocontext = (GstMatroskaTrackAudioContext *) context;
audiocontext->channels = GST_READ_UINT8 (hdr);
audiocontext->samplerate = GST_READ_UINT32_LE (hdr + 1);
+ gst_buffer_unmap (buf0, data, -1);
}
}
@@ -1249,16 +1227,17 @@ theora_streamheader_to_codecdata (const GValue * streamheader,
if (!xiphN_streamheader_to_codecdata (streamheader, context, &buf0, 3))
return FALSE;
- if (buf0 == NULL || GST_BUFFER_SIZE (buf0) < 1 + 6 + 26) {
+ if (buf0 == NULL || gst_buffer_get_size (buf0) < 1 + 6 + 26) {
GST_WARNING ("First theora header too small, ignoring");
- } else if (memcmp (GST_BUFFER_DATA (buf0), "\200theora\003\002", 9) != 0) {
+ } else if (gst_buffer_memcmp (buf0, 0, "\200theora\003\002", 9) != 0) {
GST_WARNING ("First header not a theora identification header, ignoring");
} else {
GstMatroskaTrackVideoContext *videocontext;
guint fps_num, fps_denom, par_num, par_denom;
- guint8 *hdr;
+ guint8 *data, *hdr;
- hdr = GST_BUFFER_DATA (buf0) + 1 + 6 + 3 + 2 + 2;
+ data = gst_buffer_map (buf0, NULL, NULL, GST_MAP_READ);
+ hdr = data + 1 + 6 + 3 + 2 + 2;
videocontext = (GstMatroskaTrackVideoContext *) context;
videocontext->pixel_width = GST_READ_UINT32_BE (hdr) >> 8;
@@ -1289,6 +1268,8 @@ theora_streamheader_to_codecdata (const GValue * streamheader,
videocontext->display_height = 0;
}
hdr += 3 + 3;
+
+ gst_buffer_unmap (buf0, data, -1);
}
if (buf0)
@@ -1306,9 +1287,9 @@ kate_streamheader_to_codecdata (const GValue * streamheader,
if (!xiphN_streamheader_to_codecdata (streamheader, context, &buf0, -1))
return FALSE;
- if (buf0 == NULL || GST_BUFFER_SIZE (buf0) < 64) { /* Kate ID header is 64 bytes */
+ if (buf0 == NULL || gst_buffer_get_size (buf0) < 64) { /* Kate ID header is 64 bytes */
GST_WARNING ("First kate header too small, ignoring");
- } else if (memcmp (GST_BUFFER_DATA (buf0), "\200kate\0\0\0", 8) != 0) {
+ } else if (gst_buffer_memcmp (buf0, 0, "\200kate\0\0\0", 8) != 0) {
GST_WARNING ("First header not a kate identification header, ignoring");
}
@@ -1349,19 +1330,19 @@ flac_streamheader_to_codecdata (const GValue * streamheader,
buffer = g_value_peek_pointer (bufval);
/* Need at least OggFLAC mapping header, fLaC marker and STREAMINFO block */
- if (GST_BUFFER_SIZE (buffer) < 9 + 4 + 4 + 34
- || memcmp (GST_BUFFER_DATA (buffer) + 1, "FLAC", 4) != 0
- || memcmp (GST_BUFFER_DATA (buffer) + 9, "fLaC", 4) != 0) {
+ if (gst_buffer_get_size (buffer) < 9 + 4 + 4 + 34
+ || gst_buffer_memcmp (buffer, 1, "FLAC", 4) != 0
+ || gst_buffer_memcmp (buffer, 9, "fLaC", 4) != 0) {
GST_WARNING ("Invalid streamheader for FLAC");
return FALSE;
}
- context->codec_priv = g_malloc (GST_BUFFER_SIZE (buffer) - 9);
- context->codec_priv_size = GST_BUFFER_SIZE (buffer) - 9;
- memcpy (context->codec_priv, GST_BUFFER_DATA (buffer) + 9,
- GST_BUFFER_SIZE (buffer) - 9);
+ context->codec_priv_size = gst_buffer_get_size (buffer) - 9;
+ context->codec_priv = g_malloc (context->codec_priv_size);
+ gst_buffer_extract (buffer, 9, context->codec_priv, -1);
for (i = 1; i < bufarr->len; i++) {
+ guint old_size;
bufval = &g_array_index (bufarr, GValue, i);
if (G_VALUE_TYPE (bufval) != GST_TYPE_BUFFER) {
@@ -1374,13 +1355,13 @@ flac_streamheader_to_codecdata (const GValue * streamheader,
buffer = g_value_peek_pointer (bufval);
- context->codec_priv =
- g_realloc (context->codec_priv,
- context->codec_priv_size + GST_BUFFER_SIZE (buffer));
- memcpy ((guint8 *) context->codec_priv + context->codec_priv_size,
- GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
- context->codec_priv_size =
- context->codec_priv_size + GST_BUFFER_SIZE (buffer);
+ old_size = context->codec_priv_size;
+ context->codec_priv_size += gst_buffer_get_size (buffer);
+
+ context->codec_priv = g_realloc (context->codec_priv,
+ context->codec_priv_size);
+ gst_buffer_extract (buffer, 0,
+ (guint8 *) context->codec_priv + old_size, -1);
}
return TRUE;
@@ -1393,6 +1374,7 @@ speex_streamheader_to_codecdata (const GValue * streamheader,
GArray *bufarr;
GValue *bufval;
GstBuffer *buffer;
+ guint old_size;
if (streamheader == NULL || G_VALUE_TYPE (streamheader) != GST_TYPE_ARRAY) {
GST_WARNING ("No or invalid streamheader field in the caps");
@@ -1415,16 +1397,15 @@ speex_streamheader_to_codecdata (const GValue * streamheader,
buffer = g_value_peek_pointer (bufval);
- if (GST_BUFFER_SIZE (buffer) < 80
- || memcmp (GST_BUFFER_DATA (buffer), "Speex ", 8) != 0) {
+ if (gst_buffer_get_size (buffer) < 80
+ || gst_buffer_memcmp (buffer, 0, "Speex ", 8) != 0) {
GST_WARNING ("Invalid streamheader for Speex");
return FALSE;
}
- context->codec_priv = g_malloc (GST_BUFFER_SIZE (buffer));
- context->codec_priv_size = GST_BUFFER_SIZE (buffer);
- memcpy (context->codec_priv, GST_BUFFER_DATA (buffer),
- GST_BUFFER_SIZE (buffer));
+ context->codec_priv_size = gst_buffer_get_size (buffer);
+ context->codec_priv = g_malloc (context->codec_priv_size);
+ gst_buffer_extract (buffer, 0, context->codec_priv, -1);
bufval = &g_array_index (bufarr, GValue, 1);
@@ -1438,28 +1419,26 @@ speex_streamheader_to_codecdata (const GValue * streamheader,
buffer = g_value_peek_pointer (bufval);
- context->codec_priv =
- g_realloc (context->codec_priv,
- context->codec_priv_size + GST_BUFFER_SIZE (buffer));
- memcpy ((guint8 *) context->codec_priv + context->codec_priv_size,
- GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
- context->codec_priv_size =
- context->codec_priv_size + GST_BUFFER_SIZE (buffer);
+ old_size = context->codec_priv_size;
+ context->codec_priv_size += gst_buffer_get_size (buffer);
+ context->codec_priv = g_realloc (context->codec_priv,
+ context->codec_priv_size);
+ gst_buffer_extract (buffer, 0, (guint8 *) context->codec_priv + old_size, -1);
return TRUE;
}
static const gchar *
-aac_codec_data_to_codec_id (const GstBuffer * buf)
+aac_codec_data_to_codec_id (GstBuffer * buf)
{
const gchar *result;
- gint profile;
+ guint8 profile;
/* default to MAIN */
profile = 1;
- if (GST_BUFFER_SIZE (buf) >= 2) {
- profile = GST_READ_UINT8 (GST_BUFFER_DATA (buf));
+ if (gst_buffer_get_size (buf) >= 2) {
+ gst_buffer_extract (buf, 0, &profile, 1);
profile >>= 3;
}
@@ -1505,7 +1484,7 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
gint samplerate = 0, channels = 0;
GstStructure *structure;
const GValue *codec_data = NULL;
- const GstBuffer *buf = NULL;
+ GstBuffer *buf = NULL;
const gchar *stream_format = NULL;
mux = GST_MATROSKA_MUX (GST_PAD_PARENT (pad));
@@ -1617,51 +1596,45 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
default:
goto refuse_caps;
}
- } else if (!strcmp (mimetype, "audio/x-raw-int")) {
- gint width, depth;
- gint endianness = G_LITTLE_ENDIAN;
- gboolean signedness = TRUE;
-
- if (!gst_structure_get_int (structure, "width", &width) ||
- !gst_structure_get_int (structure, "depth", &depth) ||
- !gst_structure_get_boolean (structure, "signed", &signedness)) {
- GST_DEBUG_OBJECT (mux, "broken caps, width/depth/signed field missing");
- goto refuse_caps;
- }
-
- if (depth > 8 &&
- !gst_structure_get_int (structure, "endianness", &endianness)) {
- GST_DEBUG_OBJECT (mux, "broken caps, no endianness specified");
- goto refuse_caps;
- }
-
- if (width != depth) {
- GST_DEBUG_OBJECT (mux, "width must be same as depth!");
- goto refuse_caps;
- }
+ } else if (!strcmp (mimetype, "audio/x-raw")) {
+ GstAudioInfo info;
- /* FIXME: where is this spec'ed out? (tpm) */
- if ((width == 8 && signedness) || (width >= 16 && !signedness)) {
- GST_DEBUG_OBJECT (mux, "8-bit PCM must be unsigned, 16-bit PCM signed");
+ gst_audio_info_init (&info);
+ if (!gst_audio_info_from_caps (&info, caps)) {
+ GST_DEBUG_OBJECT (mux,
+ "broken caps, rejected by gst_audio_info_from_caps");
goto refuse_caps;
}
- audiocontext->bitdepth = depth;
- if (endianness == G_BIG_ENDIAN)
- context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_AUDIO_PCM_INT_BE);
- else
- context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_AUDIO_PCM_INT_LE);
+ switch (GST_AUDIO_INFO_FORMAT (&info)) {
+ case GST_AUDIO_FORMAT_U8:
+ case GST_AUDIO_FORMAT_S16BE:
+ case GST_AUDIO_FORMAT_S16LE:
+ case GST_AUDIO_FORMAT_S24BE:
+ case GST_AUDIO_FORMAT_S24LE:
+ case GST_AUDIO_FORMAT_S32BE:
+ case GST_AUDIO_FORMAT_S32LE:
+ if (GST_AUDIO_INFO_WIDTH (&info) != GST_AUDIO_INFO_DEPTH (&info)) {
+ GST_DEBUG_OBJECT (mux, "width must be same as depth!");
+ goto refuse_caps;
+ }
+ if (GST_AUDIO_INFO_IS_BIG_ENDIAN (&info))
+ context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_AUDIO_PCM_INT_BE);
+ else
+ context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_AUDIO_PCM_INT_LE);
+ break;
- } else if (!strcmp (mimetype, "audio/x-raw-float")) {
- gint width;
+ case GST_AUDIO_FORMAT_F32LE:
+ case GST_AUDIO_FORMAT_F64LE:
+ context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_AUDIO_PCM_FLOAT);
+ break;
- if (!gst_structure_get_int (structure, "width", &width)) {
- GST_DEBUG_OBJECT (mux, "broken caps, width field missing");
- goto refuse_caps;
+ default:
+ GST_DEBUG_OBJECT (mux, "wrong format in raw audio caps");
+ goto refuse_caps;
}
- audiocontext->bitdepth = width;
- context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_AUDIO_PCM_FLOAT);
+ audiocontext->bitdepth = GST_AUDIO_INFO_WIDTH (&info);
} else if (!strcmp (mimetype, "audio/x-vorbis")) {
const GValue *streamheader;
@@ -1754,10 +1727,10 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
GstBuffer *codec_data_buf = g_value_peek_pointer (mdpr_data);
- priv_data_size = GST_BUFFER_SIZE (codec_data_buf);
+ priv_data_size = gst_buffer_get_size (codec_data_buf);
priv_data = g_malloc0 (priv_data_size);
- memcpy (priv_data, GST_BUFFER_DATA (codec_data_buf), priv_data_size);
+ gst_buffer_extract (codec_data_buf, 0, priv_data, -1);
context->codec_priv = priv_data;
context->codec_priv_size = priv_data_size;
@@ -1821,7 +1794,7 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
codec_priv_size = WAVEFORMATEX_SIZE;
if (buf)
- codec_priv_size += GST_BUFFER_SIZE (buf);
+ codec_priv_size += gst_buffer_get_size (buf);
/* serialize waveformatex structure */
codec_priv = g_malloc0 (codec_priv_size);
@@ -1832,14 +1805,14 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
GST_WRITE_UINT16_LE (codec_priv + 12, block_align);
GST_WRITE_UINT16_LE (codec_priv + 14, 0);
if (buf)
- GST_WRITE_UINT16_LE (codec_priv + 16, GST_BUFFER_SIZE (buf));
+ GST_WRITE_UINT16_LE (codec_priv + 16, gst_buffer_get_size (buf));
else
GST_WRITE_UINT16_LE (codec_priv + 16, 0);
/* process codec private/initialization data, if any */
if (buf) {
- memcpy ((guint8 *) codec_priv + WAVEFORMATEX_SIZE,
- GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ gst_buffer_extract (buf, 0,
+ (guint8 *) codec_priv + WAVEFORMATEX_SIZE, -1);
}
context->codec_id = g_strdup (GST_MATROSKA_CODEC_ID_AUDIO_ACM);
@@ -1943,7 +1916,7 @@ gst_matroska_mux_subtitle_pad_setcaps (GstPad * pad, GstCaps * caps)
*/
static GstPad *
gst_matroska_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);
GstMatroskaMux *mux = GST_MATROSKA_MUX (element);
@@ -1951,48 +1924,48 @@ gst_matroska_mux_request_new_pad (GstElement * element,
GstMatroskamuxPad *newpad;
gchar *name = NULL;
const gchar *pad_name = NULL;
- GstPadSetCapsFunction setcapsfunc = NULL;
+ GstMatroskaCapsFunc capsfunc = NULL;
GstMatroskaTrackContext *context = NULL;
gint pad_id;
- if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
+ if (templ == gst_element_class_get_pad_template (klass, "audio_%u")) {
/* don't mix named and unnamed pads, if the pad already exists we fail when
* trying to add it */
- if (req_name != NULL && sscanf (req_name, "audio_%d", &pad_id) == 1) {
+ if (req_name != NULL && sscanf (req_name, "audio_%u", &pad_id) == 1) {
pad_name = req_name;
} else {
- name = g_strdup_printf ("audio_%d", mux->num_a_streams++);
+ name = g_strdup_printf ("audio_%u", mux->num_a_streams++);
pad_name = name;
}
- setcapsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_audio_pad_setcaps);
+ capsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_audio_pad_setcaps);
context = (GstMatroskaTrackContext *)
g_new0 (GstMatroskaTrackAudioContext, 1);
context->type = GST_MATROSKA_TRACK_TYPE_AUDIO;
context->name = g_strdup ("Audio");
- } else if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
+ } else if (templ == gst_element_class_get_pad_template (klass, "video_%u")) {
/* don't mix named and unnamed pads, if the pad already exists we fail when
* trying to add it */
- if (req_name != NULL && sscanf (req_name, "video_%d", &pad_id) == 1) {
+ if (req_name != NULL && sscanf (req_name, "video_%u", &pad_id) == 1) {
pad_name = req_name;
} else {
- name = g_strdup_printf ("video_%d", mux->num_v_streams++);
+ name = g_strdup_printf ("video_%u", mux->num_v_streams++);
pad_name = name;
}
- setcapsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_video_pad_setcaps);
+ capsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_video_pad_setcaps);
context = (GstMatroskaTrackContext *)
g_new0 (GstMatroskaTrackVideoContext, 1);
context->type = GST_MATROSKA_TRACK_TYPE_VIDEO;
context->name = g_strdup ("Video");
- } else if (templ == gst_element_class_get_pad_template (klass, "subtitle_%d")) {
+ } else if (templ == gst_element_class_get_pad_template (klass, "subtitle_%u")) {
/* don't mix named and unnamed pads, if the pad already exists we fail when
* trying to add it */
- if (req_name != NULL && sscanf (req_name, "subtitle_%d", &pad_id) == 1) {
+ if (req_name != NULL && sscanf (req_name, "subtitle_%u", &pad_id) == 1) {
pad_name = req_name;
} else {
- name = g_strdup_printf ("subtitle_%d", mux->num_t_streams++);
+ name = g_strdup_printf ("subtitle_%u", mux->num_t_streams++);
pad_name = name;
}
- setcapsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_subtitle_pad_setcaps);
+ capsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_subtitle_pad_setcaps);
context = (GstMatroskaTrackContext *)
g_new0 (GstMatroskaTrackSubtitleContext, 1);
context->type = GST_MATROSKA_TRACK_TYPE_SUBTITLE;
@@ -2008,8 +1981,8 @@ gst_matroska_mux_request_new_pad (GstElement * element,
gst_matroskamux_pad_init (newpad);
collect_pad = (GstMatroskaPad *)
- gst_collect_pads_add_pad_full (mux->collect, GST_PAD (newpad),
- sizeof (GstMatroskamuxPad),
+ gst_collect_pads_add_pad (mux->collect, GST_PAD (newpad),
+ sizeof (GstMatroskaPad),
(GstCollectDataDestroyNotify) gst_matroska_pad_free);
collect_pad->track = context;
@@ -2027,7 +2000,7 @@ gst_matroska_mux_request_new_pad (GstElement * element,
gst_pad_set_event_function (GST_PAD (newpad),
GST_DEBUG_FUNCPTR (gst_matroska_mux_handle_sink_event));
- gst_pad_set_setcaps_function (GST_PAD (newpad), setcapsfunc);
+ collect_pad->capsfunc = capsfunc;
gst_pad_set_active (GST_PAD (newpad), TRUE);
if (!gst_element_add_pad (element, GST_PAD (newpad)))
goto pad_add_failed;
@@ -2216,9 +2189,9 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
GTimeVal time = { 0, 0 };
if (!strcmp (mux->doctype, GST_MATROSKA_DOCTYPE_WEBM)) {
- ebml->caps = gst_caps_new_simple ("video/webm", NULL);
+ ebml->caps = gst_caps_new_empty_simple ("video/webm");
} else {
- ebml->caps = gst_caps_new_simple ("video/x-matroska", NULL);
+ ebml->caps = gst_caps_new_empty_simple ("video/x-matroska");
}
/* we start with a EBML header */
doctype = mux->doctype;
@@ -2283,7 +2256,6 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
for (collected = mux->collect->data; collected;
collected = g_slist_next (collected)) {
GstMatroskaPad *collect_pad;
- GstFormat format = GST_FORMAT_TIME;
GstPad *thepad;
gint64 trackduration;
@@ -2292,7 +2264,7 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
/* Query the total length of the track. */
GST_DEBUG_OBJECT (thepad, "querying peer duration");
- if (gst_pad_query_peer_duration (thepad, &format, &trackduration)) {
+ if (gst_pad_peer_query_duration (thepad, GST_FORMAT_TIME, &trackduration)) {
GST_DEBUG_OBJECT (thepad, "duration: %" GST_TIME_FORMAT,
GST_TIME_ARGS (trackduration));
if (trackduration != GST_CLOCK_TIME_NONE && trackduration > duration) {
@@ -2610,7 +2582,7 @@ gst_matroska_mux_best_pad (GstMatroskaMux * mux, gboolean * popped)
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (collect_pad->buffer)),
GST_TIME_ARGS (time));
collect_pad->buffer =
- gst_buffer_make_metadata_writable (collect_pad->buffer);
+ gst_buffer_make_writable (collect_pad->buffer);
GST_BUFFER_TIMESTAMP (collect_pad->buffer) = time;
}
}
@@ -2646,15 +2618,16 @@ gst_matroska_mux_create_buffer_header (GstMatroskaTrackContext * track,
gint16 relative_timestamp, int flags)
{
GstBuffer *hdr;
+ guint8 *data = g_malloc (4);
- hdr = gst_buffer_new_and_alloc (4);
+ hdr = gst_buffer_new_wrapped (data, 4);
/* track num - FIXME: what if num >= 0x80 (unlikely)? */
- GST_BUFFER_DATA (hdr)[0] = track->num | 0x80;
+ data[0] = track->num | 0x80;
/* time relative to clustertime */
- GST_WRITE_UINT16_BE (GST_BUFFER_DATA (hdr) + 1, relative_timestamp);
+ GST_WRITE_UINT16_BE (data + 1, relative_timestamp);
/* flags */
- GST_BUFFER_DATA (hdr)[3] = flags;
+ data[3] = flags;
return hdr;
}
@@ -2669,14 +2642,18 @@ gst_matroska_mux_handle_dirac_packet (GstMatroskaMux * mux,
{
GstMatroskaTrackVideoContext *ctx =
(GstMatroskaTrackVideoContext *) collect_pad->track;
- const guint8 *data = GST_BUFFER_DATA (buf);
- guint size = GST_BUFFER_SIZE (buf);
+ guint8 *buf_data, *data;
+ gsize size;
guint8 parse_code;
guint32 next_parse_offset;
GstBuffer *ret = NULL;
gboolean is_muxing_unit = FALSE;
- if (GST_BUFFER_SIZE (buf) < 13) {
+ buf_data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ data = buf_data;
+
+ if (size < 13) {
+ gst_buffer_unmap (buf, buf_data, -1);
gst_buffer_unref (buf);
return ret;
}
@@ -2684,6 +2661,7 @@ gst_matroska_mux_handle_dirac_packet (GstMatroskaMux * mux,
/* Check if this buffer contains a picture or end-of-sequence packet */
while (size >= 13) {
if (GST_READ_UINT32_BE (data) != 0x42424344 /* 'BBCD' */ ) {
+ gst_buffer_unmap (buf, buf_data, -1);
gst_buffer_unref (buf);
return ret;
}
@@ -2714,12 +2692,13 @@ gst_matroska_mux_handle_dirac_packet (GstMatroskaMux * mux,
else
ctx->dirac_unit = gst_buffer_ref (buf);
+ gst_buffer_unmap (buf, buf_data, -1);
+
if (is_muxing_unit) {
- ret = gst_buffer_make_metadata_writable (ctx->dirac_unit);
+ ret = gst_buffer_make_writable (ctx->dirac_unit);
ctx->dirac_unit = NULL;
- gst_buffer_copy_metadata (ret, buf,
- GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS |
- GST_BUFFER_COPY_CAPS);
+ gst_buffer_copy_into (ret, buf,
+ GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
gst_buffer_unref (buf);
} else {
gst_buffer_unref (buf);
@@ -2741,9 +2720,9 @@ gst_matroska_mux_stop_streamheader (GstMatroskaMux * mux)
streamheader_buffer = gst_ebml_stop_streamheader (ebml);
if (!strcmp (mux->doctype, GST_MATROSKA_DOCTYPE_WEBM)) {
- caps = gst_caps_new_simple ("video/webm", NULL);
+ caps = gst_caps_new_empty_simple ("video/webm");
} else {
- caps = gst_caps_new_simple ("video/x-matroska", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-matroska");
}
s = gst_caps_get_structure (caps, 0);
g_value_init (&streamheader, GST_TYPE_ARRAY);
@@ -2945,14 +2924,14 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
relative_timestamp, flags);
gst_ebml_write_set_cache (ebml, 0x40);
gst_ebml_write_buffer_header (ebml, GST_MATROSKA_ID_SIMPLEBLOCK,
- GST_BUFFER_SIZE (buf) + GST_BUFFER_SIZE (hdr));
+ gst_buffer_get_size (buf) + gst_buffer_get_size (hdr));
gst_ebml_write_buffer (ebml, hdr);
gst_ebml_write_flush_cache (ebml, FALSE, GST_BUFFER_TIMESTAMP (buf));
gst_ebml_write_buffer (ebml, buf);
return gst_ebml_last_write_result (ebml);
} else {
- gst_ebml_write_set_cache (ebml, GST_BUFFER_SIZE (buf) * 2);
+ gst_ebml_write_set_cache (ebml, gst_buffer_get_size (buf) * 2);
/* write and call order slightly unnatural,
* but avoids seek and minizes pushing */
blockgroup = gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_BLOCKGROUP);
@@ -2962,9 +2941,10 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
if (write_duration)
gst_ebml_write_uint (ebml, GST_MATROSKA_ID_BLOCKDURATION, block_duration);
gst_ebml_write_buffer_header (ebml, GST_MATROSKA_ID_BLOCK,
- GST_BUFFER_SIZE (buf) + GST_BUFFER_SIZE (hdr));
+ gst_buffer_get_size (buf) + gst_buffer_get_size (hdr));
gst_ebml_write_buffer (ebml, hdr);
- gst_ebml_write_master_finish_full (ebml, blockgroup, GST_BUFFER_SIZE (buf));
+ gst_ebml_write_master_finish_full (ebml, blockgroup,
+ gst_buffer_get_size (buf));
gst_ebml_write_flush_cache (ebml, FALSE, GST_BUFFER_TIMESTAMP (buf));
gst_ebml_write_buffer (ebml, buf);
diff --git a/gst/matroska/matroska-mux.h b/gst/matroska/matroska-mux.h
index 73bdc09ac..4377f26b7 100644
--- a/gst/matroska/matroska-mux.h
+++ b/gst/matroska/matroska-mux.h
@@ -53,10 +53,13 @@ typedef struct _GstMatroskaMetaSeekIndex {
guint64 pos;
} GstMatroskaMetaSeekIndex;
+typedef gboolean (*GstMatroskaCapsFunc) (GstPad *pad, GstCaps *caps);
+
/* all information needed for one matroska stream */
typedef struct
{
GstCollectData collect; /* we extend the CollectData */
+ GstMatroskaCapsFunc capsfunc;
GstMatroskaTrackContext *track;
GstBuffer *buffer; /* the queued buffer for this pad */
diff --git a/gst/matroska/matroska-parse.c b/gst/matroska/matroska-parse.c
index 6fd1f7926..f77a8bf13 100644
--- a/gst/matroska/matroska-parse.c
+++ b/gst/matroska/matroska-parse.c
@@ -111,16 +111,14 @@ static gboolean gst_matroska_parse_element_query (GstElement * element,
static gboolean gst_matroska_parse_handle_seek_event (GstMatroskaParse * parse,
GstPad * pad, GstEvent * event);
static gboolean gst_matroska_parse_handle_src_event (GstPad * pad,
- GstEvent * event);
-static const GstQueryType *gst_matroska_parse_get_src_query_types (GstPad *
- pad);
+ GstObject * parent, GstEvent * event);
static gboolean gst_matroska_parse_handle_src_query (GstPad * pad,
- GstQuery * query);
+ GstObject * parent, GstQuery * query);
static gboolean gst_matroska_parse_handle_sink_event (GstPad * pad,
- GstEvent * event);
+ GstObject * parent, GstEvent * event);
static GstFlowReturn gst_matroska_parse_chain (GstPad * pad,
- GstBuffer * buffer);
+ GstObject * parent, GstBuffer * buffer);
static GstStateChangeReturn
gst_matroska_parse_change_state (GstElement * element,
@@ -135,22 +133,8 @@ static gboolean perform_seek_to_offset (GstMatroskaParse * parse,
guint64 offset);
GType gst_matroska_parse_get_type (void);
-GST_BOILERPLATE (GstMatroskaParse, gst_matroska_parse, GstElement,
- GST_TYPE_ELEMENT);
-
-static void
-gst_matroska_parse_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class, &src_templ);
- gst_element_class_add_static_pad_template (element_class, &sink_templ);
-
- gst_element_class_set_details_simple (element_class, "Matroska parser",
- "Codec/Parser",
- "Parses Matroska/WebM streams into video/audio/subtitles",
- "GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
-}
+#define parent_class gst_matroska_parse_parent_class
+G_DEFINE_TYPE (GstMatroskaParse, gst_matroska_parse, GST_TYPE_ELEMENT);
static void
gst_matroska_parse_finalize (GObject * object)
@@ -194,11 +178,20 @@ gst_matroska_parse_class_init (GstMatroskaParseClass * klass)
GST_DEBUG_FUNCPTR (gst_matroska_parse_set_index);
gstelement_class->get_index =
GST_DEBUG_FUNCPTR (gst_matroska_parse_get_index);
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&src_templ));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&sink_templ));
+
+ gst_element_class_set_details_simple (gstelement_class,
+ "Matroska parser", "Codec/Parser",
+ "Parses Matroska/WebM streams into video/audio/subtitles",
+ "GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
}
static void
-gst_matroska_parse_init (GstMatroskaParse * parse,
- GstMatroskaParseClass * klass)
+gst_matroska_parse_init (GstMatroskaParse * parse)
{
parse->common.sinkpad = gst_pad_new_from_static_template (&sink_templ,
"sink");
@@ -211,8 +204,6 @@ gst_matroska_parse_init (GstMatroskaParse * parse,
parse->srcpad = gst_pad_new_from_static_template (&src_templ, "src");
gst_pad_set_event_function (parse->srcpad,
GST_DEBUG_FUNCPTR (gst_matroska_parse_handle_src_event));
- gst_pad_set_query_type_function (parse->srcpad,
- GST_DEBUG_FUNCPTR (gst_matroska_parse_get_src_query_types));
gst_pad_set_query_function (parse->srcpad,
GST_DEBUG_FUNCPTR (gst_matroska_parse_handle_src_query));
gst_pad_use_fixed_caps (parse->srcpad);
@@ -229,6 +220,8 @@ gst_matroska_parse_init (GstMatroskaParse * parse,
parse->common.adapter = gst_adapter_new ();
+ GST_OBJECT_FLAG_SET (parse, GST_ELEMENT_FLAG_INDEXABLE);
+
/* finish off */
gst_matroska_parse_reset (GST_ELEMENT (parse));
}
@@ -372,7 +365,7 @@ gst_matroska_parse_reset (GstElement * element)
if (parse->common.global_tags) {
gst_tag_list_free (parse->common.global_tags);
}
- parse->common.global_tags = gst_tag_list_new ();
+ parse->common.global_tags = gst_tag_list_new_empty ();
if (parse->common.cached_buffer) {
gst_buffer_unref (parse->common.cached_buffer);
@@ -1076,19 +1069,6 @@ gst_matroska_parse_add_stream (GstMatroskaParse * parse, GstEbmlRead * ebml)
return ret;
}
-static const GstQueryType *
-gst_matroska_parse_get_src_query_types (GstPad * pad)
-{
- static const GstQueryType query_types[] = {
- GST_QUERY_POSITION,
- GST_QUERY_DURATION,
- GST_QUERY_SEEKING,
- 0
- };
-
- return query_types;
-}
-
static gboolean
gst_matroska_parse_query (GstMatroskaParse * parse, GstPad * pad,
GstQuery * query)
@@ -1113,7 +1093,7 @@ gst_matroska_parse_query (GstMatroskaParse * parse, GstPad * pad,
gst_query_set_position (query, GST_FORMAT_TIME, context->pos);
else
gst_query_set_position (query, GST_FORMAT_TIME,
- parse->common.segment.last_stop);
+ parse->common.segment.position);
GST_OBJECT_UNLOCK (parse);
} else if (format == GST_FORMAT_DEFAULT && context
&& context->default_duration) {
@@ -1173,7 +1153,7 @@ gst_matroska_parse_query (GstMatroskaParse * parse, GstPad * pad,
break;
}
default:
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, (GstObject *) parse, query);
break;
}
@@ -1187,15 +1167,14 @@ gst_matroska_parse_element_query (GstElement * element, GstQuery * query)
}
static gboolean
-gst_matroska_parse_handle_src_query (GstPad * pad, GstQuery * query)
+gst_matroska_parse_handle_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
gboolean ret;
- GstMatroskaParse *parse = GST_MATROSKA_PARSE (gst_pad_get_parent (pad));
+ GstMatroskaParse *parse = GST_MATROSKA_PARSE (parent);
ret = gst_matroska_parse_query (parse, pad, query);
- gst_object_unref (parse);
-
return ret;
}
@@ -1246,6 +1225,8 @@ gst_matroska_parse_search_cluster (GstMatroskaParse * parse, gint64 * pos)
GstFlowReturn ret = GST_FLOW_OK;
const guint chunk = 64 * 1024;
GstBuffer *buf = NULL;
+ gpointer data;
+ gsize size;
guint64 length;
guint32 id;
guint needed;
@@ -1261,13 +1242,13 @@ gst_matroska_parse_search_cluster (GstMatroskaParse * parse, gint64 * pos)
if (ret != GST_FLOW_OK)
break;
GST_DEBUG_OBJECT (parse, "read buffer size %d at offset %" G_GINT64_FORMAT,
- GST_BUFFER_SIZE (buf), newpos);
- gst_byte_reader_init_from_buffer (&reader, buf);
+ gst_buffer_get_size (buf), newpos);
+ data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_byte_reader_init (&reader, data, size);
cluster_pos = 0;
resume:
cluster_pos = gst_byte_reader_masked_scan_uint32 (&reader, 0xffffffff,
- GST_MATROSKA_ID_CLUSTER, cluster_pos,
- GST_BUFFER_SIZE (buf) - cluster_pos);
+ GST_MATROSKA_ID_CLUSTER, cluster_pos, size - cluster_pos);
if (cluster_pos >= 0) {
newpos += cluster_pos;
GST_DEBUG_OBJECT (parse,
@@ -1309,13 +1290,15 @@ gst_matroska_parse_search_cluster (GstMatroskaParse * parse, gint64 * pos)
goto resume;
} else {
/* partial cluster id may have been in tail of buffer */
- newpos += MAX (GST_BUFFER_SIZE (buf), 4) - 3;
+ newpos += MAX (size, 4) - 3;
+ gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
buf = NULL;
}
}
if (buf) {
+ gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
buf = NULL;
}
@@ -1360,7 +1343,7 @@ gst_matroska_parse_handle_seek_event (GstMatroskaParse * parse,
if (event) {
GST_DEBUG_OBJECT (parse, "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);
}
@@ -1369,7 +1352,7 @@ gst_matroska_parse_handle_seek_event (GstMatroskaParse * parse,
/* check sanity before we start flushing and all that */
GST_OBJECT_LOCK (parse);
if ((entry = gst_matroska_read_common_do_index_seek (&parse->common, track,
- seeksegment.last_stop, &parse->seek_index, &parse->seek_entry)) ==
+ seeksegment.position, &parse->seek_index, &parse->seek_entry)) ==
NULL) {
/* pull mode without index can scan later on */
GST_DEBUG_OBJECT (parse, "No matching seek entry in index");
@@ -1471,9 +1454,10 @@ gst_matroska_parse_handle_seek_push (GstMatroskaParse * parse, GstPad * pad,
}
static gboolean
-gst_matroska_parse_handle_src_event (GstPad * pad, GstEvent * event)
+gst_matroska_parse_handle_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
- GstMatroskaParse *parse = GST_MATROSKA_PARSE (gst_pad_get_parent (pad));
+ GstMatroskaParse *parse = GST_MATROSKA_PARSE (parent);
gboolean res = TRUE;
switch (GST_EVENT_TYPE (event)) {
@@ -1497,7 +1481,7 @@ gst_matroska_parse_handle_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);
GST_OBJECT_LOCK (parse);
videocontext->earliest_time = timestamp + diff;
@@ -1520,8 +1504,6 @@ gst_matroska_parse_handle_src_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (parse);
-
return res;
}
@@ -1633,6 +1615,8 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
guint32 id;
guint64 block_duration = 0;
GstBuffer *buf = NULL;
+ gpointer buf_data = NULL;
+ gsize buf_size = 0;
gint stream_num = -1, n, laces = 0;
guint size = 0;
gint *lace_size = NULL;
@@ -1666,8 +1650,10 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
if ((ret = gst_ebml_read_buffer (ebml, &id, &buf)) != GST_FLOW_OK)
break;
- data = GST_BUFFER_DATA (buf);
- size = GST_BUFFER_SIZE (buf);
+ buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
+
+ data = buf_data;
+ size = buf_size;
/* first byte(s): blocknum */
if ((n = gst_matroska_ebmlnum_uint (data, size, &num)) < 0)
@@ -1871,18 +1857,18 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
}
/* need to refresh segment info ASAP */
if (GST_CLOCK_TIME_IS_VALID (lace_time) && parse->need_newsegment) {
+ GstSegment segment;
GST_DEBUG_OBJECT (parse,
"generating segment starting at %" GST_TIME_FORMAT,
GST_TIME_ARGS (lace_time));
/* pretend we seeked here */
- gst_segment_set_seek (&parse->common.segment, parse->common.segment.rate,
+ gst_segment_do_seek (&parse->common.segment, parse->common.segment.rate,
GST_FORMAT_TIME, 0, GST_SEEK_TYPE_SET, lace_time,
GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE, NULL);
/* now convey our segment notion downstream */
- gst_matroska_parse_send_event (parse, gst_event_new_new_segment (FALSE,
- parse->common.segment.rate, parse->common.segment.format,
- parse->common.segment.start, parse->common.segment.stop,
- parse->common.segment.start));
+ segment = parse->common.segment;
+ segment.position = segment.start;
+ gst_matroska_parse_send_event (parse, gst_event_new_segment (&segment));
parse->need_newsegment = FALSE;
}
@@ -2132,8 +2118,10 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
}
done:
- if (buf)
+ if (buf) {
+ gst_buffer_unmap (buf, buf_data, buf_size);
gst_buffer_unref (buf);
+ }
g_free (lace_size);
return ret;
@@ -2417,10 +2405,9 @@ gst_matroska_parse_check_seekability (GstMatroskaParse * parse)
/* 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 (parse, "doing duration query to fix up unset stop");
- gst_pad_query_peer_duration (parse->common.sinkpad, &fmt, &stop);
+ gst_pad_peer_query_duration (parse->common.sinkpad, GST_FORMAT_BYTES,
+ &stop);
}
/* if upstream doesn't know the size, it's likely that it's not seekable in
@@ -2509,14 +2496,15 @@ gst_matroska_parse_accumulate_streamheader (GstMatroskaParse * parse,
GstBuffer *buf;
buf = gst_buffer_span (parse->streamheader, 0, buffer,
- GST_BUFFER_SIZE (parse->streamheader) + GST_BUFFER_SIZE (buffer));
+ gst_buffer_get_size (parse->streamheader) +
+ gst_buffer_get_size (buffer));
gst_buffer_unref (parse->streamheader);
parse->streamheader = buf;
} else {
parse->streamheader = gst_buffer_ref (buffer);
}
- GST_DEBUG ("%d", GST_BUFFER_SIZE (parse->streamheader));
+ GST_DEBUG ("%d", gst_buffer_get_size (parse->streamheader));
}
static GstFlowReturn
@@ -2532,7 +2520,7 @@ gst_matroska_parse_output (GstMatroskaParse * parse, GstBuffer * buffer,
GValue bufval = { 0 };
GstBuffer *buf;
- caps = gst_caps_new_simple ("video/x-matroska", NULL);
+ caps = gst_caps_new_empty_simple ("video/x-matroska");
s = gst_caps_get_structure (caps, 0);
g_value_init (&streamheader, GST_TYPE_ARRAY);
g_value_init (&bufval, GST_TYPE_BUFFER);
@@ -2548,7 +2536,6 @@ gst_matroska_parse_output (GstMatroskaParse * parse, GstBuffer * buffer,
gst_pad_set_caps (parse->srcpad, caps);
buf = gst_buffer_copy (parse->streamheader);
- gst_buffer_set_caps (buf, caps);
gst_caps_unref (caps);
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
@@ -2570,7 +2557,6 @@ gst_matroska_parse_output (GstMatroskaParse * parse, GstBuffer * buffer,
} else {
GST_BUFFER_TIMESTAMP (buffer) = parse->last_timestamp;
}
- gst_buffer_set_caps (buffer, GST_PAD_CAPS (parse->srcpad));
ret = gst_pad_push (parse->srcpad, gst_buffer_ref (buffer));
return ret;
@@ -3031,9 +3017,9 @@ perform_seek_to_offset (GstMatroskaParse * parse, guint64 offset)
}
static GstFlowReturn
-gst_matroska_parse_chain (GstPad * pad, GstBuffer * buffer)
+gst_matroska_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
- GstMatroskaParse *parse = GST_MATROSKA_PARSE (GST_PAD_PARENT (pad));
+ GstMatroskaParse *parse = GST_MATROSKA_PARSE (parent);
guint available;
GstFlowReturn ret = GST_FLOW_OK;
guint needed = 0;
@@ -3078,7 +3064,8 @@ next:
}
static gboolean
-gst_matroska_parse_handle_sink_event (GstPad * pad, GstEvent * event)
+gst_matroska_parse_handle_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
gboolean res = TRUE;
GstMatroskaParse *parse = GST_MATROSKA_PARSE (GST_PAD_PARENT (pad));
@@ -3087,23 +3074,15 @@ gst_matroska_parse_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 = 0;
- gboolean update;
- GstSegment segment;
+ const 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_event_parse_segment (event, &segment);
GST_DEBUG_OBJECT (parse,
- "received format %d newsegment %" GST_SEGMENT_FORMAT, format,
- &segment);
+ "received format %d newsegment %" GST_SEGMENT_FORMAT,
+ segment->format, segment);
if (parse->common.state < GST_MATROSKA_READ_STATE_DATA) {
GST_DEBUG_OBJECT (parse, "still starting");
@@ -3111,7 +3090,7 @@ gst_matroska_parse_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 (parse, "unsupported segment format, ignoring");
goto exit;
}
@@ -3120,15 +3099,15 @@ gst_matroska_parse_handle_sink_event (GstPad * pad, GstEvent * event)
/* clear current segment leftover */
gst_adapter_clear (parse->common.adapter);
/* and some streaming setup */
- parse->common.offset = start;
+ parse->common.offset = segment->start;
/* do not know where we are;
* need to come across a cluster and generate newsegment */
- parse->common.segment.last_stop = GST_CLOCK_TIME_NONE;
+ parse->common.segment.position = GST_CLOCK_TIME_NONE;
parse->cluster_time = GST_CLOCK_TIME_NONE;
parse->cluster_offset = 0;
parse->need_newsegment = TRUE;
/* but keep some of the upstream segment */
- parse->common.segment.rate = rate;
+ parse->common.segment.rate = segment->rate;
exit:
/* chain will send initial newsegment after pads have been added,
* or otherwise come up with one */
@@ -3158,13 +3137,13 @@ gst_matroska_parse_handle_sink_event (GstPad * pad, GstEvent * event)
gst_matroska_read_common_reset_streams (&parse->common,
GST_CLOCK_TIME_NONE, TRUE);
GST_OBJECT_UNLOCK (parse);
- parse->common.segment.last_stop = GST_CLOCK_TIME_NONE;
+ parse->common.segment.position = GST_CLOCK_TIME_NONE;
parse->cluster_time = GST_CLOCK_TIME_NONE;
parse->cluster_offset = 0;
/* fall-through */
}
default:
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, event);
break;
}
diff --git a/gst/matroska/matroska-read-common.c b/gst/matroska/matroska-read-common.c
index 5fd178fe3..0714c7054 100644
--- a/gst/matroska/matroska-read-common.c
+++ b/gst/matroska/matroska-read-common.c
@@ -58,7 +58,7 @@ GST_DEBUG_CATEGORY (matroskareadcommon_debug);
static gboolean
gst_matroska_decompress_data (GstMatroskaTrackEncoding * enc,
- guint8 ** data_out, guint * size_out,
+ gpointer * data_out, gsize * size_out,
GstMatroskaTrackCompressionAlgorithm algo)
{
guint8 *new_data = NULL;
@@ -237,8 +237,8 @@ gst_matroska_decode_content_encodings (GArray * encodings)
for (i = 0; i < encodings->len; i++) {
GstMatroskaTrackEncoding *enc =
&g_array_index (encodings, GstMatroskaTrackEncoding, i);
- guint8 *data = NULL;
- guint size;
+ gpointer data = NULL;
+ gsize size;
if ((enc->scope & GST_MATROSKA_TRACK_ENCODING_SCOPE_NEXT_CONTENT_ENCODING)
== 0)
@@ -270,11 +270,11 @@ gst_matroska_decode_content_encodings (GArray * encodings)
}
gboolean
-gst_matroska_decode_data (GArray * encodings, guint8 ** data_out,
- guint * size_out, GstMatroskaTrackEncodingScope scope, gboolean free)
+gst_matroska_decode_data (GArray * encodings, gpointer * data_out,
+ gsize * size_out, GstMatroskaTrackEncodingScope scope, gboolean free)
{
- guint8 *data;
- guint size;
+ gpointer data;
+ gsize size;
gboolean ret = TRUE;
gint i;
@@ -288,8 +288,8 @@ gst_matroska_decode_data (GArray * encodings, guint8 ** data_out,
for (i = 0; i < encodings->len; i++) {
GstMatroskaTrackEncoding *enc =
&g_array_index (encodings, GstMatroskaTrackEncoding, i);
- guint8 *new_data = NULL;
- guint new_size = 0;
+ gpointer new_data = NULL;
+ gsize new_size = 0;
if ((enc->scope & scope) == 0)
continue;
@@ -430,21 +430,31 @@ gst_matroska_read_common_found_global_tag (GstMatroskaReadCommon * common,
gst_tag_list_insert (common->global_tags, taglist, GST_TAG_MERGE_APPEND);
gst_tag_list_free (taglist);
} else {
+ GstEvent *tag_event = gst_event_new_tag (taglist);
+ gint i;
+
/* hm, already sent, no need to cache and wait anymore */
GST_DEBUG_OBJECT (common, "Sending late global tags %" GST_PTR_FORMAT,
taglist);
- gst_element_found_tags (el, taglist);
+
+ for (i = 0; i < common->src->len; i++) {
+ GstMatroskaTrackContext *stream;
+
+ stream = g_ptr_array_index (common->src, i);
+ gst_pad_push_event (stream->pad, gst_event_ref (tag_event));
+ }
+
+ gst_event_unref (tag_event);
}
}
gint64
gst_matroska_read_common_get_length (GstMatroskaReadCommon * common)
{
- GstFormat fmt = GST_FORMAT_BYTES;
gint64 end = -1;
- if (!gst_pad_query_peer_duration (common->sinkpad, &fmt, &end) ||
- fmt != GST_FORMAT_BYTES || end < 0)
+ if (!gst_pad_peer_query_duration (common->sinkpad, GST_FORMAT_BYTES,
+ &end) || end < 0)
GST_DEBUG_OBJECT (common, "no upstream length");
return end;
@@ -569,7 +579,9 @@ gst_matroska_read_common_parse_attached_file (GstMatroskaReadCommon * common,
if (filename && mimetype && data && datalen > 0) {
GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE;
GstBuffer *tagbuffer = NULL;
- GstCaps *caps;
+ GstSample *tagsample = NULL;
+ GstStructure *info = NULL;
+ GstCaps *caps = NULL;
gchar *filename_lc = g_utf8_strdown (filename, -1);
GST_DEBUG_OBJECT (common, "Creating tag for attachment with "
@@ -595,44 +607,49 @@ gst_matroska_read_common_parse_attached_file (GstMatroskaReadCommon * common,
/* First try to create an image tag buffer from this */
if (image_type != GST_TAG_IMAGE_TYPE_NONE) {
- tagbuffer =
- gst_tag_image_data_to_image_buffer (data, datalen, image_type);
+ tagsample =
+ gst_tag_image_data_to_image_sample (data, datalen, image_type);
- if (!tagbuffer)
+ if (!tagsample)
image_type = GST_TAG_IMAGE_TYPE_NONE;
+ else {
+ data = NULL;
+ tagbuffer = gst_buffer_ref (gst_sample_get_buffer (tagsample));
+ caps = gst_caps_ref (gst_sample_get_caps (tagsample));
+ info = gst_structure_copy (gst_sample_get_info (tagsample));
+ gst_sample_unref (tagsample);
+ }
}
/* if this failed create an attachment buffer */
if (!tagbuffer) {
- tagbuffer = gst_buffer_new_and_alloc (datalen);
-
- memcpy (GST_BUFFER_DATA (tagbuffer), data, datalen);
- GST_BUFFER_SIZE (tagbuffer) = datalen;
+ tagbuffer = gst_buffer_new_wrapped (g_memdup (data, datalen), datalen);
caps = gst_type_find_helper_for_buffer (NULL, tagbuffer, NULL);
if (caps == NULL)
- caps = gst_caps_new_simple (mimetype, NULL);
- gst_buffer_set_caps (tagbuffer, caps);
- gst_caps_unref (caps);
+ caps = gst_caps_new_empty_simple (mimetype);
}
- /* Set filename and description on the caps */
- caps = GST_BUFFER_CAPS (tagbuffer);
- gst_caps_set_simple (caps, "filename", G_TYPE_STRING, filename, NULL);
+ /* Set filename and description in the info */
+ if (info == NULL)
+ info = gst_structure_new_empty ("GstTagImageInfo");
+
+ gst_structure_set (info, "filename", G_TYPE_STRING, filename, NULL);
if (description)
- gst_caps_set_simple (caps, "description", G_TYPE_STRING, description,
- NULL);
+ gst_structure_set (info, "description", G_TYPE_STRING, description, NULL);
+
+ tagsample = gst_sample_new (tagbuffer, caps, NULL, info);
GST_DEBUG_OBJECT (common,
- "Created attachment buffer with caps: %" GST_PTR_FORMAT, caps);
+ "Created attachment sample: %" GST_PTR_FORMAT, tagsample);
/* and append to the tag list */
if (image_type != GST_TAG_IMAGE_TYPE_NONE)
- gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_IMAGE, tagbuffer,
+ gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_IMAGE, tagsample,
NULL);
else
gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_ATTACHMENT,
- tagbuffer, NULL);
+ tagsample, NULL);
}
g_free (filename);
@@ -658,7 +675,7 @@ gst_matroska_read_common_parse_attachments (GstMatroskaReadCommon * common,
return ret;
}
- taglist = gst_tag_list_new ();
+ taglist = gst_tag_list_new_empty ();
while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) {
if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK)
@@ -1280,9 +1297,7 @@ gst_matroska_read_common_parse_info (GstMatroskaReadCommon * common,
break;
GST_DEBUG_OBJECT (common, "Title: %s", GST_STR_NULL (text));
- taglist = gst_tag_list_new ();
- gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_TITLE, text,
- NULL);
+ taglist = gst_tag_list_new (GST_TAG_TITLE, text, NULL);
gst_matroska_read_common_found_global_tag (common, el, taglist);
g_free (text);
break;
@@ -1313,7 +1328,7 @@ gst_matroska_read_common_parse_info (GstMatroskaReadCommon * common,
dur_u = gst_gdouble_to_guint64 (dur_f *
gst_guint64_to_gdouble (common->time_scale));
if (GST_CLOCK_TIME_IS_VALID (dur_u) && dur_u <= G_MAXINT64)
- gst_segment_set_duration (&common->segment, GST_FORMAT_TIME, dur_u);
+ common->segment.duration = dur_u;
}
DEBUG_ELEMENT_STOP (common, ebml, "SegmentInfo", ret);
@@ -1518,7 +1533,7 @@ gst_matroska_read_common_parse_metadata (GstMatroskaReadCommon * common,
return ret;
}
- taglist = gst_tag_list_new ();
+ taglist = gst_tag_list_new_empty ();
while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) {
if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK)
@@ -1551,7 +1566,8 @@ static GstFlowReturn
gst_matroska_read_common_peek_adapter (GstMatroskaReadCommon * common, guint
peek, const guint8 ** data)
{
- *data = gst_adapter_peek (common->adapter, peek);
+ /* Caller needs to gst_adapter_unmap. */
+ *data = gst_adapter_map (common->adapter, peek);
if (*data == NULL)
return GST_FLOW_UNEXPECTED;
@@ -1571,19 +1587,26 @@ gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon * common, guint64
* We do it mainly to avoid pulling buffers of 1 byte all the time */
if (common->cached_buffer) {
guint64 cache_offset = GST_BUFFER_OFFSET (common->cached_buffer);
- guint cache_size = GST_BUFFER_SIZE (common->cached_buffer);
+ gsize cache_size = gst_buffer_get_size (common->cached_buffer);
if (cache_offset <= common->offset &&
(common->offset + size) <= (cache_offset + cache_size)) {
if (p_buf)
- *p_buf = gst_buffer_create_sub (common->cached_buffer,
- common->offset - cache_offset, size);
- if (bytes)
- *bytes = GST_BUFFER_DATA (common->cached_buffer) + common->offset -
- cache_offset;
+ *p_buf = gst_buffer_copy_region (common->cached_buffer,
+ GST_BUFFER_COPY_ALL, common->offset - cache_offset, size);
+ if (bytes) {
+ if (!common->cached_data)
+ common->cached_data = gst_buffer_map (common->cached_buffer,
+ NULL, NULL, GST_MAP_READ);
+ *bytes = common->cached_data + common->offset - cache_offset;
+ }
return GST_FLOW_OK;
}
/* not enough data in the cache, free cache and get a new one */
+ if (common->cached_data) {
+ gst_buffer_unmap (common->cached_buffer, common->cached_data, -1);
+ common->cached_data = NULL;
+ }
gst_buffer_unref (common->cached_buffer);
common->cached_buffer = NULL;
}
@@ -1596,11 +1619,15 @@ gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon * common, guint64
return ret;
}
- if (GST_BUFFER_SIZE (common->cached_buffer) >= size) {
+ if (gst_buffer_get_size (common->cached_buffer) >= size) {
if (p_buf)
- *p_buf = gst_buffer_create_sub (common->cached_buffer, 0, size);
- if (bytes)
- *bytes = GST_BUFFER_DATA (common->cached_buffer);
+ *p_buf = gst_buffer_copy_region (common->cached_buffer,
+ GST_BUFFER_COPY_ALL, 0, size);
+ if (bytes) {
+ common->cached_data = gst_buffer_map (common->cached_buffer,
+ NULL, NULL, GST_MAP_READ);
+ *bytes = common->cached_data;
+ }
return GST_FLOW_OK;
}
@@ -1621,10 +1648,10 @@ gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon * common, guint64
return ret;
}
- if (GST_BUFFER_SIZE (common->cached_buffer) < size) {
+ if (gst_buffer_get_size (common->cached_buffer) < size) {
GST_WARNING_OBJECT (common, "Dropping short buffer at offset %"
G_GUINT64_FORMAT ": wanted %u bytes, got %u bytes", common->offset,
- size, GST_BUFFER_SIZE (common->cached_buffer));
+ size, gst_buffer_get_size (common->cached_buffer));
gst_buffer_unref (common->cached_buffer);
common->cached_buffer = NULL;
@@ -1636,9 +1663,13 @@ gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon * common, guint64
}
if (p_buf)
- *p_buf = gst_buffer_create_sub (common->cached_buffer, 0, size);
- if (bytes)
- *bytes = GST_BUFFER_DATA (common->cached_buffer);
+ *p_buf = gst_buffer_copy_region (common->cached_buffer,
+ GST_BUFFER_COPY_ALL, 0, size);
+ if (bytes) {
+ common->cached_data = gst_buffer_map (common->cached_buffer,
+ NULL, NULL, GST_MAP_READ);
+ *bytes = common->cached_data;
+ }
return GST_FLOW_OK;
}
@@ -1664,9 +1695,15 @@ GstFlowReturn
gst_matroska_read_common_peek_id_length_push (GstMatroskaReadCommon * common,
GstElement * el, guint32 * _id, guint64 * _length, guint * _needed)
{
- return gst_ebml_peek_id_length (_id, _length, _needed,
+ GstFlowReturn ret;
+
+ ret = gst_ebml_peek_id_length (_id, _length, _needed,
(GstPeekData) gst_matroska_read_common_peek_adapter, (gpointer) common,
el, common->offset);
+
+ gst_adapter_unmap (common->adapter);
+
+ return ret;
}
static GstFlowReturn
diff --git a/gst/matroska/matroska-read-common.h b/gst/matroska/matroska-read-common.h
index cf617e6e8..752d1a80c 100644
--- a/gst/matroska/matroska-read-common.h
+++ b/gst/matroska/matroska-read-common.h
@@ -81,6 +81,7 @@ typedef struct _GstMatroskaReadCommon {
/* pull mode caching */
GstBuffer *cached_buffer;
+ guint8 *cached_data;
/* push and pull mode */
guint64 offset;
@@ -90,8 +91,8 @@ typedef struct _GstMatroskaReadCommon {
} GstMatroskaReadCommon;
GstFlowReturn gst_matroska_decode_content_encodings (GArray * encodings);
-gboolean gst_matroska_decode_data (GArray * encodings, guint8 ** data_out,
- guint * size_out, GstMatroskaTrackEncodingScope scope, gboolean free);
+gboolean gst_matroska_decode_data (GArray * encodings, gpointer * data_out,
+ gsize * size_out, GstMatroskaTrackEncodingScope scope, gboolean free);
gint gst_matroska_index_seek_find (GstMatroskaIndex * i1, GstClockTime * time,
gpointer user_data);
GstMatroskaIndex * gst_matroska_read_common_do_index_seek (
diff --git a/gst/matroska/webm-mux.c b/gst/matroska/webm-mux.c
index 885c65121..0dbac3858 100644
--- a/gst/matroska/webm-mux.c
+++ b/gst/matroska/webm-mux.c
@@ -32,8 +32,8 @@
* ]| This pipeline re-encodes a video file of any format into a WebM file.
* |[
* gst-launch-0.10 webmmux name=mux ! filesink location=test.webm \
- * videotestsrc num-buffers=250 ! video/x-raw-yuv,framerate=25/1 ! ffmpegcolorspace ! vp8enc ! queue ! mux.video_0 \
- * audiotestsrc samplesperbuffer=44100 num-buffers=10 ! audio/x-raw-float,rate=44100 ! vorbisenc ! queue ! mux.audio_0
+ * videotestsrc num-buffers=250 ! video/x-raw,framerate=25/1 ! ffmpegcolorspace ! vp8enc ! queue ! mux.video_0 \
+ * audiotestsrc samplesperbuffer=44100 num-buffers=10 ! audio/x-raw,rate=44100 ! vorbisenc ! queue ! mux.audio_0
* ]| This pipeline muxes a test video and a sine wave into a WebM file.
* </refsect2>
*/
@@ -53,8 +53,7 @@
"channels = (int) [ 1, MAX ], " \
"rate = (int) [ 1, MAX ]"
-GST_BOILERPLATE (GstWebMMux, gst_webm_mux, GstMatroskaMux,
- GST_TYPE_MATROSKA_MUX);
+G_DEFINE_TYPE (GstWebMMux, gst_webm_mux, GST_TYPE_MATROSKA_MUX);
static GstStaticPadTemplate webm_src_templ = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
@@ -63,35 +62,30 @@ static GstStaticPadTemplate webm_src_templ = GST_STATIC_PAD_TEMPLATE ("src",
);
static GstStaticPadTemplate webm_videosink_templ =
-GST_STATIC_PAD_TEMPLATE ("video_%d",
+GST_STATIC_PAD_TEMPLATE ("video_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("video/x-vp8, " COMMON_VIDEO_CAPS)
);
static GstStaticPadTemplate webm_audiosink_templ =
-GST_STATIC_PAD_TEMPLATE ("audio_%d",
+GST_STATIC_PAD_TEMPLATE ("audio_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("audio/x-vorbis, " COMMON_AUDIO_CAPS)
);
static void
-gst_webm_mux_base_init (gpointer g_class)
-{
-}
-
-static void
gst_webm_mux_class_init (GstWebMMuxClass * klass)
{
GstElementClass *gstelement_class = (GstElementClass *) klass;
- gst_element_class_add_static_pad_template (gstelement_class,
- &webm_videosink_templ);
- gst_element_class_add_static_pad_template (gstelement_class,
- &webm_audiosink_templ);
- gst_element_class_add_static_pad_template (gstelement_class,
- &webm_src_templ);
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&webm_videosink_templ));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&webm_audiosink_templ));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&webm_src_templ));
gst_element_class_set_details_simple (gstelement_class, "WebM muxer",
"Codec/Muxer",
"Muxes video and audio streams into a WebM stream",
@@ -99,7 +93,7 @@ gst_webm_mux_class_init (GstWebMMuxClass * klass)
}
static void
-gst_webm_mux_init (GstWebMMux * mux, GstWebMMuxClass * g_class)
+gst_webm_mux_init (GstWebMMux * mux)
{
GST_MATROSKA_MUX (mux)->doctype = GST_MATROSKA_DOCTYPE_WEBM;
}
diff --git a/gst/median/gstmedian.c b/gst/median/gstmedian.c
index b758750ca..6cbcbe0ff 100644
--- a/gst/median/gstmedian.c
+++ b/gst/median/gstmedian.c
@@ -102,10 +102,10 @@ gst_median_base_init (GstMedianClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class,
- &median_sink_factory);
- gst_element_class_add_static_pad_template (element_class,
- &median_src_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&median_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&median_src_factory));
gst_element_class_set_details_simple (element_class, "Median effect",
"Filter/Effect/Video",
"Apply a median filter to an image",
diff --git a/gst/monoscope/gstmonoscope.c b/gst/monoscope/gstmonoscope.c
index 14b003c24..f45b923cd 100644
--- a/gst/monoscope/gstmonoscope.c
+++ b/gst/monoscope/gstmonoscope.c
@@ -101,9 +101,10 @@ gst_monoscope_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class, &src_template);
- gst_element_class_add_static_pad_template (element_class,
- &sink_template);
+ 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, "Monoscope",
"Visualization",
"Displays a highly stabilised waveform of audio input",
diff --git a/gst/multifile/gstmultifilesink.c b/gst/multifile/gstmultifilesink.c
index 984e22396..50d1f976d 100644
--- a/gst/multifile/gstmultifilesink.c
+++ b/gst/multifile/gstmultifilesink.c
@@ -192,28 +192,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_static_pad_template (gstelement_class, &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;
@@ -293,11 +279,20 @@ gst_multi_file_sink_class_init (GstMultiFileSinkClass * klass)
gstbasesink_class->set_caps =
GST_DEBUG_FUNCPTR (gst_multi_file_sink_set_caps);
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_multi_file_sink_event);
+
+ 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;
@@ -492,16 +487,19 @@ gst_multi_file_sink_write_stream_headers (GstMultiFileSink * sink)
for (i = 0; i < sink->n_streamheaders; i++) {
GstBuffer *hdr;
+ guint8 *sdata;
+ gsize ssize;
int ret;
hdr = sink->streamheaders[i];
-
- ret = fwrite (GST_BUFFER_DATA (hdr), GST_BUFFER_SIZE (hdr), 1, sink->file);
+ sdata = gst_buffer_map (hdr, &ssize, NULL, GST_MAP_READ);
+ ret = fwrite (sdata, ssize, 1, sink->file);
+ gst_buffer_unmap (hdr, sdata, ssize);
if (ret != 1)
return FALSE;
- sink->cur_file_size += GST_BUFFER_SIZE (hdr);
+ sink->cur_file_size += ssize;
}
return TRUE;
@@ -511,14 +509,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);
@@ -550,8 +547,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;
@@ -580,8 +576,7 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
gst_multi_file_sink_write_stream_headers (multifilesink);
}
- 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;
@@ -592,8 +587,11 @@ 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);
+ if (!gst_multi_file_sink_write_stream_headers (multifilesink))
+ goto stdio_write_error;
+
+ ret = fwrite (data, size, 1, multifilesink->file);
+
if (ret != 1)
goto stdio_write_error;
@@ -601,7 +599,7 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
case GST_MULTI_FILE_SINK_NEXT_MAX_SIZE:{
guint64 new_size;
- new_size = multifilesink->cur_file_size + GST_BUFFER_SIZE (buffer);
+ new_size = multifilesink->cur_file_size + size;
if (new_size > multifilesink->max_file_size) {
GST_INFO_OBJECT (multifilesink, "current size: %" G_GUINT64_FORMAT
@@ -620,19 +618,19 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
gst_multi_file_sink_write_stream_headers (multifilesink);
}
- 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;
- multifilesink->cur_file_size += GST_BUFFER_SIZE (buffer);
+ multifilesink->cur_file_size += size;
break;
}
default:
g_assert_not_reached ();
}
+ gst_buffer_unmap (buffer, data, size);
return GST_FLOW_OK;
/* ERRORS */
@@ -653,40 +651,49 @@ 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 GstBufferListItem
-buffer_list_calc_size (GstBuffer ** buf, guint group, guint idx, gpointer data)
+static gboolean
+buffer_list_calc_size (GstBuffer ** buf, guint idx, gpointer data)
{
guint *p_size = data;
guint buf_size;
- buf_size = GST_BUFFER_SIZE (*buf);
- GST_TRACE ("buffer %u in group %u has size %u", idx, group, buf_size);
+ buf_size = gst_buffer_get_size (*buf);
+ GST_TRACE ("buffer %u has size %" G_GSIZE_FORMAT, idx, buf_size);
*p_size += buf_size;
- return GST_BUFFER_LIST_CONTINUE;
+ return TRUE;
}
-static GstBufferListItem
-buffer_list_copy_data (GstBuffer ** buf, guint group, guint idx, gpointer data)
+static gboolean
+buffer_list_copy_data (GstBuffer ** buf, guint idx, gpointer data)
{
GstBuffer *dest = data;
+ guint num, i;
- if (group == 0 && idx == 0)
- gst_buffer_copy_metadata (dest, *buf, GST_BUFFER_COPY_ALL);
+ if (idx == 0)
+ gst_buffer_copy_into (dest, *buf, GST_BUFFER_COPY_METADATA, 0, -1);
- memcpy (GST_BUFFER_DATA (dest) + GST_BUFFER_SIZE (dest),
- GST_BUFFER_DATA (*buf), GST_BUFFER_SIZE (*buf));
- GST_BUFFER_SIZE (dest) += GST_BUFFER_SIZE (*buf);
+ num = gst_buffer_n_memory (*buf);
+ for (i = 0; i < num; ++i) {
+ GstMemory *mem;
- return GST_BUFFER_LIST_CONTINUE;
+ mem = gst_buffer_peek_memory (*buf, i, GST_MAP_READ);
+ gst_buffer_take_memory (dest, -1, gst_memory_ref (mem));
+ }
+
+ return TRUE;
}
/* Our assumption for now is that the buffers in a buffer list should always
@@ -703,10 +710,9 @@ gst_multi_file_sink_render_list (GstBaseSink * sink, GstBufferList * list)
/* copy all buffers in the list into one single buffer, so we can use
* the normal render function (FIXME: optimise to avoid the memcpy) */
- buf = gst_buffer_new_and_alloc (size);
- GST_BUFFER_SIZE (buf) = 0;
+ buf = gst_buffer_new ();
gst_buffer_list_foreach (list, buffer_list_copy_data, buf);
- g_assert (GST_BUFFER_SIZE (buf) == size);
+ g_assert (gst_buffer_get_size (buf) == size);
gst_multi_file_sink_render (sink, buf);
gst_buffer_unref (buf);
@@ -774,7 +780,6 @@ gst_multi_file_sink_event (GstBaseSink * sink, GstEvent * event)
{
GstMultiFileSink *multifilesink;
gchar *filename;
- gboolean res = TRUE;
multifilesink = GST_MULTI_FILE_SINK (sink);
@@ -826,12 +831,16 @@ gst_multi_file_sink_event (GstBaseSink * sink, GstEvent * event)
}
out:
- return res;
+ return GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
+ /* ERRORS */
stdio_write_error:
- GST_ELEMENT_ERROR (multifilesink, RESOURCE, WRITE,
- ("Error while writing to file."), (NULL));
- return FALSE;
+ {
+ GST_ELEMENT_ERROR (multifilesink, RESOURCE, WRITE,
+ ("Error while writing to file."), (NULL));
+ gst_event_unref (event);
+ return FALSE;
+ }
}
static gboolean
diff --git a/gst/multifile/gstmultifilesrc.c b/gst/multifile/gstmultifilesrc.c
index 48f5c1f25..b42d9634a 100644
--- a/gst/multifile/gstmultifilesrc.c
+++ b/gst/multifile/gstmultifilesrc.c
@@ -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_static_pad_template (gstelement_class,
- &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);
diff --git a/gst/multifile/gstsplitfilesrc.c b/gst/multifile/gstsplitfilesrc.c
index 31259976e..b06a1155e 100644
--- a/gst/multifile/gstsplitfilesrc.c
+++ b/gst/multifile/gstsplitfilesrc.c
@@ -74,7 +74,6 @@ static void gst_split_file_src_finalize (GObject * obj);
static gboolean gst_split_file_src_start (GstBaseSrc * basesrc);
static gboolean gst_split_file_src_stop (GstBaseSrc * basesrc);
static gboolean gst_split_file_src_can_seek (GstBaseSrc * basesrc);
-static gboolean gst_split_file_src_check_get_range (GstBaseSrc * basesrc);
static gboolean gst_split_file_src_get_size (GstBaseSrc * basesrc, guint64 * s);
static gboolean gst_split_file_src_unlock (GstBaseSrc * basesrc);
static GstFlowReturn gst_split_file_src_create (GstBaseSrc * basesrc,
@@ -89,25 +88,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_DEBUG_CATEGORY_STATIC (splitfilesrc_debug);
#define GST_CAT_DEFAULT splitfilesrc_debug
-GST_BOILERPLATE (GstSplitFileSrc, gst_split_file_src, GstBaseSrc,
- GST_TYPE_BASE_SRC);
-
-static void
-gst_split_file_src_base_init (gpointer g_class)
-{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
- GST_DEBUG_CATEGORY_INIT (splitfilesrc_debug, "splitfilesrc", 0,
- "splitfilesrc element");
-
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_split_file_src_pad_template));
-
- gst_element_class_set_details_simple (gstelement_class, "Split-File Source",
- "Source/File",
- "Read a sequentially named set of files as if it was one large file",
- "Tim-Philipp Müller <tim.muller@collabora.co.uk>");
-}
+G_DEFINE_TYPE (GstSplitFileSrc, gst_split_file_src, GST_TYPE_BASE_SRC);
#ifdef G_OS_WIN32
#define WIN32_BLURB " Location string must be in UTF-8 encoding (on Windows)."
@@ -119,6 +100,7 @@ static void
gst_split_file_src_class_init (GstSplitFileSrcClass * klass)
{
GstBaseSrcClass *gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property = gst_split_file_src_set_property;
@@ -140,13 +122,21 @@ gst_split_file_src_class_init (GstSplitFileSrcClass * klass)
gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_split_file_src_unlock);
gstbasesrc_class->is_seekable =
GST_DEBUG_FUNCPTR (gst_split_file_src_can_seek);
- gstbasesrc_class->check_get_range =
- GST_DEBUG_FUNCPTR (gst_split_file_src_check_get_range);
+
+ GST_DEBUG_CATEGORY_INIT (splitfilesrc_debug, "splitfilesrc", 0,
+ "splitfilesrc element");
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_split_file_src_pad_template));
+
+ gst_element_class_set_details_simple (gstelement_class, "Split-File Source",
+ "Source/File",
+ "Read a sequentially named set of files as if it was one large file",
+ "Tim-Philipp Müller <tim.muller@collabora.co.uk>");
}
static void
-gst_split_file_src_init (GstSplitFileSrc * splitfilesrc,
- GstSplitFileSrcClass * g_class)
+gst_split_file_src_init (GstSplitFileSrc * splitfilesrc)
{
}
@@ -158,7 +148,7 @@ gst_split_file_src_finalize (GObject * obj)
g_free (src->location);
src->location = NULL;
- G_OBJECT_CLASS (parent_class)->finalize (obj);
+ G_OBJECT_CLASS (gst_split_file_src_parent_class)->finalize (obj);
}
static gboolean
@@ -168,12 +158,6 @@ gst_split_file_src_can_seek (GstBaseSrc * basesrc)
}
static gboolean
-gst_split_file_src_check_get_range (GstBaseSrc * basesrc)
-{
- return TRUE;
-}
-
-static gboolean
gst_split_file_src_unlock (GstBaseSrc * basesrc)
{
/* This is not actually that useful, since all normal file
@@ -502,11 +486,11 @@ gst_split_file_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
"%" G_GUINT64_FORMAT ", %s)", src->cur_part, cur_part.start,
cur_part.stop, cur_part.path);
- buf = gst_buffer_new_and_alloc (size);
+ buf = gst_buffer_new_allocate (NULL, size, 0);
GST_BUFFER_OFFSET (buf) = offset;
- data = GST_BUFFER_DATA (buf);
+ data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
cancel = src->cancellable;
@@ -556,7 +540,7 @@ gst_split_file_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
if (read < to_read) {
if (src->cur_part == src->num_parts - 1) {
/* last file part, stop reading and truncate buffer */
- GST_BUFFER_SIZE (buf) = offset - GST_BUFFER_OFFSET (buf);
+ gst_buffer_set_size (buf, offset - GST_BUFFER_OFFSET (buf));
break;
} else {
goto file_part_changed;
@@ -569,8 +553,11 @@ gst_split_file_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
GST_BUFFER_OFFSET_END (buf) = offset;
+ gst_buffer_unmap (buf, data, size);
+
*buffer = buf;
- GST_LOG_OBJECT (src, "read %u bytes into buf %p", GST_BUFFER_SIZE (buf), buf);
+ GST_LOG_OBJECT (src, "read %" G_GSIZE_FORMAT " bytes into buf %p",
+ gst_buffer_get_size (buf), buf);
return GST_FLOW_OK;
/* ERRORS */
diff --git a/gst/multipart/multipartdemux.c b/gst/multipart/multipartdemux.c
index 525143c3a..b4a0de017 100644
--- a/gst/multipart/multipartdemux.c
+++ b/gst/multipart/multipartdemux.c
@@ -75,7 +75,7 @@ enum
};
static GstStaticPadTemplate multipart_demux_src_template_factory =
-GST_STATIC_PAD_TEMPLATE ("src_%d",
+GST_STATIC_PAD_TEMPLATE ("src_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS_ANY);
@@ -113,7 +113,8 @@ static const GstNamesMap gstnames[] = {
};
-static GstFlowReturn gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf);
+static GstFlowReturn gst_multipart_demux_chain (GstPad * pad,
+ GstObject * parent, GstBuffer * buf);
static GstStateChangeReturn gst_multipart_demux_change_state (GstElement *
element, GstStateChange transition);
@@ -126,23 +127,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_static_pad_template (element_class,
- &multipart_demux_sink_template_factory);
- gst_element_class_add_static_pad_template (element_class,
- &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 +175,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 =
@@ -313,7 +307,7 @@ gst_multipart_find_pad_by_mime (GstMultipartDemux * demux, gchar * mime,
GST_DEBUG_OBJECT (demux, "creating pad with mime: %s", mime);
- name = g_strdup_printf ("src_%d", demux->numpads);
+ name = g_strdup_printf ("src_%u", demux->numpads);
pad =
gst_pad_new_from_static_template (&multipart_demux_src_template_factory,
name);
@@ -392,7 +386,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 +394,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 +404,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 +423,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 +435,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 +444,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);
return next - data;
}
@@ -471,15 +464,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);
+
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);
return MULTIPART_DATA_ERROR;
}
+eos:
+ {
+ GST_DEBUG_OBJECT (multipart, "we are EOS");
+ gst_adapter_unmap (multipart->adapter);
+ return MULTIPART_DATA_EOS;
+ }
}
static gint
@@ -495,14 +499,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);
+ /* Don't check if boundary is actually there, but let the header parsing
* bail out if it isn't */
return len;
} else {
@@ -514,7 +520,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,16 +536,18 @@ multipart_find_boundary (GstMultipartDemux * multipart, gint * datalen)
len -= 1;
*datalen = len;
+ gst_adapter_unmap (multipart->adapter);
multipart->scanpos = 0;
return pos - data;
}
}
+ gst_adapter_unmap (multipart->adapter);
multipart->scanpos = pos - data;
return MULTIPART_NEED_MORE_DATA;
}
static GstFlowReturn
-gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf)
+gst_multipart_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstMultipartDemux *multipart;
GstAdapter *adapter;
@@ -547,7 +555,7 @@ gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf)
gint size = 1;
GstFlowReturn res;
- multipart = GST_MULTIPART_DEMUX (gst_pad_get_parent (pad));
+ multipart = GST_MULTIPART_DEMUX (parent);
adapter = multipart->adapter;
res = GST_FLOW_OK;
@@ -591,16 +599,16 @@ 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);
+ tags = gst_tag_list_new (GST_TAG_CONTAINER_FORMAT, "Multipart", NULL);
gst_pad_push_event (srcpad->pad, gst_event_new_tag (tags));
GST_BUFFER_TIMESTAMP (outbuf) = 0;
@@ -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)
@@ -620,8 +626,6 @@ gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf)
}
nodata:
- gst_object_unref (multipart);
-
if (G_UNLIKELY (size == MULTIPART_DATA_ERROR))
return GST_FLOW_ERROR;
if (G_UNLIKELY (size == MULTIPART_DATA_EOS))
diff --git a/gst/multipart/multipartdemux.h b/gst/multipart/multipartdemux.h
index 5d37bc9c8..ed8f4f1a8 100644
--- a/gst/multipart/multipartdemux.h
+++ b/gst/multipart/multipartdemux.h
@@ -68,7 +68,7 @@ struct _GstMultipartDemux
GstPad *sinkpad;
GSList *srcpads;
- gint numpads;
+ guint numpads;
GstAdapter *adapter;
diff --git a/gst/multipart/multipartmux.c b/gst/multipart/multipartmux.c
index 9d3e56a1c..46da9319c 100644
--- a/gst/multipart/multipartmux.c
+++ b/gst/multipart/multipartmux.c
@@ -57,7 +57,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("multipart/x-mixed-replace")
);
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%d",
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS_ANY /* we can take anything, really */
@@ -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);
+ GstObject * parent, 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,44 +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_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &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)
@@ -158,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++) {
@@ -203,20 +171,20 @@ 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;
GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
gchar *name;
- if (templ != gst_element_class_get_pad_template (klass, "sink_%d"))
+ if (templ != gst_element_class_get_pad_template (klass, "sink_%u"))
goto wrong_template;
multipart_mux = GST_MULTIPART_MUX (element);
/* create new pad with the name */
- name = g_strdup_printf ("sink_%02d", multipart_mux->numpads);
+ name = g_strdup_printf ("sink_%u", multipart_mux->numpads);
newpad = gst_pad_new_from_template (templ, name);
g_free (name);
@@ -227,9 +195,10 @@ gst_multipart_mux_request_new_pad (GstElement * element,
multipartpad = (GstMultipartPadData *)
gst_collect_pads_add_pad (multipart_mux->collect, newpad,
- sizeof (GstMultipartPadData));
+ sizeof (GstMultipartPadData), NULL);
/* save a pointer to our data in the pad */
+ multipartpad->pad = newpad;
gst_pad_set_element_private (newpad, multipartpad);
multipart_mux->numpads++;
}
@@ -249,13 +218,11 @@ wrong_template:
/* handle events */
static gboolean
-gst_multipart_mux_handle_src_event (GstPad * pad, GstEvent * event)
+gst_multipart_mux_handle_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
- GstMultipartMux *multipart_mux;
GstEventType type;
- multipart_mux = GST_MULTIPART_MUX (gst_pad_get_parent (pad));
-
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
switch (type) {
@@ -266,9 +233,7 @@ gst_multipart_mux_handle_src_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (multipart_mux);
-
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
}
static const gchar *
@@ -428,6 +393,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");
@@ -458,8 +424,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;
@@ -468,32 +434,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
@@ -514,31 +483,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 */
@@ -588,13 +552,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
diff --git a/gst/multipart/multipartmux.h b/gst/multipart/multipartmux.h
index a52db36ee..d2711ac0e 100644
--- a/gst/multipart/multipartmux.h
+++ b/gst/multipart/multipartmux.h
@@ -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;
diff --git a/gst/replaygain/Makefile.am b/gst/replaygain/Makefile.am
index 90e84fe07..b7e948702 100644
--- a/gst/replaygain/Makefile.am
+++ b/gst/replaygain/Makefile.am
@@ -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
diff --git a/gst/replaygain/gstrganalysis.c b/gst/replaygain/gstrganalysis.c
index 4a3abdb5a..b7c30c6f2 100644
--- a/gst/replaygain/gstrganalysis.c
+++ b/gst/replaygain/gstrganalysis.c
@@ -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,28 +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_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &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;
@@ -274,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);
@@ -397,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);
@@ -407,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;
- /* 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;
+ channels = GST_AUDIO_INFO_CHANNELS (&info);
- 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;
+ if (channels < 1 || channels > 2)
+ goto invalid_format;
- } else if (g_str_equal (name, "audio/x-raw-int")) {
+ 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;
- if (sample_size != sizeof (gint16))
- goto invalid_format;
+ if (channels == 1)
+ filter->analyze = rg_analysis_analyze_mono_float;
+ else
+ filter->analyze = rg_analysis_analyze_stereo_float;
- 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;
@@ -477,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);
@@ -484,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);
@@ -527,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
@@ -646,8 +625,8 @@ gst_rg_analysis_handle_eos (GstRgAnalysis * filter)
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND,
GST_TAG_REFERENCE_LEVEL, filter->reference_level, NULL);
/* This steals our reference to the list: */
- gst_element_found_tags_for_pad (GST_ELEMENT (filter),
- GST_BASE_TRANSFORM_SRC_PAD (GST_BASE_TRANSFORM (filter)), tag_list);
+ gst_pad_push_event (GST_BASE_TRANSFORM_SRC_PAD (GST_BASE_TRANSFORM
+ (filter)), gst_event_new_tag (tag_list));
}
}
@@ -685,7 +664,7 @@ gst_rg_analysis_track_result (GstRgAnalysis * filter, GstTagList ** tag_list)
if (track_success) {
if (*tag_list == NULL)
- *tag_list = gst_tag_list_new ();
+ *tag_list = gst_tag_list_new_empty ();
gst_tag_list_add (*tag_list, GST_TAG_MERGE_APPEND,
GST_TAG_TRACK_PEAK, track_peak, GST_TAG_TRACK_GAIN, track_gain, NULL);
}
@@ -712,7 +691,7 @@ gst_rg_analysis_album_result (GstRgAnalysis * filter, GstTagList ** tag_list)
if (album_success) {
if (*tag_list == NULL)
- *tag_list = gst_tag_list_new ();
+ *tag_list = gst_tag_list_new_empty ();
gst_tag_list_add (*tag_list, GST_TAG_MERGE_APPEND,
GST_TAG_ALBUM_PEAK, album_peak, GST_TAG_ALBUM_GAIN, album_gain, NULL);
}
diff --git a/gst/replaygain/gstrglimiter.c b/gst/replaygain/gstrglimiter.c
index 2fb387b2b..3291f6d9b 100644
--- a/gst/replaygain/gstrglimiter.c
+++ b/gst/replaygain/gstrglimiter.c
@@ -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,28 +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_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &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;
@@ -112,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);
@@ -168,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;
@@ -177,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)
@@ -188,5 +193,7 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
input++;
}
+ gst_buffer_unmap (buf, data, -1);
+
return GST_FLOW_OK;
}
diff --git a/gst/replaygain/gstrgvolume.c b/gst/replaygain/gstrgvolume.c
index d3d105acf..0372ca7df 100644
--- a/gst/replaygain/gstrgvolume.c
+++ b/gst/replaygain/gstrgvolume.c
@@ -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);
@@ -130,7 +124,8 @@ static void gst_rg_volume_dispose (GObject * object);
static GstStateChangeReturn gst_rg_volume_change_state (GstElement * element,
GstStateChange transition);
-static gboolean gst_rg_volume_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rg_volume_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static GstEvent *gst_rg_volume_tag_event (GstRgVolume * self, GstEvent * event);
static void gst_rg_volume_reset (GstRgVolume * self);
@@ -139,23 +134,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_static_pad_template (element_class, &src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
@@ -202,7 +180,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.
*/
@@ -297,10 +275,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;
@@ -453,14 +443,14 @@ gst_rg_volume_change_state (GstElement * element, GstStateChange transition)
/* Event function for the ghost sink pad. */
static gboolean
-gst_rg_volume_sink_event (GstPad * pad, GstEvent * event)
+gst_rg_volume_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstRgVolume *self;
GstPad *volume_sink_pad;
GstEvent *send_event = event;
gboolean res;
- self = GST_RG_VOLUME (gst_pad_get_parent_element (pad));
+ self = GST_RG_VOLUME (parent);
volume_sink_pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));
switch (GST_EVENT_TYPE (event)) {
@@ -490,7 +480,7 @@ gst_rg_volume_sink_event (GstPad * pad, GstEvent * event)
res = TRUE;
gst_object_unref (volume_sink_pad);
- gst_object_unref (self);
+
return res;
}
diff --git a/gst/rtp/Makefile.am b/gst/rtp/Makefile.am
index 5c43cce2d..bfdc5d81b 100644
--- a/gst/rtp/Makefile.am
+++ b/gst/rtp/Makefile.am
@@ -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 \
diff --git a/gst/rtp/README b/gst/rtp/README
index 15a8bc8d5..9eefe062c 100644
--- a/gst/rtp/README
+++ b/gst/rtp/README
@@ -37,11 +37,11 @@ The following fields can or must (*) be specified in the structure:
The ssrc value currently in use. (default = the SSRC of the first RTP
packet)
- clock-base: (uint) [0 - MAXINT]
+ timestamp-offset: (uint) [0 - MAXINT]
The RTP time representing time npt-start. (default = rtptime of first RTP
packet).
- seqnum-base: (uint) [0 - MAXINT]
+ seqnum-offset: (uint) [0 - MAXINT]
The RTP sequence number representing the first rtp packet. When this
parameter is given, all sequence numbers below this seqnum should be
ignored. (default = seqnum of first RTP packet).
diff --git a/gst/rtp/fnv1hash.h b/gst/rtp/fnv1hash.h
index 398323d69..e50a5b975 100644
--- a/gst/rtp/fnv1hash.h
+++ b/gst/rtp/fnv1hash.h
@@ -21,7 +21,7 @@
#define __GST_FNV1_HASH_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
diff --git a/gst/rtp/gstasteriskh263.c b/gst/rtp/gstasteriskh263.c
index dd59c558d..1ef184bad 100644
--- a/gst/rtp/gstasteriskh263.c
+++ b/gst/rtp/gstasteriskh263.c
@@ -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",
@@ -66,29 +66,14 @@ GST_STATIC_PAD_TEMPLATE ("sink",
static void gst_asteriskh263_finalize (GObject * object);
-static GstFlowReturn gst_asteriskh263_chain (GstPad * pad, GstBuffer * buffer);
+static GstFlowReturn gst_asteriskh263_chain (GstPad * pad, GstObject * parent,
+ 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_static_pad_template (element_class,
- &gst_asteriskh263_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +87,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");
@@ -135,13 +129,13 @@ gst_asteriskh263_finalize (GObject * object)
}
static GstFlowReturn
-gst_asteriskh263_chain (GstPad * pad, GstBuffer * buf)
+gst_asteriskh263_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstAsteriskh263 *asteriskh263;
GstBuffer *outbuf;
GstFlowReturn ret;
- asteriskh263 = GST_ASTERISK_H263 (GST_OBJECT_PARENT (pad));
+ asteriskh263 = GST_ASTERISK_H263 (parent);
if (!gst_rtp_buffer_validate (buf))
goto bad_packet;
@@ -153,12 +147,18 @@ gst_asteriskh263_chain (GstPad * pad, GstBuffer * buf)
guint32 timestamp;
guint32 samples;
guint16 asterisk_len;
+ GstRTPBuffer rtp = { NULL };
+ 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 +172,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);
diff --git a/gst/rtp/gstrtp.c b/gst/rtp/gstrtp.c
index 721cee3c8..7de6da361 100644
--- a/gst/rtp/gstrtp.c
+++ b/gst/rtp/gstrtp.c
@@ -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;
diff --git a/gst/rtp/gstrtpL16depay.c b/gst/rtp/gstrtpL16depay.c
index f7aef885c..ca9f3c05d 100644
--- a/gst/rtp/gstrtpL16depay.c
+++ b/gst/rtp/gstrtpL16depay.c
@@ -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,47 +64,42 @@ 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_RTP_BASE_DEPAYLOAD);
-static gboolean gst_rtp_L16_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_L16_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_L16_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_L16_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
static void
-gst_rtp_L16_depay_base_init (gpointer klass)
+gst_rtp_L16_depay_class_init (GstRtpL16DepayClass * klass)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_L16_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_L16_depay_sink_template);
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- 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>");
-}
+ gstrtpbasedepayload_class->set_caps = gst_rtp_L16_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_L16_depay_process;
-static void
-gst_rtp_L16_depay_class_init (GstRtpL16DepayClass * klass)
-{
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ 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));
- gstbasertpdepayload_class->set_caps = gst_rtp_L16_depay_setcaps;
- gstbasertpdepayload_class->process = gst_rtp_L16_depay_process;
+ 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 */
}
@@ -129,7 +121,7 @@ gst_rtp_L16_depay_parse_int (GstStructure * structure, const gchar * field,
}
static gboolean
-gst_rtp_L16_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_L16_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstRtpL16Depay *rtpL16depay;
@@ -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 */
@@ -222,30 +211,34 @@ no_clockrate:
}
static GstBuffer *
-gst_rtp_L16_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_L16_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpL16Depay *rtpL16depay;
GstBuffer *outbuf;
gint payload_len;
gboolean marker;
+ GstRTPBuffer rtp = { NULL };
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;
}
}
diff --git a/gst/rtp/gstrtpL16depay.h b/gst/rtp/gstrtpL16depay.h
index a260d45d3..0fd950643 100644
--- a/gst/rtp/gstrtpL16depay.h
+++ b/gst/rtp/gstrtpL16depay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_L16_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -43,7 +43,7 @@ typedef struct _GstRtpL16DepayClass GstRtpL16DepayClass;
/* Definition of structure storing data for this element. */
struct _GstRtpL16Depay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
guint rate;
guint channels;
@@ -52,7 +52,7 @@ struct _GstRtpL16Depay
/* Standard definition defining a class for this element. */
struct _GstRtpL16DepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_L16_depay_get_type (void);
diff --git a/gst/rtp/gstrtpL16pay.c b/gst/rtp/gstrtpL16pay.c
index b5dc20ed3..cf5a647af 100644
--- a/gst/rtp/gstrtpL16pay.c
+++ b/gst/rtp/gstrtpL16pay.c
@@ -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 ]")
);
@@ -67,57 +64,53 @@ static GstStaticPadTemplate gst_rtp_L16_pay_src_template =
"clock-rate = (int) 44100")
);
-static gboolean gst_rtp_L16_pay_setcaps (GstBaseRTPPayload * basepayload,
+static gboolean gst_rtp_L16_pay_setcaps (GstRTPBasePayload * basepayload,
GstCaps * caps);
-static GstCaps *gst_rtp_L16_pay_getcaps (GstBaseRTPPayload * rtppayload,
- GstPad * pad);
+static GstCaps *gst_rtp_L16_pay_getcaps (GstRTPBasePayload * rtppayload,
+ GstPad * pad, GstCaps * filter);
-GST_BOILERPLATE (GstRtpL16Pay, gst_rtp_L16_pay, GstBaseRTPAudioPayload,
- GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
+#define gst_rtp_L16_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpL16Pay, gst_rtp_L16_pay, GST_TYPE_RTP_BASE_AUDIO_PAYLOAD);
static void
-gst_rtp_L16_pay_base_init (gpointer klass)
+gst_rtp_L16_pay_class_init (GstRtpL16PayClass * klass)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_L16_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_L16_pay_sink_template);
+ gstrtpbasepayload_class->set_caps = gst_rtp_L16_pay_setcaps;
+ gstrtpbasepayload_class->get_caps = gst_rtp_L16_pay_getcaps;
- gst_element_class_set_details_simple (element_class, "RTP audio payloader",
+ 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>");
-}
-
-static void
-gst_rtp_L16_pay_class_init (GstRtpL16PayClass * klass)
-{
- GstBaseRTPPayloadClass *gstbasertppayload_class;
-
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
-
- gstbasertppayload_class->set_caps = gst_rtp_L16_pay_setcaps;
- gstbasertppayload_class->get_caps = gst_rtp_L16_pay_getcaps;
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;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtpL16pay);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpL16pay);
- /* tell basertpaudiopayload that this is a sample based codec */
- gst_base_rtp_audio_payload_set_sample_based (basertpaudiopayload);
+ /* tell rtpbaseaudiopayload that this is a sample based codec */
+ gst_rtp_base_audio_payload_set_sample_based (rtpbaseaudiopayload);
}
static gboolean
-gst_rtp_L16_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
+gst_rtp_L16_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
{
GstRtpL16Pay *rtpL16pay;
GstStructure *structure;
@@ -126,9 +119,9 @@ gst_rtp_L16_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
gchar *params;
GstAudioChannelPosition *pos;
const GstRTPChannelOrder *order;
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (basepayload);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (basepayload);
rtpL16pay = GST_RTP_L16_PAY (basepayload);
structure = gst_caps_get_structure (caps, 0);
@@ -147,7 +140,7 @@ gst_rtp_L16_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
else
order = NULL;
- gst_basertppayload_set_options (basepayload, "audio", TRUE, "L16", rate);
+ gst_rtp_base_payload_set_options (basepayload, "audio", TRUE, "L16", rate);
params = g_strdup_printf ("%d", channels);
if (!order && channels > 2) {
@@ -156,11 +149,11 @@ gst_rtp_L16_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
}
if (order && order->name) {
- res = gst_basertppayload_set_outcaps (basepayload,
+ res = gst_rtp_base_payload_set_outcaps (basepayload,
"encoding-params", G_TYPE_STRING, params, "channels", G_TYPE_INT,
channels, "channel-order", G_TYPE_STRING, order->name, NULL);
} else {
- res = gst_basertppayload_set_outcaps (basepayload,
+ res = gst_rtp_base_payload_set_outcaps (basepayload,
"encoding-params", G_TYPE_STRING, params, "channels", G_TYPE_INT,
channels, NULL);
}
@@ -172,7 +165,7 @@ gst_rtp_L16_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
rtpL16pay->channels = channels;
/* octet-per-sample is 2 * channels for L16 */
- gst_base_rtp_audio_payload_set_sample_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_sample_options (rtpbaseaudiopayload,
2 * rtpL16pay->channels);
return res;
@@ -191,7 +184,8 @@ no_channels:
}
static GstCaps *
-gst_rtp_L16_pay_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad)
+gst_rtp_L16_pay_getcaps (GstRTPBasePayload * 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;
}
diff --git a/gst/rtp/gstrtpL16pay.h b/gst/rtp/gstrtpL16pay.h
index d2755db31..b24138e0f 100644
--- a/gst/rtp/gstrtpL16pay.h
+++ b/gst/rtp/gstrtpL16pay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_L16_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpaudiopayload.h>
+#include <gst/rtp/gstrtpbaseaudiopayload.h>
G_BEGIN_DECLS
@@ -41,7 +41,7 @@ typedef struct _GstRtpL16PayClass GstRtpL16PayClass;
struct _GstRtpL16Pay
{
- GstBaseRTPAudioPayload payload;
+ GstRTPBaseAudioPayload payload;
gint rate;
gint channels;
@@ -49,7 +49,7 @@ struct _GstRtpL16Pay
struct _GstRtpL16PayClass
{
- GstBaseRTPAudioPayloadClass parent_class;
+ GstRTPBaseAudioPayloadClass parent_class;
};
GType gst_rtp_L16_pay_get_type (void);
diff --git a/gst/rtp/gstrtpac3depay.c b/gst/rtp/gstrtpac3depay.c
index 650090ec9..f99853176 100644
--- a/gst/rtp/gstrtpac3depay.c
+++ b/gst/rtp/gstrtpac3depay.c
@@ -47,53 +47,47 @@ 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_RTP_BASE_DEPAYLOAD);
-static gboolean gst_rtp_ac3_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_ac3_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_ac3_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_ac3_depay_process (GstRTPBaseDepayload * 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;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_ac3_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_ac3_depay_sink_template);
+ 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 (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;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_ac3_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_ac3_depay_process;
GST_DEBUG_CATEGORY_INIT (rtpac3depay_debug, "rtpac3depay", 0,
"AC3 Audio RTP Depayloader");
}
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
-gst_rtp_ac3_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_ac3_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
gint clock_rate;
@@ -106,7 +100,7 @@ gst_rtp_ac3_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
clock_rate = 90000; /* default */
depayload->clock_rate = clock_rate;
- srccaps = gst_caps_new_simple ("audio/ac3", NULL);
+ srccaps = gst_caps_new_empty_simple ("audio/ac3");
res = gst_pad_set_caps (depayload->srcpad, srccaps);
gst_caps_unref (srccaps);
@@ -161,52 +155,53 @@ static const struct frmsize_s frmsizecod_tbl[] = {
};
static GstBuffer *
-gst_rtp_ac3_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_ac3_depay_process (GstRTPBaseDepayload * 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 %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (outbuf));
- return NULL;
+ return outbuf;
/* ERRORS */
empty_packet:
{
GST_ELEMENT_WARNING (rtpac3depay, STREAM, DECODE,
("Empty Payload."), (NULL));
+ gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
diff --git a/gst/rtp/gstrtpac3depay.h b/gst/rtp/gstrtpac3depay.h
index f0929e502..15d0779cb 100644
--- a/gst/rtp/gstrtpac3depay.h
+++ b/gst/rtp/gstrtpac3depay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_AC3_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -41,12 +41,12 @@ typedef struct _GstRtpAC3DepayClass GstRtpAC3DepayClass;
struct _GstRtpAC3Depay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
};
struct _GstRtpAC3DepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_ac3_depay_get_type (void);
diff --git a/gst/rtp/gstrtpac3pay.c b/gst/rtp/gstrtpac3pay.c
index 27d4fffeb..37c8631ea 100644
--- a/gst/rtp/gstrtpac3pay.c
+++ b/gst/rtp/gstrtpac3pay.c
@@ -53,56 +53,52 @@ static void gst_rtp_ac3_pay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_ac3_pay_change_state (GstElement * element,
GstStateChange transition);
-static gboolean gst_rtp_ac3_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_ac3_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static gboolean gst_rtp_ac3_pay_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_ac3_pay_sink_event (GstRTPBasePayload * payload,
+ GstEvent * event);
static GstFlowReturn gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay);
-static GstFlowReturn gst_rtp_ac3_pay_handle_buffer (GstBaseRTPPayload * payload,
+static GstFlowReturn gst_rtp_ac3_pay_handle_buffer (GstRTPBasePayload * 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_static_pad_template (element_class,
- &gst_rtp_ac3_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_ac3_pay_class_init (GstRtpAC3PayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_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;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->finalize = gst_rtp_ac3_pay_finalize;
gstelement_class->change_state = gst_rtp_ac3_pay_change_state;
- 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_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_DEBUG_CATEGORY_INIT (rtpac3pay_debug, "rtpac3pay", 0,
- "AC3 Audio RTP Depayloader");
+ 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>");
+
+ gstrtpbasepayload_class->set_caps = gst_rtp_ac3_pay_setcaps;
+ gstrtpbasepayload_class->sink_event = gst_rtp_ac3_pay_sink_event;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_ac3_pay_handle_buffer;
}
static void
-gst_rtp_ac3_pay_init (GstRtpAC3Pay * rtpac3pay, GstRtpAC3PayClass * klass)
+gst_rtp_ac3_pay_init (GstRtpAC3Pay * rtpac3pay)
{
rtpac3pay->adapter = gst_adapter_new ();
}
@@ -129,7 +125,7 @@ gst_rtp_ac3_pay_reset (GstRtpAC3Pay * pay)
}
static gboolean
-gst_rtp_ac3_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_ac3_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
gboolean res;
gint rate;
@@ -140,18 +136,19 @@ gst_rtp_ac3_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
if (!gst_structure_get_int (structure, "rate", &rate))
rate = 90000; /* default */
- gst_basertppayload_set_options (payload, "audio", TRUE, "AC3", rate);
- res = gst_basertppayload_set_outcaps (payload, NULL);
+ gst_rtp_base_payload_set_options (payload, "audio", TRUE, "AC3", rate);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
return res;
}
static gboolean
-gst_rtp_ac3_pay_handle_event (GstPad * pad, GstEvent * event)
+gst_rtp_ac3_pay_sink_event (GstRTPBasePayload * 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,9 @@ gst_rtp_ac3_pay_handle_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (rtpac3pay);
+ res = GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->sink_event (payload, event);
- /* FALSE to let the parent handle the event as well */
- return FALSE;
+ return res;
}
struct frmsize_s
@@ -238,7 +234,7 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay)
/* number of frames */
NF = rtpac3pay->NF;
- mtu = GST_BASE_RTP_PAYLOAD_MTU (rtpac3pay);
+ mtu = GST_RTP_BASE_PAYLOAD_MTU (rtpac3pay);
GST_LOG_OBJECT (rtpac3pay, "flushing %u bytes", avail);
@@ -247,6 +243,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 +291,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,32 +303,32 @@ 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;
- ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpac3pay), outbuf);
+ ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtpac3pay), outbuf);
}
return ret;
}
static GstFlowReturn
-gst_rtp_ac3_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_ac3_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
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);
@@ -369,11 +367,13 @@ gst_rtp_ac3_pay_handle_buffer (GstBaseRTPPayload * basepayload,
break;
NF++;
- GST_DEBUG_OBJECT (rtpac3pay, "found frame %u of size %u", NF, frame_size);
+ GST_DEBUG_OBJECT (rtpac3pay, "found frame %" G_GSIZE_FORMAT " of size %u",
+ NF, frame_size);
p += frame_size;
left -= frame_size;
}
+ gst_buffer_unmap (buffer, data, size);
if (NF == 0)
goto no_frames;
@@ -385,7 +385,7 @@ gst_rtp_ac3_pay_handle_buffer (GstBaseRTPPayload * basepayload,
/* if this buffer is going to overflow the packet, flush what we
* have. */
- if (gst_basertppayload_is_filled (basepayload,
+ if (gst_rtp_base_payload_is_filled (basepayload,
packet_len, rtpac3pay->duration + duration)) {
ret = gst_rtp_ac3_pay_flush (rtpac3pay);
avail = 0;
diff --git a/gst/rtp/gstrtpac3pay.h b/gst/rtp/gstrtpac3pay.h
index 2ca9d997d..f856a068f 100644
--- a/gst/rtp/gstrtpac3pay.h
+++ b/gst/rtp/gstrtpac3pay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_AC3_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpAC3PayClass GstRtpAC3PayClass;
struct _GstRtpAC3Pay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
GstAdapter *adapter;
GstClockTime first_ts;
@@ -52,7 +52,7 @@ struct _GstRtpAC3Pay
struct _GstRtpAC3PayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_ac3_pay_get_type (void);
diff --git a/gst/rtp/gstrtpamrdepay.c b/gst/rtp/gstrtpamrdepay.c
index fa3875902..20c6aaff1 100644
--- a/gst/rtp/gstrtpamrdepay.c
+++ b/gst/rtp/gstrtpamrdepay.c
@@ -106,57 +106,52 @@ static GstStaticPadTemplate gst_rtp_amr_depay_src_template =
"audio/AMR-WB, " "channels = (int) 1," "rate = (int) 16000")
);
-static gboolean gst_rtp_amr_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_amr_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_amr_depay_process (GstRTPBaseDepayload * 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_RTP_BASE_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;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_amr_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_amr_depay_sink_template);
+ 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 (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;
+ gstrtpbasedepayload_class->process = gst_rtp_amr_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_amr_depay_setcaps;
GST_DEBUG_CATEGORY_INIT (rtpamrdepay_debug, "rtpamrdepay", 0,
"AMR/AMR-WB RTP Depayloader");
}
static void
-gst_rtp_amr_depay_init (GstRtpAMRDepay * rtpamrdepay,
- GstRtpAMRDepayClass * klass)
+gst_rtp_amr_depay_init (GstRtpAMRDepay * rtpamrdepay)
{
- GstBaseRTPDepayload *depayload;
+ GstRTPBaseDepayload *depayload;
- depayload = GST_BASE_RTP_DEPAYLOAD (rtpamrdepay);
+ depayload = GST_RTP_BASE_DEPAYLOAD (rtpamrdepay);
- gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
+ gst_pad_use_fixed_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload));
}
static gboolean
-gst_rtp_amr_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_amr_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstCaps *srccaps;
@@ -246,7 +241,7 @@ gst_rtp_amr_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
srccaps = gst_caps_new_simple (type,
"channels", G_TYPE_INT, rtpamrdepay->channels,
"rate", G_TYPE_INT, clock_rate, NULL);
- res = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ res = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return res;
@@ -271,12 +266,15 @@ static const gint wb_frame_size[16] = {
};
static GstBuffer *
-gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpAMRDepay *rtpamrdepay;
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_DEBUG_OBJECT (depayload, "pushing buffer of size %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (outbuf));
}
return outbuf;
diff --git a/gst/rtp/gstrtpamrdepay.h b/gst/rtp/gstrtpamrdepay.h
index 92f001a12..491c007ea 100644
--- a/gst/rtp/gstrtpamrdepay.h
+++ b/gst/rtp/gstrtpamrdepay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_AMR_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -47,7 +47,7 @@ typedef enum {
struct _GstRtpAMRDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
GstRtpAMRDepayMode mode;
@@ -65,7 +65,7 @@ struct _GstRtpAMRDepay
struct _GstRtpAMRDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_amr_depay_get_type (void);
diff --git a/gst/rtp/gstrtpamrpay.c b/gst/rtp/gstrtpamrpay.c
index ea5ada6a9..e7fa1e5ac 100644
--- a/gst/rtp/gstrtpamrpay.c
+++ b/gst/rtp/gstrtpamrpay.c
@@ -85,55 +85,48 @@ static GstStaticPadTemplate gst_rtp_amr_pay_src_template =
"maxptime = (int) [ 20, MAX ], " "ptime = (int) [ 20, MAX ]")
);
-static gboolean gst_rtp_amr_pay_setcaps (GstBaseRTPPayload * basepayload,
+static gboolean gst_rtp_amr_pay_setcaps (GstRTPBasePayload * basepayload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_amr_pay_handle_buffer (GstBaseRTPPayload * pad,
+static GstFlowReturn gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * pad,
GstBuffer * buffer);
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);
-
-static void
-gst_rtp_amr_pay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_amr_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_amr_pay_sink_template);
-
- gst_element_class_set_details_simple (element_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>");
-}
+#define gst_rtp_amr_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpAMRPay, gst_rtp_amr_pay, GST_TYPE_RTP_BASE_PAYLOAD);
static void
gst_rtp_amr_pay_class_init (GstRtpAMRPayClass * klass)
{
- GstBaseRTPPayloadClass *gstbasertppayload_class;
GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
+
gstelement_class->change_state = gst_rtp_amr_pay_change_state;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_amr_pay_sink_template));
+
+ 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>");
- gstbasertppayload_class->set_caps = gst_rtp_amr_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_amr_pay_handle_buffer;
+ gstrtpbasepayload_class->set_caps = gst_rtp_amr_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_amr_pay_handle_buffer;
GST_DEBUG_CATEGORY_INIT (rtpamrpay_debug, "rtpamrpay", 0,
"AMR/AMR-WB RTP Payloader");
}
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
@@ -145,7 +138,7 @@ gst_rtp_amr_pay_reset (GstRtpAMRPay * pay)
}
static gboolean
-gst_rtp_amr_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
+gst_rtp_amr_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
{
GstRtpAMRPay *rtpamrpay;
gboolean res;
@@ -167,12 +160,12 @@ gst_rtp_amr_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
goto wrong_type;
if (rtpamrpay->mode == GST_RTP_AMR_P_MODE_NB)
- gst_basertppayload_set_options (basepayload, "audio", TRUE, "AMR", 8000);
+ gst_rtp_base_payload_set_options (basepayload, "audio", TRUE, "AMR", 8000);
else
- gst_basertppayload_set_options (basepayload, "audio", TRUE, "AMR-WB",
+ gst_rtp_base_payload_set_options (basepayload, "audio", TRUE, "AMR-WB",
16000);
- res = gst_basertppayload_set_outcaps (basepayload,
+ res = gst_rtp_base_payload_set_outcaps (basepayload,
"encoding-params", G_TYPE_STRING, "1", "octet-align", G_TYPE_STRING, "1",
/* don't set the defaults
*
@@ -228,26 +221,28 @@ static const gint wb_frame_size[16] = {
};
static GstFlowReturn
-gst_rtp_amr_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
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);
+ mtu = GST_RTP_BASE_PAYLOAD_MTU (rtpamrpay);
+
+ data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
- size = GST_BUFFER_SIZE (buffer);
- data = GST_BUFFER_DATA (buffer);
timestamp = GST_BUFFER_TIMESTAMP (buffer);
duration = GST_BUFFER_DURATION (buffer);
@@ -257,7 +252,7 @@ gst_rtp_amr_pay_handle_buffer (GstBaseRTPPayload * basepayload,
else
frame_size = wb_frame_size;
- GST_DEBUG_OBJECT (basepayload, "got %d bytes", size);
+ GST_DEBUG_OBJECT (basepayload, "got %" G_GSIZE_FORMAT " bytes", size);
/* FIXME, only
* octet aligned, no interleaving, single channel, no CRC,
@@ -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,27 +353,30 @@ 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);
- ret = gst_basertppayload_push (basepayload, outbuf);
+ gst_rtp_buffer_unmap (&rtp);
+
+ ret = gst_rtp_base_payload_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;
diff --git a/gst/rtp/gstrtpamrpay.h b/gst/rtp/gstrtpamrpay.h
index 36e32fc17..b57082370 100644
--- a/gst/rtp/gstrtpamrpay.h
+++ b/gst/rtp/gstrtpamrpay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_AMR_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -48,7 +48,7 @@ typedef enum {
struct _GstRtpAMRPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
GstRtpAMRPayMode mode;
GstClockTime first_ts;
@@ -58,7 +58,7 @@ struct _GstRtpAMRPay
struct _GstRtpAMRPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_amr_pay_get_type (void);
diff --git a/gst/rtp/gstrtpbvdepay.c b/gst/rtp/gstrtpbvdepay.c
index c1909828e..4f4def412 100644
--- a/gst/rtp/gstrtpbvdepay.c
+++ b/gst/rtp/gstrtpbvdepay.c
@@ -49,48 +49,45 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-bv, " "mode = (int) { 16, 32 }")
);
-static GstBuffer *gst_rtp_bv_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_bv_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_bv_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_bv_depay_setcaps (GstRTPBaseDepayload * 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_RTP_BASE_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;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
+
+ 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_bv_depay_sink_template));
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_bv_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
+ gstrtpbasedepayload_class->process = gst_rtp_bv_depay_process;
+ gstrtpbasedepayload_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;
}
static gboolean
-gst_rtp_bv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_bv_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstRTPBVDepay *rtpbvdepay = GST_RTP_BV_DEPAY (depayload);
GstCaps *srccaps;
@@ -124,7 +121,7 @@ gst_rtp_bv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
srccaps = gst_caps_new_simple ("audio/x-bv",
"mode", G_TYPE_INT, rtpbvdepay->mode, NULL);
- ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
GST_DEBUG ("set caps on source: %" GST_PTR_FORMAT " (ret=%d)", srccaps, ret);
gst_caps_unref (srccaps);
@@ -152,18 +149,22 @@ wrong_rate:
}
static GstBuffer *
-gst_rtp_bv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_bv_depay_process (GstRTPBaseDepayload * 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_DEBUG ("process : got %" G_GSIZE_FORMAT " bytes, mark %d ts %u seqn %d",
+ 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 */
diff --git a/gst/rtp/gstrtpbvdepay.h b/gst/rtp/gstrtpbvdepay.h
index 9cb950590..d63066ac3 100644
--- a/gst/rtp/gstrtpbvdepay.h
+++ b/gst/rtp/gstrtpbvdepay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_BV_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -41,14 +41,14 @@ typedef struct _GstRTPBVDepayClass GstRTPBVDepayClass;
struct _GstRTPBVDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
gint mode;
};
struct _GstRTPBVDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_bv_depay_get_type (void);
diff --git a/gst/rtp/gstrtpbvpay.c b/gst/rtp/gstrtpbvpay.c
index 80eae8e8e..5c07d6181 100644
--- a/gst/rtp/gstrtpbvpay.c
+++ b/gst/rtp/gstrtpbvpay.c
@@ -53,67 +53,64 @@ static GstStaticPadTemplate gst_rtp_bv_pay_src_template =
);
-static GstCaps *gst_rtp_bv_pay_sink_getcaps (GstBaseRTPPayload * payload,
- GstPad * pad);
-static gboolean gst_rtp_bv_pay_sink_setcaps (GstBaseRTPPayload * payload,
+static GstCaps *gst_rtp_bv_pay_sink_getcaps (GstRTPBasePayload * payload,
+ GstPad * pad, GstCaps * filter);
+static gboolean gst_rtp_bv_pay_sink_setcaps (GstRTPBasePayload * 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_RTP_BASE_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;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_bv_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_bv_pay_src_template);
- gst_element_class_set_details_simple (element_class, "RTP BV Payloader",
- "Codec/Payloader/Network/RTP",
- "Packetize BroadcomVoice audio streams into RTP packets (RFC 4298)",
- "Wim Taymans <wim.taymans@collabora.co.uk>");
-}
+ GST_DEBUG_CATEGORY_INIT (rtpbvpay_debug, "rtpbvpay", 0,
+ "BroadcomVoice audio RTP payloader");
-static void
-gst_rtp_bv_pay_class_init (GstRTPBVPayClass * klass)
-{
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_bv_pay_src_template));
- gstbasertppayload_class->set_caps = gst_rtp_bv_pay_sink_setcaps;
- gstbasertppayload_class->get_caps = gst_rtp_bv_pay_sink_getcaps;
+ 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>");
- GST_DEBUG_CATEGORY_INIT (rtpbvpay_debug, "rtpbvpay", 0,
- "BroadcomVoice audio RTP payloader");
+ gstrtpbasepayload_class->set_caps = gst_rtp_bv_pay_sink_setcaps;
+ gstrtpbasepayload_class->get_caps = gst_rtp_bv_pay_sink_getcaps;
}
static void
-gst_rtp_bv_pay_init (GstRTPBVPay * rtpbvpay, GstRTPBVPayClass * klass)
+gst_rtp_bv_pay_init (GstRTPBVPay * rtpbvpay)
{
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtpbvpay);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpbvpay);
rtpbvpay->mode = -1;
- /* tell basertpaudiopayload that this is a frame based codec */
- gst_base_rtp_audio_payload_set_frame_based (basertpaudiopayload);
+ /* tell rtpbaseaudiopayload that this is a frame based codec */
+ gst_rtp_base_audio_payload_set_frame_based (rtpbaseaudiopayload);
}
static gboolean
-gst_rtp_bv_pay_sink_setcaps (GstBaseRTPPayload * basertppayload, GstCaps * caps)
+gst_rtp_bv_pay_sink_setcaps (GstRTPBasePayload * rtpbasepayload, GstCaps * caps)
{
GstRTPBVPay *rtpbvpay;
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
gint mode;
GstStructure *structure;
const char *payload_name;
- rtpbvpay = GST_RTP_BV_PAY (basertppayload);
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (basertppayload);
+ rtpbvpay = GST_RTP_BV_PAY (rtpbasepayload);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpbasepayload);
structure = gst_caps_get_structure (caps, 0);
@@ -128,17 +125,17 @@ gst_rtp_bv_pay_sink_setcaps (GstBaseRTPPayload * basertppayload, GstCaps * caps)
goto wrong_mode;
if (mode == 16) {
- gst_basertppayload_set_options (basertppayload, "audio", TRUE, "BV16",
+ gst_rtp_base_payload_set_options (rtpbasepayload, "audio", TRUE, "BV16",
8000);
- basertppayload->clock_rate = 8000;
+ rtpbasepayload->clock_rate = 8000;
} else {
- gst_basertppayload_set_options (basertppayload, "audio", TRUE, "BV32",
+ gst_rtp_base_payload_set_options (rtpbasepayload, "audio", TRUE, "BV32",
16000);
- basertppayload->clock_rate = 16000;
+ rtpbasepayload->clock_rate = 16000;
}
/* set options for this frame based audio codec */
- gst_base_rtp_audio_payload_set_frame_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_frame_options (rtpbaseaudiopayload,
mode, mode == 16 ? 10 : 20);
if (mode != rtpbvpay->mode && rtpbvpay->mode != -1)
@@ -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 (GstRTPBasePayload * rtppayload, GstPad * pad,
+ GstCaps * filter)
{
GstCaps *otherpadcaps;
GstCaps *caps;
diff --git a/gst/rtp/gstrtpbvpay.h b/gst/rtp/gstrtpbvpay.h
index 58a6108de..1976693d2 100644
--- a/gst/rtp/gstrtpbvpay.h
+++ b/gst/rtp/gstrtpbvpay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_BV_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpaudiopayload.h>
+#include <gst/rtp/gstrtpbaseaudiopayload.h>
G_BEGIN_DECLS
@@ -41,14 +41,14 @@ typedef struct _GstRTPBVPayClass GstRTPBVPayClass;
struct _GstRTPBVPay
{
- GstBaseRTPAudioPayload audiopayload;
+ GstRTPBaseAudioPayload audiopayload;
gint mode;
};
struct _GstRTPBVPayClass
{
- GstBaseRTPAudioPayloadClass parent_class;
+ GstRTPBaseAudioPayloadClass parent_class;
};
GType gst_rtp_bv_pay_get_type (void);
diff --git a/gst/rtp/gstrtpceltdepay.c b/gst/rtp/gstrtpceltdepay.c
index b583efd15..2a164f276 100644
--- a/gst/rtp/gstrtpceltdepay.c
+++ b/gst/rtp/gstrtpceltdepay.c
@@ -65,46 +65,43 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-celt")
);
-static GstBuffer *gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_celt_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_celt_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_celt_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-GST_BOILERPLATE (GstRtpCELTDepay, gst_rtp_celt_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_celt_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpCELTDepay, gst_rtp_celt_depay,
+ GST_TYPE_RTP_BASE_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_static_pad_template (element_class,
- &gst_rtp_celt_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_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;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) 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));
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ 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;
+ gstrtpbasedepayload_class->process = gst_rtp_celt_depay_process;
+ gstrtpbasedepayload_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)
{
}
@@ -116,13 +113,14 @@ static const gchar gst_rtp_celt_comment[] =
"\045\0\0\0Depayloaded with GStreamer celtdepay\0\0\0\0";
static gboolean
-gst_rtp_celt_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_celt_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
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,40 +149,38 @@ 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 */
-
- srccaps = gst_caps_new_simple ("audio/x-celt", NULL);
+ 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_empty_simple ("audio/x-celt");
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);
+ gst_rtp_base_depayload_push (GST_RTP_BASE_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);
+ gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpceltdepay), buf);
return res;
@@ -197,7 +193,7 @@ no_clockrate:
}
static GstBuffer *
-gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_celt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstBuffer *outbuf = NULL;
guint8 *payload;
@@ -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_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_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+ GST_LOG_OBJECT (depayload,
+ "got %" G_GSIZE_FORMAT " bytes, mark %d ts %u seqn %d",
+ 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) {
@@ -262,8 +261,10 @@ gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
- gst_base_rtp_depayload_push (depayload, outbuf);
+ gst_rtp_base_depayload_push (depayload, outbuf);
}
+ gst_rtp_buffer_unmap (&rtp);
+
return NULL;
}
diff --git a/gst/rtp/gstrtpceltdepay.h b/gst/rtp/gstrtpceltdepay.h
index cfdc220d5..0905c681d 100644
--- a/gst/rtp/gstrtpceltdepay.h
+++ b/gst/rtp/gstrtpceltdepay.h
@@ -16,7 +16,7 @@
#define __GST_RTP_CELT_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -36,13 +36,13 @@ typedef struct _GstRtpCELTDepayClass GstRtpCELTDepayClass;
struct _GstRtpCELTDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
gint frame_size;
};
struct _GstRtpCELTDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_celt_depay_get_type (void);
diff --git a/gst/rtp/gstrtpceltpay.c b/gst/rtp/gstrtpceltpay.c
index c727efcf4..4c64ed381 100644
--- a/gst/rtp/gstrtpceltpay.c
+++ b/gst/rtp/gstrtpceltpay.c
@@ -55,56 +55,51 @@ static void gst_rtp_celt_pay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_celt_pay_change_state (GstElement *
element, GstStateChange transition);
-static gboolean gst_rtp_celt_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_celt_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstCaps *gst_rtp_celt_pay_getcaps (GstBaseRTPPayload * payload,
- GstPad * pad);
-static GstFlowReturn gst_rtp_celt_pay_handle_buffer (GstBaseRTPPayload *
+static GstCaps *gst_rtp_celt_pay_getcaps (GstRTPBasePayload * payload,
+ GstPad * pad, GstCaps * filter);
+static GstFlowReturn gst_rtp_celt_pay_handle_buffer (GstRTPBasePayload *
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_static_pad_template (element_class,
- &gst_rtp_celt_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_celt_pay_class_init (GstRtpCELTPayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
+
+ GST_DEBUG_CATEGORY_INIT (rtpceltpay_debug, "rtpceltpay", 0,
+ "CELT RTP Payloader");
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->finalize = gst_rtp_celt_pay_finalize;
gstelement_class->change_state = gst_rtp_celt_pay_change_state;
- 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;
+ 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>");
+
+ gstrtpbasepayload_class->set_caps = gst_rtp_celt_pay_setcaps;
+ gstrtpbasepayload_class->get_caps = gst_rtp_celt_pay_getcaps;
+ gstrtpbasepayload_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 ();
}
@@ -154,7 +149,7 @@ gst_rtp_celt_pay_add_queued (GstRtpCELTPay * rtpceltpay, GstBuffer * buffer,
}
static gboolean
-gst_rtp_celt_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_celt_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
/* don't configure yet, we wait for the ident packet */
return TRUE;
@@ -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 (GstRTPBasePayload * payload, GstPad * pad,
+ GstCaps * filter)
{
GstCaps *otherpadcaps;
GstCaps *caps;
@@ -206,7 +202,7 @@ gst_rtp_celt_pay_parse_ident (GstRtpCELTPay * rtpceltpay,
{
guint32 version, header_size, rate, nb_channels, frame_size, overlap;
guint32 bytes_per_packet;
- GstBaseRTPPayload *payload;
+ GstRTPBasePayload *payload;
gchar *cstr, *fsstr;
gboolean res;
@@ -253,12 +249,12 @@ gst_rtp_celt_pay_parse_ident (GstRtpCELTPay * rtpceltpay,
GST_DEBUG_OBJECT (rtpceltpay, "overlap %d, bytes_per_packet %d",
overlap, bytes_per_packet);
- payload = GST_BASE_RTP_PAYLOAD (rtpceltpay);
+ payload = GST_RTP_BASE_PAYLOAD (rtpceltpay);
- gst_basertppayload_set_options (payload, "audio", FALSE, "CELT", rate);
+ gst_rtp_base_payload_set_options (payload, "audio", FALSE, "CELT", rate);
cstr = g_strdup_printf ("%d", nb_channels);
fsstr = g_strdup_printf ("%d", frame_size);
- res = gst_basertppayload_set_outcaps (payload, "encoding-params",
+ res = gst_rtp_base_payload_set_outcaps (payload, "encoding-params",
G_TYPE_STRING, cstr, "frame-size", G_TYPE_STRING, fsstr, NULL);
g_free (cstr);
g_free (fsstr);
@@ -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,38 +333,39 @@ 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;
rtpceltpay->sbytes = 0;
rtpceltpay->qduration = 0;
- ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpceltpay), outbuf);
+ ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtpceltpay), outbuf);
return ret;
}
static GstFlowReturn
-gst_rtp_celt_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_celt_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
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,19 +383,20 @@ 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);
GST_LOG_OBJECT (rtpceltpay,
- "got buffer of duration %" GST_TIME_FORMAT ", size %u",
+ "got buffer of duration %" GST_TIME_FORMAT ", size %" G_GSIZE_FORMAT,
GST_TIME_ARGS (duration), size);
/* calculate the size of the size field and the payload */
@@ -415,7 +415,7 @@ gst_rtp_celt_pay_handle_buffer (GstBaseRTPPayload * basepayload,
packet_len = gst_rtp_buffer_calc_packet_len (payload_len, 0, 0);
- if (gst_basertppayload_is_filled (basepayload, packet_len, packet_dur)) {
+ if (gst_rtp_base_payload_is_filled (basepayload, packet_len, packet_dur)) {
/* size or duration would overflow the packet, flush the queued data */
ret = gst_rtp_celt_pay_flush_queued (rtpceltpay);
}
@@ -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/gstrtpceltpay.h b/gst/rtp/gstrtpceltpay.h
index 9213bf800..dcdd0ecc5 100644
--- a/gst/rtp/gstrtpceltpay.h
+++ b/gst/rtp/gstrtpceltpay.h
@@ -17,7 +17,7 @@
#define __GST_RTP_CELT_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
G_BEGIN_DECLS
@@ -37,7 +37,7 @@ typedef struct _GstRtpCELTPayClass GstRtpCELTPayClass;
struct _GstRtpCELTPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
guint64 packet;
@@ -50,7 +50,7 @@ struct _GstRtpCELTPay
struct _GstRtpCELTPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_celt_pay_get_type (void);
diff --git a/gst/rtp/gstrtpdepay.c b/gst/rtp/gstrtpdepay.c
deleted file mode 100644
index 1566f97ac..000000000
--- a/gst/rtp/gstrtpdepay.c
+++ /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_static_pad_template (gstelement_class,
- &gst_rtp_depay_src_rtp_template);
- gst_element_class_add_static_pad_template (gstelement_class,
- &gst_rtp_depay_src_rtcp_template);
- gst_element_class_add_static_pad_template (gstelement_class,
- &gst_rtp_depay_sink_rtp_template);
- gst_element_class_add_static_pad_template (gstelement_class,
- &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
index b2b46835a..000000000
--- a/gst/rtp/gstrtpdepay.h
+++ /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__ */
diff --git a/gst/rtp/gstrtpdvdepay.c b/gst/rtp/gstrtpdvdepay.c
index 4098c395a..03150f7c0 100644
--- a/gst/rtp/gstrtpdvdepay.c
+++ b/gst/rtp/gstrtpdvdepay.c
@@ -75,45 +75,42 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
static GstStateChangeReturn
gst_rtp_dv_depay_change_state (GstElement * element, GstStateChange transition);
-static GstBuffer *gst_rtp_dv_depay_process (GstBaseRTPDepayload * base,
+static GstBuffer *gst_rtp_dv_depay_process (GstRTPBaseDepayload * base,
GstBuffer * in);
-static gboolean gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_dv_depay_setcaps (GstRTPBaseDepayload * 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_RTP_BASE_DEPAYLOAD);
- static void gst_rtp_dv_depay_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &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)
{
GstElementClass *gstelement_class = (GstElementClass *) klass;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class =
- (GstBaseRTPDepayloadClass *) klass;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class =
+ (GstRTPBaseDepayloadClass *) 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);
- gstbasertpdepayload_class->process =
+ 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>");
+
+ gstrtpbasedepayload_class->process =
GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_process);
- gstbasertpdepayload_class->set_caps =
+ gstrtpbasedepayload_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
@@ -122,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)
{
}
@@ -162,7 +159,7 @@ parse_encode (GstRTPDVDepay * rtpdvdepay, const gchar * encode)
}
static gboolean
-gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_dv_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstRTPDVDepay *rtpdvdepay;
@@ -170,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);
@@ -214,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,
@@ -290,7 +291,7 @@ calculate_difblock_location (guint8 * block)
* NTSC.
*/
static GstBuffer *
-gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in)
+gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstBuffer * in)
{
GstBuffer *out = NULL;
guint8 *payload;
@@ -298,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 */
@@ -317,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) {
@@ -341,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);
diff --git a/gst/rtp/gstrtpdvdepay.h b/gst/rtp/gstrtpdvdepay.h
index ea7618ae3..e3176a254 100644
--- a/gst/rtp/gstrtpdvdepay.h
+++ b/gst/rtp/gstrtpdvdepay.h
@@ -21,7 +21,7 @@
#define __GSTRTPDVDEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -41,7 +41,7 @@ typedef struct _GstRTPDVDepayClass GstRTPDVDepayClass;
struct _GstRTPDVDepay
{
- GstBaseRTPDepayload parent;
+ GstRTPBaseDepayload parent;
GstBuffer *acc;
guint frame_size;
@@ -54,7 +54,7 @@ struct _GstRTPDVDepay
struct _GstRTPDVDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_dv_depay_get_type (void);
diff --git a/gst/rtp/gstrtpdvpay.c b/gst/rtp/gstrtpdvpay.c
index 7231cc61d..44a66299f 100644
--- a/gst/rtp/gstrtpdvpay.c
+++ b/gst/rtp/gstrtpdvpay.c
@@ -65,9 +65,9 @@ GST_STATIC_PAD_TEMPLATE ("src",
)
);
-static gboolean gst_rtp_dv_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_dv_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * payload,
+static GstFlowReturn gst_rtp_dv_pay_handle_buffer (GstRTPBasePayload * payload,
GstBuffer * buffer);
#define GST_TYPE_DV_PAY_MODE (gst_dv_pay_mode_get_type())
@@ -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_static_pad_template (element_class,
- &gst_rtp_dv_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_dv_pay_class_init (GstRTPDVPayClass * klass)
{
GObjectClass *gobject_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
+
+ GST_DEBUG_CATEGORY_INIT (rtpdvpay_debug, "rtpdvpay", 0, "DV RTP Payloader");
gobject_class = (GObjectClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) 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>");
+
+ gstrtpbasepayload_class->set_caps = gst_rtp_dv_pay_setcaps;
+ gstrtpbasepayload_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)
{
}
@@ -173,7 +171,7 @@ gst_dv_pay_get_property (GObject * object,
}
static gboolean
-gst_rtp_dv_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_dv_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
/* We don't do anything here, but we could check if it's a system stream and if
* it's not, default to sending the video only. We will negotiate downstream
@@ -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;
@@ -223,15 +221,15 @@ gst_dv_pay_negotiate (GstRTPDVPay * rtpdvpay, guint8 * data, guint size)
default:
break;
}
- gst_basertppayload_set_options (GST_BASE_RTP_PAYLOAD (rtpdvpay), media, TRUE,
- "DV", 90000);
+ gst_rtp_base_payload_set_options (GST_RTP_BASE_PAYLOAD (rtpdvpay), media,
+ TRUE, "DV", 90000);
if (audio_bundled) {
- res = gst_basertppayload_set_outcaps (GST_BASE_RTP_PAYLOAD (rtpdvpay),
+ res = gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (rtpdvpay),
"encode", G_TYPE_STRING, encode,
"audio", G_TYPE_STRING, "bundled", NULL);
} else {
- res = gst_basertppayload_set_outcaps (GST_BASE_RTP_PAYLOAD (rtpdvpay),
+ res = gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (rtpdvpay),
"encode", G_TYPE_STRING, encode, NULL);
}
return res;
@@ -276,7 +274,7 @@ include_dif (GstRTPDVPay * rtpdvpay, guint8 * data)
/* Get a DV frame, chop it up in pieces, and push the pieces to the RTP layer.
*/
static GstFlowReturn
-gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_dv_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
GstRTPDVPay *rtpdvpay;
@@ -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);
@@ -297,15 +296,18 @@ gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
* Therefore, we round the available room down to the nearest multiple of 80.
*
* The available room is just the packet MTU, minus the RTP header length. */
- max_payload_size = ((GST_BASE_RTP_PAYLOAD_MTU (rtpdvpay) - hdrlen) / 80) * 80;
+ max_payload_size = ((GST_RTP_BASE_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 "
- "payload fragments, at time %" GST_TIME_FORMAT, size, max_payload_size,
+ "DV RTP payloader got buffer of %" G_GSIZE_FORMAT
+ " bytes, splitting in %u byte " "payload fragments, at time %"
+ GST_TIME_FORMAT, size, max_payload_size,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
if (!rtpdvpay->negotiated) {
@@ -324,7 +326,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,20 +352,23 @@ 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. */
- ret = gst_basertppayload_push (basepayload, outbuf);
+ gst_rtp_buffer_unmap (&rtp);
+ ret = gst_rtp_base_payload_push (basepayload, outbuf);
if (ret != GST_FLOW_OK)
break;
outbuf = NULL;
}
}
+ gst_buffer_unmap (buffer, odata, osize);
gst_buffer_unref (buffer);
return ret;
diff --git a/gst/rtp/gstrtpdvpay.h b/gst/rtp/gstrtpdvpay.h
index e691b80a2..887c3bd14 100644
--- a/gst/rtp/gstrtpdvpay.h
+++ b/gst/rtp/gstrtpdvpay.h
@@ -22,7 +22,7 @@
#define __GSTRTPDVPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
G_BEGIN_DECLS
@@ -49,7 +49,7 @@ typedef enum
struct _GstRTPDVPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
gboolean negotiated;
GstDVPayMode mode;
@@ -57,7 +57,7 @@ struct _GstRTPDVPay
struct _GstRTPDVPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_dv_pay_get_type (void);
diff --git a/gst/rtp/gstrtpg722depay.c b/gst/rtp/gstrtpg722depay.c
index 726426b84..b3c66e33f 100644
--- a/gst/rtp/gstrtpg722depay.c
+++ b/gst/rtp/gstrtpg722depay.c
@@ -62,49 +62,44 @@ static GstStaticPadTemplate gst_rtp_g722_depay_sink_template =
)
);
-GST_BOILERPLATE (GstRtpG722Depay, gst_rtp_g722_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_g722_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG722Depay, gst_rtp_g722_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
-static gboolean gst_rtp_g722_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_g722_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_g722_depay_process (GstRTPBaseDepayload * 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;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_g722_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_g722_depay_sink_template);
+ GST_DEBUG_CATEGORY_INIT (rtpg722depay_debug, "rtpg722depay", 0,
+ "G722 RTP Depayloader");
- gst_element_class_set_details_simple (element_class, "RTP audio depayloader",
- "Codec/Depayloader/Network/RTP",
- "Extracts G722 audio from RTP packets",
- "Wim Taymans <wim.taymans@gmail.com>");
-}
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
-static void
-gst_rtp_g722_depay_class_init (GstRtpG722DepayClass * klass)
-{
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
- 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_g722_depay_sink_template));
- gstbasertpdepayload_class->set_caps = gst_rtp_g722_depay_setcaps;
- gstbasertpdepayload_class->process = gst_rtp_g722_depay_process;
+ 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>");
- GST_DEBUG_CATEGORY_INIT (rtpg722depay_debug, "rtpg722depay", 0,
- "G722 RTP Depayloader");
+ gstrtpbasedepayload_class->set_caps = gst_rtp_g722_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_g722_depay_process;
}
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
@@ -124,7 +119,7 @@ gst_rtp_g722_depay_parse_int (GstStructure * structure, const gchar * field,
}
static gboolean
-gst_rtp_g722_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_g722_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstRtpG722Depay *rtpg722depay;
@@ -217,24 +212,28 @@ no_clockrate:
}
static GstBuffer *
-gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_g722_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpG722Depay *rtpg722depay;
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;
}
}
diff --git a/gst/rtp/gstrtpg722depay.h b/gst/rtp/gstrtpg722depay.h
index 2f6b9800e..86e7e9104 100644
--- a/gst/rtp/gstrtpg722depay.h
+++ b/gst/rtp/gstrtpg722depay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_G722_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -43,7 +43,7 @@ typedef struct _GstRtpG722DepayClass GstRtpG722DepayClass;
/* Definition of structure storing data for this element. */
struct _GstRtpG722Depay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
guint rate;
guint channels;
@@ -52,7 +52,7 @@ struct _GstRtpG722Depay
/* Standard definition defining a class for this element. */
struct _GstRtpG722DepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_g722_depay_get_type (void);
diff --git a/gst/rtp/gstrtpg722pay.c b/gst/rtp/gstrtpg722pay.c
index 06958e188..a565f38d0 100644
--- a/gst/rtp/gstrtpg722pay.c
+++ b/gst/rtp/gstrtpg722pay.c
@@ -51,57 +51,54 @@ GST_STATIC_PAD_TEMPLATE ("src",
"clock-rate = (int) 8000")
);
-static gboolean gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload,
+static gboolean gst_rtp_g722_pay_setcaps (GstRTPBasePayload * basepayload,
GstCaps * caps);
-static GstCaps *gst_rtp_g722_pay_getcaps (GstBaseRTPPayload * rtppayload,
- GstPad * pad);
+static GstCaps *gst_rtp_g722_pay_getcaps (GstRTPBasePayload * rtppayload,
+ GstPad * pad, GstCaps * filter);
-GST_BOILERPLATE (GstRtpG722Pay, gst_rtp_g722_pay, GstBaseRTPAudioPayload,
- GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
+#define gst_rtp_g722_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG722Pay, gst_rtp_g722_pay,
+ GST_TYPE_RTP_BASE_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;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
+
+ GST_DEBUG_CATEGORY_INIT (rtpg722pay_debug, "rtpg722pay", 0,
+ "G722 RTP Payloader");
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_g722_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_g722_pay_sink_template);
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
- gst_element_class_set_details_simple (element_class, "RTP audio payloader",
+ 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_g722_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>");
-}
-
-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");
+ gstrtpbasepayload_class->set_caps = gst_rtp_g722_pay_setcaps;
+ gstrtpbasepayload_class->get_caps = gst_rtp_g722_pay_getcaps;
}
static void
-gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay, GstRtpG722PayClass * klass)
+gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay)
{
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtpg722pay);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpg722pay);
- /* tell basertpaudiopayload that this is a sample based codec */
- gst_base_rtp_audio_payload_set_sample_based (basertpaudiopayload);
+ /* tell rtpbaseaudiopayload that this is a sample based codec */
+ gst_rtp_base_audio_payload_set_sample_based (rtpbaseaudiopayload);
}
static gboolean
-gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
+gst_rtp_g722_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
{
GstRtpG722Pay *rtpg722pay;
GstStructure *structure;
@@ -110,9 +107,9 @@ gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
gchar *params;
GstAudioChannelPosition *pos;
const GstRTPChannelOrder *order;
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (basepayload);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (basepayload);
rtpg722pay = GST_RTP_G722_PAY (basepayload);
structure = gst_caps_get_structure (caps, 0);
@@ -135,7 +132,7 @@ gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
* RFC 3551 although the sampling rate is 16000 Hz */
clock_rate = 8000;
- gst_basertppayload_set_options (basepayload, "audio", TRUE, "G722",
+ gst_rtp_base_payload_set_options (basepayload, "audio", TRUE, "G722",
clock_rate);
params = g_strdup_printf ("%d", channels);
@@ -145,11 +142,11 @@ gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
}
if (order && order->name) {
- res = gst_basertppayload_set_outcaps (basepayload,
+ res = gst_rtp_base_payload_set_outcaps (basepayload,
"encoding-params", G_TYPE_STRING, params, "channels", G_TYPE_INT,
channels, "channel-order", G_TYPE_STRING, order->name, NULL);
} else {
- res = gst_basertppayload_set_outcaps (basepayload,
+ res = gst_rtp_base_payload_set_outcaps (basepayload,
"encoding-params", G_TYPE_STRING, params, "channels", G_TYPE_INT,
channels, NULL);
}
@@ -163,7 +160,7 @@ gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
/* bits-per-sample is 4 * channels for G722, but as the RTP clock runs at
* half speed (8 instead of 16 khz), pretend it's 8 bits per sample
* channels. */
- gst_base_rtp_audio_payload_set_samplebits_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_samplebits_options (rtpbaseaudiopayload,
8 * rtpg722pay->channels);
return res;
@@ -182,7 +179,8 @@ no_channels:
}
static GstCaps *
-gst_rtp_g722_pay_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad)
+gst_rtp_g722_pay_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad,
+ GstCaps * filter)
{
GstCaps *otherpadcaps;
GstCaps *caps;
diff --git a/gst/rtp/gstrtpg722pay.h b/gst/rtp/gstrtpg722pay.h
index 6712204d0..b76b1066c 100644
--- a/gst/rtp/gstrtpg722pay.h
+++ b/gst/rtp/gstrtpg722pay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_G722_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpaudiopayload.h>
+#include <gst/rtp/gstrtpbaseaudiopayload.h>
G_BEGIN_DECLS
@@ -41,7 +41,7 @@ typedef struct _GstRtpG722PayClass GstRtpG722PayClass;
struct _GstRtpG722Pay
{
- GstBaseRTPAudioPayload payload;
+ GstRTPBaseAudioPayload payload;
gint rate;
gint channels;
@@ -49,7 +49,7 @@ struct _GstRtpG722Pay
struct _GstRtpG722PayClass
{
- GstBaseRTPAudioPayloadClass parent_class;
+ GstRTPBaseAudioPayloadClass parent_class;
};
GType gst_rtp_g722_pay_get_type (void);
diff --git a/gst/rtp/gstrtpg723depay.c b/gst/rtp/gstrtpg723depay.c
index 0f6f137ce..bb9bf33ea 100644
--- a/gst/rtp/gstrtpg723depay.c
+++ b/gst/rtp/gstrtpg723depay.c
@@ -73,57 +73,53 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/G723, " "channels = (int) 1," "rate = (int) 8000")
);
-static gboolean gst_rtp_g723_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_g723_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_g723_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-GST_BOILERPLATE (GstRtpG723Depay, gst_rtp_g723_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_g723_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG723Depay, gst_rtp_g723_depay,
+ GST_TYPE_RTP_BASE_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);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_g723_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_g723_depay_sink_template);
-
- gst_element_class_set_details_simple (element_class, "RTP G.723 depayloader",
- "Codec/Depayloader/Network/RTP",
- "Extracts G.723 audio from RTP packets (RFC 3551)",
- "Wim Taymans <wim.taymans@gmail.com>");
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
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;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_g723_depay_sink_template));
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ 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>");
- gstbasertpdepayload_class->process = gst_rtp_g723_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_g723_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_g723_depay_process;
+ gstrtpbasedepayload_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;
+ GstRTPBaseDepayload *depayload;
- depayload = GST_BASE_RTP_DEPAYLOAD (rtpg723depay);
+ depayload = GST_RTP_BASE_DEPAYLOAD (rtpg723depay);
- gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
+ gst_pad_use_fixed_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload));
}
static gboolean
-gst_rtp_g723_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_g723_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstCaps *srccaps;
@@ -155,7 +151,7 @@ gst_rtp_g723_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
srccaps = gst_caps_new_simple ("audio/G723",
"channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, clock_rate, NULL);
- ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return ret;
@@ -176,16 +172,19 @@ wrong_clock_rate:
static GstBuffer *
-gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_g723_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpG723Depay *rtpg723depay;
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,16 +192,17 @@ 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 */
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
}
- GST_LOG_OBJECT (depayload, "pushing buffer of size %d",
- GST_BUFFER_SIZE (outbuf));
+ GST_LOG_OBJECT (depayload, "pushing buffer of size %" G_GSIZE_FORMAT,
+ 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;
}
}
diff --git a/gst/rtp/gstrtpg723depay.h b/gst/rtp/gstrtpg723depay.h
index fcab761fc..0071ca46a 100644
--- a/gst/rtp/gstrtpg723depay.h
+++ b/gst/rtp/gstrtpg723depay.h
@@ -22,7 +22,7 @@
#define __GST_RTP_G723_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,12 +42,12 @@ typedef struct _GstRtpG723DepayClass GstRtpG723DepayClass;
struct _GstRtpG723Depay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
};
struct _GstRtpG723DepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_g723_depay_get_type (void);
diff --git a/gst/rtp/gstrtpg723pay.c b/gst/rtp/gstrtpg723pay.c
index 3fe906f50..f196324ff 100644
--- a/gst/rtp/gstrtpg723pay.c
+++ b/gst/rtp/gstrtpg723pay.c
@@ -34,9 +34,9 @@
#define G723_FRAME_DURATION (30 * GST_MSECOND)
-static gboolean gst_rtp_g723_pay_set_caps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_g723_pay_set_caps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload *
+static GstFlowReturn gst_rtp_g723_pay_handle_buffer (GstRTPBasePayload *
payload, GstBuffer * buf);
static GstStaticPadTemplate gst_rtp_g723_pay_sink_template =
@@ -67,52 +67,47 @@ 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_static_pad_template (element_class,
- &gst_rtp_g723_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_g723_pay_class_init (GstRTPG723PayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- GstBaseRTPPayloadClass *payload_class;
+ GstRTPBasePayloadClass *payload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- payload_class = (GstBaseRTPPayloadClass *) klass;
+ payload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->finalize = gst_rtp_g723_pay_finalize;
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);
+ GstRTPBasePayload *payload = GST_RTP_BASE_PAYLOAD (pay);
pay->adapter = gst_adapter_new ();
payload->pt = GST_RTP_PAYLOAD_G723;
- gst_basertppayload_set_options (payload, "audio", FALSE, "G723", 8000);
+ gst_rtp_base_payload_set_options (payload, "audio", FALSE, "G723", 8000);
}
static void
@@ -130,7 +125,7 @@ gst_rtp_g723_pay_finalize (GObject * object)
static gboolean
-gst_rtp_g723_pay_set_caps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_g723_pay_set_caps (GstRTPBasePayload * payload, GstCaps * caps)
{
gboolean res;
GstStructure *structure;
@@ -143,7 +138,7 @@ gst_rtp_g723_pay_set_caps (GstBaseRTPPayload * payload, GstCaps * caps)
payload->pt = pt;
payload->dynamic = pt != GST_RTP_PAYLOAD_G723;
- res = gst_basertppayload_set_outcaps (payload, NULL);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
return res;
}
@@ -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,11 +173,12 @@ 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);
+ ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (pay), outbuf);
return ret;
}
@@ -193,11 +192,11 @@ static const guint size_tab[4] = {
};
static GstFlowReturn
-gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
+gst_rtp_g723_pay_handle_buffer (GstRTPBasePayload * 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)) {
@@ -231,7 +229,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
packet_dur = pay->duration + G723_FRAME_DURATION;
packet_len = gst_rtp_buffer_calc_packet_len (payload_len, 0, 0);
- if (gst_basertppayload_is_filled (payload, packet_len, packet_dur)) {
+ if (gst_rtp_base_payload_is_filled (payload, packet_len, packet_dur)) {
/* size or duration would overflow the packet, flush the queued data */
ret = gst_rtp_g723_pay_flush (pay);
}
@@ -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);
@@ -261,7 +260,8 @@ invalid_size:
{
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
("Invalid input buffer size"),
- ("Input size should be 4, 20 or 24, got %u", size));
+ ("Input size should be 4, 20 or 24, got %" G_GSIZE_FORMAT, size));
+ gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
return GST_FLOW_OK;
}
@@ -269,7 +269,9 @@ 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));
+ ("Expected input buffer size %u but got %" G_GSIZE_FORMAT,
+ size_tab[HDR], size));
+ gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
return GST_FLOW_OK;
}
diff --git a/gst/rtp/gstrtpg723pay.h b/gst/rtp/gstrtpg723pay.h
index db1570f3d..f1c77acef 100644
--- a/gst/rtp/gstrtpg723pay.h
+++ b/gst/rtp/gstrtpg723pay.h
@@ -22,7 +22,7 @@
#define __GST_RTP_G723_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpaudiopayload.h>
+#include <gst/rtp/gstrtpbaseaudiopayload.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRTPG723PayClass GstRTPG723PayClass;
struct _GstRTPG723Pay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
GstAdapter *adapter;
GstClockTime duration;
@@ -52,7 +52,7 @@ struct _GstRTPG723Pay
struct _GstRTPG723PayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_g723_pay_get_type (void);
diff --git a/gst/rtp/gstrtpg726depay.c b/gst/rtp/gstrtpg726depay.c
index 2b171a0f6..927544598 100644
--- a/gst/rtp/gstrtpg726depay.c
+++ b/gst/rtp/gstrtpg726depay.c
@@ -82,37 +82,28 @@ static void gst_rtp_g726_depay_get_property (GObject * object, guint prop_id,
static void gst_rtp_g726_depay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
-static GstBuffer *gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_g726_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_g726_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-GST_BOILERPLATE (GstRtpG726Depay, gst_rtp_g726_depay, GstBaseRTPDepayload,
- 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_static_pad_template (element_class,
- &gst_rtp_g726_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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>");
-}
+#define gst_rtp_g726_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG726Depay, gst_rtp_g726_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void
gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass)
{
GObjectClass *gobject_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
+
+ GST_DEBUG_CATEGORY_INIT (rtpg726depay_debug, "rtpg726depay", 0,
+ "G.726 RTP Depayloader");
gobject_class = (GObjectClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->set_property = gst_rtp_g726_depay_set_property;
gobject_class->get_property = gst_rtp_g726_depay_get_property;
@@ -122,28 +113,34 @@ 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));
- gstbasertpdepayload_class->process = gst_rtp_g726_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_g726_depay_setcaps;
+ 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_DEBUG_CATEGORY_INIT (rtpg726depay_debug, "rtpg726depay", 0,
- "G.726 RTP Depayloader");
+ 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>");
+
+ gstrtpbasedepayload_class->process = gst_rtp_g726_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_g726_depay_setcaps;
}
static void
-gst_rtp_g726_depay_init (GstRtpG726Depay * rtpG726depay,
- GstRtpG726DepayClass * klass)
+gst_rtp_g726_depay_init (GstRtpG726Depay * rtpG726depay)
{
- GstBaseRTPDepayload *depayload;
+ GstRTPBaseDepayload *depayload;
- depayload = GST_BASE_RTP_DEPAYLOAD (rtpG726depay);
+ depayload = GST_RTP_BASE_DEPAYLOAD (rtpG726depay);
- gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
+ gst_pad_use_fixed_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload));
rtpG726depay->force_aal2 = DEFAULT_FORCE_AAL2;
}
static gboolean
-gst_rtp_g726_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_g726_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
GstStructure *structure;
@@ -189,7 +186,7 @@ gst_rtp_g726_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
"bitrate", G_TYPE_INT, depay->bitrate,
"layout", G_TYPE_STRING, LAYOUT_G726, NULL);
- ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return ret;
@@ -205,47 +202,43 @@ unknown_encoding:
static GstBuffer *
-gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_g726_depay_process (GstRTPBaseDepayload * 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);
- 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));
+ marker = gst_rtp_buffer_get_marker (&rtp);
+
+ GST_DEBUG ("process : got %" G_GSIZE_FORMAT " bytes, mark %d ts %u seqn %d",
+ 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) {
diff --git a/gst/rtp/gstrtpg726depay.h b/gst/rtp/gstrtpg726depay.h
index 064a4fa55..119be0c01 100644
--- a/gst/rtp/gstrtpg726depay.h
+++ b/gst/rtp/gstrtpg726depay.h
@@ -17,7 +17,7 @@
#define __GST_RTP_G726_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -37,7 +37,7 @@ typedef struct _GstRtpG726DepayClass GstRtpG726DepayClass;
struct _GstRtpG726Depay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
gboolean aal2;
gboolean force_aal2;
@@ -46,7 +46,7 @@ struct _GstRtpG726Depay
struct _GstRtpG726DepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_g726_depay_get_type (void);
diff --git a/gst/rtp/gstrtpg726pay.c b/gst/rtp/gstrtpg726pay.c
index 07c0f2748..21a267038 100644
--- a/gst/rtp/gstrtpg726pay.c
+++ b/gst/rtp/gstrtpg726pay.c
@@ -70,37 +70,25 @@ static void gst_rtp_g726_pay_get_property (GObject * object, guint prop_id,
static void gst_rtp_g726_pay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
-static gboolean gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_g726_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload *
+static GstFlowReturn gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload *
payload, GstBuffer * buffer);
-GST_BOILERPLATE (GstRtpG726Pay, gst_rtp_g726_pay, GstBaseRTPAudioPayload,
- 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_static_pad_template (element_class,
- &gst_rtp_g726_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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>");
-}
+#define gst_rtp_g726_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG726Pay, gst_rtp_g726_pay,
+ GST_TYPE_RTP_BASE_AUDIO_PAYLOAD);
static void
gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
{
GObjectClass *gobject_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->set_property = gst_rtp_g726_pay_set_property;
gobject_class->get_property = gst_rtp_g726_pay_get_property;
@@ -110,39 +98,49 @@ 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));
- gstbasertppayload_class->set_caps = gst_rtp_g726_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_g726_pay_handle_buffer;
+ 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>");
+
+ gstrtpbasepayload_class->set_caps = gst_rtp_g726_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_g726_pay_handle_buffer;
GST_DEBUG_CATEGORY_INIT (rtpg726pay_debug, "rtpg726pay", 0,
"G.726 RTP Payloader");
}
static void
-gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay, GstRtpG726PayClass * klass)
+gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay)
{
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtpg726pay);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpg726pay);
- GST_BASE_RTP_PAYLOAD (rtpg726pay)->clock_rate = 8000;
+ GST_RTP_BASE_PAYLOAD (rtpg726pay)->clock_rate = 8000;
rtpg726pay->force_aal2 = DEFAULT_FORCE_AAL2;
/* sample based codec */
- gst_base_rtp_audio_payload_set_sample_based (basertpaudiopayload);
+ gst_rtp_base_audio_payload_set_sample_based (rtpbaseaudiopayload);
}
static gboolean
-gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_g726_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
gchar *encoding_name;
GstStructure *structure;
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
GstRtpG726Pay *pay;
GstCaps *peercaps;
gboolean res;
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (payload);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (payload);
pay = GST_RTP_G726_PAY (payload);
structure = gst_caps_get_structure (caps, 0);
@@ -158,22 +156,22 @@ gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
switch (pay->bitrate) {
case 16000:
encoding_name = g_strdup ("G726-16");
- gst_base_rtp_audio_payload_set_samplebits_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_samplebits_options (rtpbaseaudiopayload,
2);
break;
case 24000:
encoding_name = g_strdup ("G726-24");
- gst_base_rtp_audio_payload_set_samplebits_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_samplebits_options (rtpbaseaudiopayload,
3);
break;
case 32000:
encoding_name = g_strdup ("G726-32");
- gst_base_rtp_audio_payload_set_samplebits_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_samplebits_options (rtpbaseaudiopayload,
4);
break;
case 40000:
encoding_name = g_strdup ("G726-40");
- gst_base_rtp_audio_payload_set_samplebits_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_samplebits_options (rtpbaseaudiopayload,
5);
break;
default:
@@ -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_query_caps (payload->srcpad, NULL);
if (peercaps) {
GstCaps *filter, *intersect;
gchar *capsstr;
@@ -239,8 +237,9 @@ gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
GST_DEBUG_OBJECT (payload, "no peer caps, AAL2 %d", pay->aal2);
}
- gst_basertppayload_set_options (payload, "audio", TRUE, encoding_name, 8000);
- res = gst_basertppayload_set_outcaps (payload, NULL);
+ gst_rtp_base_payload_set_options (payload, "audio", TRUE, encoding_name,
+ 8000);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
g_free (encoding_name);
@@ -260,7 +259,7 @@ no_format:
}
static GstFlowReturn
-gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
+gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
{
GstFlowReturn res;
GstRtpG726Pay *pay;
@@ -269,16 +268,15 @@ 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);
+ GST_LOG_OBJECT (pay, "packing %" G_GSIZE_FORMAT " bytes of data", len);
/* we need to reshuffle the bytes, output is of the form:
* A B C D .. with the number of bits depending on the bitrate. */
@@ -366,10 +364,11 @@ gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
break;
}
}
+ gst_buffer_unmap (buffer, data, len);
}
res =
- GST_BASE_RTP_PAYLOAD_CLASS (parent_class)->handle_buffer (payload,
+ GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->handle_buffer (payload,
buffer);
return res;
diff --git a/gst/rtp/gstrtpg726pay.h b/gst/rtp/gstrtpg726pay.h
index ce3dbdc1d..5b1696695 100644
--- a/gst/rtp/gstrtpg726pay.h
+++ b/gst/rtp/gstrtpg726pay.h
@@ -17,7 +17,7 @@
#define __GST_RTP_G726_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpaudiopayload.h>
+#include <gst/rtp/gstrtpbaseaudiopayload.h>
G_BEGIN_DECLS typedef struct _GstRtpG726Pay GstRtpG726Pay;
typedef struct _GstRtpG726PayClass GstRtpG726PayClass;
@@ -35,7 +35,7 @@ typedef struct _GstRtpG726PayClass GstRtpG726PayClass;
struct _GstRtpG726Pay
{
- GstBaseRTPAudioPayload audiopayload;
+ GstRTPBaseAudioPayload audiopayload;
gboolean aal2;
gboolean force_aal2;
@@ -44,7 +44,7 @@ struct _GstRtpG726Pay
struct _GstRtpG726PayClass
{
- GstBaseRTPAudioPayloadClass parent_class;
+ GstRTPBaseAudioPayloadClass parent_class;
};
GType gst_rtp_g726_pay_get_type (void);
diff --git a/gst/rtp/gstrtpg729depay.c b/gst/rtp/gstrtpg729depay.c
index 69799ad8a..a6017bb2b 100644
--- a/gst/rtp/gstrtpg729depay.c
+++ b/gst/rtp/gstrtpg729depay.c
@@ -71,57 +71,53 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/G729, " "channels = (int) 1," "rate = (int) 8000")
);
-static gboolean gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_g729_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-GST_BOILERPLATE (GstRtpG729Depay, gst_rtp_g729_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_g729_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG729Depay, gst_rtp_g729_depay,
+ GST_TYPE_RTP_BASE_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);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_g729_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_g729_depay_sink_template);
-
- gst_element_class_set_details_simple (element_class, "RTP G.729 depayloader",
- "Codec/Depayloader/Network/RTP",
- "Extracts G.729 audio from RTP packets (RFC 3551)",
- "Laurent Glayal <spglegle@yahoo.fr>");
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
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;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_g729_depay_sink_template));
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ 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>");
- gstbasertpdepayload_class->process = gst_rtp_g729_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_g729_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_g729_depay_process;
+ gstrtpbasedepayload_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;
+ GstRTPBaseDepayload *depayload;
- depayload = GST_BASE_RTP_DEPAYLOAD (rtpg729depay);
+ depayload = GST_RTP_BASE_DEPAYLOAD (rtpg729depay);
- gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
+ gst_pad_use_fixed_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload));
}
static gboolean
-gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_g729_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstCaps *srccaps;
@@ -153,7 +149,7 @@ gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
srccaps = gst_caps_new_simple ("audio/G729",
"channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, clock_rate, NULL);
- ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return ret;
@@ -172,18 +168,20 @@ wrong_clock_rate:
}
}
-
static GstBuffer *
-gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpG729Depay *rtpg729depay;
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,16 +196,18 @@ 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 */
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
}
- GST_LOG_OBJECT (depayload, "pushing buffer of size %d",
- GST_BUFFER_SIZE (outbuf));
+ GST_LOG_OBJECT (depayload, "pushing buffer of size %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (outbuf));
return outbuf;
diff --git a/gst/rtp/gstrtpg729depay.h b/gst/rtp/gstrtpg729depay.h
index f02db5c50..ffd4bb918 100644
--- a/gst/rtp/gstrtpg729depay.h
+++ b/gst/rtp/gstrtpg729depay.h
@@ -20,7 +20,7 @@
#define __GST_RTP_G729_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -44,12 +44,12 @@ typedef struct _GstRtpG729DepayClass GstRtpG729DepayClass;
struct _GstRtpG729Depay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
};
struct _GstRtpG729DepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_g729_depay_get_type (void);
diff --git a/gst/rtp/gstrtpg729pay.c b/gst/rtp/gstrtpg729pay.c
index 60364cc7c..ac90dbfe9 100644
--- a/gst/rtp/gstrtpg729pay.c
+++ b/gst/rtp/gstrtpg729pay.c
@@ -44,9 +44,9 @@ GST_DEBUG_CATEGORY_STATIC (rtpg729pay_debug);
#define G729_FRAME_DURATION_MS (10)
static gboolean
-gst_rtp_g729_pay_set_caps (GstBaseRTPPayload * payload, GstCaps * caps);
+gst_rtp_g729_pay_set_caps (GstRTPBasePayload * payload, GstCaps * caps);
static GstFlowReturn
-gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf);
+gst_rtp_g729_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buf);
static GstStateChangeReturn
gst_rtp_g729_pay_change_state (GstElement * element, GstStateChange transition);
@@ -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_static_pad_template (element_class,
- &gst_rtp_g729_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_g729_pay_finalize (GObject * object)
@@ -110,23 +92,36 @@ gst_rtp_g729_pay_class_init (GstRTPG729PayClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *gstelement_class = (GstElementClass *) klass;
- GstBaseRTPPayloadClass *payload_class = GST_BASE_RTP_PAYLOAD_CLASS (klass);
+ GstRTPBasePayloadClass *payload_class = GST_RTP_BASE_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);
+ GstRTPBasePayload *payload = GST_RTP_BASE_PAYLOAD (pay);
payload->pt = GST_RTP_PAYLOAD_G729;
- gst_basertppayload_set_options (payload, "audio", FALSE, "G729", 8000);
+ gst_rtp_base_payload_set_options (payload, "audio", FALSE, "G729", 8000);
pay->adapter = gst_adapter_new ();
}
@@ -142,7 +137,7 @@ gst_rtp_g729_pay_reset (GstRTPG729Pay * pay)
}
static gboolean
-gst_rtp_g729_pay_set_caps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_g729_pay_set_caps (GstRTPBasePayload * payload, GstCaps * caps)
{
gboolean res;
GstStructure *structure;
@@ -155,7 +150,7 @@ gst_rtp_g729_pay_set_caps (GstBaseRTPPayload * payload, GstCaps * caps)
payload->pt = pt;
payload->dynamic = pt != GST_RTP_PAYLOAD_G729;
- res = gst_basertppayload_set_outcaps (payload, NULL);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
return res;
}
@@ -164,14 +159,15 @@ static GstFlowReturn
gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay,
const guint8 * data, guint payload_len)
{
- GstBaseRTPPayload *basepayload;
+ GstRTPBasePayload *basepayload;
GstClockTime duration;
guint frames;
GstBuffer *outbuf;
guint8 *payload;
GstFlowReturn ret;
+ GstRTPBuffer rtp = { NULL };
- basepayload = GST_BASE_RTP_PAYLOAD (rtpg729pay);
+ basepayload = GST_RTP_BASE_PAYLOAD (rtpg729pay);
GST_DEBUG_OBJECT (rtpg729pay, "Pushing %d bytes ts %" GST_TIME_FORMAT,
payload_len, GST_TIME_ARGS (rtpg729pay->next_ts));
@@ -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,11 +194,12 @@ 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);
+ ret = gst_rtp_base_payload_push (basepayload, outbuf);
return ret;
}
@@ -224,7 +223,7 @@ gst_rtp_g729_pay_recalc_rtp_time (GstRTPG729Pay * rtpg729pay, GstClockTime time)
}
static GstFlowReturn
-gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
+gst_rtp_g729_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buf)
{
GstFlowReturn ret = GST_FLOW_OK;
GstRTPG729Pay *rtpg729pay = GST_RTP_G729_PAY (payload);
@@ -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
@@ -260,7 +261,7 @@ gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
max_payload_len = MIN (
/* MTU max */
- (int) (gst_rtp_buffer_calc_payload_len (GST_BASE_RTP_PAYLOAD_MTU
+ (int) (gst_rtp_buffer_calc_payload_len (GST_RTP_BASE_PAYLOAD_MTU
(payload), 0, 0) / G729_FRAME_SIZE)
* G729_FRAME_SIZE,
/* ptime max */
@@ -283,8 +284,8 @@ gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
}
/* If the ptime is specified in the caps, tried to adhere to it exactly */
- if (payload->abidata.ABI.ptime) {
- guint64 ptime = payload->abidata.ABI.ptime / GST_MSECOND;
+ if (payload->ptime) {
+ guint64 ptime = payload->ptime / GST_MSECOND;
guint ptime_in_bytes = G729_FRAME_SIZE *
(guint) (ptime / G729_FRAME_DURATION_MS);
@@ -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 %" G_GSIZE_FORMAT, size));
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
diff --git a/gst/rtp/gstrtpg729pay.h b/gst/rtp/gstrtpg729pay.h
index 04c6e794c..52b9951e4 100644
--- a/gst/rtp/gstrtpg729pay.h
+++ b/gst/rtp/gstrtpg729pay.h
@@ -22,7 +22,7 @@
#define __GST_RTP_G729_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpaudiopayload.h>
+#include <gst/rtp/gstrtpbaseaudiopayload.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRTPG729PayClass GstRTPG729PayClass;
struct _GstRTPG729Pay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
GstAdapter *adapter;
GstClockTime next_ts;
@@ -54,7 +54,7 @@ struct _GstRTPG729Pay
struct _GstRTPG729PayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_g729_pay_get_type (void);
diff --git a/gst/rtp/gstrtpgsmdepay.c b/gst/rtp/gstrtpgsmdepay.c
index 989991fa2..2b31088b4 100644
--- a/gst/rtp/gstrtpgsmdepay.c
+++ b/gst/rtp/gstrtpgsmdepay.c
@@ -57,51 +57,46 @@ static GstStaticPadTemplate gst_rtp_gsm_depay_sink_template =
"clock-rate = (int) 8000")
);
-static GstBuffer *gst_rtp_gsm_depay_process (GstBaseRTPDepayload * _depayload,
+static GstBuffer *gst_rtp_gsm_depay_process (GstRTPBaseDepayload * _depayload,
GstBuffer * buf);
-static gboolean gst_rtp_gsm_depay_setcaps (GstBaseRTPDepayload * _depayload,
+static gboolean gst_rtp_gsm_depay_setcaps (GstRTPBaseDepayload * _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_RTP_BASE_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;
+ GstRTPBaseDepayloadClass *gstrtpbase_depayload_class;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_gsm_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_gsm_depay_sink_template);
- gst_element_class_set_details_simple (element_class, "RTP GSM depayloader",
- "Codec/Depayloader/Network/RTP",
- "Extracts GSM audio from RTP packets", "Zeeshan Ali <zeenix@gmail.com>");
-}
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbase_depayload_class = (GstRTPBaseDepayloadClass *) klass;
-static void
-gst_rtp_gsm_depay_class_init (GstRTPGSMDepayClass * klass)
-{
- GstBaseRTPDepayloadClass *gstbasertp_depayload_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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_gsm_depay_sink_template));
- gstbasertp_depayload_class = (GstBaseRTPDepayloadClass *) klass;
+ 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>");
- gstbasertp_depayload_class->process = gst_rtp_gsm_depay_process;
- gstbasertp_depayload_class->set_caps = gst_rtp_gsm_depay_setcaps;
+ gstrtpbase_depayload_class->process = gst_rtp_gsm_depay_process;
+ gstrtpbase_depayload_class->set_caps = gst_rtp_gsm_depay_setcaps;
GST_DEBUG_CATEGORY_INIT (rtpgsmdepay_debug, "rtpgsmdepay", 0,
"GSM Audio RTP Depayloader");
}
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
-gst_rtp_gsm_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_gsm_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
gboolean ret;
@@ -116,25 +111,30 @@ gst_rtp_gsm_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
srccaps = gst_caps_new_simple ("audio/x-gsm",
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, clock_rate, NULL);
- ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return ret;
}
static GstBuffer *
-gst_rtp_gsm_depay_process (GstBaseRTPDepayload * _depayload, GstBuffer * buf)
+gst_rtp_gsm_depay_process (GstRTPBaseDepayload * _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 (&rtp);
- marker = gst_rtp_buffer_get_marker (buf);
+ GST_DEBUG ("process : got %" G_GSIZE_FORMAT " bytes, mark %d ts %u seqn %d",
+ gst_buffer_get_size (buf), marker,
+ gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&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));
+ 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 */
diff --git a/gst/rtp/gstrtpgsmdepay.h b/gst/rtp/gstrtpgsmdepay.h
index 221f4b3e8..73234ca1a 100644
--- a/gst/rtp/gstrtpgsmdepay.h
+++ b/gst/rtp/gstrtpgsmdepay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_GSM_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -41,12 +41,12 @@ typedef struct _GstRTPGSMDepayClass GstRTPGSMDepayClass;
struct _GstRTPGSMDepay
{
- GstBaseRTPDepayload _depayload;
+ GstRTPBaseDepayload _depayload;
};
struct _GstRTPGSMDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_gsm_depay_get_type (void);
diff --git a/gst/rtp/gstrtpgsmpay.c b/gst/rtp/gstrtpgsmpay.c
index 6506262ee..d490fc990 100644
--- a/gst/rtp/gstrtpgsmpay.c
+++ b/gst/rtp/gstrtpgsmpay.c
@@ -52,52 +52,49 @@ static GstStaticPadTemplate gst_rtp_gsm_pay_src_template =
"clock-rate = (int) 8000, " "encoding-name = (string) \"GSM\"")
);
-static gboolean gst_rtp_gsm_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_gsm_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * payload,
+static GstFlowReturn gst_rtp_gsm_pay_handle_buffer (GstRTPBasePayload * 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_RTP_BASE_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;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_gsm_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_gsm_pay_src_template);
- gst_element_class_set_details_simple (element_class, "RTP GSM payloader",
- "Codec/Payloader/Network/RTP",
- "Payload-encodes GSM audio into a RTP packet",
- "Zeeshan Ali <zeenix@gmail.com>");
-}
+ GST_DEBUG_CATEGORY_INIT (rtpgsmpay_debug, "rtpgsmpay", 0,
+ "GSM Audio RTP Payloader");
-static void
-gst_rtp_gsm_pay_class_init (GstRTPGSMPayClass * klass)
-{
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_gsm_pay_src_template));
- gstbasertppayload_class->set_caps = gst_rtp_gsm_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_gsm_pay_handle_buffer;
+ 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>");
- GST_DEBUG_CATEGORY_INIT (rtpgsmpay_debug, "rtpgsmpay", 0,
- "GSM Audio RTP Payloader");
+ gstrtpbasepayload_class->set_caps = gst_rtp_gsm_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_gsm_pay_handle_buffer;
}
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;
+ GST_RTP_BASE_PAYLOAD (rtpgsmpay)->clock_rate = 8000;
+ GST_RTP_BASE_PAYLOAD_PT (rtpgsmpay) = GST_RTP_PAYLOAD_GSM;
}
static gboolean
-gst_rtp_gsm_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_gsm_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
const char *stname;
GstStructure *structure;
@@ -110,8 +107,8 @@ gst_rtp_gsm_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
if (strcmp ("audio/x-gsm", stname))
goto invalid_type;
- gst_basertppayload_set_options (payload, "audio", FALSE, "GSM", 8000);
- res = gst_basertppayload_set_outcaps (payload, NULL);
+ gst_rtp_base_payload_set_options (payload, "audio", FALSE, "GSM", 8000);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
return res;
@@ -124,19 +121,22 @@ invalid_type:
}
static GstFlowReturn
-gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_gsm_pay_handle_buffer (GstRTPBasePayload * 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_RTP_BASE_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_DEBUG ("gst_rtp_gsm_pay_chain: pushing buffer of size %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (outbuf));
- ret = gst_basertppayload_push (basepayload, outbuf);
+ ret = gst_rtp_base_payload_push (basepayload, outbuf);
return ret;
+
+ /* ERRORS */
+too_big:
+ {
+ GST_ELEMENT_ERROR (rtpgsmpay, STREAM, ENCODE, (NULL),
+ ("payload_len %u > mtu %u", payload_len,
+ GST_RTP_BASE_PAYLOAD_MTU (rtpgsmpay)));
+ gst_buffer_unmap (buffer, data, size);
+ return GST_FLOW_ERROR;
+ }
}
gboolean
diff --git a/gst/rtp/gstrtpgsmpay.h b/gst/rtp/gstrtpgsmpay.h
index 4172402e1..085da8009 100644
--- a/gst/rtp/gstrtpgsmpay.h
+++ b/gst/rtp/gstrtpgsmpay.h
@@ -22,7 +22,7 @@
#define __GST_RTP_GSM_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
G_BEGIN_DECLS
@@ -42,12 +42,12 @@ typedef struct _GstRTPGSMPayClass GstRTPGSMPayClass;
struct _GstRTPGSMPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
};
struct _GstRTPGSMPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_gsm_pay_get_type (void);
diff --git a/gst/rtp/gstrtpgstdepay.c b/gst/rtp/gstrtpgstdepay.c
index b187db492..895641f66 100644
--- a/gst/rtp/gstrtpgstdepay.c
+++ b/gst/rtp/gstrtpgstdepay.c
@@ -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_RTP_BASE_DEPAYLOAD);
static void gst_rtp_gst_depay_finalize (GObject * object);
@@ -54,52 +54,45 @@ static GstStateChangeReturn gst_rtp_gst_depay_change_state (GstElement *
element, GstStateChange transition);
static void gst_rtp_gst_depay_reset (GstRtpGSTDepay * rtpgstdepay);
-static gboolean gst_rtp_gst_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_gst_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_gst_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
static void
-gst_rtp_gst_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_gst_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
+
+ GST_DEBUG_CATEGORY_INIT (rtpgstdepay_debug, "rtpgstdepay", 0,
+ "Gstreamer RTP Depayloader");
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->finalize = gst_rtp_gst_depay_finalize;
gstelement_class->change_state = gst_rtp_gst_depay_change_state;
- gstbasertpdepayload_class->set_caps = gst_rtp_gst_depay_setcaps;
- gstbasertpdepayload_class->process = gst_rtp_gst_depay_process;
+ 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_DEBUG_CATEGORY_INIT (rtpgstdepay_debug, "rtpgstdepay", 0,
- "Gstreamer RTP Depayloader");
+ 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>");
+
+ gstrtpbasedepayload_class->set_caps = gst_rtp_gst_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_gst_depay_process;
}
static void
-gst_rtp_gst_depay_init (GstRtpGSTDepay * rtpgstdepay,
- GstRtpGSTDepayClass * klass)
+gst_rtp_gst_depay_init (GstRtpGSTDepay * rtpgstdepay)
{
rtpgstdepay->adapter = gst_adapter_new ();
}
@@ -137,7 +130,7 @@ gst_rtp_gst_depay_reset (GstRtpGSTDepay * rtpgstdepay)
}
static gboolean
-gst_rtp_gst_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_gst_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstRtpGSTDepay *rtpgstdepay;
GstStructure *structure;
@@ -177,17 +170,20 @@ gst_rtp_gst_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
}
static GstBuffer *
-gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_gst_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpGSTDepay *rtpgstdepay;
GstBuffer *subbuf, *outbuf = NULL;
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;
}
}
diff --git a/gst/rtp/gstrtpgstdepay.h b/gst/rtp/gstrtpgstdepay.h
index 7a50856d3..aa2aa8e7b 100644
--- a/gst/rtp/gstrtpgstdepay.h
+++ b/gst/rtp/gstrtpgstdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpGSTDepayClass GstRtpGSTDepayClass;
struct _GstRtpGSTDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
GstAdapter *adapter;
guint current_CV;
@@ -51,7 +51,7 @@ struct _GstRtpGSTDepay
struct _GstRtpGSTDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_gst_depay_get_type (void);
diff --git a/gst/rtp/gstrtpgstpay.c b/gst/rtp/gstrtpgstpay.c
index 3f244bc4b..ddc94878b 100644
--- a/gst/rtp/gstrtpgstpay.c
+++ b/gst/rtp/gstrtpgstpay.c
@@ -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
*
*
*/
@@ -68,47 +65,44 @@ GST_STATIC_PAD_TEMPLATE ("src",
"clock-rate = (int) 90000, " "encoding-name = (string) \"X-GST\"")
);
-static gboolean gst_rtp_gst_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_gst_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * payload,
+static GstFlowReturn gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * 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_RTP_BASE_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;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_gst_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_gst_pay_sink_template);
+ 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 (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;
+ gstrtpbasepayload_class->set_caps = gst_rtp_gst_pay_setcaps;
+ gstrtpbasepayload_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)
{
}
static gboolean
-gst_rtp_gst_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_gst_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
gboolean res;
gchar *capsstr, *capsenc;
@@ -117,9 +111,10 @@ gst_rtp_gst_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
capsenc = g_base64_encode ((guchar *) capsstr, strlen (capsstr));
g_free (capsstr);
- gst_basertppayload_set_options (payload, "application", TRUE, "X-GST", 90000);
+ gst_rtp_base_payload_set_options (payload, "application", TRUE, "X-GST",
+ 90000);
res =
- gst_basertppayload_set_outcaps (payload, "caps", G_TYPE_STRING, capsenc,
+ gst_rtp_base_payload_set_outcaps (payload, "caps", G_TYPE_STRING, capsenc,
NULL);
g_free (capsenc);
@@ -127,12 +122,12 @@ gst_rtp_gst_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
}
static GstFlowReturn
-gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
GstRtpGSTPay *rtpgstpay;
- guint8 *data;
- guint size;
+ guint8 *data, *ptr;
+ gsize size, left;
GstBuffer *outbuf;
GstFlowReturn ret;
GstClockTime timestamp;
@@ -141,8 +136,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 +145,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,25 +156,30 @@ 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));
+ towrite = MIN (packet_len, GST_RTP_BASE_PAYLOAD_MTU (rtpgstpay));
/* this is the payload length */
payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0);
/* 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 +191,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);
+ ret = gst_rtp_base_payload_push (basepayload, outbuf);
}
+ gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return ret;
diff --git a/gst/rtp/gstrtpgstpay.h b/gst/rtp/gstrtpgstpay.h
index c7a7c0274..e10401fe0 100644
--- a/gst/rtp/gstrtpgstpay.h
+++ b/gst/rtp/gstrtpgstpay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_GST_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
G_BEGIN_DECLS
@@ -41,12 +41,12 @@ typedef struct _GstRtpGSTPayClass GstRtpGSTPayClass;
struct _GstRtpGSTPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
};
struct _GstRtpGSTPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_gst_pay_get_type (void);
diff --git a/gst/rtp/gstrtph263depay.c b/gst/rtp/gstrtph263depay.c
index 08f96cca8..a3f3b1ebb 100644
--- a/gst/rtp/gstrtph263depay.c
+++ b/gst/rtp/gstrtph263depay.c
@@ -61,61 +61,55 @@ static GstStaticPadTemplate gst_rtp_h263_depay_sink_template =
"clock-rate = (int) 90000, " "encoding-name = (string) \"H263\"")
);
-GST_BOILERPLATE (GstRtpH263Depay, gst_rtp_h263_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_h263_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpH263Depay, gst_rtp_h263_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void gst_rtp_h263_depay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_h263_depay_change_state (GstElement *
element, GstStateChange transition);
-static GstBuffer *gst_rtp_h263_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_h263_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-gboolean gst_rtp_h263_depay_setcaps (GstBaseRTPDepayload * filter,
+gboolean gst_rtp_h263_depay_setcaps (GstRTPBaseDepayload * filter,
GstCaps * caps);
static void
-gst_rtp_h263_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_h263_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_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;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
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>");
+
+ gstrtpbasedepayload_class->process = gst_rtp_h263_depay_process;
+ gstrtpbasedepayload_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 ();
@@ -137,7 +131,7 @@ gst_rtp_h263_depay_finalize (GObject * object)
}
gboolean
-gst_rtp_h263_depay_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps)
+gst_rtp_h263_depay_setcaps (GstRTPBaseDepayload * filter, GstCaps * caps)
{
GstCaps *srccaps;
GstStructure *structure = gst_caps_get_structure (caps, 0);
@@ -150,14 +144,14 @@ gst_rtp_h263_depay_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps)
srccaps = gst_caps_new_simple ("video/x-h263",
"variant", G_TYPE_STRING, "itu",
"h263version", G_TYPE_STRING, "h263", NULL);
- gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (filter), srccaps);
+ gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (filter), srccaps);
gst_caps_unref (srccaps);
return TRUE;
}
static GstBuffer *
-gst_rtp_h263_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_h263_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpH263Depay *rtph263depay;
GstBuffer *outbuf;
@@ -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;
@@ -256,7 +253,7 @@ gst_rtp_h263_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
if (!F && payload_len > 4 && (GST_READ_UINT32_BE (payload) >> 10 == 0x20)) {
GST_DEBUG ("Mode A with PSC => frame start");
rtph263depay->start = TRUE;
- if (!!(payload[4] & 0x02) != I) {
+ if (! !(payload[4] & 0x02) != I) {
GST_DEBUG ("Wrong Picture Coding Type Flag in rtp header");
I = !I;
}
@@ -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);
@@ -310,14 +307,13 @@ skip:
if (rtph263depay->start) {
/* frame is completed */
guint avail;
- guint32 timestamp;
if (rtph263depay->offset) {
/* push in the leftover */
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,8 +325,7 @@ skip:
GST_DEBUG ("Pushing out a buffer of %d bytes", avail);
- timestamp = gst_rtp_buffer_get_timestamp (buf);
- gst_base_rtp_depayload_push_ts (depayload, timestamp, outbuf);
+ gst_rtp_base_depayload_push (depayload, outbuf);
rtph263depay->offset = 0;
rtph263depay->leftover = 0;
rtph263depay->start = FALSE;
@@ -338,6 +333,7 @@ skip:
rtph263depay->start = TRUE;
}
}
+ gst_rtp_buffer_unmap (&rtp);
return NULL;
}
diff --git a/gst/rtp/gstrtph263depay.h b/gst/rtp/gstrtph263depay.h
index 9cecb0953..038b8815a 100644
--- a/gst/rtp/gstrtph263depay.h
+++ b/gst/rtp/gstrtph263depay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpH263DepayClass GstRtpH263DepayClass;
struct _GstRtpH263Depay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
guint8 offset; /* offset to apply to next payload */
guint8 leftover; /* leftover from previous payload (if offset != 0) */
@@ -53,7 +53,7 @@ struct _GstRtpH263Depay
struct _GstRtpH263DepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_h263_depay_get_type (void);
diff --git a/gst/rtp/gstrtph263pay.c b/gst/rtp/gstrtph263pay.c
index 0564d7339..594a45f3f 100644
--- a/gst/rtp/gstrtph263pay.c
+++ b/gst/rtp/gstrtph263pay.c
@@ -369,13 +369,13 @@ static GstStaticPadTemplate gst_rtp_h263_pay_src_template =
static void gst_rtp_h263_pay_finalize (GObject * object);
-static gboolean gst_rtp_h263_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_h263_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
static void gst_rtp_h263_pay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_rtp_h263_pay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static GstFlowReturn gst_rtp_h263_pay_handle_buffer (GstBaseRTPPayload *
+static GstFlowReturn gst_rtp_h263_pay_handle_buffer (GstRTPBasePayload *
payload, GstBuffer * buffer);
static void gst_rtp_h263_pay_boundry_init (GstRtpH263PayBoundry * boundry,
@@ -395,38 +395,24 @@ 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_static_pad_template (element_class,
- &gst_rtp_h263_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_h263_pay_class_init (GstRtpH263PayClass * klass)
{
GObjectClass *gobject_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->finalize = gst_rtp_h263_pay_finalize;
- gstbasertppayload_class->set_caps = gst_rtp_h263_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_h263_pay_handle_buffer;
+ gstrtpbasepayload_class->set_caps = gst_rtp_h263_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_h263_pay_handle_buffer;
gobject_class->set_property = gst_rtp_h263_pay_set_property;
gobject_class->get_property = gst_rtp_h263_pay_get_property;
@@ -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 ();
@@ -462,13 +459,13 @@ gst_rtp_h263_pay_finalize (GObject * object)
}
static gboolean
-gst_rtp_h263_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_h263_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
gboolean res;
payload->pt = GST_RTP_PAYLOAD_H263;
- gst_basertppayload_set_options (payload, "video", TRUE, "H263", 90000);
- res = gst_basertppayload_set_outcaps (payload, NULL);
+ gst_rtp_base_payload_set_options (payload, "video", TRUE, "H263", 90000);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
return res;
}
@@ -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,12 +1272,14 @@ 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),
+ gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtph263pay),
package->outbuf);
GST_DEBUG ("Package pushed, returning");
@@ -1605,13 +1607,13 @@ gst_rtp_h263_pay_flush (GstRtpH263Pay * rtph263pay)
GST_DEBUG ("MTU: %d", context->mtu);
rtph263pay->available_data = gst_adapter_available (rtph263pay->adapter);
if (rtph263pay->available_data == 0) {
- ret = GST_FLOW_RESEND;
+ ret = GST_FLOW_OK;
goto end;
}
/* 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,13 +1769,14 @@ gst_rtp_h263_pay_flush (GstRtpH263Pay * rtph263pay)
end:
gst_rtp_h263_pay_context_destroy (context,
context->piclayer->ptype_srcformat);
+ gst_adapter_unmap (rtph263pay->adapter);
gst_adapter_flush (rtph263pay->adapter, rtph263pay->available_data);
return ret;
}
static GstFlowReturn
-gst_rtp_h263_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
+gst_rtp_h263_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
{
GstRtpH263Pay *rtph263pay;
diff --git a/gst/rtp/gstrtph263pay.h b/gst/rtp/gstrtph263pay.h
index 05fb7332d..211cecb33 100644
--- a/gst/rtp/gstrtph263pay.h
+++ b/gst/rtp/gstrtph263pay.h
@@ -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
@@ -23,7 +23,7 @@
#define __GST_RTP_H263_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -61,7 +61,7 @@ typedef struct _GstRtpH263PayPackage GstRtpH263PayPackage;
struct _GstRtpH263Pay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
GstAdapter *adapter;
GstClockTime first_ts;
@@ -87,7 +87,7 @@ struct _GstRtpH263PayContext
struct _GstRtpH263PayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
typedef struct _GstRtpH263PayAHeader
diff --git a/gst/rtp/gstrtph263pdepay.c b/gst/rtp/gstrtph263pdepay.c
index 37e8989a4..843ef5f90 100644
--- a/gst/rtp/gstrtph263pdepay.c
+++ b/gst/rtp/gstrtph263pdepay.c
@@ -78,58 +78,51 @@ static GstStaticPadTemplate gst_rtp_h263p_depay_sink_template =
)
);
-GST_BOILERPLATE (GstRtpH263PDepay, gst_rtp_h263p_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_h263p_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpH263PDepay, gst_rtp_h263p_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void gst_rtp_h263p_depay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_h263p_depay_change_state (GstElement *
element, GstStateChange transition);
-static GstBuffer *gst_rtp_h263p_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_h263p_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-gboolean gst_rtp_h263p_depay_setcaps (GstBaseRTPDepayload * filter,
+gboolean gst_rtp_h263p_depay_setcaps (GstRTPBaseDepayload * filter,
GstCaps * caps);
static void
-gst_rtp_h263p_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_h263p_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) 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;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
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>");
+
+ gstrtpbasedepayload_class->process = gst_rtp_h263p_depay_process;
+ gstrtpbasedepayload_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 ();
}
@@ -148,7 +141,7 @@ gst_rtp_h263p_depay_finalize (GObject * object)
}
gboolean
-gst_rtp_h263p_depay_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps)
+gst_rtp_h263p_depay_setcaps (GstRTPBaseDepayload * filter, GstCaps * caps)
{
GstCaps *srccaps = NULL;
GstStructure *structure = gst_caps_get_structure (caps, 0);
@@ -214,7 +207,7 @@ gst_rtp_h263p_depay_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps)
if (!srccaps)
goto no_caps;
- res = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (filter), srccaps);
+ res = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (filter), srccaps);
gst_caps_unref (srccaps);
return res;
@@ -233,10 +226,16 @@ no_caps:
}
static GstBuffer *
-gst_rtp_h263p_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_h263p_depay_process (GstRTPBaseDepayload * 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;
- GST_LOG_OBJECT (depayload, "Frame incomplete, storing %d", payload_len);
+ if (M) {
+ /* frame is completed: append to previous, push it out */
+ guint len, padlen;
+ guint avail;
+ guint8 *data;
- memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
+ GST_LOG_OBJECT (depayload, "Frame complete");
- gst_adapter_push (rtph263pdepay->adapter, outbuf);
+ avail = gst_adapter_available (rtph263pdepay->adapter);
+ len = avail + payload_len;
+ padlen = (len % 4) + 4;
+
+ outbuf = gst_buffer_new_and_alloc (len + padlen);
+
+ data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+ memset (data + len, 0, padlen);
+
+ /* 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;
}
}
diff --git a/gst/rtp/gstrtph263pdepay.h b/gst/rtp/gstrtph263pdepay.h
index 0e7c351aa..624e8ffe1 100644
--- a/gst/rtp/gstrtph263pdepay.h
+++ b/gst/rtp/gstrtph263pdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpH263PDepayClass GstRtpH263PDepayClass;
struct _GstRtpH263PDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
GstAdapter *adapter;
gboolean wait_start;
@@ -50,7 +50,7 @@ struct _GstRtpH263PDepay
struct _GstRtpH263PDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_h263p_depay_get_type (void);
diff --git a/gst/rtp/gstrtph263ppay.c b/gst/rtp/gstrtph263ppay.c
index d948b77f1..50e2029bc 100644
--- a/gst/rtp/gstrtph263ppay.c
+++ b/gst/rtp/gstrtph263ppay.c
@@ -101,48 +101,34 @@ static void gst_rtp_h263p_pay_set_property (GObject * object, guint prop_id,
static void gst_rtp_h263p_pay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static gboolean gst_rtp_h263p_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_h263p_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstCaps *gst_rtp_h263p_pay_sink_getcaps (GstBaseRTPPayload * payload,
- GstPad * pad);
-static GstFlowReturn gst_rtp_h263p_pay_handle_buffer (GstBaseRTPPayload *
+static GstCaps *gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload,
+ GstPad * pad, GstCaps * filter);
+static GstFlowReturn gst_rtp_h263p_pay_handle_buffer (GstRTPBasePayload *
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_static_pad_template (element_class,
- &gst_rtp_h263p_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_h263p_pay_class_init (GstRtpH263PPayClass * klass)
{
GObjectClass *gobject_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->finalize = gst_rtp_h263p_pay_finalize;
gobject_class->set_property = gst_rtp_h263p_pay_set_property;
gobject_class->get_property = gst_rtp_h263p_pay_get_property;
- gstbasertppayload_class->set_caps = gst_rtp_h263p_pay_setcaps;
- gstbasertppayload_class->get_caps = gst_rtp_h263p_pay_sink_getcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_h263p_pay_handle_buffer;
+ gstrtpbasepayload_class->set_caps = gst_rtp_h263p_pay_setcaps;
+ gstrtpbasepayload_class->get_caps = gst_rtp_h263p_pay_sink_getcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_h263p_pay_handle_buffer;
g_object_class_install_property (G_OBJECT_CLASS (klass),
PROP_FRAGMENTATION_MODE, g_param_spec_enum ("fragmentation-mode",
@@ -151,13 +137,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 ();
@@ -178,7 +173,7 @@ gst_rtp_h263p_pay_finalize (GObject * object)
}
static gboolean
-gst_rtp_h263p_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_h263p_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
gboolean res;
GstCaps *peercaps;
@@ -186,10 +181,11 @@ gst_rtp_h263p_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE);
- peercaps = gst_pad_peer_get_caps (GST_BASE_RTP_PAYLOAD_SRCPAD (payload));
+ peercaps =
+ gst_pad_peer_query_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload), NULL);
if (peercaps) {
GstCaps *intersect = gst_caps_intersect (peercaps,
- gst_pad_get_pad_template_caps (GST_BASE_RTP_PAYLOAD_SRCPAD (payload)));
+ gst_pad_get_pad_template_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload)));
gst_caps_unref (peercaps);
if (!gst_caps_is_empty (intersect)) {
@@ -202,9 +198,9 @@ gst_rtp_h263p_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
if (!encoding_name)
encoding_name = g_strdup ("H263-1998");
- gst_basertppayload_set_options (payload, "video", TRUE,
+ gst_rtp_base_payload_set_options (payload, "video", TRUE,
(gchar *) encoding_name, 90000);
- res = gst_basertppayload_set_outcaps (payload, NULL);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
g_free (encoding_name);
return res;
@@ -233,7 +229,8 @@ caps_append (GstCaps * caps, GstStructure * in_s, guint x, guint y, guint mpi)
static GstCaps *
-gst_rtp_h263p_pay_sink_getcaps (GstBaseRTPPayload * payload, GstPad * pad)
+gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad,
+ GstCaps * filter)
{
GstRtpH263PPay *rtph263ppay;
GstCaps *caps = gst_caps_new_empty ();
@@ -243,14 +240,15 @@ gst_rtp_h263p_pay_sink_getcaps (GstBaseRTPPayload * payload, GstPad * pad)
rtph263ppay = GST_RTP_H263P_PAY (payload);
- peercaps = gst_pad_peer_get_caps (GST_BASE_RTP_PAYLOAD_SRCPAD (payload));
+ peercaps =
+ gst_pad_peer_query_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload), filter);
if (!peercaps)
return
gst_caps_copy (gst_pad_get_pad_template_caps
- (GST_BASE_RTP_PAYLOAD_SINKPAD (payload)));
+ (GST_RTP_BASE_PAYLOAD_SINKPAD (payload)));
intersect = gst_caps_intersect (peercaps,
- gst_pad_get_pad_template_caps (GST_BASE_RTP_PAYLOAD_SRCPAD (payload)));
+ gst_pad_get_pad_template_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload)));
gst_caps_unref (peercaps);
if (gst_caps_is_empty (intersect))
@@ -651,13 +649,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 */
@@ -679,6 +678,7 @@ gst_rtp_h263p_pay_flush (GstRtpH263PPay * rtph263ppay)
}
parsed_len++;
}
+ gst_adapter_unmap (rtph263ppay->adapter);
}
/* for picture start frames (non-fragmented), we need to remove the first
@@ -686,7 +686,7 @@ gst_rtp_h263p_pay_flush (GstRtpH263PPay * rtph263ppay)
header_len = (fragmented && !found_gob) ? 2 : 0;
towrite = MIN (avail, gst_rtp_buffer_calc_payload_len
- (GST_BASE_RTP_PAYLOAD_MTU (rtph263ppay) - header_len, 0, 0));
+ (GST_RTP_BASE_PAYLOAD_MTU (rtph263ppay) - header_len, 0, 0));
if (next_gop > 0)
towrite = MIN (next_gop, towrite);
@@ -694,10 +694,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);
@@ -713,10 +715,12 @@ 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);
- ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtph263ppay), outbuf);
+ ret =
+ gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtph263ppay), outbuf);
avail -= towrite;
fragmented = TRUE;
@@ -726,7 +730,7 @@ gst_rtp_h263p_pay_flush (GstRtpH263PPay * rtph263ppay)
}
static GstFlowReturn
-gst_rtp_h263p_pay_handle_buffer (GstBaseRTPPayload * payload,
+gst_rtp_h263p_pay_handle_buffer (GstRTPBasePayload * payload,
GstBuffer * buffer)
{
GstRtpH263PPay *rtph263ppay;
diff --git a/gst/rtp/gstrtph263ppay.h b/gst/rtp/gstrtph263ppay.h
index b01fb843e..7e0531788 100644
--- a/gst/rtp/gstrtph263ppay.h
+++ b/gst/rtp/gstrtph263ppay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_H263P_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -48,7 +48,7 @@ typedef enum
struct _GstRtpH263PPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
GstAdapter *adapter;
GstClockTime first_timestamp;
@@ -58,7 +58,7 @@ struct _GstRtpH263PPay
struct _GstRtpH263PPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_h263p_pay_get_type (void);
diff --git a/gst/rtp/gstrtph264depay.c b/gst/rtp/gstrtph264depay.c
index 27b5d4b9f..a56e376ea 100644
--- a/gst/rtp/gstrtph264depay.c
+++ b/gst/rtp/gstrtph264depay.c
@@ -79,8 +79,9 @@ GST_STATIC_PAD_TEMPLATE ("sink",
/* "max-rcmd-nalu-size = (string) ANY " */
);
-GST_BOILERPLATE (GstRtpH264Depay, gst_rtp_h264_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_h264_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpH264Depay, gst_rtp_h264_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void gst_rtp_h264_depay_finalize (GObject * object);
static void gst_rtp_h264_depay_set_property (GObject * object, guint prop_id,
@@ -91,39 +92,23 @@ static void gst_rtp_h264_depay_get_property (GObject * object, guint prop_id,
static GstStateChangeReturn gst_rtp_h264_depay_change_state (GstElement *
element, GstStateChange transition);
-static GstBuffer *gst_rtp_h264_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_h264_depay_setcaps (GstBaseRTPDepayload * filter,
+static gboolean gst_rtp_h264_depay_setcaps (GstRTPBaseDepayload * filter,
GstCaps * caps);
-static gboolean gst_rtp_h264_depay_handle_event (GstBaseRTPDepayload * depay,
+static gboolean gst_rtp_h264_depay_handle_event (GstRTPBaseDepayload * depay,
GstEvent * event);
static void
-gst_rtp_h264_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_h264_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->finalize = gst_rtp_h264_depay_finalize;
@@ -139,19 +124,27 @@ 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;
- gstbasertpdepayload_class->set_caps = gst_rtp_h264_depay_setcaps;
- gstbasertpdepayload_class->handle_event = gst_rtp_h264_depay_handle_event;
+ gstrtpbasedepayload_class->process = gst_rtp_h264_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_h264_depay_setcaps;
+ gstrtpbasedepayload_class->handle_event = gst_rtp_h264_depay_handle_event;
GST_DEBUG_CATEGORY_INIT (rtph264depay_debug, "rtph264depay", 0,
"H264 Video RTP Depayloader");
}
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 ();
@@ -237,7 +230,7 @@ gst_rtp_h264_depay_negotiate (GstRtpH264Depay * rtph264depay)
gint merge = -1;
caps =
- gst_pad_get_allowed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (rtph264depay));
+ gst_pad_get_allowed_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (rtph264depay));
GST_DEBUG_OBJECT (rtph264depay, "allowed caps: %" GST_PTR_FORMAT, caps);
@@ -289,7 +282,7 @@ gst_rtp_h264_depay_negotiate (GstRtpH264Depay * rtph264depay)
}
static gboolean
-gst_rtp_h264_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_h264_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
gint clock_rate;
@@ -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);
@@ -306,7 +299,7 @@ gst_rtp_h264_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
clock_rate = 90000;
depayload->clock_rate = clock_rate;
- srccaps = gst_caps_new_simple ("video/x-h264", NULL);
+ srccaps = gst_caps_new_empty_simple ("video/x-h264");
/* Base64 encoded, comma separated config NALs */
ps = gst_structure_get_string (structure, "sprop-parameter-sets");
@@ -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);
@@ -510,20 +505,18 @@ static GstBuffer *
gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
GstClockTime in_timestamp, gboolean marker)
{
- GstBaseRTPDepayload *depayload = GST_BASE_RTP_DEPAYLOAD (rtph264depay);
+ GstRTPBaseDepayload *depayload = GST_RTP_BASE_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;
@@ -590,8 +584,6 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
else
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
-
- gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
}
return outbuf;
@@ -600,6 +592,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 NULL;
}
@@ -615,7 +608,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);
@@ -628,6 +621,7 @@ gst_rtp_h264_push_fragmentation_unit (GstRtpH264Depay * rtph264depay,
outdata[2] = (outsize >> 8);
outdata[3] = (outsize);
}
+ gst_buffer_unmap (outbuf, outdata, -1);
rtph264depay->current_fu_type = 0;
@@ -635,7 +629,7 @@ gst_rtp_h264_push_fragmentation_unit (GstRtpH264Depay * rtph264depay,
outbuf = gst_rtp_h264_depay_handle_nal (rtph264depay, outbuf,
rtph264depay->fu_timestamp, rtph264depay->fu_marker);
if (outbuf)
- gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtph264depay),
+ gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtph264depay),
outbuf);
return NULL;
} else {
@@ -645,11 +639,12 @@ gst_rtp_h264_push_fragmentation_unit (GstRtpH264Depay * rtph264depay,
}
static GstBuffer *
-gst_rtp_h264_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpH264Depay *rtph264depay;
GstBuffer *outbuf = NULL;
guint8 nal_unit_type;
+ GstRTPBuffer rtp = { NULL };
rtph264depay = GST_RTP_H264_DEPAY (depayload);
@@ -672,9 +667,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);
@@ -740,7 +737,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 {
@@ -753,8 +751,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);
@@ -827,10 +825,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);
@@ -843,8 +842,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);
@@ -869,7 +870,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 {
@@ -877,14 +879,15 @@ 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);
outbuf = gst_rtp_h264_depay_handle_nal (rtph264depay, outbuf, timestamp,
marker);
break;
}
}
+ gst_rtp_buffer_unmap (&rtp);
}
return outbuf;
@@ -894,23 +897,26 @@ 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;
}
}
static gboolean
-gst_rtp_h264_depay_handle_event (GstBaseRTPDepayload * depay, GstEvent * event)
+gst_rtp_h264_depay_handle_event (GstRTPBaseDepayload * depay, GstEvent * event)
{
GstRtpH264Depay *rtph264depay;
@@ -925,7 +931,7 @@ gst_rtp_h264_depay_handle_event (GstBaseRTPDepayload * depay, GstEvent * event)
}
return
- GST_BASE_RTP_DEPAYLOAD_CLASS (parent_class)->handle_event (depay, event);
+ GST_RTP_BASE_DEPAYLOAD_CLASS (parent_class)->handle_event (depay, event);
}
static GstStateChangeReturn
diff --git a/gst/rtp/gstrtph264depay.h b/gst/rtp/gstrtph264depay.h
index f50ffe6a3..33fdbc51c 100644
--- a/gst/rtp/gstrtph264depay.h
+++ b/gst/rtp/gstrtph264depay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpH264DepayClass GstRtpH264DepayClass;
struct _GstRtpH264Depay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
gboolean byte_stream;
@@ -65,7 +65,7 @@ struct _GstRtpH264Depay
struct _GstRtpH264DepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_h264_depay_get_type (void);
diff --git a/gst/rtp/gstrtph264pay.c b/gst/rtp/gstrtph264pay.c
index b648f0847..d092342f4 100644
--- a/gst/rtp/gstrtph264pay.c
+++ b/gst/rtp/gstrtph264pay.c
@@ -110,45 +110,30 @@ static void gst_rtp_h264_pay_set_property (GObject * object, guint prop_id,
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);
-static gboolean gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload,
+static GstCaps *gst_rtp_h264_pay_getcaps (GstRTPBasePayload * payload,
+ GstPad * pad, GstCaps * filter);
+static gboolean gst_rtp_h264_pay_setcaps (GstRTPBasePayload * basepayload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * pad,
+static GstFlowReturn gst_rtp_h264_pay_handle_buffer (GstRTPBasePayload * pad,
GstBuffer * buffer);
-static gboolean gst_rtp_h264_pay_handle_event (GstPad * pad, GstEvent * event);
-static GstStateChangeReturn gst_basertppayload_change_state (GstElement *
+static gboolean gst_rtp_h264_pay_sink_event (GstRTPBasePayload * payload,
+ GstEvent * event);
+static GstStateChangeReturn gst_rtp_h264_pay_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_static_pad_template (element_class,
- &gst_rtp_h264_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_h264_pay_class_init (GstRtpH264PayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->set_property = gst_rtp_h264_pay_set_property;
gobject_class->get_property = gst_rtp_h264_pay_get_property;
@@ -192,20 +177,30 @@ 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);
+ GST_DEBUG_FUNCPTR (gst_rtp_h264_pay_change_state);
- gstbasertppayload_class->get_caps = gst_rtp_h264_pay_getcaps;
- gstbasertppayload_class->set_caps = gst_rtp_h264_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_h264_pay_handle_buffer;
- gstbasertppayload_class->handle_event = gst_rtp_h264_pay_handle_event;
+ gstrtpbasepayload_class->get_caps = gst_rtp_h264_pay_getcaps;
+ gstrtpbasepayload_class->set_caps = gst_rtp_h264_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_h264_pay_handle_buffer;
+ gstrtpbasepayload_class->sink_event = gst_rtp_h264_pay_sink_event;
GST_DEBUG_CATEGORY_INIT (rtph264pay_debug, "rtph264pay", 0,
"H264 RTP Payloader");
}
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 (GstRTPBasePayload * 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_query_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload), filter);
if (allowed_caps) {
GstCaps *caps = NULL;
@@ -292,7 +288,7 @@ gst_rtp_h264_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad)
for (i = 0; i < gst_caps_get_size (allowed_caps); i++) {
GstStructure *s = gst_caps_get_structure (allowed_caps, i);
- GstStructure *new_s = gst_structure_new ("video/x-h264", NULL);
+ GstStructure *new_s = gst_structure_new_empty ("video/x-h264");
const gchar *profile_level_id;
profile_level_id = gst_structure_get_string (s, "profile-level-id");
@@ -362,13 +358,13 @@ gst_rtp_h264_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad)
}
any:
- return gst_caps_new_simple ("video/x-h264", NULL);
+ return gst_caps_new_empty_simple ("video/x-h264");
}
/* take the currently configured SPS and PPS lists and set them on the caps as
* sprop-parameter-sets */
static gboolean
-gst_rtp_h264_pay_set_sps_pps (GstBaseRTPPayload * basepayload)
+gst_rtp_h264_pay_set_sps_pps (GstRTPBasePayload * basepayload)
{
GstRtpH264Pay *payloader = GST_RTP_H264_PAY (basepayload);
gchar *profile;
@@ -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++;
@@ -404,7 +406,7 @@ gst_rtp_h264_pay_set_sps_pps (GstBaseRTPPayload * basepayload)
/* profile is 24 bit. Force it to respect the limit */
profile = g_strdup_printf ("%06x", payloader->profile & 0xffffff);
/* combine into output caps */
- res = gst_basertppayload_set_outcaps (basepayload,
+ res = gst_rtp_base_payload_set_outcaps (basepayload,
"sprop-parameter-sets", G_TYPE_STRING, sprops->str, NULL);
g_string_free (sprops, TRUE);
g_free (profile);
@@ -413,13 +415,14 @@ gst_rtp_h264_pay_set_sps_pps (GstBaseRTPPayload * basepayload)
}
static gboolean
-gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
+gst_rtp_h264_pay_setcaps (GstRTPBasePayload * 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);
@@ -428,7 +431,7 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
/* we can only set the output caps when we found the sprops and profile
* NALs */
- gst_basertppayload_set_options (basepayload, "video", TRUE, "H264", 90000);
+ gst_rtp_base_payload_set_options (basepayload, "video", TRUE, "H264", 90000);
alignment = gst_structure_get_string (str, "alignment");
if (alignment && !strcmp (alignment, "au"))
@@ -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;
@@ -542,17 +546,27 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
avcc_too_small:
{
- GST_ERROR_OBJECT (rtph264pay, "avcC size %u < 7", size);
- return FALSE;
+ GST_ERROR_OBJECT (rtph264pay, "avcC size %" G_GSIZE_FORMAT " < 7", size);
+ 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 */
@@ -768,25 +782,28 @@ gst_rtp_h264_pay_decode_nal (GstRtpH264Pay * payloader,
}
static GstFlowReturn
-gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
+gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload,
const guint8 * data, guint size, GstClockTime timestamp,
GstBuffer * buffer_orig, gboolean end_of_au);
static GstFlowReturn
-gst_rtp_h264_pay_send_sps_pps (GstBaseRTPPayload * basepayload,
+gst_rtp_h264_pay_send_sps_pps (GstRTPBasePayload * basepayload,
GstRtpH264Pay * rtph264pay, GstClockTime timestamp)
{
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");
@@ -811,7 +829,7 @@ gst_rtp_h264_pay_send_sps_pps (GstBaseRTPPayload * basepayload,
}
static GstFlowReturn
-gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
+gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload,
const guint8 * data, guint size, GstClockTime timestamp,
GstBuffer * buffer_orig, gboolean end_of_au)
{
@@ -821,12 +839,14 @@ 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);
+ mtu = GST_RTP_BASE_PAYLOAD_MTU (rtph264pay);
nalType = data[0] & 0x1f;
GST_DEBUG_OBJECT (rtph264pay, "Processing Buffer with NAL TYPE=%d", nalType);
@@ -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,27 +934,26 @@ 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);
+ ret = gst_rtp_base_payload_push_list (basepayload, list);
+ } 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);
+ ret = gst_rtp_base_payload_push (basepayload, outbuf);
}
} else {
/* fragmentation Units FU-A */
@@ -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,13 +1043,16 @@ 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);
- ret = gst_basertppayload_push (basepayload, outbuf);
+ ret = gst_rtp_base_payload_push (basepayload, outbuf);
if (ret != GST_FLOW_OK)
break;
}
@@ -1027,46 +1063,56 @@ 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);
+ ret = gst_rtp_base_payload_push_list (basepayload, list);
}
+#endif
}
return ret;
}
static GstFlowReturn
-gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_h264_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
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);
- GST_DEBUG_OBJECT (basepayload, "got %d bytes (%d)", size,
- GST_BUFFER_SIZE (buffer));
+ data = gst_adapter_map (rtph264pay->adapter, size);
+ GST_DEBUG_OBJECT (basepayload,
+ "got %" G_GSIZE_FORMAT " bytes (%" G_GSIZE_FORMAT ")", size,
+ 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);
+ GST_DEBUG_OBJECT (basepayload, "got %" G_GSIZE_FORMAT " bytes", size);
}
ret = GST_FLOW_OK;
@@ -1134,8 +1180,8 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
/* array must be empty when we get here */
g_assert (nal_queue->len == 0);
- GST_DEBUG_OBJECT (basepayload, "found first start at %u, bytes left %u",
- next, size);
+ GST_DEBUG_OBJECT (basepayload,
+ "found first start at %u, bytes left %" G_GSIZE_FORMAT, next, size);
/* first pass to locate NALs and parse SPS/PPS */
while (size > 4) {
@@ -1173,7 +1219,7 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
if (rtph264pay->sprop_parameter_sets != NULL) {
/* explicitly set profile and sprop, use those */
if (rtph264pay->update_caps) {
- if (!gst_basertppayload_set_outcaps (basepayload,
+ if (!gst_rtp_base_payload_set_outcaps (basepayload,
"sprop-parameter-sets", G_TYPE_STRING,
rtph264pay->sprop_parameter_sets, NULL))
goto caps_rejected;
@@ -1256,10 +1302,14 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
g_array_set_size (nal_queue, 0);
}
- if (rtph264pay->scan_mode == GST_H264_SCAN_MODE_BYTESTREAM)
+done:
+ if (bytestream) {
+ gst_adapter_unmap (rtph264pay->adapter);
gst_adapter_flush (rtph264pay->adapter, pushed);
- else
+ } else {
+ gst_buffer_unmap (buffer, bdata, bsize);
gst_buffer_unref (buffer);
+ }
return ret;
@@ -1267,16 +1317,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_sink_event (GstRTPBasePayload * 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,12 +1347,13 @@ gst_rtp_h264_pay_handle_event (GstPad * pad, GstEvent * event)
break;
}
- return FALSE;
+ res = GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->sink_event (payload, event);
+
+ return res;
}
static GstStateChangeReturn
-gst_basertppayload_change_state (GstElement * element,
- GstStateChange transition)
+gst_rtp_h264_pay_change_state (GstElement * element, GstStateChange transition)
{
GstStateChangeReturn ret;
GstRtpH264Pay *rtph264pay = GST_RTP_H264_PAY (element);
diff --git a/gst/rtp/gstrtph264pay.h b/gst/rtp/gstrtph264pay.h
index 6303e308a..5438e9b69 100644
--- a/gst/rtp/gstrtph264pay.h
+++ b/gst/rtp/gstrtph264pay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
G_BEGIN_DECLS
@@ -49,7 +49,7 @@ typedef struct _GstRtpH264PayClass GstRtpH264PayClass;
struct _GstRtpH264Pay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
guint profile;
GList *sps, *pps;
@@ -74,7 +74,7 @@ struct _GstRtpH264Pay
struct _GstRtpH264PayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_h264_pay_get_type (void);
diff --git a/gst/rtp/gstrtpilbcdepay.c b/gst/rtp/gstrtpilbcdepay.c
index 0cdf23f4d..813e699dd 100644
--- a/gst/rtp/gstrtpilbcdepay.c
+++ b/gst/rtp/gstrtpilbcdepay.c
@@ -66,13 +66,14 @@ static void gst_ilbc_depay_set_property (GObject * object,
static void gst_ilbc_depay_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
-static GstBuffer *gst_rtp_ilbc_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_ilbc_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_ilbc_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_ilbc_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-GST_BOILERPLATE (GstRTPiLBCDepay, gst_rtp_ilbc_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_ilbc_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPiLBCDepay, gst_rtp_ilbc_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
#define GST_TYPE_ILBC_MODE (gst_ilbc_mode_get_type())
static GType
@@ -92,28 +93,15 @@ 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_static_pad_template (element_class,
- &gst_rtp_ilbc_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->set_property = gst_ilbc_depay_set_property;
gobject_class->get_property = gst_ilbc_depay_get_property;
@@ -124,20 +112,29 @@ gst_rtp_ilbc_depay_class_init (GstRTPiLBCDepayClass * klass)
GST_TYPE_ILBC_MODE, DEFAULT_MODE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- gstbasertpdepayload_class->process = gst_rtp_ilbc_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_ilbc_depay_setcaps;
+ 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>");
+
+ gstrtpbasedepayload_class->process = gst_rtp_ilbc_depay_process;
+ gstrtpbasedepayload_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;
}
static gboolean
-gst_rtp_ilbc_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_ilbc_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstRTPiLBCDepay *rtpilbcdepay = GST_RTP_ILBC_DEPAY (depayload);
GstCaps *srccaps;
@@ -166,7 +163,7 @@ gst_rtp_ilbc_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
srccaps = gst_caps_new_simple ("audio/x-iLBC",
"mode", G_TYPE_INT, rtpilbcdepay->mode, NULL);
- ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
GST_DEBUG ("set caps on source: %" GST_PTR_FORMAT " (ret=%d)", srccaps, ret);
gst_caps_unref (srccaps);
@@ -175,18 +172,23 @@ gst_rtp_ilbc_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
}
static GstBuffer *
-gst_rtp_ilbc_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_ilbc_depay_process (GstRTPBaseDepayload * 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 (&rtp);
- marker = gst_rtp_buffer_get_marker (buf);
+ GST_DEBUG ("process : got %" G_GSIZE_FORMAT " bytes, mark %d ts %u seqn %d",
+ gst_buffer_get_size (buf), marker,
+ gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&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));
+ 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 */
diff --git a/gst/rtp/gstrtpilbcdepay.h b/gst/rtp/gstrtpilbcdepay.h
index ce8c38d5b..18db32759 100644
--- a/gst/rtp/gstrtpilbcdepay.h
+++ b/gst/rtp/gstrtpilbcdepay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_ILBC_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -46,14 +46,14 @@ typedef enum {
struct _GstRTPiLBCDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
GstiLBCMode mode;
};
struct _GstRTPiLBCDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_ilbc_depay_get_type (void);
diff --git a/gst/rtp/gstrtpilbcpay.c b/gst/rtp/gstrtpilbcpay.c
index 677f5e26a..8dbb6aab6 100644
--- a/gst/rtp/gstrtpilbcpay.c
+++ b/gst/rtp/gstrtpilbcpay.c
@@ -48,76 +48,74 @@ GST_STATIC_PAD_TEMPLATE ("src",
);
-static GstCaps *gst_rtp_ilbc_pay_sink_getcaps (GstBaseRTPPayload * payload,
- GstPad * pad);
-static gboolean gst_rtp_ilbc_pay_sink_setcaps (GstBaseRTPPayload * payload,
+static GstCaps *gst_rtp_ilbc_pay_sink_getcaps (GstRTPBasePayload * payload,
+ GstPad * pad, GstCaps * filter);
+static gboolean gst_rtp_ilbc_pay_sink_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-GST_BOILERPLATE (GstRTPILBCPay, gst_rtp_ilbc_pay, GstBaseRTPAudioPayload,
- GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
+#define gst_rtp_ilbc_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRTPILBCPay, gst_rtp_ilbc_pay,
+ GST_TYPE_RTP_BASE_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;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_ilbc_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_ilbc_pay_src_template);
- gst_element_class_set_details_simple (element_class, "RTP iLBC Payloader",
- "Codec/Payloader/Network/RTP",
- "Packetize iLBC audio streams into RTP packets",
- "Philippe Kalaf <philippe.kalaf@collabora.co.uk>");
-}
+ GST_DEBUG_CATEGORY_INIT (rtpilbcpay_debug, "rtpilbcpay", 0,
+ "iLBC audio RTP payloader");
-static void
-gst_rtp_ilbc_pay_class_init (GstRTPILBCPayClass * klass)
-{
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_ilbc_pay_src_template));
- gstbasertppayload_class->set_caps = gst_rtp_ilbc_pay_sink_setcaps;
- gstbasertppayload_class->get_caps = gst_rtp_ilbc_pay_sink_getcaps;
+ 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>");
- GST_DEBUG_CATEGORY_INIT (rtpilbcpay_debug, "rtpilbcpay", 0,
- "iLBC audio RTP payloader");
+ gstrtpbasepayload_class->set_caps = gst_rtp_ilbc_pay_sink_setcaps;
+ gstrtpbasepayload_class->get_caps = gst_rtp_ilbc_pay_sink_getcaps;
}
static void
-gst_rtp_ilbc_pay_init (GstRTPILBCPay * rtpilbcpay, GstRTPILBCPayClass * klass)
+gst_rtp_ilbc_pay_init (GstRTPILBCPay * rtpilbcpay)
{
- GstBaseRTPPayload *basertppayload;
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBasePayload *rtpbasepayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
- basertppayload = GST_BASE_RTP_PAYLOAD (rtpilbcpay);
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtpilbcpay);
+ rtpbasepayload = GST_RTP_BASE_PAYLOAD (rtpilbcpay);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpilbcpay);
/* we don't set the payload type, it should be set by the application using
* the pt property or the default 96 will be used */
- basertppayload->clock_rate = 8000;
+ rtpbasepayload->clock_rate = 8000;
rtpilbcpay->mode = -1;
- /* tell basertpaudiopayload that this is a frame based codec */
- gst_base_rtp_audio_payload_set_frame_based (basertpaudiopayload);
+ /* tell rtpbaseaudiopayload that this is a frame based codec */
+ gst_rtp_base_audio_payload_set_frame_based (rtpbaseaudiopayload);
}
static gboolean
-gst_rtp_ilbc_pay_sink_setcaps (GstBaseRTPPayload * basertppayload,
+gst_rtp_ilbc_pay_sink_setcaps (GstRTPBasePayload * rtpbasepayload,
GstCaps * caps)
{
GstRTPILBCPay *rtpilbcpay;
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
gboolean ret;
gint mode;
gchar *mode_str;
GstStructure *structure;
const char *payload_name;
- rtpilbcpay = GST_RTP_ILBC_PAY (basertppayload);
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (basertppayload);
+ rtpilbcpay = GST_RTP_ILBC_PAY (rtpbasepayload);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpbasepayload);
structure = gst_caps_get_structure (caps, 0);
@@ -131,14 +129,15 @@ gst_rtp_ilbc_pay_sink_setcaps (GstBaseRTPPayload * basertppayload,
if (mode != 20 && mode != 30)
goto wrong_mode;
- gst_basertppayload_set_options (basertppayload, "audio", TRUE, "ILBC", 8000);
+ gst_rtp_base_payload_set_options (rtpbasepayload, "audio", TRUE, "ILBC",
+ 8000);
/* set options for this frame based audio codec */
- gst_base_rtp_audio_payload_set_frame_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_frame_options (rtpbaseaudiopayload,
mode, mode == 30 ? 50 : 38);
mode_str = g_strdup_printf ("%d", mode);
ret =
- gst_basertppayload_set_outcaps (basertppayload, "mode", G_TYPE_STRING,
+ gst_rtp_base_payload_set_outcaps (rtpbasepayload, "mode", G_TYPE_STRING,
mode_str, NULL);
g_free (mode_str);
@@ -177,7 +176,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 (GstRTPBasePayload * rtppayload, GstPad * pad,
+ GstCaps * filter)
{
GstCaps *otherpadcaps;
GstCaps *caps;
diff --git a/gst/rtp/gstrtpilbcpay.h b/gst/rtp/gstrtpilbcpay.h
index 80713628f..daa369708 100644
--- a/gst/rtp/gstrtpilbcpay.h
+++ b/gst/rtp/gstrtpilbcpay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_ILBC_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpaudiopayload.h>
+#include <gst/rtp/gstrtpbaseaudiopayload.h>
G_BEGIN_DECLS
@@ -41,14 +41,14 @@ typedef struct _GstRTPILBCPayClass GstRTPILBCPayClass;
struct _GstRTPILBCPay
{
- GstBaseRTPAudioPayload audiopayload;
+ GstRTPBaseAudioPayload audiopayload;
gint mode;
};
struct _GstRTPILBCPayClass
{
- GstBaseRTPAudioPayloadClass parent_class;
+ GstRTPBaseAudioPayloadClass parent_class;
};
GType gst_rtp_ilbc_pay_get_type (void);
diff --git a/gst/rtp/gstrtpj2kdepay.c b/gst/rtp/gstrtpj2kdepay.c
index 799a0ada3..c09c18897 100644
--- a/gst/rtp/gstrtpj2kdepay.c
+++ b/gst/rtp/gstrtpj2kdepay.c
@@ -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_RTP_BASE_DEPAYLOAD);
static void gst_rtp_j2k_depay_finalize (GObject * object);
@@ -79,37 +79,21 @@ static GstStateChangeReturn
gst_rtp_j2k_depay_change_state (GstElement * element,
GstStateChange transition);
-static gboolean gst_rtp_j2k_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_j2k_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_j2k_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_j2k_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
static void
-gst_rtp_j2k_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_j2k_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->finalize = gst_rtp_j2k_depay_finalize;
@@ -121,18 +105,27 @@ 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;
- gstbasertpdepayload_class->process = gst_rtp_j2k_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_j2k_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_j2k_depay_process;
GST_DEBUG_CATEGORY_INIT (rtpj2kdepay_debug, "rtpj2kdepay", 0,
"J2K Video RTP Depayloader");
}
static void
-gst_rtp_j2k_depay_init (GstRtpJ2KDepay * rtpj2kdepay,
- GstRtpJ2KDepayClass * klass)
+gst_rtp_j2k_depay_init (GstRtpJ2KDepay * rtpj2kdepay)
{
rtpj2kdepay->buffer_list = DEFAULT_BUFFER_LIST;
@@ -189,7 +182,7 @@ gst_rtp_j2k_depay_finalize (GObject * object)
}
static gboolean
-gst_rtp_j2k_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_j2k_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
gint clock_rate;
@@ -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);
@@ -220,7 +212,7 @@ gst_rtp_j2k_depay_clear_pu (GstRtpJ2KDepay * rtpj2kdepay)
}
static GstFlowReturn
-gst_rtp_j2k_depay_flush_pu (GstBaseRTPDepayload * depayload)
+gst_rtp_j2k_depay_flush_pu (GstRTPBaseDepayload * depayload)
{
GstRtpJ2KDepay *rtpj2kdepay;
GstBuffer *mheader;
@@ -245,8 +237,9 @@ gst_rtp_j2k_depay_flush_pu (GstBaseRTPDepayload * depayload)
/* append packets */
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_DEBUG_OBJECT (rtpj2kdepay,
+ "append pu packet of size %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (buf));
gst_adapter_push (rtpj2kdepay->t_adapter, buf);
}
g_list_free (packets);
@@ -267,13 +260,16 @@ done:
}
static GstFlowReturn
-gst_rtp_j2k_depay_flush_tile (GstBaseRTPDepayload * depayload)
+gst_rtp_j2k_depay_flush_tile (GstRTPBaseDepayload * depayload)
{
GstRtpJ2KDepay *rtpj2kdepay;
guint avail, mh_id;
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 +303,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 +324,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_DEBUG_OBJECT (rtpj2kdepay, "append pu packet of size %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (buf));
gst_adapter_push (rtpj2kdepay->f_adapter, buf);
}
g_list_free (packets);
@@ -361,6 +357,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;
@@ -368,11 +365,10 @@ invalid_tile:
}
static GstFlowReturn
-gst_rtp_j2k_depay_flush_frame (GstBaseRTPDepayload * depayload)
+gst_rtp_j2k_depay_flush_frame (GstRTPBaseDepayload * depayload)
{
GstRtpJ2KDepay *rtpj2kdepay;
guint8 end[2];
- guint8 *data;
guint avail;
GstFlowReturn ret = GST_FLOW_OK;
@@ -395,18 +391,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;
@@ -421,11 +418,13 @@ gst_rtp_j2k_depay_flush_frame (GstBaseRTPDepayload * depayload)
gst_buffer_list_iterator_add_list (it, list);
gst_buffer_list_iterator_free (it);
- ret = gst_base_rtp_depayload_push_list (depayload, buflist);
- } else {
+ ret = gst_rtp_base_depayload_push_list (depayload, buflist);
+ } 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);
+ ret = gst_rtp_base_depayload_push (depayload, outbuf);
}
} else {
GST_WARNING_OBJECT (rtpj2kdepay, "empty packet");
@@ -447,24 +446,27 @@ done:
}
static GstBuffer *
-gst_rtp_j2k_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_j2k_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpJ2KDepay *rtpj2kdepay;
guint8 *payload;
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 +563,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 +576,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 +590,7 @@ empty_packet:
{
GST_ELEMENT_WARNING (rtpj2kdepay, STREAM, DECODE,
("Empty Payload."), (NULL));
+ gst_rtp_buffer_unmap (&rtp);
return NULL;
}
wrong_mh_id:
@@ -594,6 +599,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;
}
}
diff --git a/gst/rtp/gstrtpj2kdepay.h b/gst/rtp/gstrtpj2kdepay.h
index 40373b264..cea9869e5 100644
--- a/gst/rtp/gstrtpj2kdepay.h
+++ b/gst/rtp/gstrtpj2kdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpJ2KDepayClass GstRtpJ2KDepayClass;
struct _GstRtpJ2KDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
guint64 last_rtptime;
guint last_mh_id;
@@ -64,7 +64,7 @@ struct _GstRtpJ2KDepay
struct _GstRtpJ2KDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_j2k_depay_get_type (void);
diff --git a/gst/rtp/gstrtpj2kpay.c b/gst/rtp/gstrtpj2kpay.c
index ef06a714c..0eb8c3dce 100644
--- a/gst/rtp/gstrtpj2kpay.c
+++ b/gst/rtp/gstrtpj2kpay.c
@@ -105,39 +105,25 @@ static void gst_rtp_j2k_pay_set_property (GObject * object, guint prop_id,
static void gst_rtp_j2k_pay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static gboolean gst_rtp_j2k_pay_setcaps (GstBaseRTPPayload * basepayload,
+static gboolean gst_rtp_j2k_pay_setcaps (GstRTPBasePayload * basepayload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * pad,
+static GstFlowReturn gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * 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_static_pad_template (element_class,
- &gst_rtp_j2k_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * klass)
{
GObjectClass *gobject_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->set_property = gst_rtp_j2k_pay_set_property;
gobject_class->get_property = gst_rtp_j2k_pay_get_property;
@@ -147,21 +133,31 @@ gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * klass)
"Use Buffer Lists",
DEFAULT_BUFFER_LIST, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- gstbasertppayload_class->set_caps = gst_rtp_j2k_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_j2k_pay_handle_buffer;
+ 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>");
+
+ gstrtpbasepayload_class->set_caps = gst_rtp_j2k_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_j2k_pay_handle_buffer;
GST_DEBUG_CATEGORY_INIT (rtpj2kpay_debug, "rtpj2kpay", 0,
"JPEG 2000 RTP Payloader");
}
static void
-gst_rtp_j2k_pay_init (GstRtpJ2KPay * pay, GstRtpJ2KPayClass * klass)
+gst_rtp_j2k_pay_init (GstRtpJ2KPay * pay)
{
pay->buffer_list = DEFAULT_BUFFER_LIST;
}
static gboolean
-gst_rtp_j2k_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
+gst_rtp_j2k_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
{
GstStructure *caps_structure = gst_caps_get_structure (caps, 0);
GstRtpJ2KPay *pay;
@@ -178,9 +174,9 @@ gst_rtp_j2k_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
pay->width = width;
}
- gst_basertppayload_set_options (basepayload, "video", TRUE, "JPEG2000",
+ gst_rtp_base_payload_set_options (basepayload, "video", TRUE, "JPEG2000",
90000);
- res = gst_basertppayload_set_outcaps (basepayload, NULL);
+ res = gst_rtp_base_payload_set_outcaps (basepayload, NULL);
return res;
}
@@ -329,30 +325,31 @@ find_pu_end (GstRtpJ2KPay * pay, const guint8 * data, guint size,
}
static GstFlowReturn
-gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
GstRtpJ2KPay *pay;
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;
pay = GST_RTP_J2K_PAY (basepayload);
- mtu = GST_BASE_RTP_PAYLOAD_MTU (pay);
+ mtu = GST_RTP_BASE_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;
- GST_LOG_OBJECT (pay, "got buffer size %u, timestamp %" GST_TIME_FORMAT, size,
+ GST_LOG_OBJECT (pay,
+ "got buffer size %" G_GSIZE_FORMAT ", timestamp %" GST_TIME_FORMAT, size,
GST_TIME_ARGS (timestamp));
/* do some header defaults first */
@@ -368,10 +365,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 +380,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 +440,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 +469,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 +501,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,11 +514,14 @@ 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);
+ ret = gst_rtp_base_payload_push (basepayload, outbuf);
if (ret != GST_FLOW_OK)
goto done;
}
@@ -530,11 +539,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);
+ ret = gst_rtp_base_payload_push_list (basepayload, list);
}
+#endif
return ret;
}
diff --git a/gst/rtp/gstrtpj2kpay.h b/gst/rtp/gstrtpj2kpay.h
index 3042a3c13..83b9ec2c7 100644
--- a/gst/rtp/gstrtpj2kpay.h
+++ b/gst/rtp/gstrtpj2kpay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_J2K_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
G_BEGIN_DECLS
@@ -41,7 +41,7 @@ typedef struct _GstRtpJ2KPayClass GstRtpJ2KPayClass;
struct _GstRtpJ2KPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
gboolean buffer_list;
@@ -51,7 +51,7 @@ struct _GstRtpJ2KPay
struct _GstRtpJ2KPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_j2k_pay_get_type (void);
diff --git a/gst/rtp/gstrtpjpegdepay.c b/gst/rtp/gstrtpjpegdepay.c
index 3c84397ff..38be010f8 100644
--- a/gst/rtp/gstrtpjpegdepay.c
+++ b/gst/rtp/gstrtpjpegdepay.c
@@ -66,60 +66,54 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template =
)
);
-GST_BOILERPLATE (GstRtpJPEGDepay, gst_rtp_jpeg_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_jpeg_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpJPEGDepay, gst_rtp_jpeg_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void gst_rtp_jpeg_depay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_jpeg_depay_change_state (GstElement *
element, GstStateChange transition);
-static gboolean gst_rtp_jpeg_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
static void
-gst_rtp_jpeg_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_jpeg_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) 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;
- gstbasertpdepayload_class->process = gst_rtp_jpeg_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_jpeg_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_jpeg_depay_process;
GST_DEBUG_CATEGORY_INIT (rtpjpegdepay_debug, "rtpjpegdepay", 0,
"JPEG Video RTP Depayloader");
}
static void
-gst_rtp_jpeg_depay_init (GstRtpJPEGDepay * rtpjpegdepay,
- GstRtpJPEGDepayClass * klass)
+gst_rtp_jpeg_depay_init (GstRtpJPEGDepay * rtpjpegdepay)
{
rtpjpegdepay->adapter = gst_adapter_new ();
}
@@ -418,7 +412,7 @@ MakeHeaders (guint8 * p, int type, int width, int height, guint8 * qt,
};
static gboolean
-gst_rtp_jpeg_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstRtpJPEGDepay *rtpjpegdepay;
GstStructure *structure;
@@ -483,7 +477,7 @@ gst_rtp_jpeg_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
}
static GstBuffer *
-gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpJPEGDepay *rtpjpegdepay;
GstBuffer *outbuf;
@@ -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 = { NULL };
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,22 @@ 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_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 +678,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 +696,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 +705,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;
}
}
diff --git a/gst/rtp/gstrtpjpegdepay.h b/gst/rtp/gstrtpjpegdepay.h
index 11e6f31a5..0b9757056 100644
--- a/gst/rtp/gstrtpjpegdepay.h
+++ b/gst/rtp/gstrtpjpegdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpJPEGDepayClass GstRtpJPEGDepayClass;
struct _GstRtpJPEGDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
GstAdapter *adapter;
gboolean discont;
@@ -58,7 +58,7 @@ struct _GstRtpJPEGDepay
struct _GstRtpJPEGDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_jpeg_depay_get_type (void);
diff --git a/gst/rtp/gstrtpjpegpay.c b/gst/rtp/gstrtpjpegpay.c
index eae2840f0..6898377d1 100644
--- a/gst/rtp/gstrtpjpegpay.c
+++ b/gst/rtp/gstrtpjpegpay.c
@@ -230,45 +230,41 @@ static void gst_rtp_jpeg_pay_set_property (GObject * object, guint prop_id,
static void gst_rtp_jpeg_pay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static gboolean gst_rtp_jpeg_pay_setcaps (GstBaseRTPPayload * basepayload,
+static gboolean gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * pad,
+static GstFlowReturn gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * 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_static_pad_template (element_class,
- &gst_rtp_jpeg_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_jpeg_pay_class_init (GstRtpJPEGPayClass * klass)
{
GObjectClass *gobject_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->set_property = gst_rtp_jpeg_pay_set_property;
gobject_class->get_property = gst_rtp_jpeg_pay_get_property;
- gstbasertppayload_class->set_caps = gst_rtp_jpeg_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_jpeg_pay_handle_buffer;
+ 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>");
+
+ gstrtpbasepayload_class->set_caps = gst_rtp_jpeg_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_jpeg_pay_handle_buffer;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_JPEG_QUALITY,
g_param_spec_int ("quality", "Quality",
@@ -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;
@@ -299,7 +295,7 @@ gst_rtp_jpeg_pay_init (GstRtpJPEGPay * pay, GstRtpJPEGPayClass * klass)
}
static gboolean
-gst_rtp_jpeg_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
+gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
{
GstStructure *caps_structure = gst_caps_get_structure (caps, 0);
GstRtpJPEGPay *pay;
@@ -322,8 +318,8 @@ gst_rtp_jpeg_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
}
pay->width = GST_ROUND_UP_8 (width) / 8;
- gst_basertppayload_set_options (basepayload, "video", TRUE, "JPEG", 90000);
- res = gst_basertppayload_set_outcaps (basepayload, NULL);
+ gst_rtp_base_payload_set_options (basepayload, "video", TRUE, "JPEG", 90000);
+ res = gst_rtp_base_payload_set_outcaps (basepayload, NULL);
return res;
@@ -599,7 +595,7 @@ gst_rtp_jpeg_pay_scan_marker (const guint8 * data, guint size, guint * offset)
}
static GstFlowReturn
-gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
GstRtpJPEGPay *pay;
@@ -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);
+ mtu = GST_RTP_BASE_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 = { NULL };
- 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,21 +804,22 @@ 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);
+ ret = gst_rtp_base_payload_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);
+ ret = gst_rtp_base_payload_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;
}
diff --git a/gst/rtp/gstrtpjpegpay.h b/gst/rtp/gstrtpjpegpay.h
index 5d003c419..d7717d755 100644
--- a/gst/rtp/gstrtpjpegpay.h
+++ b/gst/rtp/gstrtpjpegpay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_JPEG_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
G_BEGIN_DECLS
#define GST_TYPE_RTP_JPEG_PAY \
@@ -39,7 +39,7 @@ typedef struct _GstRtpJPEGPayClass GstRtpJPEGPayClass;
struct _GstRtpJPEGPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
guint8 quality;
guint8 type;
@@ -54,7 +54,7 @@ struct _GstRtpJPEGPay
struct _GstRtpJPEGPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_jpeg_pay_get_type (void);
diff --git a/gst/rtp/gstrtpmp1sdepay.c b/gst/rtp/gstrtpmp1sdepay.c
index e7ff2fb9e..fd83dd095 100644
--- a/gst/rtp/gstrtpmp1sdepay.c
+++ b/gst/rtp/gstrtpmp1sdepay.c
@@ -62,49 +62,44 @@ 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,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+G_DEFINE_TYPE (GstRtpMP1SDepay, gst_rtp_mp1s_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
-static gboolean gst_rtp_mp1s_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_mp1s_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_mp1s_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_mp1s_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
static void
-gst_rtp_mp1s_depay_base_init (gpointer klass)
+gst_rtp_mp1s_depay_class_init (GstRtpMP1SDepayClass * klass)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
+
+ gstrtpbasedepayload_class->process = gst_rtp_mp1s_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_mp1s_depay_setcaps;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_mp1s_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_mp1s_depay_sink_template);
+ 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 (element_class,
+ 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_class_init (GstRtpMP1SDepayClass * klass)
-{
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
-
- gstbasertpdepayload_class->process = gst_rtp_mp1s_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_mp1s_depay_setcaps;
-}
-
-static void
-gst_rtp_mp1s_depay_init (GstRtpMP1SDepay * rtpmp1sdepay,
- GstRtpMP1SDepayClass * klass)
+gst_rtp_mp1s_depay_init (GstRtpMP1SDepay * rtpmp1sdepay)
{
}
static gboolean
-gst_rtp_mp1s_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_mp1s_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
GstStructure *structure;
@@ -118,22 +113,25 @@ gst_rtp_mp1s_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
srccaps = gst_caps_new_simple ("video/mpeg",
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
- res = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ res = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return res;
}
static GstBuffer *
-gst_rtp_mp1s_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_mp1s_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstBuffer *outbuf;
+ GstRTPBuffer rtp = { NULL };
- 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_DEBUG ("gst_rtp_mp1s_depay_chain: pushing buffer of size %"
+ G_GSIZE_FORMAT, gst_buffer_get_size (outbuf));
return outbuf;
}
diff --git a/gst/rtp/gstrtpmp1sdepay.h b/gst/rtp/gstrtpmp1sdepay.h
index 42915a71b..5eb413759 100644
--- a/gst/rtp/gstrtpmp1sdepay.h
+++ b/gst/rtp/gstrtpmp1sdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -41,12 +41,12 @@ typedef struct _GstRtpMP1SDepayClass GstRtpMP1SDepayClass;
struct _GstRtpMP1SDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
};
struct _GstRtpMP1SDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_mp1s_depay_get_type (void);
diff --git a/gst/rtp/gstrtpmp2tdepay.c b/gst/rtp/gstrtpmp2tdepay.c
index 609bfba1e..366dcf558 100644
--- a/gst/rtp/gstrtpmp2tdepay.c
+++ b/gst/rtp/gstrtpmp2tdepay.c
@@ -56,7 +56,7 @@ static GstStaticPadTemplate gst_rtp_mp2t_depay_sink_template =
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"video\", "
"payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
- "clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"MP2T-ES\";"
+ "clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"MP2T\";"
/* All optional parameters
*
* "profile-level-id=[1,MAX]"
@@ -68,12 +68,12 @@ static GstStaticPadTemplate gst_rtp_mp2t_depay_sink_template =
"clock-rate = (int) [1, MAX ]")
);
-GST_BOILERPLATE (GstRtpMP2TDepay, gst_rtp_mp2t_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+G_DEFINE_TYPE (GstRtpMP2TDepay, gst_rtp_mp2t_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
-static gboolean gst_rtp_mp2t_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_mp2t_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_mp2t_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_mp2t_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
static void gst_rtp_mp2t_depay_set_property (GObject * object, guint prop_id,
@@ -82,38 +82,33 @@ 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_static_pad_template (element_class,
- &gst_rtp_mp2t_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
-
- gstbasertpdepayload_class->process = gst_rtp_mp2t_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_mp2t_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_mp2t_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_mp2t_depay_setcaps;
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,14 +118,13 @@ 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;
}
static gboolean
-gst_rtp_mp2t_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_mp2t_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
GstStructure *structure;
@@ -145,33 +139,36 @@ gst_rtp_mp2t_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
srccaps = gst_caps_new_simple ("video/mpegts",
"packetsize", G_TYPE_INT, 188,
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
- res = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ res = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return res;
}
static GstBuffer *
-gst_rtp_mp2t_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_mp2t_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpMP2TDepay *rtpmp2tdepay;
GstBuffer *outbuf;
gint payload_len;
+ GstRTPBuffer rtp = { NULL };
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_DEBUG ("gst_rtp_mp2t_depay_chain: pushing buffer of size %"
+ G_GSIZE_FORMAT, 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;
}
}
diff --git a/gst/rtp/gstrtpmp2tdepay.h b/gst/rtp/gstrtpmp2tdepay.h
index 010b5ca9c..87f2b3384 100644
--- a/gst/rtp/gstrtpmp2tdepay.h
+++ b/gst/rtp/gstrtpmp2tdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -41,14 +41,14 @@ typedef struct _GstRtpMP2TDepayClass GstRtpMP2TDepayClass;
struct _GstRtpMP2TDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
guint8 skip_first_bytes;
};
struct _GstRtpMP2TDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_mp2t_depay_get_type (void);
diff --git a/gst/rtp/gstrtpmp2tpay.c b/gst/rtp/gstrtpmp2tpay.c
index 060a92fbd..35461dc49 100644
--- a/gst/rtp/gstrtpmp2tpay.c
+++ b/gst/rtp/gstrtpmp2tpay.c
@@ -42,54 +42,50 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"video\", "
"payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
- "clock-rate = (int) 90000, " "encoding-name = (string) \"MP2T-ES\"")
+ "clock-rate = (int) 90000, " "encoding-name = (string) \"MP2T\"")
);
-static gboolean gst_rtp_mp2t_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_mp2t_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_mp2t_pay_handle_buffer (GstBaseRTPPayload *
+static GstFlowReturn gst_rtp_mp2t_pay_handle_buffer (GstRTPBasePayload *
payload, GstBuffer * buffer);
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_static_pad_template (element_class,
- &gst_rtp_mp2t_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_mp2t_pay_class_init (GstRTPMP2TPayClass * klass)
{
GObjectClass *gobject_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) 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;
+ gstrtpbasepayload_class->set_caps = gst_rtp_mp2t_pay_setcaps;
+ gstrtpbasepayload_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;
+ GST_RTP_BASE_PAYLOAD (rtpmp2tpay)->clock_rate = 90000;
+ GST_RTP_BASE_PAYLOAD_PT (rtpmp2tpay) = GST_RTP_PAYLOAD_MP2T;
rtpmp2tpay->adapter = gst_adapter_new ();
}
@@ -108,12 +104,12 @@ gst_rtp_mp2t_pay_finalize (GObject * object)
}
static gboolean
-gst_rtp_mp2t_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_mp2t_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
gboolean res;
- gst_basertppayload_set_options (payload, "video", TRUE, "MP2T-ES", 90000);
- res = gst_basertppayload_set_outcaps (payload, NULL);
+ gst_rtp_base_payload_set_options (payload, "video", TRUE, "MP2T", 90000);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
return res;
}
@@ -125,23 +121,26 @@ gst_rtp_mp2t_pay_flush (GstRTPMP2TPay * rtpmp2tpay)
guint8 *payload;
GstFlowReturn ret;
GstBuffer *outbuf;
+ GstRTPBuffer rtp = { NULL };
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_DEBUG_OBJECT (rtpmp2tpay, "pushing buffer of size %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (outbuf));
- ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpmp2tpay), outbuf);
+ ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtpmp2tpay), outbuf);
/* flush the adapter content */
gst_adapter_flush (rtpmp2tpay->adapter, avail);
@@ -150,7 +149,7 @@ gst_rtp_mp2t_pay_flush (GstRTPMP2TPay * rtpmp2tpay)
}
static GstFlowReturn
-gst_rtp_mp2t_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_mp2t_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
GstRTPMP2TPay *rtpmp2tpay;
@@ -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);
@@ -179,7 +178,7 @@ gst_rtp_mp2t_pay_handle_buffer (GstBaseRTPPayload * basepayload,
/* if this buffer is going to overflow the packet, flush what we
* have. */
- if (gst_basertppayload_is_filled (basepayload,
+ if (gst_rtp_base_payload_is_filled (basepayload,
packet_len, rtpmp2tpay->duration + duration)) {
ret = gst_rtp_mp2t_pay_flush (rtpmp2tpay);
rtpmp2tpay->first_ts = timestamp;
diff --git a/gst/rtp/gstrtpmp2tpay.h b/gst/rtp/gstrtpmp2tpay.h
index e7a679b48..bd14c1791 100644
--- a/gst/rtp/gstrtpmp2tpay.h
+++ b/gst/rtp/gstrtpmp2tpay.h
@@ -22,7 +22,7 @@
#define __GST_RTP_MP2T_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -43,7 +43,7 @@ typedef struct _GstRTPMP2TPayClass GstRTPMP2TPayClass;
struct _GstRTPMP2TPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
GstAdapter *adapter;
GstClockTime first_ts;
@@ -52,7 +52,7 @@ struct _GstRTPMP2TPay
struct _GstRTPMP2TPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_mp2t_pay_get_type (void);
diff --git a/gst/rtp/gstrtpmp4adepay.c b/gst/rtp/gstrtpmp4adepay.c
index 103d389ce..ffa5774ea 100644
--- a/gst/rtp/gstrtpmp4adepay.c
+++ b/gst/rtp/gstrtpmp4adepay.c
@@ -56,14 +56,15 @@ GST_STATIC_PAD_TEMPLATE ("sink",
)
);
-GST_BOILERPLATE (GstRtpMP4ADepay, gst_rtp_mp4a_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_mp4a_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMP4ADepay, gst_rtp_mp4a_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void gst_rtp_mp4a_depay_finalize (GObject * object);
-static gboolean gst_rtp_mp4a_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_mp4a_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_mp4a_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_mp4a_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
static GstStateChangeReturn gst_rtp_mp4a_depay_change_state (GstElement *
@@ -71,47 +72,40 @@ 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_static_pad_template (element_class,
- &gst_rtp_mp4a_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->finalize = gst_rtp_mp4a_depay_finalize;
gstelement_class->change_state = gst_rtp_mp4a_depay_change_state;
- gstbasertpdepayload_class->process = gst_rtp_mp4a_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_mp4a_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_mp4a_depay_process;
+ gstrtpbasedepayload_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 ();
}
@@ -134,7 +128,7 @@ static const guint aac_sample_rates[] = { 96000, 88200, 64000, 48000,
};
static gboolean
-gst_rtp_mp4a_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_mp4a_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstRtpMP4ADepay *rtpmp4adepay;
@@ -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);
@@ -290,10 +288,12 @@ bad_config:
}
static GstBuffer *
-gst_rtp_mp4a_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_mp4a_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpMP4ADepay *rtpmp4adepay;
GstBuffer *outbuf;
+ GstRTPBuffer rtp = { NULL };
+ 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;
@@ -364,7 +367,7 @@ gst_rtp_mp4a_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
avail -= skip;
GST_BUFFER_TIMESTAMP (tmp) = timestamp;
- gst_base_rtp_depayload_push (depayload, tmp);
+ gst_rtp_base_depayload_push (depayload, tmp);
/* shift ts for next buffers */
if (rtpmp4adepay->frame_len && timestamp != -1
@@ -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;
}
}
diff --git a/gst/rtp/gstrtpmp4adepay.h b/gst/rtp/gstrtpmp4adepay.h
index 33622fcae..82b5b2640 100644
--- a/gst/rtp/gstrtpmp4adepay.h
+++ b/gst/rtp/gstrtpmp4adepay.h
@@ -21,7 +21,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -41,7 +41,7 @@ typedef struct _GstRtpMP4ADepayClass GstRtpMP4ADepayClass;
struct _GstRtpMP4ADepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
GstAdapter *adapter;
guint8 numSubFrames;
guint frame_len;
@@ -49,7 +49,7 @@ struct _GstRtpMP4ADepay
struct _GstRtpMP4ADepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_mp4a_depay_get_type (void);
diff --git a/gst/rtp/gstrtpmp4apay.c b/gst/rtp/gstrtpmp4apay.c
index bfafbd816..9c31fedb9 100644
--- a/gst/rtp/gstrtpmp4apay.c
+++ b/gst/rtp/gstrtpmp4apay.c
@@ -59,49 +59,45 @@ GST_STATIC_PAD_TEMPLATE ("src",
static void gst_rtp_mp4a_pay_finalize (GObject * object);
-static gboolean gst_rtp_mp4a_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_mp4a_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_mp4a_pay_handle_buffer (GstBaseRTPPayload *
+static GstFlowReturn gst_rtp_mp4a_pay_handle_buffer (GstRTPBasePayload *
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_RTP_BASE_PAYLOAD)
- static void gst_rtp_mp4a_pay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_mp4a_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->finalize = gst_rtp_mp4a_pay_finalize;
- gstbasertppayload_class->set_caps = gst_rtp_mp4a_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_mp4a_pay_handle_buffer;
+ gstrtpbasepayload_class->set_caps = gst_rtp_mp4a_pay_setcaps;
+ gstrtpbasepayload_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,31 +182,39 @@ 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 */
too_short:
{
GST_ELEMENT_ERROR (rtpmp4apay, STREAM, FORMAT,
- (NULL), ("config string too short, expected 2 bytes, got %d", size));
+ (NULL),
+ ("config string too short, expected 2 bytes, got %" G_GSIZE_FORMAT,
+ 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;
}
}
@@ -227,7 +230,7 @@ gst_rtp_mp4a_pay_new_caps (GstRtpMP4APay * rtpmp4apay)
gst_value_set_buffer (&v, rtpmp4apay->config);
config = gst_value_serialize (&v);
- res = gst_basertppayload_set_outcaps (GST_BASE_RTP_PAYLOAD (rtpmp4apay),
+ res = gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (rtpmp4apay),
"cpresent", G_TYPE_STRING, "0", "config", G_TYPE_STRING, config, NULL);
g_value_unset (&v);
@@ -237,7 +240,7 @@ gst_rtp_mp4a_pay_new_caps (GstRtpMP4APay * rtpmp4apay)
}
static gboolean
-gst_rtp_mp4a_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_mp4a_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
GstRtpMP4APay *rtpmp4apay;
GstStructure *structure;
@@ -271,7 +274,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 +286,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 +309,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)
@@ -321,7 +323,7 @@ gst_rtp_mp4a_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
GST_WARNING_OBJECT (payload, "Need framed AAC data as input!");
}
- gst_basertppayload_set_options (payload, "audio", TRUE, "MP4A-LATM",
+ gst_rtp_base_payload_set_options (payload, "audio", TRUE, "MP4A-LATM",
rtpmp4apay->rate);
res = gst_rtp_mp4a_pay_new_caps (rtpmp4apay);
@@ -339,14 +341,15 @@ config_failed:
/* we expect buffers as exactly one complete AU
*/
static GstFlowReturn
-gst_rtp_mp4a_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_mp4a_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
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,18 +357,18 @@ 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;
- mtu = GST_BASE_RTP_PAYLOAD_MTU (rtpmp4apay);
+ mtu = GST_RTP_BASE_PAYLOAD_MTU (rtpmp4apay);
while (size > 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 (size, 0, 0);
@@ -387,14 +390,15 @@ gst_rtp_mp4a_pay_handle_buffer (GstBaseRTPPayload * basepayload,
payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0);
GST_DEBUG_OBJECT (rtpmp4apay,
- "avail %d, towrite %d, packet_len %d, payload_len %d", size, towrite,
- packet_len, payload_len);
+ "avail %" G_GSIZE_FORMAT ", towrite %d, packet_len %d, payload_len %d",
+ size, towrite, packet_len, payload_len);
/* create buffer to hold the payload. */
outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
/* copy payload */
- payload = gst_rtp_buffer_get_payload (outbuf);
+ gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+ payload = gst_rtp_buffer_get_payload (&rtp);
if (!fragmented) {
/* first packet write the header */
@@ -414,16 +418,19 @@ 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;
- ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpmp4apay), outbuf);
+ ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtpmp4apay), outbuf);
fragmented = TRUE;
}
+ gst_buffer_unmap (buffer, bdata, -1);
gst_buffer_unref (buffer);
return ret;
diff --git a/gst/rtp/gstrtpmp4apay.h b/gst/rtp/gstrtpmp4apay.h
index 0447d83c0..867167129 100644
--- a/gst/rtp/gstrtpmp4apay.h
+++ b/gst/rtp/gstrtpmp4apay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_MP4A_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpMP4APayClass GstRtpMP4APayClass;
struct _GstRtpMP4APay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
gint rate;
gchar *params;
@@ -53,7 +53,7 @@ struct _GstRtpMP4APay
struct _GstRtpMP4APayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_mp4a_pay_get_type (void);
diff --git a/gst/rtp/gstrtpmp4gdepay.c b/gst/rtp/gstrtpmp4gdepay.c
index 1dd049b41..e619e5b4b 100644
--- a/gst/rtp/gstrtpmp4gdepay.c
+++ b/gst/rtp/gstrtpmp4gdepay.c
@@ -126,16 +126,17 @@ gst_bs_parse_read (GstBsParse * bs, guint n)
}
-GST_BOILERPLATE (GstRtpMP4GDepay, gst_rtp_mp4g_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_mp4g_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMP4GDepay, gst_rtp_mp4g_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void gst_rtp_mp4g_depay_finalize (GObject * object);
-static gboolean gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_mp4g_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_mp4g_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_mp4g_depay_handle_event (GstBaseRTPDepayload * filter,
+static gboolean gst_rtp_mp4g_depay_handle_event (GstRTPBaseDepayload * filter,
GstEvent * event);
static GstStateChangeReturn gst_rtp_mp4g_depay_change_state (GstElement *
@@ -143,47 +144,40 @@ 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_static_pad_template (element_class,
- &gst_rtp_mp4g_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->finalize = gst_rtp_mp4g_depay_finalize;
gstelement_class->change_state = gst_rtp_mp4g_depay_change_state;
- gstbasertpdepayload_class->process = gst_rtp_mp4g_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_mp4g_depay_setcaps;
- gstbasertpdepayload_class->handle_event = gst_rtp_mp4g_depay_handle_event;
+ gstrtpbasedepayload_class->process = gst_rtp_mp4g_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_mp4g_depay_setcaps;
+ gstrtpbasedepayload_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 ();
@@ -221,7 +215,7 @@ gst_rtp_mp4g_depay_parse_int (GstStructure * structure, const gchar * field,
}
static gboolean
-gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_mp4g_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstRtpMP4GDepay *rtpmp4gdepay;
@@ -354,7 +348,7 @@ gst_rtp_mp4g_depay_flush_queue (GstRtpMP4GDepay * rtpmp4gdepay)
}
GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing AU_index %u", AU_index);
- gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay), outbuf);
+ gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay), outbuf);
rtpmp4gdepay->next_AU_index = AU_index + 1;
}
}
@@ -374,7 +368,7 @@ gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf)
/* we received the expected packet, push it and flush as much as we can from
* the queue */
- gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay), outbuf);
+ gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay), outbuf);
rtpmp4gdepay->next_AU_index++;
while ((outbuf = g_queue_peek_head (rtpmp4gdepay->packets))) {
@@ -386,7 +380,7 @@ gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf)
GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing expected AU_index %u",
AU_index);
outbuf = g_queue_pop_head (rtpmp4gdepay->packets);
- gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay),
+ gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay),
outbuf);
rtpmp4gdepay->next_AU_index++;
} else {
@@ -425,11 +419,12 @@ gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf)
}
static GstBuffer *
-gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_mp4g_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpMP4GDepay *rtpmp4gdepay;
- GstBuffer *outbuf;
+ GstBuffer *outbuf = NULL;
GstClockTime timestamp;
+ GstRTPBuffer rtp = { NULL };
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;
@@ -655,7 +653,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) {
@@ -665,7 +663,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. */
@@ -676,8 +673,9 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
* RTP packet. */
timestamp = -1;
- GST_DEBUG_OBJECT (depayload, "pushing buffer of size %d",
- GST_BUFFER_SIZE (outbuf));
+ GST_DEBUG_OBJECT (depayload,
+ "pushing buffer of size %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (outbuf));
gst_rtp_mp4g_depay_queue (rtpmp4gdepay, outbuf);
@@ -687,7 +685,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 */
@@ -698,13 +696,16 @@ 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_DEBUG ("gst_rtp_mp4g_depay_chain: pushing buffer of size %"
+ G_GSIZE_FORMAT, gst_buffer_get_size (outbuf));
+ gst_rtp_buffer_unmap (&rtp);
return outbuf;
}
}
}
+
+ gst_rtp_buffer_unmap (&rtp);
return NULL;
/* ERRORS */
@@ -712,12 +713,13 @@ short_payload:
{
GST_ELEMENT_WARNING (rtpmp4gdepay, STREAM, DECODE,
("Packet payload was too short."), (NULL));
+ gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
static gboolean
-gst_rtp_mp4g_depay_handle_event (GstBaseRTPDepayload * filter, GstEvent * event)
+gst_rtp_mp4g_depay_handle_event (GstRTPBaseDepayload * filter, GstEvent * event)
{
gboolean ret;
GstRtpMP4GDepay *rtpmp4gdepay;
@@ -733,7 +735,7 @@ gst_rtp_mp4g_depay_handle_event (GstBaseRTPDepayload * filter, GstEvent * event)
}
ret =
- GST_BASE_RTP_DEPAYLOAD_CLASS (parent_class)->handle_event (filter, event);
+ GST_RTP_BASE_DEPAYLOAD_CLASS (parent_class)->handle_event (filter, event);
return ret;
}
diff --git a/gst/rtp/gstrtpmp4gdepay.h b/gst/rtp/gstrtpmp4gdepay.h
index cd088e5b1..88df29c5b 100644
--- a/gst/rtp/gstrtpmp4gdepay.h
+++ b/gst/rtp/gstrtpmp4gdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpMP4GDepayClass GstRtpMP4GDepayClass;
struct _GstRtpMP4GDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
gint profile_level_id;
gint streamtype;
@@ -74,7 +74,7 @@ struct _GstRtpMP4GDepay
struct _GstRtpMP4GDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_mp4g_depay_get_type (void);
diff --git a/gst/rtp/gstrtpmp4gpay.c b/gst/rtp/gstrtpmp4gpay.c
index 4100ab763..382994c86 100644
--- a/gst/rtp/gstrtpmp4gpay.c
+++ b/gst/rtp/gstrtpmp4gpay.c
@@ -78,55 +78,51 @@ static void gst_rtp_mp4g_pay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_mp4g_pay_change_state (GstElement * element,
GstStateChange transition);
-static gboolean gst_rtp_mp4g_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_mp4g_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_mp4g_pay_handle_buffer (GstBaseRTPPayload *
+static GstFlowReturn gst_rtp_mp4g_pay_handle_buffer (GstRTPBasePayload *
payload, GstBuffer * buffer);
-static gboolean gst_rtp_mp4g_pay_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_mp4g_pay_sink_event (GstRTPBasePayload * 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_RTP_BASE_PAYLOAD)
- static void gst_rtp_mp4g_pay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_mp4g_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->finalize = gst_rtp_mp4g_pay_finalize;
gstelement_class->change_state = gst_rtp_mp4g_pay_change_state;
- gstbasertppayload_class->set_caps = gst_rtp_mp4g_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_mp4g_pay_handle_buffer;
- gstbasertppayload_class->handle_event = gst_rtp_mp4g_pay_handle_event;
+ gstrtpbasepayload_class->set_caps = gst_rtp_mp4g_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_mp4g_pay_handle_buffer;
+ gstrtpbasepayload_class->sink_event = gst_rtp_mp4g_pay_sink_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;
}
}
@@ -368,10 +370,10 @@ gst_rtp_mp4g_pay_new_caps (GstRtpMP4GPay * rtpmp4gpay)
/* hmm, silly */
if (rtpmp4gpay->params) {
- res = gst_basertppayload_set_outcaps (GST_BASE_RTP_PAYLOAD (rtpmp4gpay),
+ res = gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (rtpmp4gpay),
"encoding-params", G_TYPE_STRING, rtpmp4gpay->params, MP4GCAPS);
} else {
- res = gst_basertppayload_set_outcaps (GST_BASE_RTP_PAYLOAD (rtpmp4gpay),
+ res = gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (rtpmp4gpay),
MP4GCAPS);
}
@@ -383,7 +385,7 @@ gst_rtp_mp4g_pay_new_caps (GstRtpMP4GPay * rtpmp4gpay)
}
static gboolean
-gst_rtp_mp4g_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_mp4g_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
GstRtpMP4GPay *rtpmp4gpay;
GstStructure *structure;
@@ -430,7 +432,7 @@ gst_rtp_mp4g_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
if (media_type == NULL)
goto config_failed;
- gst_basertppayload_set_options (payload, media_type, TRUE, "MPEG4-GENERIC",
+ gst_rtp_base_payload_set_options (payload, media_type, TRUE, "MPEG4-GENERIC",
rtpmp4gpay->rate);
res = gst_rtp_mp4g_pay_new_caps (rtpmp4gpay);
@@ -461,13 +463,14 @@ gst_rtp_mp4g_pay_flush (GstRtpMP4GPay * rtpmp4gpay)
total = avail = gst_adapter_available (rtpmp4gpay->adapter);
ret = GST_FLOW_OK;
- mtu = GST_BASE_RTP_PAYLOAD_MTU (rtpmp4gpay);
+ mtu = GST_RTP_BASE_PAYLOAD_MTU (rtpmp4gpay);
while (avail > 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 (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;
@@ -538,7 +545,7 @@ gst_rtp_mp4g_pay_flush (GstRtpMP4GPay * rtpmp4gpay)
rtpmp4gpay->offset += rtpmp4gpay->frame_len;
}
- ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpmp4gpay), outbuf);
+ ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtpmp4gpay), outbuf);
avail -= payload_len;
}
@@ -549,7 +556,7 @@ gst_rtp_mp4g_pay_flush (GstRtpMP4GPay * rtpmp4gpay)
/* we expect buffers as exactly one complete AU
*/
static GstFlowReturn
-gst_rtp_mp4g_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_mp4g_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
GstRtpMP4GPay *rtpmp4gpay;
@@ -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_sink_event (GstRTPBasePayload * 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,10 +595,8 @@ gst_rtp_mp4g_pay_handle_event (GstPad * pad, GstEvent * event)
break;
}
- g_object_unref (rtpmp4gpay);
-
/* let parent handle event too */
- return FALSE;
+ return GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->sink_event (payload, event);
}
static GstStateChangeReturn
diff --git a/gst/rtp/gstrtpmp4gpay.h b/gst/rtp/gstrtpmp4gpay.h
index d79e5df2c..65efb9e65 100644
--- a/gst/rtp/gstrtpmp4gpay.h
+++ b/gst/rtp/gstrtpmp4gpay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_MP4G_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpMP4GPayClass GstRtpMP4GPayClass;
struct _GstRtpMP4GPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
GstAdapter *adapter;
GstClockTime first_timestamp;
@@ -61,7 +61,7 @@ struct _GstRtpMP4GPay
struct _GstRtpMP4GPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_mp4g_pay_get_type (void);
diff --git a/gst/rtp/gstrtpmp4vdepay.c b/gst/rtp/gstrtpmp4vdepay.c
index ba3fef24b..ac8eeec68 100644
--- a/gst/rtp/gstrtpmp4vdepay.c
+++ b/gst/rtp/gstrtpmp4vdepay.c
@@ -53,61 +53,54 @@ GST_STATIC_PAD_TEMPLATE ("sink",
)
);
-GST_BOILERPLATE (GstRtpMP4VDepay, gst_rtp_mp4v_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_mp4v_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpMP4VDepay, gst_rtp_mp4v_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void gst_rtp_mp4v_depay_finalize (GObject * object);
-static gboolean gst_rtp_mp4v_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_mp4v_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_mp4v_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_mp4v_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
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_static_pad_template (element_class,
- &gst_rtp_mp4v_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->finalize = gst_rtp_mp4v_depay_finalize;
gstelement_class->change_state = gst_rtp_mp4v_depay_change_state;
- gstbasertpdepayload_class->process = gst_rtp_mp4v_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_mp4v_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_mp4v_depay_process;
+ gstrtpbasedepayload_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 ();
}
@@ -126,7 +119,7 @@ gst_rtp_mp4v_depay_finalize (GObject * object)
}
static gboolean
-gst_rtp_mp4v_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_mp4v_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstCaps *srccaps;
@@ -167,10 +160,11 @@ gst_rtp_mp4v_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
}
static GstBuffer *
-gst_rtp_mp4v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_mp4v_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpMP4VDepay *rtpmp4vdepay;
- GstBuffer *outbuf;
+ GstBuffer *outbuf = NULL;
+ GstRTPBuffer rtp = { NULL };
rtpmp4vdepay = GST_RTP_MP4V_DEPAY (depayload);
@@ -178,23 +172,25 @@ 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);
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_DEBUG ("gst_rtp_mp4v_depay_chain: pushing buffer of size %"
+ G_GSIZE_FORMAT, gst_buffer_get_size (outbuf));
}
- return NULL;
+
+ gst_rtp_buffer_unmap (&rtp);
+
+ return outbuf;
}
static GstStateChangeReturn
diff --git a/gst/rtp/gstrtpmp4vdepay.h b/gst/rtp/gstrtpmp4vdepay.h
index 043ea8b9b..75013e0bf 100644
--- a/gst/rtp/gstrtpmp4vdepay.h
+++ b/gst/rtp/gstrtpmp4vdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,14 +42,14 @@ typedef struct _GstRtpMP4VDepayClass GstRtpMP4VDepayClass;
struct _GstRtpMP4VDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
GstAdapter *adapter;
};
struct _GstRtpMP4VDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_mp4v_depay_get_type (void);
diff --git a/gst/rtp/gstrtpmp4vpay.c b/gst/rtp/gstrtpmp4vpay.c
index 5707a6699..1d3dc9917 100644
--- a/gst/rtp/gstrtpmp4vpay.c
+++ b/gst/rtp/gstrtpmp4vpay.c
@@ -74,42 +74,39 @@ static void gst_rtp_mp4v_pay_set_property (GObject * object, guint prop_id,
static void gst_rtp_mp4v_pay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static gboolean gst_rtp_mp4v_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_mp4v_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_mp4v_pay_handle_buffer (GstBaseRTPPayload *
+static GstFlowReturn gst_rtp_mp4v_pay_handle_buffer (GstRTPBasePayload *
payload, GstBuffer * buffer);
-static gboolean gst_rtp_mp4v_pay_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_mp4v_pay_sink_event (GstRTPBasePayload * 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_RTP_BASE_PAYLOAD)
- static void gst_rtp_mp4v_pay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_mp4v_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) 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 "
@@ -131,16 +128,16 @@ gst_rtp_mp4v_pay_class_init (GstRtpMP4VPayClass * klass)
gobject_class->finalize = gst_rtp_mp4v_pay_finalize;
- gstbasertppayload_class->set_caps = gst_rtp_mp4v_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_mp4v_pay_handle_buffer;
- gstbasertppayload_class->handle_event = gst_rtp_mp4v_pay_handle_event;
+ gstrtpbasepayload_class->set_caps = gst_rtp_mp4v_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_mp4v_pay_handle_buffer;
+ gstrtpbasepayload_class->sink_event = gst_rtp_mp4v_pay_sink_event;
GST_DEBUG_CATEGORY_INIT (rtpmp4vpay_debug, "rtpmp4vpay", 0,
"MP4 video RTP Payloader");
}
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;
@@ -183,7 +180,7 @@ gst_rtp_mp4v_pay_new_caps (GstRtpMP4VPay * rtpmp4vpay)
gst_value_set_buffer (&v, rtpmp4vpay->config);
config = gst_value_serialize (&v);
- res = gst_basertppayload_set_outcaps (GST_BASE_RTP_PAYLOAD (rtpmp4vpay),
+ res = gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (rtpmp4vpay),
"profile-level-id", G_TYPE_STRING, profile,
"config", G_TYPE_STRING, config, NULL);
@@ -196,7 +193,7 @@ gst_rtp_mp4v_pay_new_caps (GstRtpMP4VPay * rtpmp4vpay)
}
static gboolean
-gst_rtp_mp4v_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_mp4v_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
GstRtpMP4VPay *rtpmp4vpay;
GstStructure *structure;
@@ -205,7 +202,7 @@ gst_rtp_mp4v_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
rtpmp4vpay = GST_RTP_MP4V_PAY (payload);
- gst_basertppayload_set_options (payload, "video", TRUE, "MP4V-ES",
+ gst_rtp_base_payload_set_options (payload, "video", TRUE, "MP4V-ES",
rtpmp4vpay->rate);
res = TRUE;
@@ -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,64 +272,54 @@ 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 = { NULL };
/* this will be the total lenght of the packet */
packet_len = gst_rtp_buffer_calc_packet_len (avail, 0, 0);
/* fill one MTU or all available bytes */
- towrite = MIN (packet_len, GST_BASE_RTP_PAYLOAD_MTU (rtpmp4vpay));
+ towrite = MIN (packet_len, GST_RTP_BASE_PAYLOAD_MTU (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);
+ /* 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);
- /* copy payload */
- payload = gst_rtp_buffer_get_payload (outbuf);
-
- 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);
+ ret =
+ gst_rtp_base_payload_push (GST_RTP_BASE_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);
+ gst_rtp_base_payload_push_list (GST_RTP_BASE_PAYLOAD (rtpmp4vpay),
+ list);
}
return ret;
@@ -400,16 +381,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;
@@ -453,12 +438,13 @@ gst_rtp_mp4v_pay_depay_data (GstRtpMP4VPay * enc, guint8 * data, guint size,
/* we expect buffers starting on startcodes.
*/
static GstFlowReturn
-gst_rtp_mp4v_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_mp4v_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
GstRtpMP4VPay *rtpmp4vpay;
GstFlowReturn ret;
- guint size, avail;
+ guint avail;
+ gsize size;
guint packet_len;
guint8 *data;
gboolean flush;
@@ -472,8 +458,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 +475,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 +544,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;
@@ -574,7 +563,7 @@ gst_rtp_mp4v_pay_handle_buffer (GstBaseRTPPayload * basepayload,
/* get packet length of data and see if we exceeded MTU. */
packet_len = gst_rtp_buffer_calc_packet_len (avail + size, 0, 0);
- if (gst_basertppayload_is_filled (basepayload,
+ if (gst_rtp_base_payload_is_filled (basepayload,
packet_len, rtpmp4vpay->duration + duration)) {
ret = gst_rtp_mp4v_pay_flush (rtpmp4vpay);
rtpmp4vpay->first_timestamp = timestamp;
@@ -590,16 +579,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_sink_event (GstRTPBasePayload * 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,10 +601,8 @@ gst_rtp_mp4v_pay_handle_event (GstPad * pad, GstEvent * event)
break;
}
- g_object_unref (rtpmp4vpay);
-
/* let parent handle event too */
- return FALSE;
+ return GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->sink_event (pay, event);
}
static void
diff --git a/gst/rtp/gstrtpmp4vpay.h b/gst/rtp/gstrtpmp4vpay.h
index 0f8ab14f6..abdc9035a 100644
--- a/gst/rtp/gstrtpmp4vpay.h
+++ b/gst/rtp/gstrtpmp4vpay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_MP4V_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpMP4VPayClass GstRtpMP4VPayClass;
struct _GstRtpMP4VPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
GstAdapter *adapter;
GstClockTime first_timestamp;
@@ -64,7 +64,7 @@ struct _GstRtpMP4VPay
struct _GstRtpMP4VPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_mp4v_pay_get_type (void);
diff --git a/gst/rtp/gstrtpmpadepay.c b/gst/rtp/gstrtpmpadepay.c
index 2b442c8f8..2f2956a85 100644
--- a/gst/rtp/gstrtpmpadepay.c
+++ b/gst/rtp/gstrtpmpadepay.c
@@ -50,53 +50,48 @@ 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_RTP_BASE_DEPAYLOAD);
-static gboolean gst_rtp_mpa_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_mpa_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_mpa_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_mpa_depay_process (GstRTPBaseDepayload * 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;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
+
+ GST_DEBUG_CATEGORY_INIT (rtpmpadepay_debug, "rtpmpadepay", 0,
+ "MPEG Audio RTP Depayloader");
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_mpa_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_mpa_depay_sink_template);
+ 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 (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");
+ gstrtpbasedepayload_class->set_caps = gst_rtp_mpa_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_mpa_depay_process;
}
static void
-gst_rtp_mpa_depay_init (GstRtpMPADepay * rtpmpadepay,
- GstRtpMPADepayClass * klass)
+gst_rtp_mpa_depay_init (GstRtpMPADepay * rtpmpadepay)
{
/* needed because of GST_BOILERPLATE */
}
static gboolean
-gst_rtp_mpa_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_mpa_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstCaps *outcaps;
@@ -118,56 +113,64 @@ gst_rtp_mpa_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
}
static GstBuffer *
-gst_rtp_mpa_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_mpa_depay_process (GstRTPBaseDepayload * 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 %" G_GSIZE_FORMAT "",
+ gst_buffer_get_size (outbuf));
+
+ gst_rtp_buffer_unmap (&rtp);
- return NULL;
+ /* FIXME, we can push half mpeg frames when they are split over multiple
+ * RTP packets */
+ return outbuf;
/* ERRORS */
empty_packet:
{
GST_ELEMENT_WARNING (rtpmpadepay, STREAM, DECODE,
("Empty Payload."), (NULL));
+ gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
diff --git a/gst/rtp/gstrtpmpadepay.h b/gst/rtp/gstrtpmpadepay.h
index a6e9527e2..36196f5de 100644
--- a/gst/rtp/gstrtpmpadepay.h
+++ b/gst/rtp/gstrtpmpadepay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_MPA_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -41,12 +41,12 @@ typedef struct _GstRtpMPADepayClass GstRtpMPADepayClass;
struct _GstRtpMPADepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
};
struct _GstRtpMPADepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_mpa_depay_get_type (void);
diff --git a/gst/rtp/gstrtpmpapay.c b/gst/rtp/gstrtpmpapay.c
index af2b78e43..5cef0898c 100644
--- a/gst/rtp/gstrtpmpapay.c
+++ b/gst/rtp/gstrtpmpapay.c
@@ -56,56 +56,52 @@ static void gst_rtp_mpa_pay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_mpa_pay_change_state (GstElement * element,
GstStateChange transition);
-static gboolean gst_rtp_mpa_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_mpa_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static gboolean gst_rtp_mpa_pay_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_mpa_pay_sink_event (GstRTPBasePayload * payload,
+ GstEvent * event);
static GstFlowReturn gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay);
-static GstFlowReturn gst_rtp_mpa_pay_handle_buffer (GstBaseRTPPayload * payload,
+static GstFlowReturn gst_rtp_mpa_pay_handle_buffer (GstRTPBasePayload * 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_static_pad_template (element_class,
- &gst_rtp_mpa_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_mpa_pay_class_init (GstRtpMPAPayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_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;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->finalize = gst_rtp_mpa_pay_finalize;
gstelement_class->change_state = gst_rtp_mpa_pay_change_state;
- 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_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_DEBUG_CATEGORY_INIT (rtpmpapay_debug, "rtpmpapay", 0,
- "MPEG Audio RTP Depayloader");
+ 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>");
+
+ gstrtpbasepayload_class->set_caps = gst_rtp_mpa_pay_setcaps;
+ gstrtpbasepayload_class->sink_event = gst_rtp_mpa_pay_sink_event;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_mpa_pay_handle_buffer;
}
static void
-gst_rtp_mpa_pay_init (GstRtpMPAPay * rtpmpapay, GstRtpMPAPayClass * klass)
+gst_rtp_mpa_pay_init (GstRtpMPAPay * rtpmpapay)
{
rtpmpapay->adapter = gst_adapter_new ();
}
@@ -133,22 +129,23 @@ gst_rtp_mpa_pay_reset (GstRtpMPAPay * pay)
}
static gboolean
-gst_rtp_mpa_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_mpa_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
gboolean res;
- gst_basertppayload_set_options (payload, "audio", TRUE, "MPA", 90000);
- res = gst_basertppayload_set_outcaps (payload, NULL);
+ gst_rtp_base_payload_set_options (payload, "audio", TRUE, "MPA", 90000);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
return res;
}
static gboolean
-gst_rtp_mpa_pay_handle_event (GstPad * pad, GstEvent * event)
+gst_rtp_mpa_pay_sink_event (GstRTPBasePayload * 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,9 @@ gst_rtp_mpa_pay_handle_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (rtpmpapay);
+ ret = GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->sink_event (payload, event);
- /* FALSE to let the parent handle the event as well */
- return FALSE;
+ return ret;
}
static GstFlowReturn
@@ -192,12 +188,13 @@ 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);
/* fill one MTU or all available bytes */
- towrite = MIN (packet_len, GST_BASE_RTP_PAYLOAD_MTU (rtpmpapay));
+ towrite = MIN (packet_len, GST_RTP_BASE_PAYLOAD_MTU (rtpmpapay));
/* this is the payload length */
payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0);
@@ -205,9 +202,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 +215,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,19 +228,21 @@ 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;
- ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpmpapay), outbuf);
+ ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtpmpapay), outbuf);
}
return ret;
}
static GstFlowReturn
-gst_rtp_mpa_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_mpa_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
GstRtpMPAPay *rtpmpapay;
@@ -252,7 +253,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);
@@ -269,7 +270,7 @@ gst_rtp_mpa_pay_handle_buffer (GstBaseRTPPayload * basepayload,
/* if this buffer is going to overflow the packet, flush what we
* have. */
- if (gst_basertppayload_is_filled (basepayload,
+ if (gst_rtp_base_payload_is_filled (basepayload,
packet_len, rtpmpapay->duration + duration)) {
ret = gst_rtp_mpa_pay_flush (rtpmpapay);
avail = 0;
diff --git a/gst/rtp/gstrtpmpapay.h b/gst/rtp/gstrtpmpapay.h
index cdab19669..3a5c854e2 100644
--- a/gst/rtp/gstrtpmpapay.h
+++ b/gst/rtp/gstrtpmpapay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_MPA_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpMPAPayClass GstRtpMPAPayClass;
struct _GstRtpMPAPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
GstAdapter *adapter;
GstClockTime first_ts;
@@ -51,7 +51,7 @@ struct _GstRtpMPAPay
struct _GstRtpMPAPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_mpa_pay_get_type (void);
diff --git a/gst/rtp/gstrtpmparobustdepay.c b/gst/rtp/gstrtpmparobustdepay.c
index 17645a49a..50ac10128 100644
--- a/gst/rtp/gstrtpmparobustdepay.c
+++ b/gst/rtp/gstrtpmparobustdepay.c
@@ -69,34 +69,19 @@ 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_RTP_BASE_DEPAYLOAD);
static GstStateChangeReturn gst_rtp_mpa_robust_change_state (GstElement *
element, GstStateChange transition);
-static gboolean gst_rtp_mpa_robust_depay_setcaps (GstBaseRTPDepayload *
+static gboolean gst_rtp_mpa_robust_depay_setcaps (GstRTPBaseDepayload *
depayload, GstCaps * caps);
-static GstBuffer *gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload *
+static GstBuffer *gst_rtp_mpa_robust_depay_process (GstRTPBaseDepayload *
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_static_pad_template (element_class,
- &gst_rtp_mpa_robust_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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,40 +94,48 @@ 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)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_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;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->finalize = gst_rtp_mpa_robust_depay_finalize;
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_rtp_mpa_robust_change_state);
- gstbasertpdepayload_class->set_caps = gst_rtp_mpa_robust_depay_setcaps;
- gstbasertpdepayload_class->process = gst_rtp_mpa_robust_depay_process;
+ 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_DEBUG_CATEGORY_INIT (rtpmparobustdepay_debug, "rtpmparobustdepay", 0,
- "Robust MPEG Audio RTP Depayloader");
+ 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>");
+
+ gstrtpbasedepayload_class->set_caps = gst_rtp_mpa_robust_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_mpa_robust_depay_process;
}
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 ();
}
static gboolean
-gst_rtp_mpa_robust_depay_setcaps (GstBaseRTPDepayload * depayload,
+gst_rtp_mpa_robust_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps)
{
GstRtpMPARobustDepay *rtpmpadepay;
@@ -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;
@@ -485,7 +495,7 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
if (G_UNLIKELY (frame->layer != 3)) {
GST_DEBUG_OBJECT (rtpmpadepay, "layer %d frame, sending as-is",
frame->layer);
- gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmpadepay),
+ gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmpadepay),
frame->buffer);
frame->buffer = NULL;
/* and remove it from any further consideration */
@@ -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);
}
}
@@ -601,7 +617,7 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
rtpmpadepay->size -= head->data_size;
gst_rtp_mpa_robust_depay_dequeue_frame (rtpmpadepay);
/* send */
- ret = gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmpadepay),
+ ret = gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmpadepay),
buf);
}
}
@@ -625,7 +641,7 @@ gst_rtp_mpa_robust_depay_submit_adu (GstRtpMPARobustDepay * rtpmpadepay,
}
static GstBuffer *
-gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * depayload,
+gst_rtp_mpa_robust_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf)
{
GstRtpMPARobustDepay *rtpmpadepay;
@@ -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);
@@ -661,8 +680,8 @@ gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * depayload,
*/
while (payload_len) {
if (G_LIKELY (rtpmpadepay->has_descriptor)) {
- cont = !!(payload[offset] & 0x80);
- dtype = !!(payload[offset] & 0x40);
+ cont = ! !(payload[offset] & 0x80);
+ dtype = ! !(payload[offset] & 0x40);
if (dtype) {
size = (payload[offset] & 0x3f) << 8 | payload[offset + 1];
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;
}
}
diff --git a/gst/rtp/gstrtpmparobustdepay.h b/gst/rtp/gstrtpmparobustdepay.h
index 8ef5af10b..d8fa84e8b 100644
--- a/gst/rtp/gstrtpmparobustdepay.h
+++ b/gst/rtp/gstrtpmparobustdepay.h
@@ -22,7 +22,7 @@
#define __GST_RTP_MPA_ROBUST_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
#include <gst/base/gstadapter.h>
#include <gst/base/gstbytewriter.h>
@@ -44,7 +44,7 @@ typedef struct _GstRtpMPARobustDepayClass GstRtpMPARobustDepayClass;
struct _GstRtpMPARobustDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
GstAdapter *adapter;
gboolean has_descriptor;
@@ -66,7 +66,7 @@ struct _GstRtpMPARobustDepay
struct _GstRtpMPARobustDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_mpa_robust_depay_get_type (void);
diff --git a/gst/rtp/gstrtpmpvdepay.c b/gst/rtp/gstrtpmpvdepay.c
index c48c82b20..09e2ef0f5 100644
--- a/gst/rtp/gstrtpmpvdepay.c
+++ b/gst/rtp/gstrtpmpvdepay.c
@@ -53,53 +53,46 @@ 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_RTP_BASE_DEPAYLOAD);
-static gboolean gst_rtp_mpv_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_mpv_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_mpv_depay_process (GstRTPBaseDepayload * 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;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_mpv_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_mpv_depay_sink_template);
+ 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 (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;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_mpv_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_mpv_depay_process;
GST_DEBUG_CATEGORY_INIT (rtpmpvdepay_debug, "rtpmpvdepay", 0,
"MPEG Video RTP Depayloader");
}
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
-gst_rtp_mpv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_mpv_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
gint clock_rate;
@@ -122,20 +115,23 @@ gst_rtp_mpv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
}
static GstBuffer *
-gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_mpv_depay_process (GstRTPBaseDepayload * 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_rtp_mpv_depay_chain: pushing buffer of size %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (outbuf));
}
-
return outbuf;
}
diff --git a/gst/rtp/gstrtpmpvdepay.h b/gst/rtp/gstrtpmpvdepay.h
index ca366d55e..49e3e2d87 100644
--- a/gst/rtp/gstrtpmpvdepay.h
+++ b/gst/rtp/gstrtpmpvdepay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_MPV_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -41,12 +41,12 @@ typedef struct _GstRtpMPVDepayClass GstRtpMPVDepayClass;
struct _GstRtpMPVDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
};
struct _GstRtpMPVDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_mpv_depay_get_type (void);
diff --git a/gst/rtp/gstrtpmpvpay.c b/gst/rtp/gstrtpmpvpay.c
index 9fa897fc9..661f6243b 100644
--- a/gst/rtp/gstrtpmpvpay.c
+++ b/gst/rtp/gstrtpmpvpay.c
@@ -54,58 +54,54 @@ static GstStateChangeReturn gst_rtp_mpv_pay_change_state (GstElement * element,
static void gst_rtp_mpv_pay_finalize (GObject * object);
static GstFlowReturn gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay);
-static gboolean gst_rtp_mpv_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_mpv_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_mpv_pay_handle_buffer (GstBaseRTPPayload *
+static GstFlowReturn gst_rtp_mpv_pay_handle_buffer (GstRTPBasePayload *
payload, GstBuffer * buffer);
-static gboolean gst_rtp_mpv_pay_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_mpv_pay_sink_event (GstRTPBasePayload * 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_static_pad_template (element_class,
- &gst_rtp_mpv_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_mpv_pay_class_init (GstRTPMPVPayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->finalize = gst_rtp_mpv_pay_finalize;
gstelement_class->change_state = gst_rtp_mpv_pay_change_state;
- 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;
+ 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>");
+
+ gstrtpbasepayload_class->set_caps = gst_rtp_mpv_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_mpv_pay_handle_buffer;
+ gstrtpbasepayload_class->sink_event = gst_rtp_mpv_pay_sink_event;
GST_DEBUG_CATEGORY_INIT (rtpmpvpay_debug, "rtpmpvpay", 0,
"MPEG2 ES Video RTP Payloader");
}
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;
+ GST_RTP_BASE_PAYLOAD (rtpmpvpay)->clock_rate = 90000;
+ GST_RTP_BASE_PAYLOAD_PT (rtpmpvpay) = GST_RTP_PAYLOAD_MPV;
rtpmpvpay->adapter = gst_adapter_new ();
}
@@ -133,18 +129,19 @@ gst_rtp_mpv_pay_reset (GstRTPMPVPay * pay)
}
static gboolean
-gst_rtp_mpv_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_mpv_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
- gst_basertppayload_set_options (payload, "video", FALSE, "MPV", 90000);
- return gst_basertppayload_set_outcaps (payload, NULL);
+ gst_rtp_base_payload_set_options (payload, "video", FALSE, "MPV", 90000);
+ return gst_rtp_base_payload_set_outcaps (payload, NULL);
}
static gboolean
-gst_rtp_mpv_pay_handle_event (GstPad * pad, GstEvent * event)
+gst_rtp_mpv_pay_sink_event (GstRTPBasePayload * 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,9 @@ gst_rtp_mpv_pay_handle_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (rtpmpvpay);
+ ret = GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->sink_event (payload, event);
- /* FALSE to let the parent handle the event as well */
- return FALSE;
+ return ret;
}
static GstFlowReturn
@@ -181,16 +177,19 @@ 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);
- towrite = MIN (packet_len, GST_BASE_RTP_PAYLOAD_MTU (rtpmpvpay));
+ towrite = MIN (packet_len, GST_RTP_BASE_PAYLOAD_MTU (rtpmpvpay));
payload_len = gst_rtp_buffer_calc_payload_len (towrite, 4, 0);
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,18 +210,19 @@ 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;
- ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpmpvpay), outbuf);
+ ret = gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtpmpvpay), outbuf);
}
return ret;
}
static GstFlowReturn
-gst_rtp_mpv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_mpv_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
GstRTPMPVPay *rtpmpvpay;
@@ -263,7 +263,7 @@ gst_rtp_mpv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
GST_LOG_OBJECT (rtpmpvpay, "available %d, rtp packet length %d", avail,
packet_len);
- if (gst_basertppayload_is_filled (basepayload,
+ if (gst_rtp_base_payload_is_filled (basepayload,
packet_len, rtpmpvpay->duration)) {
ret = gst_rtp_mpv_pay_flush (rtpmpvpay);
} else {
diff --git a/gst/rtp/gstrtpmpvpay.h b/gst/rtp/gstrtpmpvpay.h
index d16162ef3..94d0b5c4e 100644
--- a/gst/rtp/gstrtpmpvpay.h
+++ b/gst/rtp/gstrtpmpvpay.h
@@ -22,7 +22,7 @@
#define __GST_RTP_MPV_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -43,7 +43,7 @@ typedef struct _GstRTPMPVPayClass GstRTPMPVPayClass;
struct _GstRTPMPVPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
GstAdapter *adapter;
GstClockTime first_ts;
@@ -52,7 +52,7 @@ struct _GstRTPMPVPay
struct _GstRTPMPVPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_mpv_pay_get_type (void);
diff --git a/gst/rtp/gstrtppcmadepay.c b/gst/rtp/gstrtppcmadepay.c
index 04e509eb5..15cff86c4 100644
--- a/gst/rtp/gstrtppcmadepay.c
+++ b/gst/rtp/gstrtppcmadepay.c
@@ -60,53 +60,50 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-alaw, channels = (int) 1, rate = (int) [1, MAX ]")
);
-static GstBuffer *gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_pcma_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_pcma_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_pcma_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-GST_BOILERPLATE (GstRtpPcmaDepay, gst_rtp_pcma_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
-
-static void
-gst_rtp_pcma_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_pcma_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_pcma_depay_sink_template);
- gst_element_class_set_details_simple (element_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>");
-}
+#define gst_rtp_pcma_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpPcmaDepay, gst_rtp_pcma_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void
gst_rtp_pcma_depay_class_init (GstRtpPcmaDepayClass * klass)
{
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gstbasertpdepayload_class->process = gst_rtp_pcma_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_pcma_depay_setcaps;
+ 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_pcma_depay_sink_template));
+
+ 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>");
+
+ gstrtpbasedepayload_class->process = gst_rtp_pcma_depay_process;
+ gstrtpbasedepayload_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;
+ GstRTPBaseDepayload *depayload;
- depayload = GST_BASE_RTP_DEPAYLOAD (rtppcmadepay);
+ depayload = GST_RTP_BASE_DEPAYLOAD (rtppcmadepay);
- gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
+ gst_pad_use_fixed_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload));
}
static gboolean
-gst_rtp_pcma_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_pcma_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
GstStructure *structure;
@@ -121,27 +118,31 @@ gst_rtp_pcma_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
srccaps = gst_caps_new_simple ("audio/x-alaw",
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, clock_rate, NULL);
- ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return ret;
}
static GstBuffer *
-gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_pcma_depay_process (GstRTPBaseDepayload * 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_DEBUG ("process : got %" G_GSIZE_FORMAT " bytes, mark %d ts %u seqn %d",
+ 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;
}
diff --git a/gst/rtp/gstrtppcmadepay.h b/gst/rtp/gstrtppcmadepay.h
index 12403149f..7ea0f454e 100644
--- a/gst/rtp/gstrtppcmadepay.h
+++ b/gst/rtp/gstrtppcmadepay.h
@@ -16,7 +16,7 @@
#define __GST_RTP_PCMA_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -36,12 +36,12 @@ typedef struct _GstRtpPcmaDepayClass GstRtpPcmaDepayClass;
struct _GstRtpPcmaDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
};
struct _GstRtpPcmaDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_pcma_depay_get_type (void);
diff --git a/gst/rtp/gstrtppcmapay.c b/gst/rtp/gstrtppcmapay.c
index ea379a044..b943b929c 100644
--- a/gst/rtp/gstrtppcmapay.c
+++ b/gst/rtp/gstrtppcmapay.c
@@ -50,62 +50,60 @@ static GstStaticPadTemplate gst_rtp_pcma_pay_src_template =
"clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"PCMA\"")
);
-static gboolean gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_pcma_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-GST_BOILERPLATE (GstRtpPcmaPay, gst_rtp_pcma_pay, GstBaseRTPAudioPayload,
- GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
+#define gst_rtp_pcma_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpPcmaPay, gst_rtp_pcma_pay,
+ GST_TYPE_RTP_BASE_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;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
+
+ 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_pcma_pay_src_template));
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_pcma_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
+ gstrtpbasepayload_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;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtppcmapay);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtppcmapay);
- GST_BASE_RTP_PAYLOAD (rtppcmapay)->clock_rate = 8000;
+ GST_RTP_BASE_PAYLOAD (rtppcmapay)->clock_rate = 8000;
- /* tell basertpaudiopayload that this is a sample based codec */
- gst_base_rtp_audio_payload_set_sample_based (basertpaudiopayload);
+ /* tell rtpbaseaudiopayload that this is a sample based codec */
+ gst_rtp_base_audio_payload_set_sample_based (rtpbaseaudiopayload);
/* octet-per-sample is 1 for PCM */
- gst_base_rtp_audio_payload_set_sample_options (basertpaudiopayload, 1);
+ gst_rtp_base_audio_payload_set_sample_options (rtpbaseaudiopayload, 1);
}
static gboolean
-gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_pcma_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
gboolean res;
payload->pt = GST_RTP_PAYLOAD_PCMA;
- gst_basertppayload_set_options (payload, "audio", FALSE, "PCMA", 8000);
- res = gst_basertppayload_set_outcaps (payload, NULL);
+ gst_rtp_base_payload_set_options (payload, "audio", FALSE, "PCMA", 8000);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
return res;
}
diff --git a/gst/rtp/gstrtppcmapay.h b/gst/rtp/gstrtppcmapay.h
index a51e975e4..5fde1bf69 100644
--- a/gst/rtp/gstrtppcmapay.h
+++ b/gst/rtp/gstrtppcmapay.h
@@ -17,7 +17,7 @@
#define __GST_RTP_PCMA_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpaudiopayload.h>
+#include <gst/rtp/gstrtpbaseaudiopayload.h>
G_BEGIN_DECLS
@@ -37,12 +37,12 @@ typedef struct _GstRtpPcmaPayClass GstRtpPcmaPayClass;
struct _GstRtpPcmaPay
{
- GstBaseRTPAudioPayload audiopayload;
+ GstRTPBaseAudioPayload audiopayload;
};
struct _GstRtpPcmaPayClass
{
- GstBaseRTPAudioPayloadClass parent_class;
+ GstRTPBaseAudioPayloadClass parent_class;
};
GType gst_rtp_pcma_pay_get_type (void);
diff --git a/gst/rtp/gstrtppcmudepay.c b/gst/rtp/gstrtppcmudepay.c
index d09e0614f..fe3fa5ce4 100644
--- a/gst/rtp/gstrtppcmudepay.c
+++ b/gst/rtp/gstrtppcmudepay.c
@@ -61,53 +61,50 @@ GST_STATIC_PAD_TEMPLATE ("src",
"channels = (int) 1, rate = (int) [1, MAX ]")
);
-static GstBuffer *gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_pcmu_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_pcmu_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_pcmu_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-GST_BOILERPLATE (GstRtpPcmuDepay, gst_rtp_pcmu_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
-
-static void
-gst_rtp_pcmu_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_pcmu_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_pcmu_depay_sink_template);
- gst_element_class_set_details_simple (element_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>");
-}
+#define gst_rtp_pcmu_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpPcmuDepay, gst_rtp_pcmu_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void
gst_rtp_pcmu_depay_class_init (GstRtpPcmuDepayClass * klass)
{
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gstbasertpdepayload_class->process = gst_rtp_pcmu_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_pcmu_depay_setcaps;
+ 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_pcmu_depay_sink_template));
+
+ 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>");
+
+ gstrtpbasedepayload_class->process = gst_rtp_pcmu_depay_process;
+ gstrtpbasedepayload_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;
+ GstRTPBaseDepayload *depayload;
- depayload = GST_BASE_RTP_DEPAYLOAD (rtppcmudepay);
+ depayload = GST_RTP_BASE_DEPAYLOAD (rtppcmudepay);
- gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
+ gst_pad_use_fixed_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload));
}
static gboolean
-gst_rtp_pcmu_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_pcmu_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
GstStructure *structure;
@@ -122,27 +119,31 @@ gst_rtp_pcmu_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
srccaps = gst_caps_new_simple ("audio/x-mulaw",
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, clock_rate, NULL);
- ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return ret;
}
static GstBuffer *
-gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_pcmu_depay_process (GstRTPBaseDepayload * 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_DEBUG ("process : got %" G_GSIZE_FORMAT " bytes, mark %d ts %u seqn %d",
+ 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) =
diff --git a/gst/rtp/gstrtppcmudepay.h b/gst/rtp/gstrtppcmudepay.h
index 72a37d116..922ceb9d9 100644
--- a/gst/rtp/gstrtppcmudepay.h
+++ b/gst/rtp/gstrtppcmudepay.h
@@ -16,7 +16,7 @@
#define __GST_RTP_PCMU_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -36,12 +36,12 @@ typedef struct _GstRtpPcmuDepayClass GstRtpPcmuDepayClass;
struct _GstRtpPcmuDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
};
struct _GstRtpPcmuDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_pcmu_depay_get_type (void);
diff --git a/gst/rtp/gstrtppcmupay.c b/gst/rtp/gstrtppcmupay.c
index 5b555b3d6..5998b092d 100644
--- a/gst/rtp/gstrtppcmupay.c
+++ b/gst/rtp/gstrtppcmupay.c
@@ -50,62 +50,60 @@ static GstStaticPadTemplate gst_rtp_pcmu_pay_src_template =
"clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"PCMU\"")
);
-static gboolean gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_pcmu_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-GST_BOILERPLATE (GstRtpPcmuPay, gst_rtp_pcmu_pay, GstBaseRTPAudioPayload,
- GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
+#define gst_rtp_pcmu_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpPcmuPay, gst_rtp_pcmu_pay,
+ GST_TYPE_RTP_BASE_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;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
+
+ 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_pcmu_pay_src_template));
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_pcmu_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
+ gstrtpbasepayload_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;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtppcmupay);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtppcmupay);
- GST_BASE_RTP_PAYLOAD (rtppcmupay)->clock_rate = 8000;
+ GST_RTP_BASE_PAYLOAD (rtppcmupay)->clock_rate = 8000;
- /* tell basertpaudiopayload that this is a sample based codec */
- gst_base_rtp_audio_payload_set_sample_based (basertpaudiopayload);
+ /* tell rtpbaseaudiopayload that this is a sample based codec */
+ gst_rtp_base_audio_payload_set_sample_based (rtpbaseaudiopayload);
/* octet-per-sample is 1 for PCM */
- gst_base_rtp_audio_payload_set_sample_options (basertpaudiopayload, 1);
+ gst_rtp_base_audio_payload_set_sample_options (rtpbaseaudiopayload, 1);
}
static gboolean
-gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_pcmu_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
gboolean res;
payload->pt = GST_RTP_PAYLOAD_PCMU;
- gst_basertppayload_set_options (payload, "audio", FALSE, "PCMU", 8000);
- res = gst_basertppayload_set_outcaps (payload, NULL);
+ gst_rtp_base_payload_set_options (payload, "audio", FALSE, "PCMU", 8000);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
return res;
}
diff --git a/gst/rtp/gstrtppcmupay.h b/gst/rtp/gstrtppcmupay.h
index f43ec3b43..58da8033f 100644
--- a/gst/rtp/gstrtppcmupay.h
+++ b/gst/rtp/gstrtppcmupay.h
@@ -17,7 +17,7 @@
#define __GST_RTP_PCMU_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpaudiopayload.h>
+#include <gst/rtp/gstrtpbaseaudiopayload.h>
G_BEGIN_DECLS
@@ -37,12 +37,12 @@ typedef struct _GstRtpPcmuPayClass GstRtpPcmuPayClass;
struct _GstRtpPcmuPay
{
- GstBaseRTPAudioPayload audiopayload;
+ GstRTPBaseAudioPayload audiopayload;
};
struct _GstRtpPcmuPayClass
{
- GstBaseRTPAudioPayloadClass parent_class;
+ GstRTPBaseAudioPayloadClass parent_class;
};
GType gst_rtp_pcmu_pay_get_type (void);
diff --git a/gst/rtp/gstrtpqcelpdepay.c b/gst/rtp/gstrtpqcelpdepay.c
index 810b58e62..d597558c3 100644
--- a/gst/rtp/gstrtpqcelpdepay.c
+++ b/gst/rtp/gstrtpqcelpdepay.c
@@ -72,55 +72,51 @@ GST_STATIC_PAD_TEMPLATE ("src",
static void gst_rtp_qcelp_depay_finalize (GObject * object);
-static gboolean gst_rtp_qcelp_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_qcelp_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_qcelp_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_qcelp_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-GST_BOILERPLATE (GstRtpQCELPDepay, gst_rtp_qcelp_depay, GstBaseRTPDepayload,
- 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_static_pad_template (element_class,
- &gst_rtp_qcelp_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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>");
-}
+#define gst_rtp_qcelp_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpQCELPDepay, gst_rtp_qcelp_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void
gst_rtp_qcelp_depay_class_init (GstRtpQCELPDepayClass * klass)
{
GObjectClass *gobject_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->finalize = gst_rtp_qcelp_depay_finalize;
- gstbasertpdepayload_class->process = gst_rtp_qcelp_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_qcelp_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_qcelp_depay_process;
+ gstrtpbasedepayload_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;
+ GstRTPBaseDepayload G_GNUC_UNUSED *depayload;
- depayload = GST_BASE_RTP_DEPAYLOAD (rtpqcelpdepay);
+ depayload = GST_RTP_BASE_DEPAYLOAD (rtpqcelpdepay);
}
static void
@@ -141,14 +137,14 @@ gst_rtp_qcelp_depay_finalize (GObject * object)
static gboolean
-gst_rtp_qcelp_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_qcelp_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
gboolean res;
srccaps = gst_caps_new_simple ("audio/qcelp",
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
- res = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ res = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return res;
@@ -212,7 +208,7 @@ flush_packets (GstRtpQCELPDepay * depay)
outbuf = g_ptr_array_index (depay->packets, i);
g_ptr_array_index (depay->packets, i) = NULL;
- gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (depay), outbuf);
+ gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (depay), outbuf);
}
/* and reset interleaving state */
@@ -245,15 +241,18 @@ 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;
}
static GstBuffer *
-gst_rtp_qcelp_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_qcelp_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpQCELPDepay *depay;
GstBuffer *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 = { NULL };
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;
@@ -361,7 +363,7 @@ gst_rtp_qcelp_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
if (!depay->interleaved || index == 0) {
/* not interleaved or first frame in packet, just push */
- gst_base_rtp_depayload_push (depayload, outbuf);
+ gst_rtp_base_depayload_push (depayload, outbuf);
if (timestamp != -1)
timestamp += FRAME_DURATION;
@@ -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;
}
}
diff --git a/gst/rtp/gstrtpqcelpdepay.h b/gst/rtp/gstrtpqcelpdepay.h
index e78c90621..bd01d33c7 100644
--- a/gst/rtp/gstrtpqcelpdepay.h
+++ b/gst/rtp/gstrtpqcelpdepay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_QCELP_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -41,7 +41,7 @@ typedef struct _GstRtpQCELPDepayClass GstRtpQCELPDepayClass;
struct _GstRtpQCELPDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
gboolean interleaved;
guint bundling;
@@ -50,7 +50,7 @@ struct _GstRtpQCELPDepay
struct _GstRtpQCELPDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_qcelp_depay_get_type (void);
diff --git a/gst/rtp/gstrtpqdmdepay.c b/gst/rtp/gstrtpqdmdepay.c
index 01397098a..cc5aa4395 100644
--- a/gst/rtp/gstrtpqdmdepay.c
+++ b/gst/rtp/gstrtpqdmdepay.c
@@ -46,8 +46,9 @@ GST_STATIC_PAD_TEMPLATE ("sink",
"encoding-name = (string)\"X-QDM\"")
);
-GST_BOILERPLATE (GstRtpQDM2Depay, gst_rtp_qdm2_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_qdm2_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpQDM2Depay, gst_rtp_qdm2_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static const guint8 headheader[20] = {
0x0, 0x0, 0x0, 0xc, 0x66, 0x72, 0x6d, 0x61,
@@ -60,50 +61,43 @@ static void gst_rtp_qdm2_depay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_qdm2_depay_change_state (GstElement *
element, GstStateChange transition);
-static GstBuffer *gst_rtp_qdm2_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_qdm2_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-gboolean gst_rtp_qdm2_depay_setcaps (GstBaseRTPDepayload * filter,
+gboolean gst_rtp_qdm2_depay_setcaps (GstRTPBaseDepayload * filter,
GstCaps * caps);
static void
-gst_rtp_qdm2_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_qdm2_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gstbasertpdepayload_class->process = gst_rtp_qdm2_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_qdm2_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_qdm2_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_qdm2_depay_setcaps;
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 ();
}
@@ -123,7 +117,7 @@ gst_rtp_qdm2_depay_finalize (GObject * object)
// only on the sink
gboolean
-gst_rtp_qdm2_depay_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps)
+gst_rtp_qdm2_depay_setcaps (GstRTPBaseDepayload * filter, GstCaps * caps)
{
GstStructure *structure = gst_caps_get_structure (caps, 0);
gint clock_rate;
@@ -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);
@@ -233,11 +227,12 @@ add_packet (GstRtpQDM2Depay * depay, guint32 pid, guint32 len, guint8 * data)
}
static GstBuffer *
-gst_rtp_qdm2_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_qdm2_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpQDM2Depay *rtpqdm2depay;
- GstBuffer *outbuf;
+ GstBuffer *outbuf = NULL;
guint16 seq;
+ GstRTPBuffer rtp = { NULL };
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,15 +306,17 @@ 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,
"rate", G_TYPE_INT, rtpqdm2depay->samplerate,
"channels", G_TYPE_INT, rtpqdm2depay->channs,
"codec_data", GST_TYPE_BUFFER, codecdata, NULL);
- gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), caps);
+ gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), caps);
gst_caps_unref (caps);
rtpqdm2depay->configured = TRUE;
} else {
@@ -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;
}
}
diff --git a/gst/rtp/gstrtpqdmdepay.h b/gst/rtp/gstrtpqdmdepay.h
index e3ae3dc3f..38f8681c0 100644
--- a/gst/rtp/gstrtpqdmdepay.h
+++ b/gst/rtp/gstrtpqdmdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -49,7 +49,7 @@ typedef struct _QDM2Packet {
struct _GstRtpQDM2Depay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
GstAdapter *adapter;
@@ -73,7 +73,7 @@ struct _GstRtpQDM2Depay
struct _GstRtpQDM2DepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_qdm2_depay_get_type (void);
diff --git a/gst/rtp/gstrtpsirendepay.c b/gst/rtp/gstrtpsirendepay.c
index 9213f24db..a76a9af29 100644
--- a/gst/rtp/gstrtpsirendepay.c
+++ b/gst/rtp/gstrtpsirendepay.c
@@ -46,56 +46,51 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-siren, " "dct-length = (int) 320")
);
-static GstBuffer *gst_rtp_siren_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_siren_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_siren_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_siren_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-GST_BOILERPLATE (GstRTPSirenDepay, gst_rtp_siren_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+G_DEFINE_TYPE (GstRTPSirenDepay, gst_rtp_siren_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void
-gst_rtp_siren_depay_base_init (gpointer klass)
+gst_rtp_siren_depay_class_init (GstRTPSirenDepayClass * klass)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
+
+ gstrtpbasedepayload_class->process = gst_rtp_siren_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_siren_depay_setcaps;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_siren_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_siren_depay_sink_template);
- gst_element_class_set_details_simple (element_class,
+ 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_class_init (GstRTPSirenDepayClass * klass)
-{
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
-
- gstbasertpdepayload_class->process = gst_rtp_siren_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_siren_depay_setcaps;
-}
-
-static void
-gst_rtp_siren_depay_init (GstRTPSirenDepay * rtpsirendepay,
- GstRTPSirenDepayClass * klass)
+gst_rtp_siren_depay_init (GstRTPSirenDepay * rtpsirendepay)
{
}
static gboolean
-gst_rtp_siren_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_siren_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
gboolean ret;
srccaps = gst_caps_new_simple ("audio/x-siren",
"dct-length", G_TYPE_INT, 320, NULL);
- ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
GST_DEBUG ("set caps on source: %" GST_PTR_FORMAT " (ret=%d)", srccaps, ret);
gst_caps_unref (srccaps);
@@ -107,11 +102,14 @@ gst_rtp_siren_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
}
static GstBuffer *
-gst_rtp_siren_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_siren_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstBuffer *outbuf;
+ GstRTPBuffer rtp = { NULL };
- 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;
}
diff --git a/gst/rtp/gstrtpsirendepay.h b/gst/rtp/gstrtpsirendepay.h
index cbb18cb3e..1483f1d19 100644
--- a/gst/rtp/gstrtpsirendepay.h
+++ b/gst/rtp/gstrtpsirendepay.h
@@ -23,7 +23,7 @@
#define __GST_RTP_SIREN_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS typedef struct _GstRTPSirenDepay GstRTPSirenDepay;
typedef struct _GstRTPSirenDepayClass GstRTPSirenDepayClass;
@@ -42,13 +42,13 @@ typedef struct _GstRTPSirenDepayClass GstRTPSirenDepayClass;
struct _GstRTPSirenDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
};
struct _GstRTPSirenDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_siren_depay_get_type (void);
diff --git a/gst/rtp/gstrtpsirenpay.c b/gst/rtp/gstrtpsirenpay.c
index e878d4fbc..3a55eb415 100644
--- a/gst/rtp/gstrtpsirenpay.c
+++ b/gst/rtp/gstrtpsirenpay.c
@@ -48,69 +48,64 @@ GST_STATIC_PAD_TEMPLATE ("src",
"bitrate = (string) \"16000\", " "dct-length = (int) 320")
);
-static gboolean gst_rtp_siren_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_siren_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-GST_BOILERPLATE (GstRTPSirenPay, gst_rtp_siren_pay, GstBaseRTPAudioPayload,
- GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
+G_DEFINE_TYPE (GstRTPSirenPay, gst_rtp_siren_pay,
+ GST_TYPE_RTP_BASE_AUDIO_PAYLOAD);
static void
-gst_rtp_siren_pay_base_init (gpointer klass)
+gst_rtp_siren_pay_class_init (GstRTPSirenPayClass * klass)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
+
+ gstrtpbasepayload_class->set_caps = gst_rtp_siren_pay_setcaps;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_siren_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_siren_pay_src_template);
- gst_element_class_set_details_simple (element_class,
+ 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>");
-}
-
-static void
-gst_rtp_siren_pay_class_init (GstRTPSirenPayClass * klass)
-{
- GstBaseRTPPayloadClass *gstbasertppayload_class;
-
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
-
- gstbasertppayload_class->set_caps = gst_rtp_siren_pay_setcaps;
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;
+ GstRTPBasePayload *rtpbasepayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
- basertppayload = GST_BASE_RTP_PAYLOAD (rtpsirenpay);
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtpsirenpay);
+ rtpbasepayload = GST_RTP_BASE_PAYLOAD (rtpsirenpay);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpsirenpay);
/* we don't set the payload type, it should be set by the application using
* the pt property or the default 96 will be used */
- basertppayload->clock_rate = 16000;
+ rtpbasepayload->clock_rate = 16000;
- /* tell basertpaudiopayload that this is a frame based codec */
- gst_base_rtp_audio_payload_set_frame_based (basertpaudiopayload);
+ /* tell rtpbaseaudiopayload that this is a frame based codec */
+ gst_rtp_base_audio_payload_set_frame_based (rtpbaseaudiopayload);
}
static gboolean
-gst_rtp_siren_pay_setcaps (GstBaseRTPPayload * basertppayload, GstCaps * caps)
+gst_rtp_siren_pay_setcaps (GstRTPBasePayload * rtpbasepayload, GstCaps * caps)
{
GstRTPSirenPay *rtpsirenpay;
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
gint dct_length;
GstStructure *structure;
const char *payload_name;
- rtpsirenpay = GST_RTP_SIREN_PAY (basertppayload);
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (basertppayload);
+ rtpsirenpay = GST_RTP_SIREN_PAY (rtpbasepayload);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpbasepayload);
structure = gst_caps_get_structure (caps, 0);
@@ -122,12 +117,12 @@ gst_rtp_siren_pay_setcaps (GstBaseRTPPayload * basertppayload, GstCaps * caps)
if (g_ascii_strcasecmp ("audio/x-siren", payload_name))
goto wrong_caps;
- gst_basertppayload_set_options (basertppayload, "audio", TRUE, "SIREN",
+ gst_rtp_base_payload_set_options (rtpbasepayload, "audio", TRUE, "SIREN",
16000);
/* set options for this frame based audio codec */
- gst_base_rtp_audio_payload_set_frame_options (basertpaudiopayload, 20, 40);
+ gst_rtp_base_audio_payload_set_frame_options (rtpbaseaudiopayload, 20, 40);
- return gst_basertppayload_set_outcaps (basertppayload, NULL);
+ return gst_rtp_base_payload_set_outcaps (rtpbasepayload, NULL);
/* ERRORS */
wrong_dct:
diff --git a/gst/rtp/gstrtpsirenpay.h b/gst/rtp/gstrtpsirenpay.h
index cb6625eaa..ee9f3d230 100644
--- a/gst/rtp/gstrtpsirenpay.h
+++ b/gst/rtp/gstrtpsirenpay.h
@@ -23,7 +23,7 @@
#define __GST_RTP_SIREN_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpaudiopayload.h>
+#include <gst/rtp/gstrtpbaseaudiopayload.h>
G_BEGIN_DECLS
#define GST_TYPE_RTP_SIREN_PAY \
@@ -41,12 +41,12 @@ typedef struct _GstRTPSirenPayClass GstRTPSirenPayClass;
struct _GstRTPSirenPay
{
- GstBaseRTPAudioPayload audiopayload;
+ GstRTPBaseAudioPayload audiopayload;
};
struct _GstRTPSirenPayClass
{
- GstBaseRTPAudioPayloadClass parent_class;
+ GstRTPBaseAudioPayloadClass parent_class;
};
GType gst_rtp_siren_pay_get_type (void);
diff --git a/gst/rtp/gstrtpspeexdepay.c b/gst/rtp/gstrtpspeexdepay.c
index 29903b91f..47948e5d9 100644
--- a/gst/rtp/gstrtpspeexdepay.c
+++ b/gst/rtp/gstrtpspeexdepay.c
@@ -58,43 +58,38 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-speex")
);
-static GstBuffer *gst_rtp_speex_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_speex_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_speex_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_speex_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-GST_BOILERPLATE (GstRtpSPEEXDepay, gst_rtp_speex_depay, GstBaseRTPDepayload,
- 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_static_pad_template (element_class,
- &gst_rtp_speex_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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>");
-}
+G_DEFINE_TYPE (GstRtpSPEEXDepay, gst_rtp_speex_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void
gst_rtp_speex_depay_class_init (GstRtpSPEEXDepayClass * klass)
{
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class->process = gst_rtp_speex_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_speex_depay_setcaps;
- 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)
{
}
@@ -117,13 +112,13 @@ static const gchar gst_rtp_speex_comment[] =
"\045\0\0\0Depayloaded with GStreamer speexdepay\0\0\0\0";
static gboolean
-gst_rtp_speex_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_speex_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
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,20 +169,20 @@ 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);
+ srccaps = gst_caps_new_empty_simple ("audio/x-speex");
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);
+ gst_rtp_base_depayload_push (GST_RTP_BASE_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);
+ gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpspeexdepay), buf);
return res;
@@ -200,17 +195,21 @@ no_clockrate:
}
static GstBuffer *
-gst_rtp_speex_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_speex_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstBuffer *outbuf = NULL;
+ GstRTPBuffer rtp = { NULL };
+
+ 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_DEBUG ("process : got %" G_GSIZE_FORMAT " bytes, mark %d ts %u seqn %d",
+ 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;
diff --git a/gst/rtp/gstrtpspeexdepay.h b/gst/rtp/gstrtpspeexdepay.h
index 07b727f85..f78d32cf0 100644
--- a/gst/rtp/gstrtpspeexdepay.h
+++ b/gst/rtp/gstrtpspeexdepay.h
@@ -16,7 +16,7 @@
#define __GST_RTP_SPEEX_DEPAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -36,12 +36,12 @@ typedef struct _GstRtpSPEEXDepayClass GstRtpSPEEXDepayClass;
struct _GstRtpSPEEXDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
};
struct _GstRtpSPEEXDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_speex_depay_get_type (void);
diff --git a/gst/rtp/gstrtpspeexpay.c b/gst/rtp/gstrtpspeexpay.c
index bc69fb059..d3319d852 100644
--- a/gst/rtp/gstrtpspeexpay.c
+++ b/gst/rtp/gstrtpspeexpay.c
@@ -53,60 +53,53 @@ GST_STATIC_PAD_TEMPLATE ("src",
static GstStateChangeReturn gst_rtp_speex_pay_change_state (GstElement *
element, GstStateChange transition);
-static gboolean gst_rtp_speex_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_speex_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstCaps *gst_rtp_speex_pay_getcaps (GstBaseRTPPayload * payload,
- GstPad * pad);
-static GstFlowReturn gst_rtp_speex_pay_handle_buffer (GstBaseRTPPayload *
+static GstCaps *gst_rtp_speex_pay_getcaps (GstRTPBasePayload * payload,
+ GstPad * pad, GstCaps * filter);
+static GstFlowReturn gst_rtp_speex_pay_handle_buffer (GstRTPBasePayload *
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_static_pad_template (element_class,
- &gst_rtp_speex_pay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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_RTP_BASE_PAYLOAD);
static void
gst_rtp_speex_pay_class_init (GstRtpSPEEXPayClass * klass)
{
GstElementClass *gstelement_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gstelement_class = (GstElementClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gstelement_class->change_state = gst_rtp_speex_pay_change_state;
- 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;
+ gstrtpbasepayload_class->set_caps = gst_rtp_speex_pay_setcaps;
+ gstrtpbasepayload_class->get_caps = gst_rtp_speex_pay_getcaps;
+ gstrtpbasepayload_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 */
+ GST_RTP_BASE_PAYLOAD (rtpspeexpay)->clock_rate = 8000;
+ GST_RTP_BASE_PAYLOAD_PT (rtpspeexpay) = 110; /* Create String */
}
static gboolean
-gst_rtp_speex_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_speex_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
/* don't configure yet, we wait for the ident packet */
return TRUE;
@@ -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 (GstRTPBasePayload * 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;
}
@@ -143,7 +144,7 @@ gst_rtp_speex_pay_parse_ident (GstRtpSPEEXPay * rtpspeexpay,
const guint8 * data, guint size)
{
guint32 version, header_size, rate, mode, nb_channels;
- GstBaseRTPPayload *payload;
+ GstRTPBasePayload *payload;
gchar *cstr;
gboolean res;
@@ -181,11 +182,11 @@ gst_rtp_speex_pay_parse_ident (GstRtpSPEEXPay * rtpspeexpay,
GST_DEBUG_OBJECT (rtpspeexpay, "rate %d, mode %d, nb_channels %d",
rate, mode, nb_channels);
- payload = GST_BASE_RTP_PAYLOAD (rtpspeexpay);
+ payload = GST_RTP_BASE_PAYLOAD (rtpspeexpay);
- gst_basertppayload_set_options (payload, "audio", FALSE, "SPEEX", rate);
+ gst_rtp_base_payload_set_options (payload, "audio", FALSE, "SPEEX", rate);
cstr = g_strdup_printf ("%d", nb_channels);
- res = gst_basertppayload_set_outcaps (payload, "encoding-params",
+ res = gst_rtp_base_payload_set_outcaps (payload, "encoding-params",
G_TYPE_STRING, cstr, NULL);
g_free (cstr);
@@ -227,20 +228,21 @@ payload_too_small:
}
static GstFlowReturn
-gst_rtp_speex_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_speex_pay_handle_buffer (GstRTPBasePayload * 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 = { NULL };
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:
@@ -273,21 +275,25 @@ gst_rtp_speex_pay_handle_buffer (GstBaseRTPPayload * basepayload,
outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
/* FIXME, assert for now */
- g_assert (payload_len <= GST_BASE_RTP_PAYLOAD_MTU (rtpspeexpay));
+ g_assert (payload_len <= GST_RTP_BASE_PAYLOAD_MTU (rtpspeexpay));
/* copy timestamp and duration */
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);
- ret = gst_basertppayload_push (basepayload, outbuf);
+ gst_rtp_buffer_unmap (&rtp);
+
+ ret = gst_rtp_base_payload_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;
}
diff --git a/gst/rtp/gstrtpspeexpay.h b/gst/rtp/gstrtpspeexpay.h
index f43986ae0..253978e98 100644
--- a/gst/rtp/gstrtpspeexpay.h
+++ b/gst/rtp/gstrtpspeexpay.h
@@ -17,7 +17,7 @@
#define __GST_RTP_SPEEX_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
G_BEGIN_DECLS
@@ -37,14 +37,14 @@ typedef struct _GstRtpSPEEXPayClass GstRtpSPEEXPayClass;
struct _GstRtpSPEEXPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
guint64 packet;
};
struct _GstRtpSPEEXPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_speex_pay_get_type (void);
diff --git a/gst/rtp/gstrtpsv3vdepay.c b/gst/rtp/gstrtpsv3vdepay.c
index b29fe021d..ed8dd9e93 100644
--- a/gst/rtp/gstrtpsv3vdepay.c
+++ b/gst/rtp/gstrtpsv3vdepay.c
@@ -47,58 +47,51 @@ 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,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_sv3v_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpSV3VDepay, gst_rtp_sv3v_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void gst_rtp_sv3v_depay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_sv3v_depay_change_state (GstElement *
element, GstStateChange transition);
-static GstBuffer *gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_sv3v_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-gboolean gst_rtp_sv3v_depay_setcaps (GstBaseRTPDepayload * filter,
+gboolean gst_rtp_sv3v_depay_setcaps (GstRTPBaseDepayload * filter,
GstCaps * caps);
static void
-gst_rtp_sv3v_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_sv3v_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gstbasertpdepayload_class->process = gst_rtp_sv3v_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_sv3v_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_sv3v_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_sv3v_depay_setcaps;
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 ();
}
@@ -118,7 +111,7 @@ gst_rtp_sv3v_depay_finalize (GObject * object)
// only on the sink
gboolean
-gst_rtp_sv3v_depay_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps)
+gst_rtp_sv3v_depay_setcaps (GstRTPBaseDepayload * filter, GstCaps * caps)
{
GstStructure *structure = gst_caps_get_structure (caps, 0);
gint clock_rate;
@@ -133,7 +126,7 @@ gst_rtp_sv3v_depay_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps)
}
static GstBuffer *
-gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_sv3v_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpSV3VDepay *rtpsv3vdepay;
static struct
@@ -155,11 +148,14 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
gboolean C, S, E;
GstBuffer *outbuf = NULL;
guint16 seq;
+ GstRTPBuffer rtp = { NULL };
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_RTP_BASE_DEPAYLOAD_SRCPAD
+ (depayload)))) {
GST_DEBUG ("Already configured, skipping config parsing");
goto beach;
}
@@ -231,19 +229,21 @@ 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,
"width", G_TYPE_INT, rtpsv3vdepay->width,
"height", G_TYPE_INT, rtpsv3vdepay->height,
"codec_data", GST_TYPE_BUFFER, codec_data, NULL);
- gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), caps);
+ gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), caps);
gst_caps_unref (caps);
GST_DEBUG ("Depayloader now configured");
@@ -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;
}
}
diff --git a/gst/rtp/gstrtpsv3vdepay.h b/gst/rtp/gstrtpsv3vdepay.h
index 7c55afdee..86db193b6 100644
--- a/gst/rtp/gstrtpsv3vdepay.h
+++ b/gst/rtp/gstrtpsv3vdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpSV3VDepayClass GstRtpSV3VDepayClass;
struct _GstRtpSV3VDepay
{
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
GstAdapter *adapter;
@@ -55,7 +55,7 @@ struct _GstRtpSV3VDepay
struct _GstRtpSV3VDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_sv3v_depay_get_type (void);
diff --git a/gst/rtp/gstrtptheoradepay.c b/gst/rtp/gstrtptheoradepay.c
index 1e3826220..9f5580a7e 100644
--- a/gst/rtp/gstrtptheoradepay.c
+++ b/gst/rtp/gstrtptheoradepay.c
@@ -60,57 +60,52 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("video/x-theora")
);
-GST_BOILERPLATE (GstRtpTheoraDepay, gst_rtp_theora_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_theora_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpTheoraDepay, gst_rtp_theora_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
-static gboolean gst_rtp_theora_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_theora_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_theora_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_theora_depay_packet_lost (GstBaseRTPDepayload *
+static gboolean gst_rtp_theora_depay_packet_lost (GstRTPBaseDepayload *
depayload, GstEvent * event);
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_static_pad_template (element_class,
- &gst_rtp_theora_depay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->finalize = gst_rtp_theora_depay_finalize;
- gstbasertpdepayload_class->process = gst_rtp_theora_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_theora_depay_setcaps;
- gstbasertpdepayload_class->packet_lost = gst_rtp_theora_depay_packet_lost;
+ gstrtpbasedepayload_class->process = gst_rtp_theora_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_theora_depay_setcaps;
+ gstrtpbasedepayload_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 |
@@ -204,7 +198,8 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
data += 6;
GST_DEBUG_OBJECT (rtptheoradepay,
- "header %d, ident 0x%08x, length %u, left %u", i, ident, length, size);
+ "header %d, ident 0x%08x, length %u, left %" G_GSIZE_FORMAT, i, ident,
+ length, size);
/* FIXME check if we already got this ident */
@@ -241,6 +236,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 +253,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 +288,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,12 +297,13 @@ 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);
}
static gboolean
-gst_rtp_theora_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_theora_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstRtpTheoraDepay *rtptheoradepay;
@@ -330,16 +332,15 @@ 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;
}
/* set caps on pad and on header */
- srccaps = gst_caps_new_simple ("video/x-theora", NULL);
+ srccaps = gst_caps_new_empty_simple ("video/x-theora");
res = gst_pad_set_caps (depayload->srcpad, srccaps);
gst_caps_unref (srccaps);
@@ -381,7 +382,7 @@ gst_rtp_theora_depay_switch_codebook (GstRtpTheoraDepay * rtptheoradepay,
GstBuffer *header = GST_BUFFER_CAST (headers->data);
gst_buffer_ref (header);
- gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtptheoradepay),
+ gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtptheoradepay),
header);
}
/* remember the current config */
@@ -397,20 +398,22 @@ gst_rtp_theora_depay_switch_codebook (GstRtpTheoraDepay * rtptheoradepay,
}
static GstBuffer *
-gst_rtp_theora_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpTheoraDepay *rtptheoradepay;
GstBuffer *outbuf;
GstFlowReturn ret;
gint payload_len;
guint8 *payload, *to_free = NULL;
- guint32 timestamp;
guint32 header, ident;
guint8 F, TDT, packets;
+ GstRTPBuffer rtp = { NULL };
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,8 +525,6 @@ gst_rtp_theora_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
* .. theora data |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+*
*/
- timestamp = gst_rtp_buffer_get_timestamp (buf);
-
while (payload_len >= 2) {
guint16 length;
@@ -550,13 +551,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)
@@ -565,18 +570,9 @@ gst_rtp_theora_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
payload += length;
payload_len -= length;
- if (timestamp != -1)
- /* push with timestamp of the last packet, which is the same timestamp that
- * should apply to the first assembled packet. */
- ret = gst_base_rtp_depayload_push_ts (depayload, timestamp, outbuf);
- else
- ret = gst_base_rtp_depayload_push (depayload, outbuf);
-
+ ret = gst_rtp_base_depayload_push (depayload, outbuf);
if (ret != GST_FLOW_OK)
break;
-
- /* make sure we don't set a timestamp on next buffers */
- timestamp = -1;
}
g_free (to_free);
@@ -584,10 +580,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 +604,7 @@ packet_short:
ignore_reserved:
{
GST_WARNING_OBJECT (rtptheoradepay, "reserved TDT ignored");
+ gst_rtp_buffer_unmap (&rtp);
return NULL;
}
length_short:
@@ -623,18 +622,20 @@ invalid_configuration:
}
request_config:
{
- gst_pad_push_event (GST_BASE_RTP_DEPAYLOAD_SINKPAD (depayload),
+ gst_pad_push_event (GST_RTP_BASE_DEPAYLOAD_SINKPAD (depayload),
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:
{
rtptheoradepay->needs_keyframe = TRUE;
- gst_pad_push_event (GST_BASE_RTP_DEPAYLOAD_SINKPAD (depayload),
+ gst_pad_push_event (GST_RTP_BASE_DEPAYLOAD_SINKPAD (depayload),
gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM,
- gst_structure_new ("GstForceKeyUnit", NULL)));
+ gst_structure_new_empty ("GstForceKeyUnit")));
+ gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
@@ -647,20 +648,20 @@ gst_rtp_theora_depay_plugin_init (GstPlugin * plugin)
}
static gboolean
-gst_rtp_theora_depay_packet_lost (GstBaseRTPDepayload * depayload,
+gst_rtp_theora_depay_packet_lost (GstRTPBaseDepayload * depayload,
GstEvent * event)
{
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;
- gst_pad_push_event (GST_BASE_RTP_DEPAYLOAD_SINKPAD (depayload),
+ gst_pad_push_event (GST_RTP_BASE_DEPAYLOAD_SINKPAD (depayload),
gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM,
- gst_structure_new ("GstForceKeyUnit", NULL)));
+ gst_structure_new_empty ("GstForceKeyUnit")));
return TRUE;
}
diff --git a/gst/rtp/gstrtptheoradepay.h b/gst/rtp/gstrtptheoradepay.h
index dff261c43..320e9b7ef 100644
--- a/gst/rtp/gstrtptheoradepay.h
+++ b/gst/rtp/gstrtptheoradepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -47,7 +47,7 @@ typedef struct _GstRtpTheoraConfig {
struct _GstRtpTheoraDepay
{
- GstBaseRTPDepayload parent;
+ GstRTPBaseDepayload parent;
GList *configs;
GstRtpTheoraConfig *config;
@@ -60,7 +60,7 @@ struct _GstRtpTheoraDepay
struct _GstRtpTheoraDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_theora_depay_get_type (void);
diff --git a/gst/rtp/gstrtptheorapay.c b/gst/rtp/gstrtptheorapay.c
index a4c09193e..3183b1cf0 100644
--- a/gst/rtp/gstrtptheorapay.c
+++ b/gst/rtp/gstrtptheorapay.c
@@ -75,16 +75,16 @@ 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_RTP_BASE_PAYLOAD);
-static gboolean gst_rtp_theora_pay_setcaps (GstBaseRTPPayload * basepayload,
+static gboolean gst_rtp_theora_pay_setcaps (GstRTPBasePayload * basepayload,
GstCaps * caps);
static GstStateChangeReturn gst_rtp_theora_pay_change_state (GstElement *
element, GstStateChange transition);
-static GstFlowReturn gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * pad,
+static GstFlowReturn gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * pad,
GstBuffer * buffer);
-static gboolean gst_rtp_theora_pay_handle_event (GstPad * pad,
+static gboolean gst_rtp_theora_pay_sink_event (GstRTPBasePayload * payload,
GstEvent * event);
@@ -94,41 +94,35 @@ 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_static_pad_template (element_class,
- &gst_rtp_theora_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
GstElementClass *gstelement_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gstelement_class->change_state = gst_rtp_theora_pay_change_state;
- gstbasertppayload_class->set_caps = gst_rtp_theora_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_theora_pay_handle_buffer;
- gstbasertppayload_class->handle_event = gst_rtp_theora_pay_handle_event;
+ gstrtpbasepayload_class->set_caps = gst_rtp_theora_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_theora_pay_handle_buffer;
+ gstrtpbasepayload_class->sink_event = gst_rtp_theora_pay_sink_event;
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;
}
@@ -172,7 +165,7 @@ gst_rtp_theora_pay_cleanup (GstRtpTheoraPay * rtptheorapay)
}
static gboolean
-gst_rtp_theora_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
+gst_rtp_theora_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
{
GstRtpTheoraPay *rtptheorapay;
@@ -187,11 +180,14 @@ static void
gst_rtp_theora_pay_reset_packet (GstRtpTheoraPay * rtptheorapay, guint8 TDT)
{
guint payload_len;
+ GstRTPBuffer rtp = { NULL };
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;
@@ -210,7 +206,7 @@ gst_rtp_theora_pay_init_packet (GstRtpTheoraPay * rtptheorapay, guint8 TDT,
/* new packet allocate max packet size */
rtptheorapay->packet =
- gst_rtp_buffer_new_allocate_len (GST_BASE_RTP_PAYLOAD_MTU
+ gst_rtp_buffer_new_allocate_len (GST_RTP_BASE_PAYLOAD_MTU
(rtptheorapay), 0, 0);
gst_rtp_theora_pay_reset_packet (rtptheorapay, TDT);
@@ -223,6 +219,7 @@ gst_rtp_theora_pay_flush_packet (GstRtpTheoraPay * rtptheorapay)
GstFlowReturn ret;
guint8 *payload;
guint hlen;
+ GstRTPBuffer rtp = { NULL };
/* 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,15 +249,17 @@ 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;
/* push, this gives away our ref to the packet, so clear it. */
ret =
- gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtptheorapay),
+ gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtptheorapay),
rtptheorapay->packet);
rtptheorapay->packet = NULL;
@@ -266,7 +267,7 @@ gst_rtp_theora_pay_flush_packet (GstRtpTheoraPay * rtptheorapay)
}
static gboolean
-gst_rtp_theora_pay_finish_headers (GstBaseRTPPayload * basepayload)
+gst_rtp_theora_pay_finish_headers (GstRTPBasePayload * basepayload)
{
GstRtpTheoraPay *rtptheorapay = GST_RTP_THEORA_PAY (basepayload);
GList *walk;
@@ -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 */
@@ -438,13 +445,13 @@ gst_rtp_theora_pay_finish_headers (GstBaseRTPPayload * basepayload)
/* configure payloader settings */
wstr = g_strdup_printf ("%d", rtptheorapay->width);
hstr = g_strdup_printf ("%d", rtptheorapay->height);
- gst_basertppayload_set_options (basepayload, "video", TRUE, "THEORA", 90000);
- res = gst_basertppayload_set_outcaps (basepayload,
- "sampling", G_TYPE_STRING, "YCbCr-4:2:0",
- "width", G_TYPE_STRING, wstr,
- "height", G_TYPE_STRING, hstr,
- "configuration", G_TYPE_STRING, configuration,
- "delivery-method", G_TYPE_STRING, "inline",
+ gst_rtp_base_payload_set_options (basepayload, "video", TRUE, "THEORA",
+ 90000);
+ res =
+ gst_rtp_base_payload_set_outcaps (basepayload, "sampling", G_TYPE_STRING,
+ "YCbCr-4:2:0", "width", G_TYPE_STRING, wstr, "height", G_TYPE_STRING,
+ hstr, "configuration", G_TYPE_STRING, configuration, "delivery-method",
+ G_TYPE_STRING, "inline",
/* don't set the other defaults
*/
NULL);
@@ -463,7 +470,7 @@ no_headers:
}
static gboolean
-gst_rtp_theora_pay_parse_id (GstBaseRTPPayload * basepayload, guint8 * data,
+gst_rtp_theora_pay_parse_id (GstRTPBasePayload * basepayload, guint8 * data,
guint size)
{
GstRtpTheoraPay *rtptheorapay;
@@ -532,6 +539,7 @@ gst_rtp_theora_pay_payload_buffer (GstRtpTheoraPay * rtptheorapay, guint8 TDT,
guint plen;
guint8 *ppos, *payload;
gboolean fragmented;
+ GstRTPBuffer rtp = { NULL };
/* size increases with packet length and 2 bytes size eader. */
newduration = rtptheorapay->payload_duration;
@@ -542,7 +550,7 @@ gst_rtp_theora_pay_payload_buffer (GstRtpTheoraPay * rtptheorapay, guint8 TDT,
packet_len = gst_rtp_buffer_calc_packet_len (newsize, 0, 0);
/* check buffer filled against length and max latency */
- flush = gst_basertppayload_is_filled (GST_BASE_RTP_PAYLOAD (rtptheorapay),
+ flush = gst_rtp_base_payload_is_filled (GST_RTP_BASE_PAYLOAD (rtptheorapay),
packet_len, newduration);
/* we can store up to 15 theora packets in one RTP packet. */
flush |= (rtptheorapay->payload_pkts == 15);
@@ -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,16 +631,19 @@ gst_rtp_theora_pay_payload_buffer (GstRtpTheoraPay * rtptheorapay, guint8 TDT,
}
} while (size);
+ if (rtp.buffer)
+ gst_rtp_buffer_unmap (&rtp);
+
return ret;
}
static GstFlowReturn
-gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
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:
@@ -747,12 +763,14 @@ done:
wrong_size:
{
GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
- ("Invalid packet size (%d <= 0xffff)", size), (NULL));
+ ("Invalid packet size (%" G_GSIZE_FORMAT " <= 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_sink_event (GstRTPBasePayload * 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:
@@ -785,7 +805,7 @@ gst_rtp_theora_pay_handle_event (GstPad * pad, GstEvent * event)
break;
}
/* false to let parent handle event as well */
- return FALSE;
+ return GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->sink_event (payload, event);
}
static GstStateChangeReturn
diff --git a/gst/rtp/gstrtptheorapay.h b/gst/rtp/gstrtptheorapay.h
index 198e37533..5d46937aa 100644
--- a/gst/rtp/gstrtptheorapay.h
+++ b/gst/rtp/gstrtptheorapay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_THEORA_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpTheoraPayClass GstRtpTheoraPayClass;
struct _GstRtpTheoraPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
/* the headers */
gboolean need_headers;
@@ -72,7 +72,7 @@ struct _GstRtpTheoraPay
struct _GstRtpTheoraPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_theora_pay_get_type (void);
diff --git a/gst/rtp/gstrtpvorbisdepay.c b/gst/rtp/gstrtpvorbisdepay.c
index 1694af8ab..ccd4b3e0b 100644
--- a/gst/rtp/gstrtpvorbisdepay.c
+++ b/gst/rtp/gstrtpvorbisdepay.c
@@ -57,12 +57,13 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-vorbis")
);
-GST_BOILERPLATE (GstRtpVorbisDepay, gst_rtp_vorbis_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_vorbis_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpVorbisDepay, gst_rtp_vorbis_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
-static gboolean gst_rtp_vorbis_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_vorbis_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_vorbis_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_vorbis_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
static void gst_rtp_vorbis_depay_finalize (GObject * object);
@@ -70,48 +71,40 @@ 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_static_pad_template (element_class,
- &gst_rtp_vorbis_depay_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gobject_class->finalize = gst_rtp_vorbis_depay_finalize;
gstelement_class->change_state = gst_rtp_vorbis_depay_change_state;
- gstbasertpdepayload_class->process = gst_rtp_vorbis_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_vorbis_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_vorbis_depay_process;
+ gstrtpbasedepayload_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 |
@@ -235,7 +227,8 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
offset += 6;
GST_DEBUG_OBJECT (rtpvorbisdepay,
- "header %d, ident 0x%08x, length %u, left %u", i, ident, length, size);
+ "header %d, ident 0x%08x, length %u, left %" G_GSIZE_FORMAT, i, ident,
+ length, size);
/* FIXME check if we already got this ident */
@@ -293,13 +286,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 +304,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 +323,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,12 +332,13 @@ 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);
}
static gboolean
-gst_rtp_vorbis_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_vorbis_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstRtpVorbisDepay *rtpvorbisdepay;
@@ -368,9 +366,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 {
@@ -381,7 +378,7 @@ gst_rtp_vorbis_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
depayload->clock_rate = clock_rate;
/* set caps on pad and on header */
- srccaps = gst_caps_new_simple ("audio/x-vorbis", NULL);
+ srccaps = gst_caps_new_empty_simple ("audio/x-vorbis");
res = gst_pad_set_caps (depayload->srcpad, srccaps);
gst_caps_unref (srccaps);
@@ -421,7 +418,7 @@ gst_rtp_vorbis_depay_switch_codebook (GstRtpVorbisDepay * rtpvorbisdepay,
GstBuffer *header = GST_BUFFER_CAST (headers->data);
gst_buffer_ref (header);
- gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpvorbisdepay),
+ gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpvorbisdepay),
header);
}
/* remember the current config */
@@ -437,20 +434,22 @@ gst_rtp_vorbis_depay_switch_codebook (GstRtpVorbisDepay * rtpvorbisdepay,
}
static GstBuffer *
-gst_rtp_vorbis_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_vorbis_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpVorbisDepay *rtpvorbisdepay;
GstBuffer *outbuf;
GstFlowReturn ret;
gint payload_len;
guint8 *payload, *to_free = NULL;
- guint32 timestamp;
guint32 header, ident;
guint8 F, VDT, packets;
+ GstRTPBuffer rtp = { NULL };
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,8 +564,6 @@ gst_rtp_vorbis_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
* .. vorbis data |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+*
*/
- timestamp = gst_rtp_buffer_get_timestamp (buf);
-
while (payload_len > 2) {
guint16 length;
@@ -593,38 +590,36 @@ 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;
payload_len -= length;
- if (timestamp != -1)
- /* push with timestamp of the last packet, which is the same timestamp that
- * should apply to the first assembled packet. */
- ret = gst_base_rtp_depayload_push_ts (depayload, timestamp, outbuf);
- else
- ret = gst_base_rtp_depayload_push (depayload, outbuf);
-
+ ret = gst_rtp_base_depayload_push (depayload, outbuf);
if (ret != GST_FLOW_OK)
break;
-
- /* make sure we don't set a timestamp on next buffers */
- timestamp = -1;
}
g_free (to_free);
+ gst_rtp_buffer_unmap (&rtp);
+
return NULL;
no_output:
{
+ gst_rtp_buffer_unmap (&rtp);
return NULL;
}
/* ERORRS */
@@ -632,23 +627,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 +655,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;
}
}
diff --git a/gst/rtp/gstrtpvorbisdepay.h b/gst/rtp/gstrtpvorbisdepay.h
index 0b06118eb..fb362f7b2 100644
--- a/gst/rtp/gstrtpvorbisdepay.h
+++ b/gst/rtp/gstrtpvorbisdepay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -47,7 +47,7 @@ typedef struct _GstRtpVorbisConfig {
struct _GstRtpVorbisDepay
{
- GstBaseRTPDepayload parent;
+ GstRTPBaseDepayload parent;
GList *configs;
GstRtpVorbisConfig *config;
@@ -58,7 +58,7 @@ struct _GstRtpVorbisDepay
struct _GstRtpVorbisDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_vorbis_depay_get_type (void);
diff --git a/gst/rtp/gstrtpvorbispay.c b/gst/rtp/gstrtpvorbispay.c
index 12b82ec42..75b961e6b 100644
--- a/gst/rtp/gstrtpvorbispay.c
+++ b/gst/rtp/gstrtpvorbispay.c
@@ -58,56 +58,50 @@ 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_RTP_BASE_PAYLOAD);
-static gboolean gst_rtp_vorbis_pay_setcaps (GstBaseRTPPayload * basepayload,
+static gboolean gst_rtp_vorbis_pay_setcaps (GstRTPBasePayload * basepayload,
GstCaps * caps);
static GstStateChangeReturn gst_rtp_vorbis_pay_change_state (GstElement *
element, GstStateChange transition);
-static GstFlowReturn gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * pad,
+static GstFlowReturn gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * pad,
GstBuffer * buffer);
-static gboolean gst_rtp_vorbis_pay_handle_event (GstPad * pad,
+static gboolean gst_rtp_vorbis_pay_sink_event (GstRTPBasePayload * payload,
GstEvent * event);
static void
-gst_rtp_vorbis_pay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_vorbis_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
gstelement_class = (GstElementClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gstelement_class->change_state = gst_rtp_vorbis_pay_change_state;
- gstbasertppayload_class->set_caps = gst_rtp_vorbis_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_vorbis_pay_handle_buffer;
- gstbasertppayload_class->handle_event = gst_rtp_vorbis_pay_handle_event;
+ gstrtpbasepayload_class->set_caps = gst_rtp_vorbis_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_vorbis_pay_handle_buffer;
+ gstrtpbasepayload_class->sink_event = gst_rtp_vorbis_pay_sink_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 */
}
@@ -131,7 +125,7 @@ gst_rtp_vorbis_pay_cleanup (GstRtpVorbisPay * rtpvorbispay)
}
static gboolean
-gst_rtp_vorbis_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
+gst_rtp_vorbis_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
{
GstRtpVorbisPay *rtpvorbispay;
@@ -146,11 +140,14 @@ static void
gst_rtp_vorbis_pay_reset_packet (GstRtpVorbisPay * rtpvorbispay, guint8 VDT)
{
guint payload_len;
+ GstRTPBuffer rtp = { NULL };
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;
@@ -169,7 +166,7 @@ gst_rtp_vorbis_pay_init_packet (GstRtpVorbisPay * rtpvorbispay, guint8 VDT,
/* new packet allocate max packet size */
rtpvorbispay->packet =
- gst_rtp_buffer_new_allocate_len (GST_BASE_RTP_PAYLOAD_MTU
+ gst_rtp_buffer_new_allocate_len (GST_RTP_BASE_PAYLOAD_MTU
(rtpvorbispay), 0, 0);
gst_rtp_vorbis_pay_reset_packet (rtpvorbispay, VDT);
GST_BUFFER_TIMESTAMP (rtpvorbispay->packet) = timestamp;
@@ -181,6 +178,7 @@ gst_rtp_vorbis_pay_flush_packet (GstRtpVorbisPay * rtpvorbispay)
GstFlowReturn ret;
guint8 *payload;
guint hlen;
+ GstRTPBuffer rtp = { NULL };
/* 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,15 +208,17 @@ 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;
/* push, this gives away our ref to the packet, so clear it. */
ret =
- gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpvorbispay),
+ gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtpvorbispay),
rtpvorbispay->packet);
rtpvorbispay->packet = NULL;
@@ -224,7 +226,7 @@ gst_rtp_vorbis_pay_flush_packet (GstRtpVorbisPay * rtpvorbispay)
}
static gboolean
-gst_rtp_vorbis_pay_finish_headers (GstBaseRTPPayload * basepayload)
+gst_rtp_vorbis_pay_finish_headers (GstRTPBasePayload * basepayload)
{
GstRtpVorbisPay *rtpvorbispay = GST_RTP_VORBIS_PAY (basepayload);
GList *walk;
@@ -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 */
@@ -381,10 +385,10 @@ gst_rtp_vorbis_pay_finish_headers (GstBaseRTPPayload * basepayload)
/* configure payloader settings */
cstr = g_strdup_printf ("%d", rtpvorbispay->channels);
- gst_basertppayload_set_options (basepayload, "audio", TRUE, "VORBIS",
+ gst_rtp_base_payload_set_options (basepayload, "audio", TRUE, "VORBIS",
rtpvorbispay->rate);
res =
- gst_basertppayload_set_outcaps (basepayload, "encoding-params",
+ gst_rtp_base_payload_set_outcaps (basepayload, "encoding-params",
G_TYPE_STRING, cstr, "configuration", G_TYPE_STRING, configuration, NULL);
g_free (cstr);
g_free (configuration);
@@ -400,7 +404,7 @@ no_headers:
}
static gboolean
-gst_rtp_vorbis_pay_parse_id (GstBaseRTPPayload * basepayload, guint8 * data,
+gst_rtp_vorbis_pay_parse_id (GstRTPBasePayload * basepayload, guint8 * data,
guint size)
{
GstRtpVorbisPay *rtpvorbispay = GST_RTP_VORBIS_PAY (basepayload);
@@ -465,12 +469,13 @@ invalid_channels:
}
static GstFlowReturn
-gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
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 = { NULL };
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;
@@ -537,7 +543,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload,
packet_len = gst_rtp_buffer_calc_packet_len (newsize, 0, 0);
/* check buffer filled against length and max latency */
- flush = gst_basertppayload_is_filled (basepayload, packet_len, newduration);
+ flush = gst_rtp_base_payload_is_filled (basepayload, packet_len, newduration);
/* we can store up to 15 vorbis packets in one RTP packet. */
flush |= (rtpvorbispay->payload_pkts == 15);
/* flush if we have a new VDT */
@@ -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:
@@ -619,12 +633,15 @@ done:
wrong_size:
{
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
- ("Invalid packet size (1 < %d <= 0xffff)", size), (NULL));
+ ("Invalid packet size (1 < %" G_GSIZE_FORMAT " <= 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 +649,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 +657,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_sink_event (GstRTPBasePayload * 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:
@@ -657,7 +676,7 @@ gst_rtp_vorbis_pay_handle_event (GstPad * pad, GstEvent * event)
break;
}
/* false to let parent handle event as well */
- return FALSE;
+ return GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->sink_event (payload, event);
}
static GstStateChangeReturn
diff --git a/gst/rtp/gstrtpvorbispay.h b/gst/rtp/gstrtpvorbispay.h
index 9c86b5ba5..1d14d2c17 100644
--- a/gst/rtp/gstrtpvorbispay.h
+++ b/gst/rtp/gstrtpvorbispay.h
@@ -21,7 +21,7 @@
#define __GST_RTP_VORBIS_PAY_H__
#include <gst/gst.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GstRtpVorbisPayClass GstRtpVorbisPayClass;
struct _GstRtpVorbisPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload payload;
/* the headers */
gboolean need_headers;
@@ -65,7 +65,7 @@ struct _GstRtpVorbisPay
struct _GstRtpVorbisPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_vorbis_pay_get_type (void);
diff --git a/gst/rtp/gstrtpvrawdepay.c b/gst/rtp/gstrtpvrawdepay.c
index a18167c05..eb5a8ceea 100644
--- a/gst/rtp/gstrtpvrawdepay.c
+++ b/gst/rtp/gstrtpvrawdepay.c
@@ -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,58 +47,52 @@ GST_STATIC_PAD_TEMPLATE ("sink",
"clock-rate = (int) 90000, " "encoding-name = (string) \"RAW\"")
);
-GST_BOILERPLATE (GstRtpVRawDepay, gst_rtp_vraw_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_vraw_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpVRawDepay, gst_rtp_vraw_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
-static gboolean gst_rtp_vraw_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_vraw_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
static GstStateChangeReturn gst_rtp_vraw_depay_change_state (GstElement *
element, GstStateChange transition);
-static gboolean gst_rtp_vraw_depay_handle_event (GstBaseRTPDepayload * filter,
+static gboolean gst_rtp_vraw_depay_handle_event (GstRTPBaseDepayload * filter,
GstEvent * event);
static void
-gst_rtp_vraw_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_vraw_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gstelement_class = (GstElementClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gstelement_class->change_state = gst_rtp_vraw_depay_change_state;
- gstbasertpdepayload_class->set_caps = gst_rtp_vraw_depay_setcaps;
- gstbasertpdepayload_class->process = gst_rtp_vraw_depay_process;
- gstbasertpdepayload_class->handle_event = gst_rtp_vraw_depay_handle_event;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_vraw_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_vraw_depay_process;
+ gstrtpbasedepayload_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,27 +105,79 @@ 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_RTP_BASE_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_VIDEO_META);
+
+ 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
-gst_rtp_vraw_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * 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;
- gint rmask = 0, gmask = 0, bmask = 0, amask = 0, bpp = 0, depth = 0;
+ 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))
@@ -157,131 +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";
- rmask = 0x00ff0000;
- gmask = 0x0000ff00;
- bmask = 0x000000ff;
- depth = 24;
- bpp = 24;
} else if (!strcmp (str, "RGBA")) {
format = GST_VIDEO_FORMAT_RGBA;
pgroup = 4;
- ystride = width * 4;
- outsize = ystride * height;
- type = "video/x-raw-rgb";
- rmask = 0xff000000;
- gmask = 0x00ff0000;
- bmask = 0x0000ff00;
- amask = 0x000000ff;
- depth = 32;
- bpp = 32;
} 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";
- rmask = 0x000000ff;
- gmask = 0x0000ff00;
- bmask = 0x00ff0000;
- depth = 24;
- bpp = 24;
} else if (!strcmp (str, "BGRA")) {
format = GST_VIDEO_FORMAT_BGRA;
pgroup = 4;
- ystride = width * 4;
- outsize = ystride * height;
- type = "video/x-raw-rgb";
- rmask = 0x0000ff00;
- gmask = 0x00ff0000;
- bmask = 0xff000000;
- amask = 0x000000ff;
- depth = 32;
- bpp = 32;
} 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);
-
- if (!strcmp (type, "video/x-raw-rgb")) {
- gst_caps_set_simple (srccaps,
- "endianness", G_TYPE_INT, G_BIG_ENDIAN,
- "red_mask", G_TYPE_INT, rmask,
- "green_mask", G_TYPE_INT, gmask,
- "blue_mask", G_TYPE_INT, bmask,
- "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
-
- if (amask > 0) {
- gst_caps_set_simple (srccaps, "alpha_mask", G_TYPE_INT, amask, NULL);
- }
- }
- res = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ srccaps = gst_video_info_to_caps (&rtpvrawdepay->vinfo);
+ res = gst_pad_set_caps (GST_RTP_BASE_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;
@@ -311,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)
+gst_rtp_vraw_depay_process (GstRTPBaseDepayload * 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 = { NULL };
+ 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;
@@ -333,14 +312,22 @@ gst_rtp_vraw_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GST_LOG_OBJECT (depayload, "new frame with timestamp %u", timestamp);
/* new timestamp, flush old buffer and create new output buffer */
if (rtpvrawdepay->outbuf) {
- gst_base_rtp_depayload_push_ts (depayload, rtpvrawdepay->timestamp,
- rtpvrawdepay->outbuf);
+ gst_rtp_base_depayload_push (depayload, rtpvrawdepay->outbuf);
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_RTP_BASE_DEPAYLOAD_SRCPAD (depayload))) {
+ GstCaps *caps;
+
+ caps =
+ gst_pad_get_current_caps (GST_RTP_BASE_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... */
@@ -350,23 +337,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;
@@ -434,7 +424,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:
@@ -529,11 +519,13 @@ 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,
- rtpvrawdepay->outbuf);
+ gst_rtp_base_depayload_push (depayload, rtpvrawdepay->outbuf);
rtpvrawdepay->outbuf = NULL;
}
rtpvrawdepay->timestamp = -1;
@@ -545,27 +537,40 @@ 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;
}
}
static gboolean
-gst_rtp_vraw_depay_handle_event (GstBaseRTPDepayload * filter, GstEvent * event)
+gst_rtp_vraw_depay_handle_event (GstRTPBaseDepayload * filter, GstEvent * event)
{
gboolean ret;
GstRtpVRawDepay *rtpvrawdepay;
@@ -581,7 +586,7 @@ gst_rtp_vraw_depay_handle_event (GstBaseRTPDepayload * filter, GstEvent * event)
}
ret =
- GST_BASE_RTP_DEPAYLOAD_CLASS (parent_class)->handle_event (filter, event);
+ GST_RTP_BASE_DEPAYLOAD_CLASS (parent_class)->handle_event (filter, event);
return ret;
}
diff --git a/gst/rtp/gstrtpvrawdepay.h b/gst/rtp/gstrtpvrawdepay.h
index 77cb6bf70..d51e48671 100644
--- a/gst/rtp/gstrtpvrawdepay.h
+++ b/gst/rtp/gstrtpvrawdepay.h
@@ -22,7 +22,9 @@
#include <gst/gst.h>
#include <gst/video/video.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/video/gstvideometa.h>
+#include <gst/video/gstvideopool.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
G_BEGIN_DECLS
@@ -42,10 +44,10 @@ typedef struct _GstRtpVRawDepayClass GstRtpVRawDepayClass;
struct _GstRtpVRawDepay
{
- GstBaseRTPDepayload payload;
+ GstRTPBaseDepayload payload;
- gint width, height;
- GstVideoFormat format;
+ GstBufferPool *pool;
+ GstVideoInfo vinfo;
GstBuffer *outbuf;
guint32 timestamp;
@@ -53,14 +55,11 @@ struct _GstRtpVRawDepay
gint pgroup;
gint xinc, yinc;
- guint yp, up, vp;
- gint ystride;
- gint uvstride;
};
struct _GstRtpVRawDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_vraw_depay_get_type (void);
diff --git a/gst/rtp/gstrtpvrawpay.c b/gst/rtp/gstrtpvrawpay.c
index 7228ea8b8..a463ef868 100644
--- a/gst/rtp/gstrtpvrawpay.c
+++ b/gst/rtp/gstrtpvrawpay.c
@@ -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) 0x00FF0000, "
- "green_mask = (int) 0x0000FF00, "
- "blue_mask = (int) 0x000000FF, "
- "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) 0x000000FF, "
- "green_mask = (int) 0x0000FF00, "
- "blue_mask = (int) 0x00FF0000, "
- "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 ]; ")
);
@@ -104,229 +66,151 @@ GST_STATIC_PAD_TEMPLATE ("src",
)
);
-static gboolean gst_rtp_vraw_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_vraw_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_vraw_pay_handle_buffer (GstBaseRTPPayload *
+static GstFlowReturn gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload *
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_RTP_BASE_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);
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
+ GstElementClass *gstelement_class;
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_vraw_pay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_vraw_pay_sink_template);
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
- gst_element_class_set_details_simple (element_class,
+ gstrtpbasepayload_class->set_caps = gst_rtp_vraw_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_vraw_pay_handle_buffer;
+
+ 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 (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_vraw_pay_sink_template));
+
+ 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)
{
}
static gboolean
-gst_rtp_vraw_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_vraw_pay_setcaps (GstRTPBasePayload * 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);
+ if (!gst_video_info_from_caps (&info, caps))
+ goto invalid_caps;
- /* start parsing the format */
- name = gst_structure_get_name (s);
-
- /* 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 == 0x00FF0000) {
- 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) {
- res = gst_basertppayload_set_outcaps (payload, "sampling", G_TYPE_STRING,
+ gst_rtp_base_payload_set_options (payload, "video", TRUE, "RAW", 90000);
+ if (info.flags & GST_VIDEO_FLAG_INTERLACED) {
+ res = gst_rtp_base_payload_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,
colorimetrystr, "interlace", G_TYPE_STRING, "true", NULL);
} else {
- res = gst_basertppayload_set_outcaps (payload, "sampling", G_TYPE_STRING,
+ res = gst_rtp_base_payload_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,
colorimetrystr, NULL);
@@ -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,56 +231,50 @@ 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
-gst_rtp_vraw_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
+gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * 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 = { NULL, };
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 %" G_GSIZE_FORMAT " 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);
+ mtu = GST_RTP_BASE_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,18 +485,21 @@ 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 */
- ret = gst_basertppayload_push (payload, out);
+ ret = gst_rtp_base_payload_push (payload, out);
}
}
+
+ 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;
}
diff --git a/gst/rtp/gstrtpvrawpay.h b/gst/rtp/gstrtpvrawpay.h
index 0e6adf46d..f2032eb65 100644
--- a/gst/rtp/gstrtpvrawpay.h
+++ b/gst/rtp/gstrtpvrawpay.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/video/video.h>
-#include <gst/rtp/gstbasertppayload.h>
+#include <gst/rtp/gstrtpbasepayload.h>
G_BEGIN_DECLS
@@ -42,23 +42,22 @@ typedef struct _GstRtpVRawPayClass GstRtpVRawPayClass;
struct _GstRtpVRawPay
{
- GstBaseRTPPayload payload;
+ GstRTPBasePayload 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;
};
struct _GstRtpVRawPayClass
{
- GstBaseRTPPayloadClass parent_class;
+ GstRTPBasePayloadClass parent_class;
};
GType gst_rtp_vraw_pay_get_type (void);
diff --git a/gst/rtpmanager/Makefile.am b/gst/rtpmanager/Makefile.am
index f61099c1b..bfcb02824 100644
--- a/gst/rtpmanager/Makefile.am
+++ b/gst/rtpmanager/Makefile.am
@@ -36,9 +36,9 @@ noinst_HEADERS = gstrtpbin.h \
gstrtpsession.h
libgstrtpmanager_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
- $(WARNING_CFLAGS) $(ERROR_CFLAGS)
+ $(GST_NET_CFLAGS) $(WARNING_CFLAGS) $(ERROR_CFLAGS)
libgstrtpmanager_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
- -lgstnetbuffer-@GST_MAJORMINOR@ -lgstrtp-@GST_MAJORMINOR@ \
+ $(GST_NET_LIBS) -lgstrtp-@GST_MAJORMINOR@ \
$(GST_BASE_LIBS) $(GST_LIBS_LIBS)
libgstrtpmanager_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstrtpmanager_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c
index b322f8ecc..bc1259a9e 100644
--- a/gst/rtpmanager/gstrtpbin.c
+++ b/gst/rtpmanager/gstrtpbin.c
@@ -28,30 +28,30 @@
* #GstRtpBin is configured with a number of request pads that define the
* functionality that is activated, similar to the #GstRtpSession element.
*
- * To use #GstRtpBin as an RTP receiver, request a recv_rtp_sink_\%d pad. The session
+ * To use #GstRtpBin as an RTP receiver, request a recv_rtp_sink_\%u pad. The session
* number must be specified in the pad name.
- * Data received on the recv_rtp_sink_\%d pad will be processed in the #GstRtpSession
+ * Data received on the recv_rtp_sink_\%u pad will be processed in the #GstRtpSession
* manager and after being validated forwarded on #GstRtpSsrcDemux element. Each
* RTP stream is demuxed based on the SSRC and send to a #GstRtpJitterBuffer. After
* the packets are released from the jitterbuffer, they will be forwarded to a
* #GstRtpPtDemux element. The #GstRtpPtDemux element will demux the packets based
- * on the payload type and will create a unique pad recv_rtp_src_\%d_\%d_\%d on
+ * on the payload type and will create a unique pad recv_rtp_src_\%u_\%u_\%u on
* gstrtpbin with the session number, SSRC and payload type respectively as the pad
* name.
*
- * To also use #GstRtpBin as an RTCP receiver, request a recv_rtcp_sink_\%d pad. The
+ * To also use #GstRtpBin as an RTCP receiver, request a recv_rtcp_sink_\%u pad. The
* session number must be specified in the pad name.
*
* If you want the session manager to generate and send RTCP packets, request
- * the send_rtcp_src_\%d pad with the session number in the pad name. Packet pushed
+ * the send_rtcp_src_\%u pad with the session number in the pad name. Packet pushed
* on this pad contain SR/RR RTCP reports that should be sent to all participants
* in the session.
*
- * To use #GstRtpBin as a sender, request a send_rtp_sink_\%d pad, which will
- * automatically create a send_rtp_src_\%d pad. If the session number is not provided,
+ * To use #GstRtpBin as a sender, request a send_rtp_sink_\%u pad, which will
+ * automatically create a send_rtp_src_\%u pad. If the session number is not provided,
* the pad from the lowest available session will be returned. The session manager will modify the
* SSRC in the RTP packets to its own SSRC and wil forward the packets on the
- * send_rtp_src_\%d pad after updating its internal state.
+ * send_rtp_src_\%u pad after updating its internal state.
*
* The session manager needs the clock-rate of the payload types it is handling
* and will signal the #GstRtpSession::request-pt-map signal when it needs such a
@@ -134,21 +134,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_rtp_bin_debug);
/* sink pads */
static GstStaticPadTemplate rtpbin_recv_rtp_sink_template =
-GST_STATIC_PAD_TEMPLATE ("recv_rtp_sink_%d",
+GST_STATIC_PAD_TEMPLATE ("recv_rtp_sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("application/x-rtp")
);
static GstStaticPadTemplate rtpbin_recv_rtcp_sink_template =
-GST_STATIC_PAD_TEMPLATE ("recv_rtcp_sink_%d",
+GST_STATIC_PAD_TEMPLATE ("recv_rtcp_sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("application/x-rtcp")
);
static GstStaticPadTemplate rtpbin_send_rtp_sink_template =
-GST_STATIC_PAD_TEMPLATE ("send_rtp_sink_%d",
+GST_STATIC_PAD_TEMPLATE ("send_rtp_sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("application/x-rtp")
@@ -156,21 +156,21 @@ GST_STATIC_PAD_TEMPLATE ("send_rtp_sink_%d",
/* src pads */
static GstStaticPadTemplate rtpbin_recv_rtp_src_template =
-GST_STATIC_PAD_TEMPLATE ("recv_rtp_src_%d_%d_%d",
+GST_STATIC_PAD_TEMPLATE ("recv_rtp_src_%u_%u_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("application/x-rtp")
);
static GstStaticPadTemplate rtpbin_send_rtcp_src_template =
-GST_STATIC_PAD_TEMPLATE ("send_rtcp_src_%d",
+GST_STATIC_PAD_TEMPLATE ("send_rtcp_src_%u",
GST_PAD_SRC,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("application/x-rtcp")
);
static GstStaticPadTemplate rtpbin_send_rtp_src_template =
-GST_STATIC_PAD_TEMPLATE ("send_rtp_src_%d",
+GST_STATIC_PAD_TEMPLATE ("send_rtp_src_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("application/x-rtp")
@@ -555,10 +555,10 @@ create_session (GstRtpBin * rtpbin, gint id)
GstElement *session, *demux;
GstState target;
- if (!(session = gst_element_factory_make ("gstrtpsession", NULL)))
+ if (!(session = gst_element_factory_make ("rtpsession", NULL)))
goto no_session;
- if (!(demux = gst_element_factory_make ("gstrtpssrcdemux", NULL)))
+ if (!(demux = gst_element_factory_make ("rtpssrcdemux", NULL)))
goto no_demux;
sess = g_new0 (GstRtpBinSession, 1);
@@ -615,13 +615,13 @@ create_session (GstRtpBin * rtpbin, gint id)
/* ERRORS */
no_session:
{
- g_warning ("gstrtpbin: could not create gstrtpsession element");
+ g_warning ("rtpbin: could not create gstrtpsession element");
return NULL;
}
no_demux:
{
gst_object_unref (session);
- g_warning ("gstrtpbin: could not create gstrtpssrcdemux element");
+ g_warning ("rtpbin: could not create gstrtpssrcdemux element");
return NULL;
}
}
@@ -1304,6 +1304,7 @@ gst_rtp_bin_handle_sync (GstElement * jitterbuffer, GstStructure * s,
guint64 clock_base;
guint64 extrtptime;
GstBuffer *buffer;
+ GstRTCPBuffer rtcp = { NULL };
bin = stream->bin;
@@ -1324,7 +1325,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:
@@ -1384,6 +1388,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
@@ -1398,11 +1403,11 @@ create_stream (GstRtpBinSession * session, guint32 ssrc)
rtpbin = session->bin;
- if (!(buffer = gst_element_factory_make ("gstrtpjitterbuffer", NULL)))
+ if (!(buffer = gst_element_factory_make ("rtpjitterbuffer", NULL)))
goto no_jitterbuffer;
if (!rtpbin->ignore_pt)
- if (!(demux = gst_element_factory_make ("gstrtpptdemux", NULL)))
+ if (!(demux = gst_element_factory_make ("rtpptdemux", NULL)))
goto no_demux;
@@ -1466,13 +1471,13 @@ create_stream (GstRtpBinSession * session, guint32 ssrc)
/* ERRORS */
no_jitterbuffer:
{
- g_warning ("gstrtpbin: could not create gstrtpjitterbuffer element");
+ g_warning ("rtpbin: could not create gstrtpjitterbuffer element");
return NULL;
}
no_demux:
{
gst_object_unref (buffer);
- g_warning ("gstrtpbin: could not create gstrtpptdemux element");
+ g_warning ("rtpbin: could not create gstrtpptdemux element");
return NULL;
}
}
@@ -1525,38 +1530,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_static_pad_template (element_class,
- &rtpbin_recv_rtp_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &rtpbin_recv_rtcp_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &rtpbin_send_rtp_sink_template);
-
- /* src pads */
- gst_element_class_add_static_pad_template (element_class,
- &rtpbin_recv_rtp_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &rtpbin_send_rtcp_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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)
@@ -1865,6 +1844,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);
@@ -1876,7 +1876,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;
@@ -2358,14 +2358,13 @@ new_payload_found (GstElement * element, guint pt, GstPad * pad,
/* ghost the pad to the parent */
klass = GST_ELEMENT_GET_CLASS (rtpbin);
- templ = gst_element_class_get_pad_template (klass, "recv_rtp_src_%d_%d_%d");
- padname = g_strdup_printf ("recv_rtp_src_%d_%u_%d",
+ templ = gst_element_class_get_pad_template (klass, "recv_rtp_src_%u_%u_%u");
+ padname = g_strdup_printf ("recv_rtp_src_%u_%u_%u",
stream->session->id, stream->ssrc, pt);
gpad = gst_ghost_pad_new_from_template (padname, pad, templ);
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);
@@ -2493,7 +2492,7 @@ new_ssrc_pad_found (GstElement * element, guint ssrc, GstPad * pad,
/* get pad and link */
GST_DEBUG_OBJECT (rtpbin, "linking jitterbuffer RTP");
- padname = g_strdup_printf ("src_%d", ssrc);
+ padname = g_strdup_printf ("src_%u", ssrc);
srcpad = gst_element_get_static_pad (element, padname);
g_free (padname);
sinkpad = gst_element_get_static_pad (stream->buffer, "sink");
@@ -2502,7 +2501,7 @@ new_ssrc_pad_found (GstElement * element, guint ssrc, GstPad * pad,
gst_object_unref (srcpad);
GST_DEBUG_OBJECT (rtpbin, "linking jitterbuffer RTCP");
- padname = g_strdup_printf ("rtcp_src_%d", ssrc);
+ padname = g_strdup_printf ("rtcp_src_%u", ssrc);
srcpad = gst_element_get_static_pad (element, padname);
g_free (padname);
sinkpad = gst_element_get_request_pad (stream->buffer, "sink_rtcp");
@@ -2542,13 +2541,12 @@ new_ssrc_pad_found (GstElement * element, guint ssrc, GstPad * pad,
/* ghost the pad to the parent */
klass = GST_ELEMENT_GET_CLASS (rtpbin);
- templ = gst_element_class_get_pad_template (klass, "recv_rtp_src_%d_%d_%d");
- padname = g_strdup_printf ("recv_rtp_src_%d_%u_%d",
+ templ = gst_element_class_get_pad_template (klass, "recv_rtp_src_%u_%u_%u");
+ padname = g_strdup_printf ("recv_rtp_src_%u_%u_%u",
stream->session->id, stream->ssrc, 255);
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);
@@ -2587,7 +2585,7 @@ create_recv_rtp (GstRtpBin * rtpbin, GstPadTemplate * templ, const gchar * name)
GstPadLinkReturn lres;
/* first get the session number */
- if (name == NULL || sscanf (name, "recv_rtp_sink_%d", &sessid) != 1)
+ if (name == NULL || sscanf (name, "recv_rtp_sink_%u", &sessid) != 1)
goto no_name;
GST_DEBUG_OBJECT (rtpbin, "finding session %d", sessid);
@@ -2648,7 +2646,7 @@ create_recv_rtp (GstRtpBin * rtpbin, GstPadTemplate * templ, const gchar * name)
/* ERRORS */
no_name:
{
- g_warning ("gstrtpbin: invalid name given");
+ g_warning ("rtpbin: invalid name given");
return NULL;
}
create_error:
@@ -2658,12 +2656,12 @@ create_error:
}
pad_failed:
{
- g_warning ("gstrtpbin: failed to get session pad");
+ g_warning ("rtpbin: failed to get session pad");
return NULL;
}
link_failed:
{
- g_warning ("gstrtpbin: failed to link pads");
+ g_warning ("rtpbin: failed to link pads");
return NULL;
}
}
@@ -2709,7 +2707,7 @@ create_recv_rtcp (GstRtpBin * rtpbin, GstPadTemplate * templ,
GstPadLinkReturn lres;
/* first get the session number */
- if (name == NULL || sscanf (name, "recv_rtcp_sink_%d", &sessid) != 1)
+ if (name == NULL || sscanf (name, "recv_rtcp_sink_%u", &sessid) != 1)
goto no_name;
GST_DEBUG_OBJECT (rtpbin, "finding session %d", sessid);
@@ -2759,7 +2757,7 @@ create_recv_rtcp (GstRtpBin * rtpbin, GstPadTemplate * templ,
/* ERRORS */
no_name:
{
- g_warning ("gstrtpbin: invalid name given");
+ g_warning ("rtpbin: invalid name given");
return NULL;
}
create_error:
@@ -2769,12 +2767,12 @@ create_error:
}
pad_failed:
{
- g_warning ("gstrtpbin: failed to get session pad");
+ g_warning ("rtpbin: failed to get session pad");
return NULL;
}
link_failed:
{
- g_warning ("gstrtpbin: failed to link pads");
+ g_warning ("rtpbin: failed to link pads");
return NULL;
}
}
@@ -2812,7 +2810,7 @@ create_send_rtp (GstRtpBin * rtpbin, GstPadTemplate * templ, const gchar * name)
GstElementClass *klass;
/* first get the session number */
- if (name == NULL || sscanf (name, "send_rtp_sink_%d", &sessid) != 1)
+ if (name == NULL || sscanf (name, "send_rtp_sink_%u", &sessid) != 1)
goto no_name;
/* get or create session */
@@ -2847,8 +2845,8 @@ create_send_rtp (GstRtpBin * rtpbin, GstPadTemplate * templ, const gchar * name)
/* ghost the new source pad */
klass = GST_ELEMENT_GET_CLASS (rtpbin);
- gname = g_strdup_printf ("send_rtp_src_%d", sessid);
- templ = gst_element_class_get_pad_template (klass, "send_rtp_src_%d");
+ gname = g_strdup_printf ("send_rtp_src_%u", sessid);
+ templ = gst_element_class_get_pad_template (klass, "send_rtp_src_%u");
session->send_rtp_src_ghost =
gst_ghost_pad_new_from_template (gname, session->send_rtp_src, templ);
gst_pad_set_active (session->send_rtp_src_ghost, TRUE);
@@ -2860,7 +2858,7 @@ create_send_rtp (GstRtpBin * rtpbin, GstPadTemplate * templ, const gchar * name)
/* ERRORS */
no_name:
{
- g_warning ("gstrtpbin: invalid name given");
+ g_warning ("rtpbin: invalid name given");
return NULL;
}
create_error:
@@ -2870,13 +2868,12 @@ create_error:
}
pad_failed:
{
- g_warning ("gstrtpbin: failed to get session pad for session %d", sessid);
+ g_warning ("rtpbin: failed to get session pad for session %d", sessid);
return NULL;
}
no_srcpad:
{
- g_warning ("gstrtpbin: failed to get rtp source pad for session %d",
- sessid);
+ g_warning ("rtpbin: failed to get rtp source pad for session %d", sessid);
return NULL;
}
}
@@ -2918,7 +2915,7 @@ create_rtcp (GstRtpBin * rtpbin, GstPadTemplate * templ, const gchar * name)
GstRtpBinSession *session;
/* first get the session number */
- if (name == NULL || sscanf (name, "send_rtcp_src_%d", &sessid) != 1)
+ if (name == NULL || sscanf (name, "send_rtcp_src_%u", &sessid) != 1)
goto no_name;
/* get or create session */
@@ -2946,17 +2943,17 @@ create_rtcp (GstRtpBin * rtpbin, GstPadTemplate * templ, const gchar * name)
/* ERRORS */
no_name:
{
- g_warning ("gstrtpbin: invalid name given");
+ g_warning ("rtpbin: invalid name given");
return NULL;
}
no_session:
{
- g_warning ("gstrtpbin: session with id %d does not exist", sessid);
+ g_warning ("rtpbin: session with id %d does not exist", sessid);
return NULL;
}
pad_failed:
{
- g_warning ("gstrtpbin: failed to get rtcp pad for session %d", sessid);
+ g_warning ("rtpbin: failed to get rtcp pad for session %d", sessid);
return NULL;
}
}
@@ -2987,24 +2984,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) {
@@ -3012,7 +3009,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:
@@ -3027,6 +3024,7 @@ gst_rtp_bin_get_free_pad_name (GstElement * element, GstPadTemplate * templ)
break;
}
}
+ g_value_unset (&data);
gst_iterator_free (pad_it);
}
@@ -3038,7 +3036,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;
@@ -3065,16 +3063,16 @@ gst_rtp_bin_request_new_pad (GstElement * element,
GST_DEBUG_OBJECT (rtpbin, "Trying to request a pad with name %s", pad_name);
/* figure out the template */
- if (templ == gst_element_class_get_pad_template (klass, "recv_rtp_sink_%d")) {
+ if (templ == gst_element_class_get_pad_template (klass, "recv_rtp_sink_%u")) {
result = create_recv_rtp (rtpbin, templ, pad_name);
} else if (templ == gst_element_class_get_pad_template (klass,
- "recv_rtcp_sink_%d")) {
+ "recv_rtcp_sink_%u")) {
result = create_recv_rtcp (rtpbin, templ, pad_name);
} else if (templ == gst_element_class_get_pad_template (klass,
- "send_rtp_sink_%d")) {
+ "send_rtp_sink_%u")) {
result = create_send_rtp (rtpbin, templ, pad_name);
} else if (templ == gst_element_class_get_pad_template (klass,
- "send_rtcp_src_%d")) {
+ "send_rtcp_src_%u")) {
result = create_rtcp (rtpbin, templ, pad_name);
} else
goto wrong_template;
@@ -3089,7 +3087,7 @@ wrong_template:
{
g_free (pad_name);
GST_RTP_BIN_UNLOCK (rtpbin);
- g_warning ("gstrtpbin: this is not our template");
+ g_warning ("rtpbin: this is not our template");
return NULL;
}
}
@@ -3139,7 +3137,7 @@ gst_rtp_bin_release_pad (GstElement * element, GstPad * pad)
unknown_pad:
{
GST_RTP_BIN_UNLOCK (rtpbin);
- g_warning ("gstrtpbin: %s:%s is not one of our request pads",
+ g_warning ("rtpbin: %s:%s is not one of our request pads",
GST_DEBUG_PAD_NAME (pad));
return;
}
diff --git a/gst/rtpmanager/gstrtpjitterbuffer.c b/gst/rtpmanager/gstrtpjitterbuffer.c
index c69d47772..0d1ca7fb6 100644
--- a/gst/rtpmanager/gstrtpjitterbuffer.c
+++ b/gst/rtpmanager/gstrtpjitterbuffer.c
@@ -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,34 +232,38 @@ 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 GstIterator *gst_rtp_jitter_buffer_iterate_internal_links (GstPad * pad);
+static GstCaps *gst_rtp_jitter_buffer_getcaps (GstPad * pad, GstCaps * filter);
+static GstIterator *gst_rtp_jitter_buffer_iterate_internal_links (GstPad * pad,
+ GstObject * parent);
/* 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);
+ GstObject * parent, GstEvent * event);
static GstFlowReturn gst_rtp_jitter_buffer_chain (GstPad * pad,
- GstBuffer * buffer);
+ GstObject * parent, GstBuffer * buffer);
static gboolean gst_rtp_jitter_buffer_sink_rtcp_event (GstPad * pad,
- GstEvent * event);
+ GstObject * parent, GstEvent * event);
static GstFlowReturn gst_rtp_jitter_buffer_chain_rtcp (GstPad * pad,
- GstBuffer * buffer);
+ GstObject * parent, GstBuffer * buffer);
+
+static gboolean gst_rtp_jitter_buffer_sink_query (GstPad * pad,
+ GstObject * parent, GstQuery * query);
/* srcpad overrides */
static gboolean gst_rtp_jitter_buffer_src_event (GstPad * pad,
- GstEvent * event);
-static gboolean
-gst_rtp_jitter_buffer_src_activate_push (GstPad * pad, gboolean active);
+ GstObject * parent, GstEvent * event);
+static gboolean gst_rtp_jitter_buffer_src_activate_mode (GstPad * pad,
+ GstObject * parent, GstPadMode mode, gboolean active);
static void gst_rtp_jitter_buffer_loop (GstRtpJitterBuffer * jitterbuffer);
-static gboolean gst_rtp_jitter_buffer_query (GstPad * pad, GstQuery * query);
+static gboolean gst_rtp_jitter_buffer_src_query (GstPad * pad,
+ GstObject * parent, GstQuery * query);
static void
gst_rtp_jitter_buffer_clear_pt_map (GstRtpJitterBuffer * jitterbuffer);
@@ -268,25 +272,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_static_pad_template (element_class,
- &gst_rtp_jitter_buffer_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_jitter_buffer_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +428,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 +449,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;
@@ -478,12 +475,10 @@ gst_rtp_jitter_buffer_init (GstRtpJitterBuffer * jitterbuffer,
gst_pad_new_from_static_template (&gst_rtp_jitter_buffer_src_template,
"src");
- gst_pad_set_activatepush_function (priv->srcpad,
- GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_src_activate_push));
+ gst_pad_set_activatemode_function (priv->srcpad,
+ GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_src_activate_mode));
gst_pad_set_query_function (priv->srcpad,
- GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_query));
- gst_pad_set_getcaps_function (priv->srcpad,
- GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_getcaps));
+ GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_src_query));
gst_pad_set_event_function (priv->srcpad,
GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_src_event));
@@ -495,13 +490,13 @@ 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));
+ gst_pad_set_query_function (priv->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_sink_query));
gst_element_add_pad (GST_ELEMENT (jitterbuffer), priv->srcpad);
gst_element_add_pad (GST_ELEMENT (jitterbuffer), priv->sinkpad);
+
+ GST_OBJECT_FLAG_SET (jitterbuffer, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
}
static void
@@ -520,13 +515,14 @@ gst_rtp_jitter_buffer_finalize (GObject * object)
}
static GstIterator *
-gst_rtp_jitter_buffer_iterate_internal_links (GstPad * pad)
+gst_rtp_jitter_buffer_iterate_internal_links (GstPad * pad, GstObject * parent)
{
GstRtpJitterBuffer *jitterbuffer;
GstPad *otherpad = NULL;
GstIterator *it;
+ GValue val = { 0, };
- jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));
+ jitterbuffer = GST_RTP_JITTER_BUFFER (parent);
if (pad == jitterbuffer->priv->sinkpad) {
otherpad = jitterbuffer->priv->srcpad;
@@ -536,10 +532,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);
-
- gst_object_unref (jitterbuffer);
+ 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);
return it;
}
@@ -585,7 +581,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;
@@ -719,7 +715,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;
@@ -732,7 +728,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_query_caps (other, filter);
templ = gst_pad_get_pad_template_caps (pad);
if (caps == NULL) {
@@ -837,29 +833,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)
{
@@ -911,33 +884,38 @@ gst_rtp_jitter_buffer_flush_stop (GstRtpJitterBuffer * jitterbuffer)
}
static gboolean
-gst_rtp_jitter_buffer_src_activate_push (GstPad * pad, gboolean active)
+gst_rtp_jitter_buffer_src_activate_mode (GstPad * pad, GstObject * parent,
+ GstPadMode mode, gboolean active)
{
- gboolean result = TRUE;
+ gboolean result;
GstRtpJitterBuffer *jitterbuffer = NULL;
- jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));
+ jitterbuffer = GST_RTP_JITTER_BUFFER (parent);
- if (active) {
- /* allow data processing */
- gst_rtp_jitter_buffer_flush_stop (jitterbuffer);
+ switch (mode) {
+ case GST_PAD_MODE_PUSH:
+ if (active) {
+ /* allow data processing */
+ gst_rtp_jitter_buffer_flush_stop (jitterbuffer);
- /* start pushing out buffers */
- GST_DEBUG_OBJECT (jitterbuffer, "Starting task on srcpad");
- gst_pad_start_task (jitterbuffer->priv->srcpad,
- (GstTaskFunction) gst_rtp_jitter_buffer_loop, jitterbuffer);
- } else {
- /* make sure all data processing stops ASAP */
- gst_rtp_jitter_buffer_flush_start (jitterbuffer);
+ /* start pushing out buffers */
+ GST_DEBUG_OBJECT (jitterbuffer, "Starting task on srcpad");
+ result = gst_pad_start_task (jitterbuffer->priv->srcpad,
+ (GstTaskFunction) gst_rtp_jitter_buffer_loop, jitterbuffer);
+ } else {
+ /* make sure all data processing stops ASAP */
+ gst_rtp_jitter_buffer_flush_start (jitterbuffer);
- /* NOTE this will hardlock if the state change is called from the src pad
- * task thread because we will _join() the thread. */
- GST_DEBUG_OBJECT (jitterbuffer, "Stopping task on srcpad");
- result = gst_pad_stop_task (pad);
+ /* NOTE this will hardlock if the state change is called from the src pad
+ * task thread because we will _join() the thread. */
+ GST_DEBUG_OBJECT (jitterbuffer, "Stopping task on srcpad");
+ result = gst_pad_stop_task (pad);
+ }
+ break;
+ default:
+ result = FALSE;
+ break;
}
-
- gst_object_unref (jitterbuffer);
-
return result;
}
@@ -1006,17 +984,14 @@ gst_rtp_jitter_buffer_change_state (GstElement * element,
}
static gboolean
-gst_rtp_jitter_buffer_src_event (GstPad * pad, GstEvent * event)
+gst_rtp_jitter_buffer_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
gboolean ret = TRUE;
GstRtpJitterBuffer *jitterbuffer;
GstRtpJitterBufferPrivate *priv;
- jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));
- if (G_UNLIKELY (jitterbuffer == NULL)) {
- gst_event_unref (event);
- return FALSE;
- }
+ jitterbuffer = GST_RTP_JITTER_BUFFER (parent);
priv = jitterbuffer->priv;
GST_DEBUG_OBJECT (jitterbuffer, "received %s", GST_EVENT_TYPE_NAME (event));
@@ -1045,52 +1020,51 @@ gst_rtp_jitter_buffer_src_event (GstPad * pad, GstEvent * event)
ret = gst_pad_push_event (priv->sinkpad, event);
break;
}
- gst_object_unref (jitterbuffer);
return ret;
}
static gboolean
-gst_rtp_jitter_buffer_sink_event (GstPad * pad, GstEvent * event)
+gst_rtp_jitter_buffer_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
gboolean ret = TRUE;
GstRtpJitterBuffer *jitterbuffer;
GstRtpJitterBufferPrivate *priv;
- jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));
- if (G_UNLIKELY (jitterbuffer == NULL)) {
- gst_event_unref (event);
- return FALSE;
- }
+ jitterbuffer = GST_RTP_JITTER_BUFFER (parent);
priv = jitterbuffer->priv;
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);
- gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
- &start, &stop, &time);
+ /* set same caps on srcpad on success */
+ if (ret)
+ gst_pad_set_caps (priv->srcpad, caps);
+
+ 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);
@@ -1102,7 +1076,9 @@ gst_rtp_jitter_buffer_sink_event (GstPad * pad, GstEvent * event)
break;
case GST_EVENT_FLUSH_STOP:
ret = gst_pad_push_event (priv->srcpad, event);
- ret = gst_rtp_jitter_buffer_src_activate_push (priv->srcpad, TRUE);
+ ret =
+ gst_rtp_jitter_buffer_src_activate_mode (priv->srcpad, parent,
+ GST_PAD_MODE_PUSH, TRUE);
break;
case GST_EVENT_EOS:
{
@@ -1131,7 +1107,6 @@ gst_rtp_jitter_buffer_sink_event (GstPad * pad, GstEvent * event)
}
done:
- gst_object_unref (jitterbuffer);
return ret;
@@ -1146,11 +1121,12 @@ newseg_wrong_format:
}
static gboolean
-gst_rtp_jitter_buffer_sink_rtcp_event (GstPad * pad, GstEvent * event)
+gst_rtp_jitter_buffer_sink_rtcp_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstRtpJitterBuffer *jitterbuffer;
- jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));
+ jitterbuffer = GST_RTP_JITTER_BUFFER (parent);
GST_DEBUG_OBJECT (jitterbuffer, "received %s", GST_EVENT_TYPE_NAME (event));
@@ -1163,7 +1139,6 @@ gst_rtp_jitter_buffer_sink_rtcp_event (GstPad * pad, GstEvent * event)
break;
}
gst_event_unref (event);
- gst_object_unref (jitterbuffer);
return TRUE;
}
@@ -1258,7 +1233,8 @@ post_buffering_percent (GstRtpJitterBuffer * jitterbuffer, gint percent)
}
static GstFlowReturn
-gst_rtp_jitter_buffer_chain (GstPad * pad, GstBuffer * buffer)
+gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer)
{
GstRtpJitterBuffer *jitterbuffer;
GstRtpJitterBufferPrivate *priv;
@@ -1269,15 +1245,19 @@ 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));
+ jitterbuffer = GST_RTP_JITTER_BUFFER (parent);
if (G_UNLIKELY (!gst_rtp_buffer_validate (buffer)))
goto invalid_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
@@ -1288,8 +1268,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));
@@ -1297,19 +1275,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)) {
@@ -1385,8 +1364,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);
}
@@ -1394,7 +1373,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
@@ -1427,8 +1406,6 @@ finished:
if (percent != -1)
post_buffering_percent (jitterbuffer, percent);
- gst_object_unref (jitterbuffer);
-
return ret;
/* ERRORS */
@@ -1438,7 +1415,6 @@ invalid_buffer:
GST_ELEMENT_WARNING (jitterbuffer, STREAM, DECODE, (NULL),
("Received invalid RTP payload, dropping"));
gst_buffer_unref (buffer);
- gst_object_unref (jitterbuffer);
return GST_FLOW_OK;
}
no_clock_rate:
@@ -1546,9 +1522,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);
@@ -1590,6 +1569,7 @@ gst_rtp_jitter_buffer_loop (GstRtpJitterBuffer * jitterbuffer)
GstClockID id;
GstClockTime sync_time;
gint percent = -1;
+ GstRTPBuffer rtp = { NULL };
priv = jitterbuffer->priv;
@@ -1684,7 +1664,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
@@ -1962,7 +1944,8 @@ pause:
}
static GstFlowReturn
-gst_rtp_jitter_buffer_chain_rtcp (GstPad * pad, GstBuffer * buffer)
+gst_rtp_jitter_buffer_chain_rtcp (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer)
{
GstRtpJitterBuffer *jitterbuffer;
GstRtpJitterBufferPrivate *priv;
@@ -1975,17 +1958,20 @@ gst_rtp_jitter_buffer_chain_rtcp (GstPad * pad, GstBuffer * buffer)
guint64 ext_rtptime, diff;
guint32 rtptime;
gboolean drop = FALSE;
+ GstRTCPBuffer rtcp = { NULL };
guint64 clock_base;
- jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));
+ jitterbuffer = GST_RTP_JITTER_BUFFER (parent);
if (G_UNLIKELY (!gst_rtcp_buffer_validate (buffer)))
goto invalid_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)) {
@@ -1996,6 +1982,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);
@@ -2068,7 +2055,6 @@ gst_rtp_jitter_buffer_chain_rtcp (GstPad * pad, GstBuffer * buffer)
done:
gst_buffer_unref (buffer);
- gst_object_unref (jitterbuffer);
return ret;
@@ -2080,24 +2066,59 @@ 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;
}
}
static gboolean
-gst_rtp_jitter_buffer_query (GstPad * pad, GstQuery * query)
+gst_rtp_jitter_buffer_sink_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
+{
+ gboolean res = FALSE;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = gst_rtp_jitter_buffer_getcaps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_query_default (pad, parent, query);
+ break;
+ }
+
+ return res;
+}
+
+static gboolean
+gst_rtp_jitter_buffer_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
GstRtpJitterBuffer *jitterbuffer;
GstRtpJitterBufferPrivate *priv;
gboolean res = FALSE;
- jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));
- if (G_UNLIKELY (jitterbuffer == NULL))
- return FALSE;
+ jitterbuffer = GST_RTP_JITTER_BUFFER (parent);
priv = jitterbuffer->priv;
switch (GST_QUERY_TYPE (query)) {
@@ -2144,7 +2165,7 @@ gst_rtp_jitter_buffer_query (GstPad * pad, GstQuery * query)
gst_query_parse_position (query, &fmt, NULL);
if (fmt != GST_FORMAT_TIME) {
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, parent, query);
break;
}
@@ -2162,17 +2183,26 @@ gst_rtp_jitter_buffer_query (GstPad * pad, GstQuery * query)
gst_query_set_position (query, GST_FORMAT_TIME, start + last_out);
res = TRUE;
} else {
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, parent, query);
}
break;
}
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = gst_rtp_jitter_buffer_getcaps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+ res = TRUE;
+ break;
+ }
default:
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, parent, query);
break;
}
- gst_object_unref (jitterbuffer);
-
return res;
}
diff --git a/gst/rtpmanager/gstrtpmanager.c b/gst/rtpmanager/gstrtpmanager.c
index f38a77a80..6902bf553 100644
--- a/gst/rtpmanager/gstrtpmanager.c
+++ b/gst/rtpmanager/gstrtpmanager.c
@@ -30,23 +30,22 @@
static gboolean
plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "gstrtpbin", GST_RANK_NONE,
- GST_TYPE_RTP_BIN))
+ if (!gst_element_register (plugin, "rtpbin", GST_RANK_NONE, GST_TYPE_RTP_BIN))
return FALSE;
- if (!gst_element_register (plugin, "gstrtpjitterbuffer", GST_RANK_NONE,
+ if (!gst_element_register (plugin, "rtpjitterbuffer", GST_RANK_NONE,
GST_TYPE_RTP_JITTER_BUFFER))
return FALSE;
- if (!gst_element_register (plugin, "gstrtpptdemux", GST_RANK_NONE,
+ if (!gst_element_register (plugin, "rtpptdemux", GST_RANK_NONE,
GST_TYPE_RTP_PT_DEMUX))
return FALSE;
- if (!gst_element_register (plugin, "gstrtpsession", GST_RANK_NONE,
+ if (!gst_element_register (plugin, "rtpsession", GST_RANK_NONE,
GST_TYPE_RTP_SESSION))
return FALSE;
- if (!gst_element_register (plugin, "gstrtpssrcdemux", GST_RANK_NONE,
+ if (!gst_element_register (plugin, "rtpssrcdemux", GST_RANK_NONE,
GST_TYPE_RTP_SSRC_DEMUX))
return FALSE;
@@ -55,6 +54,6 @@ plugin_init (GstPlugin * plugin)
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
- "gstrtpmanager",
+ "rtpmanager",
"RTP session management plugin library",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/gst/rtpmanager/gstrtpptdemux.c b/gst/rtpmanager/gstrtpptdemux.c
index 0679438fa..7c24509b7 100644
--- a/gst/rtpmanager/gstrtpptdemux.c
+++ b/gst/rtpmanager/gstrtpptdemux.c
@@ -88,7 +88,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
);
static GstStaticPadTemplate rtp_pt_demux_src_template =
-GST_STATIC_PAD_TEMPLATE ("src_%d",
+GST_STATIC_PAD_TEMPLATE ("src_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("application/x-rtp, " "payload = (int) [ 0, 255 ]")
@@ -117,43 +117,31 @@ 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);
static void gst_rtp_pt_demux_release (GstRtpPtDemux * ptdemux);
static gboolean gst_rtp_pt_demux_setup (GstRtpPtDemux * ptdemux);
-static gboolean gst_rtp_pt_demux_sink_event (GstPad * pad, GstEvent * event);
-static GstFlowReturn gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf);
+static gboolean gst_rtp_pt_demux_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static GstFlowReturn gst_rtp_pt_demux_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buf);
static GstStateChangeReturn gst_rtp_pt_demux_change_state (GstElement * element,
GstStateChange transition);
static void gst_rtp_pt_demux_clear_pt_map (GstRtpPtDemux * rtpdemux);
static GstRtpPtDemuxPad *find_pad_for_pt (GstRtpPtDemux * rtpdemux, guint8 pt);
-static gboolean gst_rtp_pt_demux_src_event (GstPad * pad, GstEvent * event);
+static gboolean gst_rtp_pt_demux_src_event (GstPad * pad, GstObject * parent,
+ 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_static_pad_template (gstelement_klass,
- &rtp_pt_demux_sink_template);
- gst_element_class_add_static_pad_template (gstelement_klass,
- &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 +210,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 +272,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);
@@ -300,22 +296,24 @@ gst_rtp_pt_demux_clear_pt_map (GstRtpPtDemux * rtpdemux)
}
static GstFlowReturn
-gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf)
+gst_rtp_pt_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstFlowReturn ret = GST_FLOW_OK;
GstRtpPtDemux *rtpdemux;
- GstElement *element = GST_ELEMENT (GST_OBJECT_PARENT (pad));
guint8 pt;
GstPad *srcpad;
GstRtpPtDemuxPad *rtpdemuxpad;
GstCaps *caps;
+ GstRTPBuffer rtp = {NULL};
- rtpdemux = GST_RTP_PT_DEMUX (GST_OBJECT_PARENT (pad));
+ rtpdemux = GST_RTP_PT_DEMUX (parent);
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);
@@ -327,8 +325,8 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf)
gchar *padname;
klass = GST_ELEMENT_GET_CLASS (rtpdemux);
- templ = gst_element_class_get_pad_template (klass, "src_%d");
- padname = g_strdup_printf ("src_%d", pt);
+ templ = gst_element_class_get_pad_template (klass, "src_%u");
+ padname = g_strdup_printf ("src_%u", pt);
srcpad = gst_pad_new_from_template (templ, padname);
gst_pad_use_fixed_caps (srcpad);
g_free (padname);
@@ -353,7 +351,7 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf)
GST_OBJECT_UNLOCK (rtpdemux);
gst_pad_set_active (srcpad, TRUE);
- gst_element_add_pad (element, srcpad);
+ gst_element_add_pad (GST_ELEMENT_CAST (rtpdemux), srcpad);
GST_DEBUG ("emitting new-payload-type for pt %d", pt);
g_signal_emit (G_OBJECT (rtpdemux),
@@ -385,8 +383,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);
@@ -428,16 +424,12 @@ find_pad_for_pt (GstRtpPtDemux * rtpdemux, guint8 pt)
}
static gboolean
-gst_rtp_pt_demux_sink_event (GstPad * pad, GstEvent * event)
+gst_rtp_pt_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstRtpPtDemux *rtpdemux;
gboolean res = FALSE;
- rtpdemux = GST_RTP_PT_DEMUX (gst_pad_get_parent (pad));
- if (G_UNLIKELY (rtpdemux == NULL)) {
- gst_event_unref (event);
- return FALSE;
- }
+ rtpdemux = GST_RTP_PT_DEMUX (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CUSTOM_DOWNSTREAM:
@@ -456,27 +448,26 @@ gst_rtp_pt_demux_sink_event (GstPad * pad, GstEvent * event)
gst_event_unref (event);
} else {
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, event);
}
break;
}
default:
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, event);
break;
}
- gst_object_unref (rtpdemux);
return res;
}
static gboolean
-gst_rtp_pt_demux_src_event (GstPad * pad, GstEvent * event)
+gst_rtp_pt_demux_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstRtpPtDemux *demux;
const GstStructure *s;
- demux = GST_RTP_PT_DEMUX (gst_pad_get_parent (pad));
+ demux = GST_RTP_PT_DEMUX (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CUSTOM_UPSTREAM:
@@ -490,11 +481,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;
}
}
@@ -504,13 +497,9 @@ gst_rtp_pt_demux_src_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (demux);
-
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
}
-
-
/*
* Reserves resources for the object.
*/
diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c
index 68284383c..3a00974ba 100644
--- a/gst/rtpmanager/gstrtpsession.c
+++ b/gst/rtpmanager/gstrtpsession.c
@@ -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_static_pad_template (element_class,
- &rtpsession_recv_rtp_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &rtpsession_recv_rtcp_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &rtpsession_send_rtp_sink_template);
-
- /* src pads */
- gst_element_class_add_static_pad_template (element_class,
- &rtpsession_recv_rtp_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &rtpsession_sync_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &rtpsession_send_rtp_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 ();
@@ -981,7 +979,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:
@@ -1103,12 +1101,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))) {
- caps = gst_caps_new_simple ("application/x-rtcp", NULL);
+ if (!(caps = gst_pad_get_current_caps (rtcp_src))) {
+ caps = gst_caps_new_empty_simple ("application/x-rtcp");
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);
@@ -1162,12 +1158,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))) {
- caps = gst_caps_new_simple ("application/x-rtcp", NULL);
+ if (!(caps = gst_pad_get_current_caps (sync_src))) {
+ caps = gst_caps_new_empty_simple ("application/x-rtcp");
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);
@@ -1323,52 +1317,48 @@ gst_rtp_session_reconsider (RTPSession * sess, gpointer user_data)
}
static gboolean
-gst_rtp_session_event_recv_rtp_sink (GstPad * pad, GstEvent * event)
+gst_rtp_session_event_recv_rtp_sink (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstRtpSession *rtpsession;
gboolean ret = FALSE;
- rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
- if (G_UNLIKELY (rtpsession == NULL)) {
- gst_event_unref (event);
- return FALSE;
- }
+ rtpsession = GST_RTP_SESSION (parent);
GST_DEBUG_OBJECT (rtpsession, "received event %s",
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_event_copy_segment (event, &in_segment);
+ GST_DEBUG_OBJECT (rtpsession, "received segment %" GST_SEGMENT_FORMAT,
+ &in_segment);
- 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_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);
@@ -1378,7 +1368,6 @@ gst_rtp_session_event_recv_rtp_sink (GstPad * pad, GstEvent * event)
ret = gst_pad_push_event (rtpsession->recv_rtp_src, event);
break;
}
- gst_object_unref (rtpsession);
return ret;
@@ -1417,7 +1406,8 @@ gst_rtp_session_request_remote_key_unit (GstRtpSession * rtpsession,
}
static gboolean
-gst_rtp_session_event_recv_rtp_src (GstPad * pad, GstEvent * event)
+gst_rtp_session_event_recv_rtp_src (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstRtpSession *rtpsession;
gboolean forward = TRUE;
@@ -1426,11 +1416,7 @@ gst_rtp_session_event_recv_rtp_src (GstPad * pad, GstEvent * event)
guint32 ssrc;
guint pt;
- rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
- if (G_UNLIKELY (rtpsession == NULL)) {
- gst_event_unref (event);
- return FALSE;
- }
+ rtpsession = GST_RTP_SESSION (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CUSTOM_UPSTREAM:
@@ -1456,22 +1442,18 @@ gst_rtp_session_event_recv_rtp_src (GstPad * pad, GstEvent * event)
if (forward)
ret = gst_pad_push_event (rtpsession->recv_rtp_sink, event);
- gst_object_unref (rtpsession);
-
return ret;
}
static GstIterator *
-gst_rtp_session_iterate_internal_links (GstPad * pad)
+gst_rtp_session_iterate_internal_links (GstPad * pad, GstObject * parent)
{
GstRtpSession *rtpsession;
GstPad *otherpad = NULL;
GstIterator *it = NULL;
- rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
- if (G_UNLIKELY (rtpsession == NULL))
- return NULL;
+ rtpsession = GST_RTP_SESSION (parent);
GST_RTP_SESSION_LOCK (rtpsession);
if (pad == rtpsession->recv_rtp_src) {
@@ -1486,13 +1468,15 @@ 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);
}
- gst_object_unref (rtpsession);
-
return it;
}
@@ -1516,7 +1500,8 @@ gst_rtp_session_sink_setcaps (GstPad * pad, GstCaps * caps)
* forward the packet on the rtp_src pad
*/
static GstFlowReturn
-gst_rtp_session_chain_recv_rtp (GstPad * pad, GstBuffer * buffer)
+gst_rtp_session_chain_recv_rtp (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer)
{
GstRtpSession *rtpsession;
GstRtpSessionPrivate *priv;
@@ -1524,7 +1509,7 @@ gst_rtp_session_chain_recv_rtp (GstPad * pad, GstBuffer * buffer)
GstClockTime current_time, running_time;
GstClockTime timestamp;
- rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
+ rtpsession = GST_RTP_SESSION (parent);
priv = rtpsession->priv;
GST_LOG_OBJECT (rtpsession, "received RTP packet");
@@ -1547,7 +1532,6 @@ gst_rtp_session_chain_recv_rtp (GstPad * pad, GstBuffer * buffer)
goto push_error;
done:
- gst_object_unref (rtpsession);
return ret;
@@ -1561,12 +1545,13 @@ push_error:
}
static gboolean
-gst_rtp_session_event_recv_rtcp_sink (GstPad * pad, GstEvent * event)
+gst_rtp_session_event_recv_rtcp_sink (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstRtpSession *rtpsession;
gboolean ret = FALSE;
- rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
+ rtpsession = GST_RTP_SESSION (parent);
GST_DEBUG_OBJECT (rtpsession, "received event %s",
GST_EVENT_TYPE_NAME (event));
@@ -1576,7 +1561,6 @@ gst_rtp_session_event_recv_rtcp_sink (GstPad * pad, GstEvent * event)
ret = gst_pad_push_event (rtpsession->sync_src, event);
break;
}
- gst_object_unref (rtpsession);
return ret;
}
@@ -1585,14 +1569,15 @@ gst_rtp_session_event_recv_rtcp_sink (GstPad * pad, GstEvent * event)
* forward the SR packets to the sync_src pad.
*/
static GstFlowReturn
-gst_rtp_session_chain_recv_rtcp (GstPad * pad, GstBuffer * buffer)
+gst_rtp_session_chain_recv_rtcp (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer)
{
GstRtpSession *rtpsession;
GstRtpSessionPrivate *priv;
GstClockTime current_time;
guint64 ntpnstime;
- rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
+ rtpsession = GST_RTP_SESSION (parent);
priv = rtpsession->priv;
GST_LOG_OBJECT (rtpsession, "received RTCP packet");
@@ -1602,18 +1587,17 @@ gst_rtp_session_chain_recv_rtcp (GstPad * pad, GstBuffer * buffer)
rtp_session_process_rtcp (priv->session, buffer, current_time, ntpnstime);
- gst_object_unref (rtpsession);
-
return GST_FLOW_OK; /* always return OK */
}
static gboolean
-gst_rtp_session_query_send_rtcp_src (GstPad * pad, GstQuery * query)
+gst_rtp_session_query_send_rtcp_src (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
GstRtpSession *rtpsession;
gboolean ret = FALSE;
- rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
+ rtpsession = GST_RTP_SESSION (parent);
GST_DEBUG_OBJECT (rtpsession, "received QUERY");
@@ -1628,22 +1612,17 @@ gst_rtp_session_query_send_rtcp_src (GstPad * pad, GstQuery * query)
break;
}
- gst_object_unref (rtpsession);
-
return ret;
}
static gboolean
-gst_rtp_session_event_send_rtcp_src (GstPad * pad, GstEvent * event)
+gst_rtp_session_event_send_rtcp_src (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstRtpSession *rtpsession;
gboolean ret = TRUE;
- rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
- if (G_UNLIKELY (rtpsession == NULL)) {
- gst_event_unref (event);
- return FALSE;
- }
+ rtpsession = GST_RTP_SESSION (parent);
GST_DEBUG_OBJECT (rtpsession, "received EVENT");
switch (GST_EVENT_TYPE (event)) {
@@ -1659,52 +1638,51 @@ gst_rtp_session_event_send_rtcp_src (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (rtpsession);
return ret;
}
static gboolean
-gst_rtp_session_event_send_rtp_sink (GstPad * pad, GstEvent * event)
+gst_rtp_session_event_send_rtp_sink (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstRtpSession *rtpsession;
gboolean ret = FALSE;
- rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
+ rtpsession = GST_RTP_SESSION (parent);
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);
@@ -1738,13 +1716,12 @@ gst_rtp_session_event_send_rtp_sink (GstPad * pad, GstEvent * event)
break;
}
}
- gst_object_unref (rtpsession);
return ret;
}
static GstCaps *
-gst_rtp_session_getcaps_send_rtp (GstPad * pad)
+gst_rtp_session_getcaps_send_rtp (GstPad * pad, GstCaps * filter)
{
GstRtpSession *rtpsession;
GstRtpSessionPrivate *priv;
@@ -1761,10 +1738,17 @@ gst_rtp_session_getcaps_send_rtp (GstPad * pad)
* internal SSRC so that we don't have to patch it. Create a structure with
* the SSRC and another one without. */
s1 = gst_structure_new ("application/x-rtp", "ssrc", G_TYPE_UINT, ssrc, NULL);
- s2 = gst_structure_new ("application/x-rtp", NULL);
+ s2 = gst_structure_new_empty ("application/x-rtp");
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);
@@ -1773,6 +1757,32 @@ gst_rtp_session_getcaps_send_rtp (GstPad * pad)
}
static gboolean
+gst_rtp_session_query_send_rtp (GstPad * pad, GstObject * parent,
+ GstQuery * query)
+{
+ gboolean res = FALSE;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = gst_rtp_session_getcaps_send_rtp (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_query_default (pad, parent, query);
+ break;
+ }
+
+ return res;
+}
+
+static gboolean
gst_rtp_session_setcaps_send_rtp (GstPad * pad, GstCaps * caps)
{
GstRtpSession *rtpsession;
@@ -1797,16 +1807,14 @@ gst_rtp_session_setcaps_send_rtp (GstPad * pad, GstCaps * caps)
* send to RTP session manager and forward to send_rtp_src.
*/
static GstFlowReturn
-gst_rtp_session_chain_send_rtp_common (GstPad * pad, gpointer data,
- gboolean is_list)
+gst_rtp_session_chain_send_rtp_common (GstRtpSession * rtpsession,
+ gpointer data, gboolean is_list)
{
- GstRtpSession *rtpsession;
GstRtpSessionPrivate *priv;
GstFlowReturn ret;
GstClockTime timestamp, running_time;
GstClockTime current_time;
- rtpsession = GST_RTP_SESSION (gst_pad_get_parent (pad));
priv = rtpsession->priv;
GST_LOG_OBJECT (rtpsession, "received RTP %s", is_list ? "list" : "packet");
@@ -1817,7 +1825,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
@@ -1843,7 +1851,6 @@ gst_rtp_session_chain_send_rtp_common (GstPad * pad, gpointer data,
goto push_error;
done:
- gst_object_unref (rtpsession);
return ret;
@@ -1857,15 +1864,21 @@ push_error:
}
static GstFlowReturn
-gst_rtp_session_chain_send_rtp (GstPad * pad, GstBuffer * buffer)
+gst_rtp_session_chain_send_rtp (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer)
{
- return gst_rtp_session_chain_send_rtp_common (pad, buffer, FALSE);
+ GstRtpSession *rtpsession = GST_RTP_SESSION (parent);
+
+ return gst_rtp_session_chain_send_rtp_common (rtpsession, buffer, FALSE);
}
static GstFlowReturn
-gst_rtp_session_chain_send_rtp_list (GstPad * pad, GstBufferList * list)
+gst_rtp_session_chain_send_rtp_list (GstPad * pad, GstObject * parent,
+ GstBufferList * list)
{
- return gst_rtp_session_chain_send_rtp_common (pad, list, TRUE);
+ GstRtpSession *rtpsession = GST_RTP_SESSION (parent);
+
+ return gst_rtp_session_chain_send_rtp_common (rtpsession, list, TRUE);
}
/* Create sinkpad to receive RTP packets from senders. This will also create a
@@ -1883,8 +1896,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);
@@ -1995,10 +2006,8 @@ create_send_rtp_sink (GstRtpSession * rtpsession)
gst_rtp_session_chain_send_rtp);
gst_pad_set_chain_list_function (rtpsession->send_rtp_sink,
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_query_function (rtpsession->send_rtp_sink,
+ gst_rtp_session_query_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,
@@ -2075,7 +2084,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;
diff --git a/gst/rtpmanager/gstrtpssrcdemux.c b/gst/rtpmanager/gstrtpssrcdemux.c
index 294b31cc5..c09ee3d25 100644
--- a/gst/rtpmanager/gstrtpssrcdemux.c
+++ b/gst/rtpmanager/gstrtpssrcdemux.c
@@ -70,14 +70,14 @@ GST_STATIC_PAD_TEMPLATE ("rtcp_sink",
);
static GstStaticPadTemplate rtp_ssrc_demux_src_template =
-GST_STATIC_PAD_TEMPLATE ("src_%d",
+GST_STATIC_PAD_TEMPLATE ("src_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("application/x-rtp")
);
static GstStaticPadTemplate rtp_ssrc_demux_rtcp_src_template =
-GST_STATIC_PAD_TEMPLATE ("rtcp_src_%d",
+GST_STATIC_PAD_TEMPLATE ("rtcp_src_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("application/x-rtcp")
@@ -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);
@@ -111,21 +110,25 @@ static void gst_rtp_ssrc_demux_clear_ssrc (GstRtpSsrcDemux * demux,
guint32 ssrc);
/* sinkpad stuff */
-static GstFlowReturn gst_rtp_ssrc_demux_chain (GstPad * pad, GstBuffer * buf);
-static gboolean gst_rtp_ssrc_demux_sink_event (GstPad * pad, GstEvent * event);
+static GstFlowReturn gst_rtp_ssrc_demux_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buf);
+static gboolean gst_rtp_ssrc_demux_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static GstFlowReturn gst_rtp_ssrc_demux_rtcp_chain (GstPad * pad,
- GstBuffer * buf);
+ GstObject * parent, GstBuffer * buf);
static gboolean gst_rtp_ssrc_demux_rtcp_sink_event (GstPad * pad,
- GstEvent * event);
+ GstObject * parent, GstEvent * event);
static GstIterator *gst_rtp_ssrc_demux_iterate_internal_links_sink (GstPad *
- pad);
+ pad, GstObject * parent);
/* srcpad stuff */
-static gboolean gst_rtp_ssrc_demux_src_event (GstPad * pad, GstEvent * event);
-static GstIterator *gst_rtp_ssrc_demux_iterate_internal_links_src (GstPad *
- pad);
-static gboolean gst_rtp_ssrc_demux_src_query (GstPad * pad, GstQuery * query);
+static gboolean gst_rtp_ssrc_demux_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static GstIterator *gst_rtp_ssrc_demux_iterate_internal_links_src (GstPad * pad,
+ GstObject * parent);
+static gboolean gst_rtp_ssrc_demux_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
static guint gst_rtp_ssrc_demux_signals[LAST_SIGNAL] = { 0 };
@@ -165,6 +168,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);
@@ -174,13 +178,13 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
}
klass = GST_ELEMENT_GET_CLASS (demux);
- templ = gst_element_class_get_pad_template (klass, "src_%d");
- padname = g_strdup_printf ("src_%d", ssrc);
+ templ = gst_element_class_get_pad_template (klass, "src_%u");
+ padname = g_strdup_printf ("src_%u", ssrc);
rtp_pad = gst_pad_new_from_template (templ, padname);
g_free (padname);
- templ = gst_element_class_get_pad_template (klass, "rtcp_src_%d");
- padname = g_strdup_printf ("rtcp_src_%d", ssrc);
+ templ = gst_element_class_get_pad_template (klass, "rtcp_src_%u");
+ padname = g_strdup_printf ("rtcp_src_%u", ssrc);
rtcp_pad = gst_pad_new_from_template (templ, padname);
g_free (padname);
@@ -196,9 +200,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 +230,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_static_pad_template (gstelement_klass,
- &rtp_ssrc_demux_sink_template);
- gst_element_class_add_static_pad_template (gstelement_klass,
- &rtp_ssrc_demux_rtcp_sink_template);
- gst_element_class_add_static_pad_template (gstelement_klass,
- &rtp_ssrc_demux_src_template);
- gst_element_class_add_static_pad_template (gstelement_klass,
- &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 +291,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);
@@ -419,21 +420,17 @@ unknown_pad:
}
static gboolean
-gst_rtp_ssrc_demux_sink_event (GstPad * pad, GstEvent * event)
+gst_rtp_ssrc_demux_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstRtpSsrcDemux *demux;
gboolean res = FALSE;
- demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
- if (G_UNLIKELY (demux == NULL)) {
- gst_event_unref (event);
- return FALSE;
- }
+ demux = GST_RTP_SSRC_DEMUX (parent);
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;
@@ -464,20 +461,19 @@ gst_rtp_ssrc_demux_sink_event (GstPad * pad, GstEvent * event)
}
}
- gst_object_unref (demux);
return res;
}
static gboolean
-gst_rtp_ssrc_demux_rtcp_sink_event (GstPad * pad, GstEvent * event)
+gst_rtp_ssrc_demux_rtcp_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstRtpSsrcDemux *demux;
gboolean res = FALSE;
- demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
+ demux = GST_RTP_SSRC_DEMUX (parent);
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_NEWSEGMENT:
default:
{
GSList *walk;
@@ -503,25 +499,27 @@ gst_rtp_ssrc_demux_rtcp_sink_event (GstPad * pad, GstEvent * event)
break;
}
}
- gst_object_unref (demux);
return res;
}
static GstFlowReturn
-gst_rtp_ssrc_demux_chain (GstPad * pad, GstBuffer * buf)
+gst_rtp_ssrc_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstFlowReturn ret;
GstRtpSsrcDemux *demux;
guint32 ssrc;
GstRtpSsrcDemuxPad *dpad;
+ GstRTPBuffer rtp = {NULL};
GstPad *srcpad;
- demux = GST_RTP_SSRC_DEMUX (GST_OBJECT_PARENT (pad));
+ demux = GST_RTP_SSRC_DEMUX (parent);
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);
@@ -560,22 +558,27 @@ create_failed:
}
static GstFlowReturn
-gst_rtp_ssrc_demux_rtcp_chain (GstPad * pad, GstBuffer * buf)
+gst_rtp_ssrc_demux_rtcp_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buf)
{
GstFlowReturn ret;
GstRtpSsrcDemux *demux;
guint32 ssrc;
GstRtpSsrcDemuxPad *dpad;
GstRTCPPacket packet;
+ GstRTCPBuffer rtcp;
GstPad *srcpad;
- demux = GST_RTP_SSRC_DEMUX (GST_OBJECT_PARENT (pad));
+ demux = GST_RTP_SSRC_DEMUX (parent);
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 +590,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);
@@ -631,12 +635,13 @@ create_failed:
}
static gboolean
-gst_rtp_ssrc_demux_src_event (GstPad * pad, GstEvent * event)
+gst_rtp_ssrc_demux_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstRtpSsrcDemux *demux;
const GstStructure *s;
- demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
+ demux = GST_RTP_SSRC_DEMUX (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CUSTOM_UPSTREAM:
@@ -650,11 +655,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;
}
}
@@ -664,23 +671,18 @@ gst_rtp_ssrc_demux_src_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (demux);
-
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
}
static GstIterator *
-gst_rtp_ssrc_demux_iterate_internal_links_src (GstPad * pad)
+gst_rtp_ssrc_demux_iterate_internal_links_src (GstPad * pad, GstObject * parent)
{
GstRtpSsrcDemux *demux;
GstPad *otherpad = NULL;
GstIterator *it = NULL;
GSList *current;
- demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
-
- if (!demux)
- return NULL;
+ demux = GST_RTP_SSRC_DEMUX (parent);
GST_PAD_LOCK (demux);
for (current = demux->srcpads; current; current = g_slist_next (current)) {
@@ -694,11 +696,17 @@ 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);
return it;
}
@@ -718,39 +726,39 @@ src_pad_compare_func (gconstpointer a, gconstpointer b)
}
static GstIterator *
-gst_rtp_ssrc_demux_iterate_internal_links_sink (GstPad * pad)
+gst_rtp_ssrc_demux_iterate_internal_links_sink (GstPad * pad,
+ GstObject * parent)
{
GstRtpSsrcDemux *demux;
GstIterator *it = NULL;
- const gchar *prefix = NULL;
-
- demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
+ GValue gval = { 0, };
- if (!demux)
- return NULL;
+ demux = GST_RTP_SSRC_DEMUX (parent);
+ g_value_init (&gval, G_TYPE_STRING);
if (pad == demux->rtp_sink)
- prefix = "src_";
+ g_value_set_static_string (&gval, "src_");
else if (pad == demux->rtcp_sink)
- prefix = "rtcp_src_";
+ g_value_set_static_string (&gval, "rtcp_src_");
else
g_assert_not_reached ();
- it = gst_element_iterate_src_pads (GST_ELEMENT (demux));
+ it = gst_element_iterate_src_pads (GST_ELEMENT_CAST (demux));
- return gst_iterator_filter (it, src_pad_compare_func, (gpointer) prefix);
+ it = gst_iterator_filter (it, src_pad_compare_func, &gval);
+
+ return it;
}
static gboolean
-gst_rtp_ssrc_demux_src_query (GstPad * pad, GstQuery * query)
+gst_rtp_ssrc_demux_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
GstRtpSsrcDemux *demux;
gboolean res = FALSE;
- demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
- if (G_UNLIKELY (demux == NULL))
- return FALSE;
+ demux = GST_RTP_SSRC_DEMUX (parent);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_LATENCY:
@@ -775,10 +783,9 @@ gst_rtp_ssrc_demux_src_query (GstPad * pad, GstQuery * query)
break;
}
default:
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, parent, query);
break;
}
- gst_object_unref (demux);
return res;
}
diff --git a/gst/rtpmanager/rtpjitterbuffer.c b/gst/rtpmanager/rtpjitterbuffer.c
index 5db5da49f..512f0935d 100644
--- a/gst/rtpmanager/rtpjitterbuffer.c
+++ b/gst/rtpmanager/rtpjitterbuffer.c
@@ -608,18 +608,24 @@ rtp_jitter_buffer_insert (RTPJitterBuffer * jbuf, GstBuffer * buf,
GList *list;
guint32 rtptime;
guint16 seqnum;
+ GstRTPBuffer rtp = {NULL};
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 = {NULL};
- 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);
/* rtp time jumps are checked for during skew calculation, but bypassed
* in other mode, so mind those here and reset jb if needed.
* Only reset if valid input time, which is likely for UDP input
@@ -693,11 +699,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;
}
@@ -854,6 +863,7 @@ rtp_jitter_buffer_get_ts_diff (RTPJitterBuffer * jbuf)
guint64 high_ts, low_ts;
GstBuffer *high_buf, *low_buf;
guint32 result;
+ GstRTPBuffer rtp = {NULL};
g_return_val_if_fail (jbuf != NULL, 0);
@@ -863,8 +873,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) {
diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c
index f499106f2..985c21d8f 100644
--- a/gst/rtpmanager/rtpsession.c
+++ b/gst/rtpmanager/rtpsession.c
@@ -21,7 +21,6 @@
#include <gst/rtp/gstrtpbuffer.h>
#include <gst/rtp/gstrtcpbuffer.h>
-#include <gst/netbuffer/gstnetbuffer.h>
#include "gstrtpbin-marshal.h"
#include "rtpsession.h"
@@ -160,7 +159,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 +196,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);
}
@@ -1277,7 +1276,7 @@ check_collision (RTPSession * sess, RTPSource * source,
}
if (have_from) {
- if (gst_netaddress_equal (from, &arrival->address)) {
+ if (gst_net_address_equal (from, &arrival->address)) {
/* Address is the same */
return FALSE;
} else {
@@ -1287,7 +1286,7 @@ check_collision (RTPSession * sess, RTPSource * source,
if (rtp_source_find_conflicting_address (source,
&arrival->address, arrival->current_time)) {
gchar buf1[40];
- gst_netaddress_to_string (&arrival->address, buf1, 40);
+ gst_net_address_to_string (&arrival->address, buf1, 40);
GST_LOG ("Known conflict on %x for %s, dropping packet",
rtp_source_get_ssrc (source), buf1);
return TRUE;
@@ -1300,8 +1299,8 @@ check_collision (RTPSession * sess, RTPSource * source,
rtp_source_add_conflicting_address (source, from,
arrival->current_time);
- gst_netaddress_to_string (from, buf1, 40);
- gst_netaddress_to_string (&arrival->address, buf2, 40);
+ gst_net_address_to_string (from, buf1, 40);
+ gst_net_address_to_string (&arrival->address, buf2, 40);
GST_DEBUG ("New conflict for ssrc %x, replacing %s with %s,"
" saving old as known conflict",
rtp_source_get_ssrc (source), buf1, buf2);
@@ -1696,26 +1695,32 @@ update_arrival_stats (RTPSession * sess, RTPArrivalStats * arrival,
gboolean rtp, GstBuffer * buffer, GstClockTime current_time,
GstClockTime running_time, guint64 ntpnstime)
{
+ GstNetAddressMeta *meta;
+ GstRTPBuffer rtpb = { NULL };
+
/* 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_net_address_meta (buffer);
+ if (meta) {
+ arrival->have_address = TRUE;
+ memcpy (&arrival->address, &meta->naddr, sizeof (GstNetAddress));
+ } else {
+ arrival->have_address = FALSE;
}
}
@@ -1744,6 +1749,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
guint32 csrcs[16];
guint8 i, count;
guint64 oldrate;
+ GstRTPBuffer rtp = { NULL };
g_return_val_if_fail (RTP_IS_SESSION (sess), GST_FLOW_ERROR);
g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
@@ -1761,23 +1767,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);
@@ -1994,7 +2005,7 @@ rtp_session_process_sdes (RTPSession * sess, GstRTCPPacket * packet,
if (!source)
return;
- sdes = gst_structure_new ("application/x-rtp-source-sdes", NULL);
+ sdes = gst_structure_new_empty ("application/x-rtp-source-sdes");
more_entries = gst_rtcp_packet_sdes_first_entry (packet);
j = 0;
@@ -2282,8 +2293,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;
}
@@ -2349,6 +2360,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);
@@ -2367,7 +2379,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;
@@ -2410,6 +2423,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) {
@@ -2428,7 +2443,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);
@@ -2480,7 +2495,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_length (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));
}
@@ -2738,9 +2758,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;
@@ -2748,7 +2771,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,
@@ -2763,9 +2786,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 */
@@ -2916,9 +2941,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);
@@ -2972,6 +3000,8 @@ session_sdes (RTPSession * sess, ReportData * data)
}
data->has_sdes = TRUE;
+
+ gst_rtcp_buffer_unmap (&rtcp);
}
/* schedule a BYE packet */
@@ -2979,6 +3009,7 @@ static void
session_bye (RTPSession * sess, ReportData * data)
{
GstRTCPPacket *packet = &data->packet;
+ GstRTCPBuffer rtcp;
/* open packet */
session_start_rtcp (sess, data);
@@ -2986,14 +3017,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
@@ -3215,10 +3250,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,
@@ -3332,15 +3364,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
@@ -3352,9 +3389,12 @@ rtp_session_on_sending_rtcp (RTPSession * sess, GstBuffer * buffer,
gpointer key, value;
gboolean started_fir = FALSE;
GstRTCPPacket fir_rtcppacket;
+ GstRTCPBuffer rtcp;
RTP_SESSION_LOCK (sess);
+ gst_rtcp_buffer_map (buffer, GST_MAP_WRITE, &rtcp);
+
g_hash_table_iter_init (&iter, sess->ssrcs[sess->mask_idx]);
while (g_hash_table_iter_next (&iter, &key, &value)) {
guint media_ssrc = GPOINTER_TO_UINT (key);
@@ -3363,7 +3403,7 @@ rtp_session_on_sending_rtcp (RTPSession * sess, GstBuffer * buffer,
if (media_src->send_fir) {
if (!started_fir) {
- if (!gst_rtcp_buffer_add_packet (buffer, GST_RTCP_TYPE_PSFB,
+ if (!gst_rtcp_buffer_add_packet (&rtcp, GST_RTCP_TYPE_PSFB,
&fir_rtcppacket))
break;
gst_rtcp_packet_fb_set_type (&fir_rtcppacket, GST_RTCP_PSFB_TYPE_FIR);
@@ -3402,22 +3442,20 @@ rtp_session_on_sending_rtcp (RTPSession * sess, GstBuffer * buffer,
if (media_src->send_pli && !rtp_source_has_retained (media_src,
has_pli_compare_func, NULL)) {
- if (gst_rtcp_buffer_add_packet (buffer, GST_RTCP_TYPE_PSFB,
- &pli_rtcppacket)) {
- gst_rtcp_packet_fb_set_type (&pli_rtcppacket, GST_RTCP_PSFB_TYPE_PLI);
- gst_rtcp_packet_fb_set_sender_ssrc (&pli_rtcppacket,
- rtp_source_get_ssrc (sess->source));
- gst_rtcp_packet_fb_set_media_ssrc (&pli_rtcppacket, media_ssrc);
- ret = TRUE;
- } else {
+ if (!gst_rtcp_buffer_add_packet (&rtcp, GST_RTCP_TYPE_PSFB,
+ &pli_rtcppacket))
/* Break because the packet is full, will put next request in a
- * further packet
- */
+ * further packet */
break;
- }
+ gst_rtcp_packet_fb_set_type (&pli_rtcppacket, GST_RTCP_PSFB_TYPE_PLI);
+ gst_rtcp_packet_fb_set_sender_ssrc (&pli_rtcppacket,
+ rtp_source_get_ssrc (sess->source));
+ gst_rtcp_packet_fb_set_media_ssrc (&pli_rtcppacket, media_ssrc);
+ ret = TRUE;
}
media_src->send_pli = FALSE;
}
+ gst_rtcp_buffer_unmap (&rtcp);
RTP_SESSION_UNLOCK (sess);
diff --git a/gst/rtpmanager/rtpsession.h b/gst/rtpmanager/rtpsession.h
index ecc0b98f3..929b6d494 100644
--- a/gst/rtpmanager/rtpsession.h
+++ b/gst/rtpmanager/rtpsession.h
@@ -21,7 +21,6 @@
#define __RTP_SESSION_H__
#include <gst/gst.h>
-#include <gst/netbuffer/gstnetbuffer.h>
#include "rtpsource.h"
diff --git a/gst/rtpmanager/rtpsource.c b/gst/rtpmanager/rtpsource.c
index f1ee4acd0..9d7386769 100644
--- a/gst/rtpmanager/rtpsource.c
+++ b/gst/rtpmanager/rtpsource.c
@@ -230,7 +230,7 @@ rtp_source_init (RTPSource * src)
src->probation = RTP_DEFAULT_PROBATION;
src->closing = FALSE;
- src->sdes = gst_structure_new ("application/x-rtp-source-sdes", NULL);
+ src->sdes = gst_structure_new_empty ("application/x-rtp-source-sdes");
src->payload = -1;
src->clock_rate = -1;
@@ -307,12 +307,12 @@ rtp_source_create_stats (RTPSource * src)
/* add address and port */
if (src->have_rtp_from) {
- gst_netaddress_to_string (&src->rtp_from, address_str,
+ gst_net_address_to_string (&src->rtp_from, address_str,
sizeof (address_str));
gst_structure_set (s, "rtp-from", G_TYPE_STRING, address_str, NULL);
}
if (src->have_rtcp_from) {
- gst_netaddress_to_string (&src->rtcp_from, address_str,
+ gst_net_address_to_string (&src->rtcp_from, address_str,
sizeof (address_str));
gst_structure_set (s, "rtcp-from", G_TYPE_STRING, address_str, NULL);
}
@@ -897,20 +897,24 @@ calculate_jitter (RTPSource * src, GstBuffer * buffer,
gint32 diff;
gint clock_rate;
guint8 pt;
+ GstRTPBuffer rtp = { NULL };
/* 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 = { NULL };
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 = { NULL };
+
*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 = { NULL };
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_length (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",
@@ -1695,7 +1718,7 @@ rtp_source_find_conflicting_address (RTPSource * src, GstNetAddress * address,
item; item = g_list_next (item)) {
RTPConflictingAddress *known_conflict = item->data;
- if (gst_netaddress_equal (address, &known_conflict->address)) {
+ if (gst_net_address_equal (address, &known_conflict->address)) {
known_conflict->time = time;
return TRUE;
}
@@ -1755,7 +1778,7 @@ rtp_source_timeout (RTPSource * src, GstClockTime current_time,
src->conflicting_addresses =
g_list_delete_link (src->conflicting_addresses, item);
- gst_netaddress_to_string (&known_conflict->address, buf, 40);
+ gst_net_address_to_string (&known_conflict->address, buf, 40);
GST_DEBUG ("collision %p timed out: %s", known_conflict, buf);
g_free (known_conflict);
}
@@ -1783,8 +1806,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;
diff --git a/gst/rtpmanager/rtpsource.h b/gst/rtpmanager/rtpsource.h
index fc204aeed..ca95dff25 100644
--- a/gst/rtpmanager/rtpsource.h
+++ b/gst/rtpmanager/rtpsource.h
@@ -22,7 +22,7 @@
#include <gst/gst.h>
#include <gst/rtp/gstrtcpbuffer.h>
-#include <gst/netbuffer/gstnetbuffer.h>
+#include <gst/net/gstnetaddressmeta.h>
#include "rtpstats.h"
diff --git a/gst/rtpmanager/rtpstats.h b/gst/rtpmanager/rtpstats.h
index 4560595ed..bbaf5d947 100644
--- a/gst/rtpmanager/rtpstats.h
+++ b/gst/rtpmanager/rtpstats.h
@@ -21,7 +21,7 @@
#define __RTP_STATS_H__
#include <gst/gst.h>
-#include <gst/netbuffer/gstnetbuffer.h>
+#include <gst/net/gstnetaddressmeta.h>
/**
* RTPSenderReport:
diff --git a/gst/rtsp/gstrtpdec.c b/gst/rtsp/gstrtpdec.c
index 02e68ddc7..b48cabbc5 100644
--- a/gst/rtsp/gstrtpdec.c
+++ b/gst/rtsp/gstrtpdec.c
@@ -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
@@ -87,28 +87,28 @@ enum
};
static GstStaticPadTemplate gst_rtp_dec_recv_rtp_sink_template =
-GST_STATIC_PAD_TEMPLATE ("recv_rtp_sink_%d",
+GST_STATIC_PAD_TEMPLATE ("recv_rtp_sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("application/x-rtp")
);
static GstStaticPadTemplate gst_rtp_dec_recv_rtcp_sink_template =
-GST_STATIC_PAD_TEMPLATE ("recv_rtcp_sink_%d",
+GST_STATIC_PAD_TEMPLATE ("recv_rtcp_sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("application/x-rtcp")
);
static GstStaticPadTemplate gst_rtp_dec_recv_rtp_src_template =
-GST_STATIC_PAD_TEMPLATE ("recv_rtp_src_%d_%d_%d",
+GST_STATIC_PAD_TEMPLATE ("recv_rtp_src_%u_%u_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("application/x-rtp")
);
static GstStaticPadTemplate gst_rtp_dec_rtcp_src_template =
-GST_STATIC_PAD_TEMPLATE ("rtcp_src_%d",
+GST_STATIC_PAD_TEMPLATE ("rtcp_src_%u",
GST_PAD_SRC,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("application/x-rtcp")
@@ -124,11 +124,13 @@ 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);
-static GstFlowReturn gst_rtp_dec_chain_rtcp (GstPad * pad, GstBuffer * buffer);
+static GstFlowReturn gst_rtp_dec_chain_rtp (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
+static GstFlowReturn gst_rtp_dec_chain_rtcp (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
/* Manages the receiving end of the packets.
@@ -193,29 +195,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_static_pad_template (element_class,
- &gst_rtp_dec_recv_rtp_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_dec_recv_rtcp_sink_template);
- /* src pads */
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_dec_recv_rtp_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +279,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;
@@ -405,7 +389,6 @@ gst_rtp_dec_class_init (GstRTPDecClass * g_class)
NULL, NULL, gst_rtp_dec_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
G_TYPE_UINT, G_TYPE_UINT);
-
gstelement_class->provide_clock =
GST_DEBUG_FUNCPTR (gst_rtp_dec_provide_clock);
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_dec_change_state);
@@ -413,14 +396,30 @@ 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;
+
+ GST_OBJECT_FLAG_SET (rtpdec, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
}
static void
@@ -437,7 +436,7 @@ gst_rtp_dec_finalize (GObject * object)
}
static gboolean
-gst_rtp_dec_query_src (GstPad * pad, GstQuery * query)
+gst_rtp_dec_query_src (GstPad * pad, GstObject * parent, GstQuery * query)
{
gboolean res;
@@ -450,30 +449,34 @@ gst_rtp_dec_query_src (GstPad * pad, GstQuery * query)
break;
}
default:
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, parent, query);
break;
}
return res;
}
static GstFlowReturn
-gst_rtp_dec_chain_rtp (GstPad * pad, GstBuffer * buffer)
+gst_rtp_dec_chain_rtp (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstFlowReturn res;
GstRTPDec *rtpdec;
GstRTPDecSession *session;
guint32 ssrc;
guint8 pt;
+ GstRTPBuffer rtp = { NULL, };
- rtpdec = GST_RTP_DEC (GST_PAD_PARENT (pad));
+ rtpdec = GST_RTP_DEC (parent);
GST_DEBUG_OBJECT (rtpdec, "got rtp packet");
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);
@@ -512,13 +515,13 @@ gst_rtp_dec_chain_rtp (GstPad * pad, GstBuffer * buffer)
caps = (GstCaps *) g_value_get_boxed (&ret);
- name = g_strdup_printf ("recv_rtp_src_%d_%u_%d", session->id, ssrc, pt);
+ name = g_strdup_printf ("recv_rtp_src_%u_%u_%u", session->id, ssrc, pt);
klass = GST_ELEMENT_GET_CLASS (rtpdec);
- templ = gst_element_class_get_pad_template (klass, "recv_rtp_src_%d_%d_%d");
+ templ = gst_element_class_get_pad_template (klass, "recv_rtp_src_%u_%u_%u");
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 +531,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;
@@ -544,7 +545,7 @@ bad_packet:
}
static GstFlowReturn
-gst_rtp_dec_chain_rtcp (GstPad * pad, GstBuffer * buffer)
+gst_rtp_dec_chain_rtcp (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstRTPDec *src;
@@ -554,7 +555,7 @@ gst_rtp_dec_chain_rtcp (GstPad * pad, GstBuffer * buffer)
gboolean more;
#endif
- src = GST_RTP_DEC (GST_PAD_PARENT (pad));
+ src = GST_RTP_DEC (parent);
GST_DEBUG_OBJECT (src, "got rtcp packet");
@@ -782,7 +783,7 @@ create_recv_rtp (GstRTPDec * rtpdec, GstPadTemplate * templ, const gchar * name)
GstRTPDecSession *session;
/* first get the session number */
- if (name == NULL || sscanf (name, "recv_rtp_sink_%d", &sessid) != 1)
+ if (name == NULL || sscanf (name, "recv_rtp_sink_%u", &sessid) != 1)
goto no_name;
GST_DEBUG_OBJECT (rtpdec, "finding session %d", sessid);
@@ -838,7 +839,7 @@ create_recv_rtcp (GstRTPDec * rtpdec, GstPadTemplate * templ,
GstRTPDecSession *session;
/* first get the session number */
- if (name == NULL || sscanf (name, "recv_rtcp_sink_%d", &sessid) != 1)
+ if (name == NULL || sscanf (name, "recv_rtcp_sink_%u", &sessid) != 1)
goto no_name;
GST_DEBUG_OBJECT (rtpdec, "finding session %d", sessid);
@@ -890,7 +891,7 @@ create_rtcp (GstRTPDec * rtpdec, GstPadTemplate * templ, const gchar * name)
GstRTPDecSession *session;
/* first get the session number */
- if (name == NULL || sscanf (name, "rtcp_src_%d", &sessid) != 1)
+ if (name == NULL || sscanf (name, "rtcp_src_%u", &sessid) != 1)
goto no_name;
/* get or create session */
@@ -930,7 +931,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;
@@ -943,12 +944,12 @@ gst_rtp_dec_request_new_pad (GstElement * element,
klass = GST_ELEMENT_GET_CLASS (element);
/* figure out the template */
- if (templ == gst_element_class_get_pad_template (klass, "recv_rtp_sink_%d")) {
+ if (templ == gst_element_class_get_pad_template (klass, "recv_rtp_sink_%u")) {
result = create_recv_rtp (rtpdec, templ, name);
} else if (templ == gst_element_class_get_pad_template (klass,
- "recv_rtcp_sink_%d")) {
+ "recv_rtcp_sink_%u")) {
result = create_recv_rtcp (rtpdec, templ, name);
- } else if (templ == gst_element_class_get_pad_template (klass, "rtcp_src_%d")) {
+ } else if (templ == gst_element_class_get_pad_template (klass, "rtcp_src_%u")) {
result = create_rtcp (rtpdec, templ, name);
} else
goto wrong_template;
diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c
index b7b790f37..b86ab6d7c 100644
--- a/gst/rtsp/gstrtspsrc.c
+++ b/gst/rtsp/gstrtspsrc.c
@@ -104,20 +104,20 @@
GST_DEBUG_CATEGORY_STATIC (rtspsrc_debug);
#define GST_CAT_DEFAULT (rtspsrc_debug)
-static GstStaticPadTemplate rtptemplate = GST_STATIC_PAD_TEMPLATE ("stream%d",
+static GstStaticPadTemplate rtptemplate = GST_STATIC_PAD_TEMPLATE ("stream_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("application/x-rtp; application/x-rdt"));
/* templates used internally */
static GstStaticPadTemplate anysrctemplate =
-GST_STATIC_PAD_TEMPLATE ("internalsrc%d",
+GST_STATIC_PAD_TEMPLATE ("internalsrc_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate anysinktemplate =
-GST_STATIC_PAD_TEMPLATE ("internalsink%d",
+GST_STATIC_PAD_TEMPLATE ("internalsink_%u",
GST_PAD_SINK,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS_ANY);
@@ -250,8 +250,7 @@ static void gst_rtspsrc_handle_message (GstBin * bin, GstMessage * message);
static gboolean gst_rtspsrc_setup_auth (GstRTSPSrc * src,
GstRTSPMessage * response);
-static void gst_rtspsrc_loop_send_cmd (GstRTSPSrc * src, gint cmd,
- gboolean flush);
+static void gst_rtspsrc_loop_send_cmd (GstRTSPSrc * src, gint cmd);
static GstRTSPResult gst_rtspsrc_send_cb (GstRTSPExtension * ext,
GstRTSPMessage * request, GstRTSPMessage * response, GstRTSPSrc * src);
@@ -264,7 +263,7 @@ static GstRTSPResult gst_rtspsrc_close (GstRTSPSrc * src, gboolean async,
gboolean only_close);
static gboolean gst_rtspsrc_uri_set_uri (GstURIHandler * handler,
- const gchar * uri);
+ const gchar * uri, GError ** error);
static gboolean gst_rtspsrc_activate_streams (GstRTSPSrc * src);
static gboolean gst_rtspsrc_loop (GstRTSPSrc * src);
@@ -292,38 +291,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_static_pad_template (element_class, &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)
@@ -336,6 +306,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;
@@ -380,9 +352,9 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_CONNECTION_SPEED,
- g_param_spec_uint ("connection-speed", "Connection Speed",
+ g_param_spec_uint64 ("connection-speed", "Connection Speed",
"Network connection speed in kbps (0 = unknown)",
- 0, G_MAXINT / 1000, DEFAULT_CONNECTION_SPEED,
+ 0, G_MAXUINT64 / 1000, DEFAULT_CONNECTION_SPEED,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_NAT_METHOD,
@@ -495,6 +467,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 ();
@@ -502,7 +484,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;
@@ -550,7 +532,7 @@ gst_rtspsrc_init (GstRTSPSrc * src, GstRTSPSrcClass * g_class)
src->state = GST_RTSP_STATE_INVALID;
- GST_OBJECT_FLAG_SET (src, GST_ELEMENT_IS_SOURCE);
+ GST_OBJECT_FLAG_SET (src, GST_ELEMENT_FLAG_SOURCE);
}
static void
@@ -659,7 +641,7 @@ gst_rtspsrc_set_property (GObject * object, guint prop_id, const GValue * value,
switch (prop_id) {
case PROP_LOCATION:
gst_rtspsrc_uri_set_uri (GST_URI_HANDLER (rtspsrc),
- g_value_get_string (value));
+ g_value_get_string (value), NULL);
break;
case PROP_PROTOCOLS:
rtspsrc->protocols = g_value_get_flags (value);
@@ -680,7 +662,7 @@ gst_rtspsrc_set_property (GObject * object, guint prop_id, const GValue * value,
rtspsrc->latency = g_value_get_uint (value);
break;
case PROP_CONNECTION_SPEED:
- rtspsrc->connection_speed = g_value_get_uint (value);
+ rtspsrc->connection_speed = g_value_get_uint64 (value);
break;
case PROP_NAT_METHOD:
rtspsrc->nat_method = g_value_get_enum (value);
@@ -770,7 +752,7 @@ gst_rtspsrc_get_property (GObject * object, guint prop_id, GValue * value,
g_value_set_uint (value, rtspsrc->latency);
break;
case PROP_CONNECTION_SPEED:
- g_value_set_uint (value, rtspsrc->connection_speed);
+ g_value_set_uint64 (value, rtspsrc->connection_speed);
break;
case PROP_NAT_METHOD:
g_value_set_enum (value, rtspsrc->nat_method);
@@ -1627,18 +1609,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 */
@@ -1694,7 +1672,7 @@ gst_rtspsrc_flush (GstRTSPSrc * src, gboolean flush, gboolean playing)
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; playing %d", playing);
cmd = CMD_LOOP;
if (playing)
@@ -1708,7 +1686,7 @@ gst_rtspsrc_flush (GstRTSPSrc * src, gboolean flush, gboolean playing)
}
}
gst_rtspsrc_push_event (src, event, FALSE);
- gst_rtspsrc_loop_send_cmd (src, cmd, flush);
+ gst_rtspsrc_loop_send_cmd (src, cmd);
/* set up manager before data-flow resumes */
/* to manage jitterbuffer buffer mode */
@@ -1870,7 +1848,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);
}
@@ -1899,24 +1877,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, playing);
- } 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 */
@@ -1926,20 +1886,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");
@@ -1967,13 +1924,14 @@ no_format:
}
static gboolean
-gst_rtspsrc_handle_src_event (GstPad * pad, GstEvent * event)
+gst_rtspsrc_handle_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstRTSPSrc *src;
gboolean res = TRUE;
gboolean forward;
- src = GST_RTSPSRC_CAST (gst_pad_get_parent (pad));
+ src = GST_RTSPSRC_CAST (parent);
GST_DEBUG_OBJECT (src, "pad %s:%s received event %s",
GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE_NAME (event));
@@ -2002,7 +1960,6 @@ gst_rtspsrc_handle_src_event (GstPad * pad, GstEvent * event)
} else {
gst_event_unref (event);
}
- gst_object_unref (src);
return res;
}
@@ -2010,7 +1967,8 @@ gst_rtspsrc_handle_src_event (GstPad * pad, GstEvent * event)
/* this is the final event function we receive on the internal source pad when
* we deal with TCP connections */
static gboolean
-gst_rtspsrc_handle_internal_src_event (GstPad * pad, GstEvent * event)
+gst_rtspsrc_handle_internal_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstRTSPSrc *src;
gboolean res;
@@ -2036,7 +1994,8 @@ gst_rtspsrc_handle_internal_src_event (GstPad * pad, GstEvent * event)
/* this is the final query function we receive on the internal source pad when
* we deal with TCP connections */
static gboolean
-gst_rtspsrc_handle_internal_src_query (GstPad * pad, GstQuery * query)
+gst_rtspsrc_handle_internal_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
GstRTSPSrc *src;
gboolean res = TRUE;
@@ -2084,12 +2043,13 @@ gst_rtspsrc_handle_internal_src_query (GstPad * pad, GstQuery * query)
/* this query is executed on the ghost source pad exposed on rtspsrc. */
static gboolean
-gst_rtspsrc_handle_src_query (GstPad * pad, GstQuery * query)
+gst_rtspsrc_handle_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
GstRTSPSrc *src;
gboolean res = FALSE;
- src = GST_RTSPSRC_CAST (gst_pad_get_parent (pad));
+ src = GST_RTSPSRC_CAST (parent);
GST_DEBUG_OBJECT (src, "pad %s:%s received query %s",
GST_DEBUG_PAD_NAME (pad), GST_QUERY_TYPE_NAME (query));
@@ -2143,7 +2103,6 @@ gst_rtspsrc_handle_src_query (GstPad * pad, GstQuery * query)
break;
}
}
- gst_object_unref (src);
return res;
}
@@ -2151,13 +2110,14 @@ gst_rtspsrc_handle_src_query (GstPad * pad, GstQuery * query)
/* callback for RTCP messages to be sent to the server when operating in TCP
* mode. */
static GstFlowReturn
-gst_rtspsrc_sink_chain (GstPad * pad, GstBuffer * buffer)
+gst_rtspsrc_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstRTSPSrc *src;
GstRTSPStream *stream;
GstFlowReturn res = GST_FLOW_OK;
guint8 *data;
guint size;
+ gsize bsize;
GstRTSPResult ret;
GstRTSPMessage message = { 0 };
GstRTSPConnection *conn;
@@ -2165,8 +2125,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]);
@@ -2187,20 +2147,17 @@ 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 GstPadProbeReturn
+pad_blocked (GstPad * pad, GstPadProbeInfo * info, 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));
@@ -2214,12 +2171,12 @@ pad_blocked (GstPad * pad, gboolean blocked, GstRTSPSrc * src)
gst_rtspsrc_activate_streams (src);
- return;
+ return GST_PAD_PROBE_OK;
was_ok:
{
GST_OBJECT_UNLOCK (src);
- return;
+ return GST_PAD_PROBE_OK;
}
}
@@ -2240,7 +2197,7 @@ new_manager_pad (GstElement * manager, GstPad * pad, GstRTSPSrc * src)
GST_RTSP_STATE_LOCK (src);
/* find stream */
name = gst_object_get_name (GST_OBJECT_CAST (pad));
- if (sscanf (name, "recv_rtp_src_%d_%d_%d", &id, &ssrc, &pt) != 3)
+ if (sscanf (name, "recv_rtp_src_%u_%u_%u", &id, &ssrc, &pt) != 3)
goto unknown_stream;
GST_DEBUG_OBJECT (src, "stream: %u, SSRC %d, PT %d", id, ssrc, pt);
@@ -2483,10 +2440,10 @@ gst_rtspsrc_stream_configure_manager (GstRTSPSrc * src, GstRTSPStream * stream,
/* we stream directly to the manager, get some pads. Each RTSP stream goes
* into a separate RTP session. */
- name = g_strdup_printf ("recv_rtp_sink_%d", stream->id);
+ name = g_strdup_printf ("recv_rtp_sink_%u", stream->id);
stream->channelpad[0] = gst_element_get_request_pad (src->manager, name);
g_free (name);
- name = g_strdup_printf ("recv_rtcp_sink_%d", stream->id);
+ name = g_strdup_printf ("recv_rtcp_sink_%u", stream->id);
stream->channelpad[1] = gst_element_get_request_pad (src->manager, name);
g_free (name);
@@ -2595,7 +2552,7 @@ gst_rtspsrc_stream_configure_tcp (GstRTSPSrc * src, GstRTSPStream * stream,
GST_DEBUG_OBJECT (src, "no manager, creating pad");
/* create a new pad we will use to stream to */
- name = g_strdup_printf ("stream%d", stream->id);
+ name = g_strdup_printf ("stream_%u", stream->id);
template = gst_static_pad_template_get (&rtptemplate);
stream->channelpad[0] = gst_pad_new_from_template (template, name);
gst_object_unref (template);
@@ -2612,7 +2569,7 @@ gst_rtspsrc_stream_configure_tcp (GstRTSPSrc * src, GstRTSPStream * stream,
template = gst_static_pad_template_get (&anysrctemplate);
/* allocate pads for sending the channel data into the manager */
- pad0 = gst_pad_new_from_template (template, "internalsrc0");
+ pad0 = gst_pad_new_from_template (template, "internalsrc_0");
gst_pad_link (pad0, stream->channelpad[0]);
gst_object_unref (stream->channelpad[0]);
stream->channelpad[0] = pad0;
@@ -2624,7 +2581,7 @@ gst_rtspsrc_stream_configure_tcp (GstRTSPSrc * src, GstRTSPStream * stream,
if (stream->channelpad[1]) {
/* if we have a sinkpad for the other channel, create a pad and link to the
* manager. */
- pad1 = gst_pad_new_from_template (template, "internalsrc1");
+ pad1 = gst_pad_new_from_template (template, "internalsrc_1");
gst_pad_set_event_function (pad1, gst_rtspsrc_handle_internal_src_event);
gst_pad_link (pad1, stream->channelpad[1]);
gst_object_unref (stream->channelpad[1]);
@@ -2639,13 +2596,13 @@ gst_rtspsrc_stream_configure_tcp (GstRTSPSrc * src, GstRTSPStream * stream,
template = gst_static_pad_template_get (&anysinktemplate);
- stream->rtcppad = gst_pad_new_from_template (template, "internalsink0");
+ stream->rtcppad = gst_pad_new_from_template (template, "internalsink_0");
gst_pad_set_chain_function (stream->rtcppad, gst_rtspsrc_sink_chain);
gst_pad_set_element_private (stream->rtcppad, stream);
gst_pad_set_active (stream->rtcppad, TRUE);
/* get session RTCP pad */
- name = g_strdup_printf ("send_rtcp_src_%d", stream->id);
+ name = g_strdup_printf ("send_rtcp_src_%u", stream->id);
pad = gst_element_get_request_pad (src->manager, name);
g_free (name);
@@ -2744,8 +2701,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);
@@ -2760,8 +2716,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);
}
@@ -2812,8 +2767,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_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM, pad_blocked, src, NULL);
if (stream->channelpad[0]) {
GST_DEBUG_OBJECT (src, "connecting UDP source 0 to manager");
@@ -2913,7 +2869,7 @@ gst_rtspsrc_stream_configure_udp_sinks (GstRTSPSrc * src,
"sizetype", 2, "sizemax", 200, "silent", TRUE, NULL);
/* we don't want to consider this a sink */
- GST_OBJECT_FLAG_UNSET (stream->udpsink[0], GST_ELEMENT_IS_SINK);
+ GST_OBJECT_FLAG_UNSET (stream->udpsink[0], GST_ELEMENT_FLAG_SINK);
/* keep everything locked */
gst_element_set_locked_state (stream->udpsink[0], TRUE);
@@ -2956,7 +2912,7 @@ gst_rtspsrc_stream_configure_udp_sinks (GstRTSPSrc * src,
}
/* we don't want to consider this a sink */
- GST_OBJECT_FLAG_UNSET (stream->udpsink[1], GST_ELEMENT_IS_SINK);
+ GST_OBJECT_FLAG_UNSET (stream->udpsink[1], GST_ELEMENT_FLAG_SINK);
/* we keep this playing always */
gst_element_set_locked_state (stream->udpsink[1], TRUE);
@@ -2968,7 +2924,7 @@ gst_rtspsrc_stream_configure_udp_sinks (GstRTSPSrc * src,
stream->rtcppad = gst_element_get_static_pad (stream->udpsink[1], "sink");
/* get session RTCP pad */
- name = g_strdup_printf ("send_rtcp_src_%d", stream->id);
+ name = g_strdup_printf ("send_rtcp_src_%u", stream->id);
pad = gst_element_get_request_pad (src->manager, name);
g_free (name);
@@ -3064,7 +3020,7 @@ gst_rtspsrc_stream_configure_transport (GstRTSPStream * stream,
/* create ghostpad, don't add just yet, this will be done when we activate
* the stream. */
- name = g_strdup_printf ("stream%d", stream->id);
+ name = g_strdup_printf ("stream_%u", stream->id);
template = gst_static_pad_template_get (&rtptemplate);
stream->srcpad = gst_ghost_pad_new_from_template (name, outpad, template);
gst_pad_set_event_function (stream->srcpad, gst_rtspsrc_handle_src_event);
@@ -3166,11 +3122,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;
}
}
@@ -3186,7 +3141,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;
@@ -3667,9 +3622,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);
@@ -3682,12 +3636,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
@@ -4105,12 +4053,10 @@ gst_rtspsrc_loop_end_cmd (GstRTSPSrc * src, gint cmd, GstRTSPResult ret)
}
static void
-gst_rtspsrc_loop_send_cmd (GstRTSPSrc * src, gint cmd, gboolean flush)
+gst_rtspsrc_loop_send_cmd (GstRTSPSrc * src, gint cmd)
{
gint old;
- /* FIXME flush param mute; remove at discretion */
-
/* start new request */
gst_rtspsrc_loop_start_cmd (src, cmd);
@@ -4172,7 +4118,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);
}
@@ -4720,7 +4666,7 @@ error_response:
else
transports = GST_RTSP_LOWER_TRANS_UNKNOWN;
- gst_rtspsrc_uri_set_uri (GST_URI_HANDLER (src), new_location);
+ gst_rtspsrc_uri_set_uri (GST_URI_HANDLER (src), new_location, NULL);
/* set old transports */
if (src->conninfo.url && transports != GST_RTSP_LOWER_TRANS_UNKNOWN)
@@ -5432,7 +5378,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;
@@ -5458,7 +5404,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;
}
@@ -5475,7 +5421,7 @@ gst_rtspsrc_open_from_sdp (GstRTSPSrc * src, GstSDPMessage * sdp,
if (src->props)
gst_structure_remove_all_fields (src->props);
else
- src->props = gst_structure_empty_new ("RTSPProperties");
+ src->props = gst_structure_new_empty ("RTSPProperties");
if (src->debug)
gst_sdp_message_dump (sdp);
@@ -6025,11 +5971,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);
@@ -6181,7 +6127,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);
@@ -6437,7 +6383,7 @@ gst_rtspsrc_handle_message (GstBin * bin, GstMessage * message)
/* we only act on the first udp timeout message, others are irrelevant
* and can be ignored. */
if (!ignore_timeout)
- gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_RECONNECT, TRUE);
+ gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_RECONNECT);
/* eat and free */
gst_message_unref (message);
return;
@@ -6562,7 +6508,7 @@ gst_rtspsrc_start (GstRTSPSrc * src)
src->loop_cmd = CMD_WAIT;
if (src->task == NULL) {
- src->task = gst_task_create ((GstTaskFunction) gst_rtspsrc_thread, src);
+ src->task = gst_task_new ((GstTaskFunction) gst_rtspsrc_thread, src);
if (src->task == NULL)
goto task_error;
@@ -6588,7 +6534,7 @@ gst_rtspsrc_stop (GstRTSPSrc * src)
GST_DEBUG_OBJECT (src, "stopping");
/* also cancels pending task */
- gst_rtspsrc_loop_send_cmd (src, CMD_WAIT, TRUE);
+ gst_rtspsrc_loop_send_cmd (src, CMD_WAIT);
GST_OBJECT_LOCK (src);
if ((task = src->task)) {
@@ -6636,12 +6582,12 @@ gst_rtspsrc_change_state (GstElement * element, GstStateChange transition)
/* first attempt, don't ignore timeouts */
rtspsrc->ignore_timeout = FALSE;
rtspsrc->open_error = FALSE;
- gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_OPEN, FALSE);
+ gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_OPEN);
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
/* unblock the tcp tasks and make the loop waiting */
- gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_WAIT, TRUE);
+ gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_WAIT);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
@@ -6655,18 +6601,18 @@ gst_rtspsrc_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
- gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_PLAY, FALSE);
+ gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_PLAY);
break;
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
/* send pause request and keep the idle task around */
- gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_PAUSE, FALSE);
+ gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_PAUSE);
ret = GST_STATE_CHANGE_NO_PREROLL;
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
ret = GST_STATE_CHANGE_NO_PREROLL;
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
- gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_CLOSE, FALSE);
+ gst_rtspsrc_loop_send_cmd (rtspsrc, CMD_CLOSE);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
gst_rtspsrc_stop (rtspsrc);
@@ -6706,31 +6652,32 @@ 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)
+static const gchar *const *
+gst_rtspsrc_uri_get_protocols (GType type)
{
static const gchar *protocols[] =
{ "rtsp", "rtspu", "rtspt", "rtsph", "rtsp-sdp", NULL };
- return (gchar **) protocols;
+ return protocols;
}
-static const gchar *
+static gchar *
gst_rtspsrc_uri_get_uri (GstURIHandler * handler)
{
GstRTSPSrc *src = GST_RTSPSRC (handler);
- /* should not dup */
- return src->conninfo.location;
+ /* FIXME: make thread-safe */
+ return g_strdup (src->conninfo.location);
}
static gboolean
-gst_rtspsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_rtspsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
GstRTSPSrc *src;
GstRTSPResult res;
@@ -6790,6 +6737,8 @@ was_ok:
sdp_failed:
{
GST_ERROR_OBJECT (src, "Could not create new SDP (%d)", res);
+ g_set_error_literal (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
+ "Could not create SDP");
return FALSE;
}
invalid_sdp:
@@ -6797,12 +6746,16 @@ invalid_sdp:
GST_ERROR_OBJECT (src, "Not a valid SDP (%d) '%s'", res,
GST_STR_NULL (uri));
gst_sdp_message_free (sdp);
+ g_set_error_literal (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
+ "Invalid SDP");
return FALSE;
}
parse_error:
{
GST_ERROR_OBJECT (src, "Not a valid RTSP url '%s' (%d)",
GST_STR_NULL (uri), res);
+ g_set_error_literal (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
+ "Invalid RTSP URI");
return FALSE;
}
}
diff --git a/gst/rtsp/gstrtspsrc.h b/gst/rtsp/gstrtspsrc.h
index cf8f81c44..bcfa31e75 100644
--- a/gst/rtsp/gstrtspsrc.h
+++ b/gst/rtsp/gstrtspsrc.h
@@ -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;
@@ -201,7 +201,7 @@ struct _GstRTSPSrc {
GTimeVal tcp_timeout;
GTimeVal *ptcp_timeout;
guint latency;
- guint connection_speed;
+ guint64 connection_speed;
GstRTSPNatMethod nat_method;
gboolean do_rtcp;
gchar *proxy_host;
diff --git a/gst/shapewipe/Makefile.am b/gst/shapewipe/Makefile.am
index 35cf5df03..863459727 100644
--- a/gst/shapewipe/Makefile.am
+++ b/gst/shapewipe/Makefile.am
@@ -2,8 +2,8 @@ plugin_LTLIBRARIES = libgstshapewipe.la
libgstshapewipe_la_SOURCES = gstshapewipe.c
-libgstshapewipe_la_CFLAGS = $(GIO_CFLAGS) $(GST_CFLAGS) $(GST_CONTROLLER_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
-libgstshapewipe_la_LIBADD = $(GIO_LIBS) $(GST_LIBS) $(GST_CONTROLLER_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstvideo-@GST_MAJORMINOR@
+libgstshapewipe_la_CFLAGS = $(GIO_CFLAGS) $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
+libgstshapewipe_la_LIBADD = $(GIO_LIBS) $(GST_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstvideo-@GST_MAJORMINOR@
libgstshapewipe_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstshapewipe_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/gst/shapewipe/gstshapewipe.c b/gst/shapewipe/gstshapewipe.c
index 3397dda8f..1a4d86024 100644
--- a/gst/shapewipe/gstshapewipe.c
+++ b/gst/shapewipe/gstshapewipe.c
@@ -32,7 +32,7 @@
* <refsect2>
* <title>Example launch line</title>
* |[
- * gst-launch -v videotestsrc ! video/x-raw-yuv,format=(fourcc)AYUV,width=640,height=480 ! shapewipe position=0.5 name=shape ! videomixer name=mixer ! ffmpegcolorspace ! autovideosink filesrc location=mask.png ! typefind ! decodebin2 ! ffmpegcolorspace ! videoscale ! queue ! shape.mask_sink videotestsrc pattern=snow ! video/x-raw-yuv,format=(fourcc)AYUV,width=640,height=480 ! queue ! mixer.
+ * gst-launch -v videotestsrc ! video/x-raw,format=(string)AYUV,width=640,height=480 ! shapewipe position=0.5 name=shape ! videomixer name=mixer ! videoconvert ! autovideosink filesrc location=mask.png ! typefind ! decodebin2 ! videoconvert ! videoscale ! queue ! shape.mask_sink videotestsrc pattern=snow ! video/x-raw,format=(string)AYUV,width=640,height=480 ! queue ! mixer.
* ]| This pipeline adds the transition from mask.png with position 0.5 to an SMPTE test screen and snow.
* </refsect2>
*/
@@ -45,7 +45,6 @@
#include <string.h>
#include <gst/gst.h>
-#include <gst/controller/gstcontroller.h>
#include "gstshapewipe.h"
@@ -66,24 +65,30 @@ static GstStateChangeReturn gst_shape_wipe_change_state (GstElement * element,
GstStateChange transition);
static GstFlowReturn gst_shape_wipe_video_sink_chain (GstPad * pad,
- GstBuffer * buffer);
+ GstObject * parent, GstBuffer * buffer);
static gboolean gst_shape_wipe_video_sink_event (GstPad * pad,
- GstEvent * event);
-static gboolean gst_shape_wipe_video_sink_setcaps (GstPad * pad,
+ GstObject * parent, GstEvent * event);
+static gboolean gst_shape_wipe_video_sink_setcaps (GstShapeWipe * self,
GstCaps * caps);
-static GstCaps *gst_shape_wipe_video_sink_getcaps (GstPad * pad);
-static GstFlowReturn gst_shape_wipe_video_sink_bufferalloc (GstPad * pad,
- guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
+static GstCaps *gst_shape_wipe_video_sink_getcaps (GstPad * pad,
+ GstCaps * filter);
static gboolean gst_shape_wipe_video_sink_query (GstPad * pad,
- GstQuery * query);
+ GstObject * parent, GstQuery * query);
static GstFlowReturn gst_shape_wipe_mask_sink_chain (GstPad * pad,
- GstBuffer * buffer);
-static gboolean gst_shape_wipe_mask_sink_event (GstPad * pad, GstEvent * event);
-static gboolean gst_shape_wipe_mask_sink_setcaps (GstPad * pad, GstCaps * caps);
-static GstCaps *gst_shape_wipe_mask_sink_getcaps (GstPad * pad);
-static gboolean gst_shape_wipe_src_event (GstPad * pad, GstEvent * event);
-static GstCaps *gst_shape_wipe_src_getcaps (GstPad * pad);
-static gboolean gst_shape_wipe_src_query (GstPad * pad, GstQuery * query);
+ GstObject * parent, GstBuffer * buffer);
+static gboolean gst_shape_wipe_mask_sink_event (GstPad * pad,
+ GstObject * parent, GstEvent * event);
+static gboolean gst_shape_wipe_mask_sink_setcaps (GstShapeWipe * self,
+ GstCaps * caps);
+static GstCaps *gst_shape_wipe_mask_sink_getcaps (GstPad * pad,
+ GstCaps * filter);
+static gboolean gst_shape_wipe_mask_sink_query (GstPad * pad,
+ GstObject * parent, GstQuery * query);
+static gboolean gst_shape_wipe_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static GstCaps *gst_shape_wipe_src_getcaps (GstPad * pad, GstCaps * filter);
+static gboolean gst_shape_wipe_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
enum
{
@@ -96,53 +101,32 @@ 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",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-gray, "
- "bpp = 8, "
- "depth = 8, "
+ GST_STATIC_CAPS ("video/x-raw, "
+ "format = (string) GRAY8, "
"width = " GST_VIDEO_SIZE_RANGE ", "
"height = " GST_VIDEO_SIZE_RANGE ", " "framerate = 0/1 ; "
- "video/x-raw-gray, " "bpp = 16, " "depth = 16, "
- "endianness = BYTE_ORDER, " "width = " GST_VIDEO_SIZE_RANGE ", "
+ "video/x-raw, " "format = (string) " GST_VIDEO_NE (GRAY16) ", "
+ "width = " GST_VIDEO_SIZE_RANGE ", "
"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_static_pad_template (gstelement_class,
- &video_sink_pad_template);
- gst_element_class_add_static_pad_template (gstelement_class,
- &mask_sink_pad_template);
- gst_element_class_add_static_pad_template (gstelement_class,
- &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 +149,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");
@@ -176,12 +173,6 @@ gst_shape_wipe_init (GstShapeWipe * self, GstShapeWipeClass * g_class)
GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_chain));
gst_pad_set_event_function (self->video_sinkpad,
GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_event));
- gst_pad_set_setcaps_function (self->video_sinkpad,
- GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_setcaps));
- gst_pad_set_getcaps_function (self->video_sinkpad,
- GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_getcaps));
- gst_pad_set_bufferalloc_function (self->video_sinkpad,
- GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_bufferalloc));
gst_pad_set_query_function (self->video_sinkpad,
GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_query));
gst_element_add_pad (GST_ELEMENT (self), self->video_sinkpad);
@@ -192,17 +183,13 @@ gst_shape_wipe_init (GstShapeWipe * self, GstShapeWipeClass * g_class)
GST_DEBUG_FUNCPTR (gst_shape_wipe_mask_sink_chain));
gst_pad_set_event_function (self->mask_sinkpad,
GST_DEBUG_FUNCPTR (gst_shape_wipe_mask_sink_event));
- gst_pad_set_setcaps_function (self->mask_sinkpad,
- GST_DEBUG_FUNCPTR (gst_shape_wipe_mask_sink_setcaps));
- gst_pad_set_getcaps_function (self->mask_sinkpad,
- GST_DEBUG_FUNCPTR (gst_shape_wipe_mask_sink_getcaps));
+ gst_pad_set_query_function (self->mask_sinkpad,
+ GST_DEBUG_FUNCPTR (gst_shape_wipe_mask_sink_query));
gst_element_add_pad (GST_ELEMENT (self), self->mask_sinkpad);
self->srcpad = gst_pad_new_from_static_template (&src_pad_template, "src");
gst_pad_set_event_function (self->srcpad,
GST_DEBUG_FUNCPTR (gst_shape_wipe_src_event));
- gst_pad_set_getcaps_function (self->srcpad,
- GST_DEBUG_FUNCPTR (gst_shape_wipe_src_getcaps));
gst_pad_set_query_function (self->srcpad,
GST_DEBUG_FUNCPTR (gst_shape_wipe_src_query));
gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
@@ -290,8 +277,7 @@ gst_shape_wipe_reset (GstShapeWipe * self)
g_cond_signal (self->mask_cond);
g_mutex_unlock (self->mask_mutex);
- self->fmt = GST_VIDEO_FORMAT_UNKNOWN;
- self->width = self->height = 0;
+ gst_video_info_init (&self->info);
self->mask_bpp = 0;
gst_segment_init (&self->segment, GST_FORMAT_TIME);
@@ -300,84 +286,55 @@ gst_shape_wipe_reset (GstShapeWipe * self)
self->frame_duration = 0;
}
-static GstFlowReturn
-gst_shape_wipe_video_sink_bufferalloc (GstPad * pad, guint64 offset, guint size,
- GstCaps * caps, GstBuffer ** buf)
-{
- GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
- GstFlowReturn ret = GST_FLOW_OK;
-
- GST_LOG_OBJECT (pad, "Allocating buffer with offset 0x%" G_GINT64_MODIFIER
- "x and size %u with caps: %" GST_PTR_FORMAT, offset, size, caps);
-
- *buf = NULL;
-
- ret = gst_pad_alloc_buffer (self->srcpad, offset, size, caps, buf);
- if (G_UNLIKELY (ret != GST_FLOW_OK))
- GST_ERROR_OBJECT (pad, "Allocating buffer failed: %s",
- gst_flow_get_name (ret));
-
- gst_object_unref (self);
-
- return ret;
-}
-
static gboolean
-gst_shape_wipe_video_sink_setcaps (GstPad * pad, GstCaps * caps)
+gst_shape_wipe_video_sink_setcaps (GstShapeWipe * self, GstCaps * caps)
{
- GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
gboolean ret = TRUE;
- GstStructure *s;
- GstVideoFormat fmt;
- gint width, height;
- gint fps_n, fps_d;
+ GstVideoInfo info;
- GST_DEBUG_OBJECT (pad, "Setting caps: %" GST_PTR_FORMAT, caps);
+ GST_DEBUG_OBJECT (self, "Setting caps: %" GST_PTR_FORMAT, caps);
- s = gst_caps_get_structure (caps, 0);
-
- if (!gst_video_format_parse_caps (caps, &fmt, &width, &height) ||
- !gst_structure_get_fraction (s, "framerate", &fps_n, &fps_d)) {
- GST_ERROR_OBJECT (pad, "Invalid caps");
- ret = FALSE;
- goto done;
- }
+ if (!gst_video_info_from_caps (&info, caps))
+ goto invalid_caps;
- self->fmt = fmt;
- if (self->width != width || self->height != height) {
+ if (self->info.width != info.width || self->info.height != info.height) {
g_mutex_lock (self->mask_mutex);
- self->width = width;
- self->height = height;
-
+ self->info = info;
if (self->mask)
gst_buffer_unref (self->mask);
self->mask = NULL;
g_mutex_unlock (self->mask_mutex);
}
- if (fps_n != 0)
- self->frame_duration = gst_util_uint64_scale (GST_SECOND, fps_d, fps_n);
+
+ if (info.fps_n != 0)
+ self->frame_duration =
+ gst_util_uint64_scale (GST_SECOND, info.fps_d, info.fps_n);
else
self->frame_duration = 0;
ret = gst_pad_set_caps (self->srcpad, caps);
-done:
- gst_object_unref (self);
-
return ret;
+
+ /* ERRORS */
+invalid_caps:
+ {
+ GST_ERROR_OBJECT (self, "Invalid caps");
+ return FALSE;
+ }
}
static GstCaps *
-gst_shape_wipe_video_sink_getcaps (GstPad * pad)
+gst_shape_wipe_video_sink_getcaps (GstPad * pad, GstCaps * filter)
{
GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
GstCaps *ret, *tmp;
- if (GST_PAD_CAPS (pad))
- return gst_caps_copy (GST_PAD_CAPS (pad));
+ if (gst_pad_has_current_caps (pad))
+ return gst_pad_get_current_caps (pad);
- tmp = gst_pad_peer_get_caps (self->srcpad);
+ tmp = gst_pad_peer_query_caps (self->srcpad, NULL);
if (tmp) {
ret = gst_caps_intersect (tmp, gst_pad_get_pad_template_caps (pad));
gst_caps_unref (tmp);
@@ -390,7 +347,7 @@ gst_shape_wipe_video_sink_getcaps (GstPad * pad)
if (gst_caps_is_empty (ret))
goto done;
- tmp = gst_pad_peer_get_caps (pad);
+ tmp = gst_pad_peer_query_caps (pad, NULL);
GST_LOG_OBJECT (pad, "peerpad accepted caps: %" GST_PTR_FORMAT, tmp);
if (tmp) {
@@ -407,19 +364,19 @@ gst_shape_wipe_video_sink_getcaps (GstPad * pad)
if (gst_caps_is_empty (ret))
goto done;
- if (self->height && self->width) {
+ if (self->info.height && self->info.width) {
guint i, n;
n = gst_caps_get_size (ret);
for (i = 0; i < n; i++) {
GstStructure *s = gst_caps_get_structure (ret, i);
- gst_structure_set (s, "width", G_TYPE_INT, self->width, "height",
- G_TYPE_INT, self->height, NULL);
+ gst_structure_set (s, "width", G_TYPE_INT, self->info.width, "height",
+ G_TYPE_INT, self->info.height, NULL);
}
}
- tmp = gst_pad_peer_get_caps (self->mask_sinkpad);
+ tmp = gst_pad_peer_query_caps (self->mask_sinkpad, NULL);
GST_LOG_OBJECT (pad, "mask accepted caps: %" GST_PTR_FORMAT, tmp);
if (tmp) {
@@ -437,20 +394,12 @@ gst_shape_wipe_video_sink_getcaps (GstPad * pad)
n = gst_caps_get_size (tmp);
- tmp2 = gst_caps_new_empty ();
for (i = 0; i < n; i++) {
GstStructure *s = gst_caps_get_structure (tmp, i);
- GstStructure *c;
-
- gst_structure_remove_fields (s, "format", "bpp", "depth", "endianness",
- "framerate", "red_mask", "green_mask", "blue_mask", "alpha_mask",
- NULL);
- gst_structure_set_name (s, "video/x-raw-yuv");
- c = gst_structure_copy (s);
- gst_structure_set_name (c, "video/x-raw-rgb");
- gst_caps_append_structure (tmp2, c);
+
+ gst_structure_remove_fields (s, "format", "framerate", NULL);
+ gst_structure_set_name (s, "video/x-raw");
}
- gst_caps_append (tmp, tmp2);
intersection = gst_caps_intersect (tmp, ret);
gst_caps_unref (tmp);
@@ -467,14 +416,13 @@ done:
}
static gboolean
-gst_shape_wipe_mask_sink_setcaps (GstPad * pad, GstCaps * caps)
+gst_shape_wipe_mask_sink_setcaps (GstShapeWipe * self, GstCaps * caps)
{
- GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
gboolean ret = TRUE;
GstStructure *s;
gint width, height, bpp;
- GST_DEBUG_OBJECT (pad, "Setting caps: %" GST_PTR_FORMAT, caps);
+ GST_DEBUG_OBJECT (self, "Setting caps: %" GST_PTR_FORMAT, caps);
s = gst_caps_get_structure (caps, 0);
@@ -485,36 +433,34 @@ gst_shape_wipe_mask_sink_setcaps (GstPad * pad, GstCaps * caps)
goto done;
}
- if ((self->width != width || self->height != height) &&
- self->width > 0 && self->height > 0) {
- GST_ERROR_OBJECT (pad, "Mask caps must have the same width/height "
+ if ((self->info.width != width || self->info.height != height) &&
+ self->info.width > 0 && self->info.height > 0) {
+ GST_ERROR_OBJECT (self, "Mask caps must have the same width/height "
"as the video caps");
ret = FALSE;
goto done;
} else {
- self->width = width;
- self->height = height;
+ self->info.width = width;
+ self->info.height = height;
}
self->mask_bpp = bpp;
done:
- gst_object_unref (self);
-
return ret;
}
static GstCaps *
-gst_shape_wipe_mask_sink_getcaps (GstPad * pad)
+gst_shape_wipe_mask_sink_getcaps (GstPad * pad, GstCaps * filter)
{
GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
GstCaps *ret, *tmp;
guint i, n;
- if (GST_PAD_CAPS (pad))
- return gst_caps_copy (GST_PAD_CAPS (pad));
+ if (gst_pad_has_current_caps (pad))
+ return gst_pad_get_current_caps (pad);
- tmp = gst_pad_peer_get_caps (self->video_sinkpad);
+ tmp = gst_pad_peer_query_caps (self->video_sinkpad, NULL);
if (tmp) {
ret =
gst_caps_intersect (tmp,
@@ -529,7 +475,7 @@ gst_shape_wipe_mask_sink_getcaps (GstPad * pad)
if (gst_caps_is_empty (ret))
goto done;
- tmp = gst_pad_peer_get_caps (self->srcpad);
+ tmp = gst_pad_peer_query_caps (self->srcpad, NULL);
GST_LOG_OBJECT (pad, "srcpad accepted caps: %" GST_PTR_FORMAT, ret);
if (tmp) {
@@ -552,28 +498,25 @@ gst_shape_wipe_mask_sink_getcaps (GstPad * pad)
GstStructure *s = gst_caps_get_structure (ret, i);
GstStructure *t;
- gst_structure_set_name (s, "video/x-raw-gray");
- gst_structure_remove_fields (s, "format", "framerate", "bpp", "depth",
- "endianness", "framerate", "red_mask", "green_mask", "blue_mask",
- "alpha_mask", NULL);
+ gst_structure_set_name (s, "video/x-raw");
+ gst_structure_remove_fields (s, "format", "framerate", NULL);
- if (self->width && self->height)
- gst_structure_set (s, "width", G_TYPE_INT, self->width, "height",
- G_TYPE_INT, self->height, NULL);
+ if (self->info.width && self->info.height)
+ gst_structure_set (s, "width", G_TYPE_INT, self->info.width, "height",
+ G_TYPE_INT, self->info.height, NULL);
gst_structure_set (s, "framerate", GST_TYPE_FRACTION, 0, 1, NULL);
t = gst_structure_copy (s);
- gst_structure_set (s, "bpp", G_TYPE_INT, 16, "depth", G_TYPE_INT, 16,
- "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
- gst_structure_set (t, "bpp", G_TYPE_INT, 8, "depth", G_TYPE_INT, 8, NULL);
+ gst_structure_set (s, "format", G_TYPE_STRING, GST_VIDEO_NE (GRAY16), NULL);
+ gst_structure_set (t, "format", G_TYPE_STRING, "GRAY8", NULL);
gst_caps_append_structure (tmp, t);
}
gst_caps_append (ret, tmp);
- tmp = gst_pad_peer_get_caps (pad);
+ tmp = gst_pad_peer_query_caps (pad, NULL);
GST_LOG_OBJECT (pad, "peer accepted caps: %" GST_PTR_FORMAT, tmp);
if (tmp) {
@@ -594,17 +537,17 @@ done:
}
static GstCaps *
-gst_shape_wipe_src_getcaps (GstPad * pad)
+gst_shape_wipe_src_getcaps (GstPad * pad, GstCaps * filter)
{
GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
GstCaps *ret, *tmp;
- if (GST_PAD_CAPS (pad))
- return gst_caps_copy (GST_PAD_CAPS (pad));
- else if (GST_PAD_CAPS (self->video_sinkpad))
- return gst_caps_copy (GST_PAD_CAPS (self->video_sinkpad));
+ if (gst_pad_has_current_caps (pad))
+ return gst_pad_get_current_caps (pad);
+ else if (gst_pad_has_current_caps (self->video_sinkpad))
+ return gst_pad_get_current_caps (self->video_sinkpad);
- tmp = gst_pad_peer_get_caps (self->video_sinkpad);
+ tmp = gst_pad_peer_query_caps (self->video_sinkpad, NULL);
if (tmp) {
ret =
gst_caps_intersect (tmp,
@@ -619,7 +562,7 @@ gst_shape_wipe_src_getcaps (GstPad * pad)
if (gst_caps_is_empty (ret))
goto done;
- tmp = gst_pad_peer_get_caps (pad);
+ tmp = gst_pad_peer_query_caps (pad, NULL);
GST_LOG_OBJECT (pad, "peer accepted caps: %" GST_PTR_FORMAT, ret);
if (tmp) {
GstCaps *intersection;
@@ -635,19 +578,19 @@ gst_shape_wipe_src_getcaps (GstPad * pad)
if (gst_caps_is_empty (ret))
goto done;
- if (self->height && self->width) {
+ if (self->info.height && self->info.width) {
guint i, n;
n = gst_caps_get_size (ret);
for (i = 0; i < n; i++) {
GstStructure *s = gst_caps_get_structure (ret, i);
- gst_structure_set (s, "width", G_TYPE_INT, self->width, "height",
- G_TYPE_INT, self->height, NULL);
+ gst_structure_set (s, "width", G_TYPE_INT, self->info.width, "height",
+ G_TYPE_INT, self->info.height, NULL);
}
}
- tmp = gst_pad_peer_get_caps (self->mask_sinkpad);
+ tmp = gst_pad_peer_query_caps (self->mask_sinkpad, NULL);
GST_LOG_OBJECT (pad, "mask sink accepted caps: %" GST_PTR_FORMAT, ret);
if (tmp) {
GstCaps *intersection, *tmp2;
@@ -663,20 +606,12 @@ gst_shape_wipe_src_getcaps (GstPad * pad)
tmp = intersection;
n = gst_caps_get_size (tmp);
- tmp2 = gst_caps_new_empty ();
for (i = 0; i < n; i++) {
GstStructure *s = gst_caps_get_structure (tmp, i);
- GstStructure *c;
-
- gst_structure_remove_fields (s, "format", "bpp", "depth", "endianness",
- "framerate", "red_mask", "green_mask", "blue_mask", "alpha_mask",
- NULL);
- gst_structure_set_name (s, "video/x-raw-yuv");
- c = gst_structure_copy (s);
- gst_caps_append_structure (tmp2, c);
+ gst_structure_remove_fields (s, "format", "framerate", NULL);
+ gst_structure_set_name (s, "video/x-raw");
}
- gst_caps_append (tmp, tmp2);
intersection = gst_caps_intersect (tmp, ret);
gst_caps_unref (tmp);
@@ -694,46 +629,61 @@ done:
}
static gboolean
-gst_shape_wipe_video_sink_query (GstPad * pad, GstQuery * query)
+gst_shape_wipe_video_sink_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
- GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
+ GstShapeWipe *self = GST_SHAPE_WIPE (parent);
gboolean ret;
- GstPad *peer = gst_pad_get_peer (self->srcpad);
GST_LOG_OBJECT (pad, "Handling query of type '%s'",
gst_query_type_get_name (GST_QUERY_TYPE (query)));
- if (!peer) {
- GST_INFO_OBJECT (pad, "No peer yet, dropping query");
- ret = FALSE;
- } else {
- ret = gst_pad_query (peer, query);
- gst_object_unref (peer);
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = gst_shape_wipe_video_sink_getcaps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+ ret = TRUE;
+ break;
+ }
+ default:
+ ret = gst_pad_peer_query (self->srcpad, query);
+ break;
}
- gst_object_unref (self);
return ret;
}
static gboolean
-gst_shape_wipe_src_query (GstPad * pad, GstQuery * query)
+gst_shape_wipe_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
- GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
+ GstShapeWipe *self = GST_SHAPE_WIPE (parent);
gboolean ret;
- GstPad *peer = gst_pad_get_peer (self->video_sinkpad);
GST_LOG_OBJECT (pad, "Handling query of type '%s'",
gst_query_type_get_name (GST_QUERY_TYPE (query)));
- if (!peer) {
- GST_INFO_OBJECT (pad, "No peer yet, dropping query");
- ret = FALSE;
- } else {
- ret = gst_pad_query (peer, query);
- gst_object_unref (peer);
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = gst_shape_wipe_src_getcaps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+ ret = TRUE;
+ break;
+ }
+ default:
+ ret = gst_pad_peer_query (self->video_sinkpad, query);
+ break;
}
- gst_object_unref (self);
return ret;
}
@@ -812,20 +762,20 @@ gst_shape_wipe_do_qos (GstShapeWipe * self, GstClockTime timestamp)
#define CREATE_ARGB_FUNCTIONS(depth, name, shift, a, r, g, b) \
static void \
-gst_shape_wipe_blend_##name##_##depth (GstShapeWipe * self, GstBuffer * inbuf, \
- GstBuffer * maskbuf, GstBuffer * outbuf) \
+gst_shape_wipe_blend_##name##_##depth (GstShapeWipe * self, GstVideoFrame * inframe, \
+ GstVideoFrame * maskframe, GstVideoFrame * outframe) \
{ \
- const guint##depth *mask = (const guint##depth *) GST_BUFFER_DATA (maskbuf); \
- const guint8 *input = (const guint8 *) GST_BUFFER_DATA (inbuf); \
- guint8 *output = (guint8 *) GST_BUFFER_DATA (outbuf); \
+ const guint##depth *mask = (const guint##depth *) GST_VIDEO_FRAME_PLANE_DATA (maskframe, 0); \
+ const guint8 *input = (const guint8 *) GST_VIDEO_FRAME_PLANE_DATA (inframe, 0); \
+ guint8 *output = (guint8 *) GST_VIDEO_FRAME_PLANE_DATA (outframe, 0); \
guint i, j; \
- guint mask_increment = ((depth == 16) ? GST_ROUND_UP_2 (self->width) : \
- GST_ROUND_UP_4 (self->width)) - self->width; \
+ guint mask_increment = ((depth == 16) ? GST_ROUND_UP_2 (self->info.width) : \
+ GST_ROUND_UP_4 (self->info.width)) - self->info.width; \
gfloat position = self->mask_position; \
gfloat low = position - (self->mask_border / 2.0f); \
gfloat high = position + (self->mask_border / 2.0f); \
guint32 low_i, high_i, round_i; \
- gint width = self->width, height = self->height; \
+ gint width = self->info.width, height = self->info.height; \
\
if (low < 0.0f) { \
high = 0.0f; \
@@ -882,15 +832,18 @@ CREATE_ARGB_FUNCTIONS (16, bgra, 0, 3, 2, 1, 0);
CREATE_ARGB_FUNCTIONS (8, bgra, 8, 3, 2, 1, 0);
static GstFlowReturn
-gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
+gst_shape_wipe_video_sink_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer)
{
- GstShapeWipe *self = GST_SHAPE_WIPE (GST_PAD_PARENT (pad));
+ GstShapeWipe *self = GST_SHAPE_WIPE (parent);
GstFlowReturn ret = GST_FLOW_OK;
GstBuffer *mask = NULL, *outbuf = NULL;
GstClockTime timestamp;
gboolean new_outbuf = FALSE;
+ GstVideoFrame inframe, outframe, maskframe;
- if (G_UNLIKELY (self->fmt == GST_VIDEO_FORMAT_UNKNOWN))
+ if (G_UNLIKELY (GST_VIDEO_INFO_FORMAT (&self->info) ==
+ GST_VIDEO_FORMAT_UNKNOWN))
goto not_negotiated;
timestamp = GST_BUFFER_TIMESTAMP (buffer);
@@ -898,7 +851,7 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
gst_segment_to_stream_time (&self->segment, GST_FORMAT_TIME, timestamp);
if (GST_CLOCK_TIME_IS_VALID (timestamp))
- gst_object_sync_values (G_OBJECT (self), timestamp);
+ gst_object_sync_values (GST_OBJECT (self), timestamp);
GST_LOG_OBJECT (self,
"Blending buffer with timestamp %" GST_TIME_FORMAT " at position %f",
@@ -924,39 +877,42 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
/* Try to blend inplace, if it's not possible
* get a new buffer from downstream. */
if (!gst_buffer_is_writable (buffer)) {
- ret =
- gst_pad_alloc_buffer_and_set_caps (self->srcpad, GST_BUFFER_OFFSET_NONE,
- GST_BUFFER_SIZE (buffer), GST_PAD_CAPS (self->srcpad), &outbuf);
- if (G_UNLIKELY (ret != GST_FLOW_OK))
- goto alloc_failed;
-
- gst_buffer_copy_metadata (outbuf, buffer, GST_BUFFER_COPY_ALL);
+ outbuf = gst_buffer_new_allocate (NULL, gst_buffer_get_size (buffer), 0);
+ gst_buffer_copy_into (outbuf, buffer, GST_BUFFER_COPY_METADATA, 0, -1);
new_outbuf = TRUE;
} else {
outbuf = buffer;
}
- switch (self->fmt) {
+ gst_video_frame_map (&inframe, &self->info, buffer, GST_MAP_READ);
+ gst_video_frame_map (&maskframe, &self->info, mask, GST_MAP_READ);
+ gst_video_frame_map (&outframe, &self->info, outbuf, GST_MAP_WRITE);
+
+ switch (GST_VIDEO_INFO_FORMAT (&self->info)) {
case GST_VIDEO_FORMAT_AYUV:
case GST_VIDEO_FORMAT_ARGB:
case GST_VIDEO_FORMAT_ABGR:
if (self->mask_bpp == 16)
- gst_shape_wipe_blend_argb_16 (self, buffer, mask, outbuf);
+ gst_shape_wipe_blend_argb_16 (self, &inframe, &maskframe, &outframe);
else
- gst_shape_wipe_blend_argb_8 (self, buffer, mask, outbuf);
+ gst_shape_wipe_blend_argb_8 (self, &inframe, &maskframe, &outframe);
break;
case GST_VIDEO_FORMAT_BGRA:
case GST_VIDEO_FORMAT_RGBA:
if (self->mask_bpp == 16)
- gst_shape_wipe_blend_bgra_16 (self, buffer, mask, outbuf);
+ gst_shape_wipe_blend_bgra_16 (self, &inframe, &maskframe, &outframe);
else
- gst_shape_wipe_blend_bgra_8 (self, buffer, mask, outbuf);
+ gst_shape_wipe_blend_bgra_8 (self, &inframe, &maskframe, &outframe);
break;
default:
g_assert_not_reached ();
break;
}
+ gst_video_frame_unmap (&outframe);
+ gst_video_frame_unmap (&maskframe);
+ gst_video_frame_unmap (&inframe);
+
gst_buffer_unref (mask);
if (new_outbuf)
gst_buffer_unref (buffer);
@@ -969,34 +925,37 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
/* Errors */
not_negotiated:
- GST_ERROR_OBJECT (self, "No valid caps yet");
- gst_buffer_unref (buffer);
- return GST_FLOW_NOT_NEGOTIATED;
+ {
+ GST_ERROR_OBJECT (self, "No valid caps yet");
+ gst_buffer_unref (buffer);
+ return GST_FLOW_NOT_NEGOTIATED;
+ }
shutdown:
- GST_DEBUG_OBJECT (self, "Shutting down");
- gst_buffer_unref (buffer);
- return GST_FLOW_WRONG_STATE;
+ {
+ GST_DEBUG_OBJECT (self, "Shutting down");
+ gst_buffer_unref (buffer);
+ return GST_FLOW_WRONG_STATE;
+ }
qos:
- GST_DEBUG_OBJECT (self, "Dropping buffer because of QoS");
- gst_buffer_unref (buffer);
- gst_buffer_unref (mask);
- return GST_FLOW_OK;
-alloc_failed:
- GST_ERROR_OBJECT (self, "Buffer allocation from downstream failed: %s",
- gst_flow_get_name (ret));
- gst_buffer_unref (buffer);
- gst_buffer_unref (mask);
- return ret;
+ {
+ GST_DEBUG_OBJECT (self, "Dropping buffer because of QoS");
+ gst_buffer_unref (buffer);
+ gst_buffer_unref (mask);
+ return GST_FLOW_OK;
+ }
push_failed:
- GST_ERROR_OBJECT (self, "Pushing buffer downstream failed: %s",
- gst_flow_get_name (ret));
- return ret;
+ {
+ GST_ERROR_OBJECT (self, "Pushing buffer downstream failed: %s",
+ gst_flow_get_name (ret));
+ return ret;
+ }
}
static GstFlowReturn
-gst_shape_wipe_mask_sink_chain (GstPad * pad, GstBuffer * buffer)
+gst_shape_wipe_mask_sink_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer)
{
- GstShapeWipe *self = GST_SHAPE_WIPE (GST_PAD_PARENT (pad));
+ GstShapeWipe *self = GST_SHAPE_WIPE (parent);
GstFlowReturn ret = GST_FLOW_OK;
g_mutex_lock (self->mask_mutex);
@@ -1047,29 +1006,33 @@ gst_shape_wipe_change_state (GstElement * element, GstStateChange transition)
}
static gboolean
-gst_shape_wipe_video_sink_event (GstPad * pad, GstEvent * event)
+gst_shape_wipe_video_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
- GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
+ GstShapeWipe *self = GST_SHAPE_WIPE (parent);
gboolean ret;
GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_NEWSEGMENT:{
- GstFormat fmt;
- gboolean is_update;
- gint64 start, end, base;
- gdouble rate;
-
- gst_event_parse_new_segment (event, &is_update, &rate, &fmt, &start,
- &end, &base);
- if (fmt == GST_FORMAT_TIME) {
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ ret = gst_shape_wipe_video_sink_setcaps (self, caps);
+ gst_event_unref (event);
+ break;
+ }
+ case GST_EVENT_SEGMENT:
+ {
+ GstSegment seg;
+
+ gst_event_copy_segment (event, &seg);
+ if (seg.format == GST_FORMAT_TIME) {
GST_DEBUG_OBJECT (pad,
- "Got NEWSEGMENT event in GST_FORMAT_TIME, passing on (%"
- GST_TIME_FORMAT " - %" GST_TIME_FORMAT ")", GST_TIME_ARGS (start),
- GST_TIME_ARGS (end));
- gst_segment_set_newsegment (&self->segment, is_update, rate, fmt, start,
- end, base);
+ "Got SEGMENT event in GST_FORMAT_TIME %" GST_PTR_FORMAT, &seg);
+ self->segment = seg;
} else {
gst_segment_init (&self->segment, GST_FORMAT_TIME);
}
@@ -1083,18 +1046,26 @@ gst_shape_wipe_video_sink_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (self);
return ret;
}
static gboolean
-gst_shape_wipe_mask_sink_event (GstPad * pad, GstEvent * event)
+gst_shape_wipe_mask_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
- GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
+ GstShapeWipe *self = GST_SHAPE_WIPE (parent);
GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ gst_shape_wipe_mask_sink_setcaps (self, caps);
+ break;
+ }
case GST_EVENT_FLUSH_STOP:
g_mutex_lock (self->mask_mutex);
gst_buffer_replace (&self->mask, NULL);
@@ -1107,25 +1078,55 @@ gst_shape_wipe_mask_sink_event (GstPad * pad, GstEvent * event)
/* Dropping all events here */
gst_event_unref (event);
- gst_object_unref (self);
return TRUE;
}
static gboolean
-gst_shape_wipe_src_event (GstPad * pad, GstEvent * event)
+gst_shape_wipe_mask_sink_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
- GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
+ gboolean ret;
+
+ GST_LOG_OBJECT (pad, "Handling query of type '%s'",
+ gst_query_type_get_name (GST_QUERY_TYPE (query)));
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = gst_shape_wipe_mask_sink_getcaps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+ ret = TRUE;
+ break;
+ }
+ default:
+ ret = gst_pad_query_default (pad, parent, query);
+ break;
+ }
+
+ return ret;
+}
+
+
+static gboolean
+gst_shape_wipe_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+ GstShapeWipe *self = GST_SHAPE_WIPE (parent);
gboolean ret;
GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (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_shape_wipe_update_qos (self, proportion, diff, timestamp);
}
@@ -1135,7 +1136,6 @@ gst_shape_wipe_src_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (self);
return ret;
}
@@ -1145,8 +1145,6 @@ plugin_init (GstPlugin * plugin)
GST_DEBUG_CATEGORY_INIT (gst_shape_wipe_debug, "shapewipe", 0,
"shapewipe element");
- gst_controller_init (NULL, NULL);
-
if (!gst_element_register (plugin, "shapewipe", GST_RANK_NONE,
GST_TYPE_SHAPE_WIPE))
return FALSE;
diff --git a/gst/shapewipe/gstshapewipe.h b/gst/shapewipe/gstshapewipe.h
index 36b4fc552..296ef597a 100644
--- a/gst/shapewipe/gstshapewipe.h
+++ b/gst/shapewipe/gstshapewipe.h
@@ -59,8 +59,7 @@ struct _GstShapeWipe
GCond *mask_cond;
gint mask_bpp;
- GstVideoFormat fmt;
- gint width, height;
+ GstVideoInfo info;
gboolean shutdown;
diff --git a/gst/smpte/Makefile.am b/gst/smpte/Makefile.am
index 34bb039a0..cb517e64b 100644
--- a/gst/smpte/Makefile.am
+++ b/gst/smpte/Makefile.am
@@ -4,10 +4,9 @@ libgstsmpte_la_SOURCES = gstsmpte.c gstmask.c barboxwipes.c paint.c gstsmptealph
noinst_HEADERS = gstsmpte.h gstmask.h paint.h gstsmptealpha.h
-libgstsmpte_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(GST_CONTROLLER_CFLAGS)
+libgstsmpte_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
libgstsmpte_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(LIBM) \
- -lgstvideo-$(GST_MAJORMINOR) \
- $(GST_CONTROLLER_LIBS)
+ -lgstvideo-$(GST_MAJORMINOR)
libgstsmpte_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstsmpte_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/gst/smpte/gstsmpte.c b/gst/smpte/gstsmpte.c
index 4b21cd002..a830e6a52 100644
--- a/gst/smpte/gstsmpte.c
+++ b/gst/smpte/gstsmpte.c
@@ -196,12 +196,12 @@ gst_smpte_base_init (GstSMPTEClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class,
- &gst_smpte_sink1_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_smpte_sink2_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_smpte_src_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smpte_sink1_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smpte_sink2_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smpte_src_template));
gst_element_class_set_details_simple (element_class, "SMPTE transitions",
"Filter/Editor/Video",
"Apply the standard SMPTE transitions on video images",
@@ -366,9 +366,9 @@ gst_smpte_init (GstSMPTE * smpte)
gst_collect_pads_start (smpte->collect);
gst_collect_pads_add_pad (smpte->collect, smpte->sinkpad1,
- sizeof (GstCollectData));
+ sizeof (GstCollectData), NULL);
gst_collect_pads_add_pad (smpte->collect, smpte->sinkpad2,
- sizeof (GstCollectData));
+ sizeof (GstCollectData), NULL);
smpte->fps = DEFAULT_PROP_FPS;
smpte->type = DEFAULT_PROP_TYPE;
diff --git a/gst/smpte/gstsmptealpha.c b/gst/smpte/gstsmptealpha.c
index 3fb9ca83a..b329617f3 100644
--- a/gst/smpte/gstsmptealpha.c
+++ b/gst/smpte/gstsmptealpha.c
@@ -53,8 +53,6 @@
#endif
#include <string.h>
-#include <gst/controller/gstcontroller.h>
-
#include "gstsmptealpha.h"
#include "paint.h"
@@ -163,10 +161,10 @@ gst_smpte_alpha_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class,
- &gst_smpte_alpha_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_smpte_alpha_src_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smpte_alpha_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smpte_alpha_src_template));
gst_element_class_set_details_simple (element_class, "SMPTE transitions",
"Filter/Editor/Video",
"Apply the standard SMPTE transitions as alpha on video images",
@@ -441,7 +439,7 @@ gst_smpte_alpha_before_transform (GstBaseTransform * trans, GstBuffer * buf)
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (smpte), stream_time);
+ gst_object_sync_values (GST_OBJECT (smpte), stream_time);
}
static GstFlowReturn
@@ -745,9 +743,6 @@ gst_smpte_alpha_plugin_init (GstPlugin * plugin)
GST_DEBUG_CATEGORY_INIT (gst_smpte_alpha_debug, "smptealpha", 0,
"SMPTE alpha effect");
- /* initialize gst controller library */
- gst_controller_init (NULL, NULL);
-
return gst_element_register (plugin, "smptealpha", GST_RANK_NONE,
GST_TYPE_SMPTE_ALPHA);
}
diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c
index 4d7250b0f..e9bd8a5ce 100644
--- a/gst/spectrum/gstspectrum.c
+++ b/gst/spectrum/gstspectrum.c
@@ -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 "{ S16LE, S24LE, S32LE, F32LE, F64LE }"
+#else
+# define FORMATS "{ S16BE, S24BE, S32BE, F32BE, F64BE }"
+#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:
+ 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));
+ "message frames todo: %u, fft frames todo: %u, input frames %"
+ G_GSIZE_FORMAT, 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,17 +924,18 @@ 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;
have_full_interval = (spectrum->num_frames == spectrum->frames_todo);
- GST_LOG_OBJECT (spectrum, "size: %u, do-fft = %d, do-message = %d", size,
+ GST_LOG_OBJECT (spectrum,
+ "size: %" G_GSIZE_FORMAT ", do-fft = %d, do-message = %d", size,
(spectrum->num_frames % nfft == 0), have_full_interval);
/* If we have enough frames for an FFT or we have all frames required for
@@ -1145,6 +992,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;
diff --git a/gst/udp/Makefile.am b/gst/udp/Makefile.am
index 71a5971c5..3e2bdbf94 100644
--- a/gst/udp/Makefile.am
+++ b/gst/udp/Makefile.am
@@ -17,9 +17,8 @@ libgstudp_la_SOURCES = gstudp.c gstudpsrc.c gstudpsink.c gstmultiudpsink.c gstdy
# adding -D_GNU_SOURCE to get non-POSIX extensions like EAI_ADDRFAMILY
# with glibc >= 2.8 when including netdb.h (see glibc sources bug 6452)
-libgstudp_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) -D_GNU_SOURCE
-libgstudp_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstnetbuffer-@GST_MAJORMINOR@ \
- $(GST_BASE_LIBS) $(WIN32_LIBS)
+libgstudp_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_NET_CFLAGS) $(GST_CFLAGS) -D_GNU_SOURCE
+libgstudp_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_NET_LIBS) $(WIN32_LIBS)
libgstudp_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstudp_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/gst/udp/gstdynudpsink.c b/gst/udp/gstdynudpsink.c
index 18c58ca10..2b1ad265d 100644
--- a/gst/udp/gstdynudpsink.c
+++ b/gst/udp/gstdynudpsink.c
@@ -36,7 +36,7 @@
#include <sys/time.h>
#endif
#include <sys/types.h>
-#include <gst/netbuffer/gstnetbuffer.h>
+#include <gst/net/gstnetaddressmeta.h>
GST_DEBUG_CATEGORY_STATIC (dynudpsink_debug);
#define GST_CAT_DEFAULT (dynudpsink_debug)
@@ -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_static_pad_template (element_class,
- &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,33 +175,34 @@ static GstFlowReturn
gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
{
GstDynUDPSink *sink;
- gint ret, size;
+ gint ret;
+ gsize size;
guint8 *data;
- GstNetBuffer *netbuf;
+ GstNetAddressMeta *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_net_address_meta (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);
+ GST_DEBUG ("about to send %" G_GSIZE_FORMAT " 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_net_address_get_ip4_address (&meta->naddr, &destaddr, &destport);
- GST_DEBUG ("sending %d bytes to client %d port %d", size, destaddr, destport);
+ GST_DEBUG ("sending %" G_GSIZE_FORMAT " bytes to client %d port %d", size,
+ destaddr, destport);
theiraddr.sin_family = AF_INET;
theiraddr.sin_addr.s_addr = destaddr;
@@ -247,13 +214,15 @@ 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;
}
}
- GST_DEBUG ("sent %d bytes", size);
+ GST_DEBUG ("sent %" G_GSIZE_FORMAT " bytes", size);
return GST_FLOW_OK;
diff --git a/gst/udp/gstmultiudpsink.c b/gst/udp/gstmultiudpsink.c
index a2d74a71f..a302465bd 100644
--- a/gst/udp/gstmultiudpsink.c
+++ b/gst/udp/gstmultiudpsink.c
@@ -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_static_pad_template (element_class,
- &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)
@@ -362,10 +322,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;
@@ -488,19 +458,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 "
@@ -558,109 +530,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 (%" G_GSIZE_FORMAT " > %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
diff --git a/gst/udp/gstudp.c b/gst/udp/gstudp.c
index fbdbfea27..b95213e8c 100644
--- a/gst/udp/gstudp.c
+++ b/gst/udp/gstudp.c
@@ -21,7 +21,7 @@
#include "config.h"
#endif
-#include <gst/netbuffer/gstnetbuffer.h>
+#include <gst/net/gstnetaddressmeta.h>
#include "gstudpsrc.h"
#include "gstmultiudpsink.h"
@@ -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_net_address_meta_get_info ();
if (!gst_element_register (plugin, "udpsink", GST_RANK_NONE,
GST_TYPE_UDPSINK))
diff --git a/gst/udp/gstudpsink.c b/gst/udp/gstudpsink.c
index 26c70cdd9..036662f25 100644
--- a/gst/udp/gstudpsink.c
+++ b/gst/udp/gstudpsink.c
@@ -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;
-}
+#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_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>");
-}
-
-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)
@@ -168,7 +124,7 @@ gst_udpsink_finalize (GstUDPSink * udpsink)
}
static gboolean
-gst_udpsink_set_uri (GstUDPSink * sink, const gchar * uri)
+gst_udpsink_set_uri (GstUDPSink * sink, const gchar * uri, GError ** error)
{
gst_multiudpsink_remove (GST_MULTIUDPSINK (sink), sink->uri.host,
sink->uri.port);
@@ -186,6 +142,8 @@ wrong_uri:
{
GST_ELEMENT_ERROR (sink, RESOURCE, READ, (NULL),
("error parsing uri %s", uri));
+ g_set_error_literal (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
+ "Could not parse UDP URI");
return FALSE;
}
}
@@ -251,20 +209,20 @@ 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)
+static const gchar *const *
+gst_udpsink_uri_get_protocols (GType type)
{
- static gchar *protocols[] = { (char *) "udp", NULL };
+ static const gchar *protocols[] = { "udp", NULL };
return protocols;
}
-static const gchar *
+static gchar *
gst_udpsink_uri_get_uri (GstURIHandler * handler)
{
GstUDPSink *sink = GST_UDPSINK (handler);
@@ -272,18 +230,14 @@ gst_udpsink_uri_get_uri (GstURIHandler * handler)
g_free (sink->uristr);
sink->uristr = gst_udp_uri_string (&sink->uri);
- return sink->uristr;
+ return g_strdup (sink->uristr);
}
static gboolean
-gst_udpsink_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_udpsink_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
- gboolean ret;
- GstUDPSink *sink = GST_UDPSINK (handler);
-
- ret = gst_udpsink_set_uri (sink, uri);
-
- return ret;
+ return gst_udpsink_set_uri (GST_UDPSINK (handler), uri, error);
}
static void
diff --git a/gst/udp/gstudpsrc.c b/gst/udp/gstudpsrc.c
index ec644af00..9169d6b13 100644
--- a/gst/udp/gstudpsrc.c
+++ b/gst/udp/gstudpsrc.c
@@ -116,7 +116,7 @@
#include <io.h>
#endif
-#include <gst/netbuffer/gstnetbuffer.h>
+#include <gst/net/gstnetaddressmeta.h>
#ifdef HAVE_FIONREAD_IN_SYS_FILIO
#include <sys/filio.h>
@@ -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,48 +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_static_pad_template (element_class, &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;
@@ -300,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;
@@ -310,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);
@@ -361,7 +347,7 @@ gst_udpsrc_finalize (GObject * object)
}
static GstCaps *
-gst_udpsrc_getcaps (GstBaseSrc * src)
+gst_udpsrc_getcaps (GstBaseSrc * src, GstCaps * filter)
{
GstUDPSrc *udpsrc;
@@ -408,7 +394,8 @@ static GstFlowReturn
gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
{
GstUDPSrc *udpsrc;
- GstNetBuffer *outbuf;
+ GstNetAddressMeta *meta;
+ GstBuffer *outbuf;
union gst_sockaddr
{
struct sockaddr sa;
@@ -419,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
@@ -497,6 +485,7 @@ no_select:
pktdata = g_malloc (readsize);
pktsize = readsize;
+ offset = 0;
while (TRUE) {
slen = sizeof (sa);
@@ -526,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_net_address_meta (outbuf);
switch (sa.sa.sa_family) {
case AF_INET:
{
- gst_netaddress_set_ip4_address (&outbuf->from, sa.sa_in.sin_addr.s_addr,
+ gst_net_address_set_ip4_address (&meta->naddr, sa.sa_in.sin_addr.s_addr,
sa.sa_in.sin_port);
}
break;
@@ -553,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_net_address_set_ip6_address (&meta->naddr, ip6, sa.sa_in6.sin6_port);
}
break;
default:
@@ -609,7 +599,7 @@ skip_error:
}
static gboolean
-gst_udpsrc_set_uri (GstUDPSrc * src, const gchar * uri)
+gst_udpsrc_set_uri (GstUDPSrc * src, const gchar * uri, GError ** error)
{
if (gst_udp_parse_uri (uri, &src->uri) < 0)
goto wrong_uri;
@@ -624,6 +614,8 @@ wrong_uri:
{
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("error parsing uri %s", uri));
+ g_set_error_literal (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
+ "Could not parse UDP URI");
return FALSE;
}
}
@@ -660,7 +652,7 @@ gst_udpsrc_set_property (GObject * object, guint prop_id, const GValue * value,
udpsrc->multi_iface = g_value_dup_string (value);
break;
case PROP_URI:
- gst_udpsrc_set_uri (udpsrc, g_value_get_string (value));
+ gst_udpsrc_set_uri (udpsrc, g_value_get_string (value), NULL);
break;
case PROP_CAPS:
{
@@ -1022,40 +1014,36 @@ 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)
+static const gchar *const *
+gst_udpsrc_uri_get_protocols (GType type)
{
- static gchar *protocols[] = { (char *) "udp", NULL };
+ static const gchar *protocols[] = { "udp", NULL };
return protocols;
}
-static const gchar *
+static gchar *
gst_udpsrc_uri_get_uri (GstURIHandler * handler)
{
GstUDPSrc *src = GST_UDPSRC (handler);
+ /* FIXME: make thread-safe; maybe we can get rid of this assignment here? */
g_free (src->uristr);
src->uristr = gst_udp_uri_string (&src->uri);
- return src->uristr;
+ return g_strdup (src->uristr);
}
static gboolean
-gst_udpsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_udpsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
- gboolean ret;
-
- GstUDPSrc *src = GST_UDPSRC (handler);
-
- ret = gst_udpsrc_set_uri (src, uri);
-
- return ret;
+ return gst_udpsrc_set_uri (GST_UDPSRC (handler), uri, error);
}
static void
diff --git a/gst/videobox/Makefile.am b/gst/videobox/Makefile.am
index 90dcd4b8f..21f04a079 100644
--- a/gst/videobox/Makefile.am
+++ b/gst/videobox/Makefile.am
@@ -6,12 +6,10 @@ include $(top_srcdir)/common/orc.mak
libgstvideobox_la_SOURCES = gstvideobox.c
nodist_libgstvideobox_la_SOURCES = $(ORC_NODIST_SOURCES)
libgstvideobox_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_CONTROLLER_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS) \
$(ORC_CFLAGS)
libgstvideobox_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
- $(GST_CONTROLLER_LIBS) \
$(GST_BASE_LIBS) \
$(GST_LIBS) \
$(ORC_LIBS) \
diff --git a/gst/videobox/gstvideobox.c b/gst/videobox/gstvideobox.c
index 691c5f123..2294d262f 100644
--- a/gst/videobox/gstvideobox.c
+++ b/gst/videobox/gstvideobox.c
@@ -64,8 +64,6 @@
#include <math.h>
#include <string.h>
-#include <gst/controller/gstcontroller.h>
-
GST_DEBUG_CATEGORY_STATIC (videobox_debug);
#define GST_CAT_DEFAULT videobox_debug
@@ -2466,10 +2464,10 @@ gst_video_box_base_init (gpointer g_class)
"Resizes a video by adding borders or cropping",
"Wim Taymans <wim@fluendo.com>");
- gst_element_class_add_static_pad_template (element_class,
- &gst_video_box_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_video_box_src_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_video_box_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_video_box_src_template));
}
static void
@@ -3365,7 +3363,7 @@ gst_video_box_before_transform (GstBaseTransform * trans, GstBuffer * in)
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (video_box), stream_time);
+ gst_object_sync_values (GST_OBJECT (video_box), stream_time);
}
static GstFlowReturn
@@ -3389,8 +3387,6 @@ gst_video_box_transform (GstBaseTransform * trans, GstBuffer * in,
static gboolean
plugin_init (GstPlugin * plugin)
{
- gst_controller_init (NULL, NULL);
-
GST_DEBUG_CATEGORY_INIT (videobox_debug, "videobox", 0,
"Resizes a video by adding borders or cropping");
diff --git a/gst/videocrop/Makefile.am b/gst/videocrop/Makefile.am
index 2b9838b65..9341cfdba 100644
--- a/gst/videocrop/Makefile.am
+++ b/gst/videocrop/Makefile.am
@@ -6,7 +6,7 @@ plugin_LTLIBRARIES = libgstvideocrop.la
libgstvideocrop_la_SOURCES = gstvideocrop.c gstaspectratiocrop.c
libgstvideocrop_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS)
-libgstvideocrop_la_LIBADD = $(GST_BASE_LIBS)
+libgstvideocrop_la_LIBADD = $(GST_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR)
libgstvideocrop_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstvideocrop_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/gst/videocrop/gstaspectratiocrop.c b/gst/videocrop/gstaspectratiocrop.c
index b37217aed..eb0ece2bf 100644
--- a/gst/videocrop/gstaspectratiocrop.c
+++ b/gst/videocrop/gstaspectratiocrop.c
@@ -53,26 +53,10 @@ enum
};
/* we support the same caps as videocrop */
-#define ASPECT_RATIO_CROP_CAPS \
- GST_VIDEO_CAPS_RGBx ";" \
- GST_VIDEO_CAPS_xRGB ";" \
- GST_VIDEO_CAPS_BGRx ";" \
- GST_VIDEO_CAPS_xBGR ";" \
- GST_VIDEO_CAPS_RGBA ";" \
- GST_VIDEO_CAPS_ARGB ";" \
- GST_VIDEO_CAPS_BGRA ";" \
- GST_VIDEO_CAPS_ABGR ";" \
- GST_VIDEO_CAPS_RGB ";" \
- GST_VIDEO_CAPS_BGR ";" \
- GST_VIDEO_CAPS_YUV ("AYUV") ";" \
- GST_VIDEO_CAPS_YUV ("YUY2") ";" \
- GST_VIDEO_CAPS_YUV ("YVYU") ";" \
- GST_VIDEO_CAPS_YUV ("UYVY") ";" \
- GST_VIDEO_CAPS_YUV ("Y800") ";" \
- GST_VIDEO_CAPS_YUV ("I420") ";" \
- GST_VIDEO_CAPS_YUV ("YV12") ";" \
- GST_VIDEO_CAPS_RGB_16 ";" \
- GST_VIDEO_CAPS_RGB_15
+#define ASPECT_RATIO_CROP_CAPS \
+ GST_VIDEO_CAPS_MAKE ("{ RGBx, xRGB, BGRx, xBGR, " \
+ "RGBA, ARGB, BGRA, ABGR, RGB, BGR, AYUV, YUY2, " \
+ "YVYU, UYVY, Y800, I420, RGB16, RGB15, GRAY8 }")
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
@@ -86,8 +70,8 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS (ASPECT_RATIO_CROP_CAPS)
);
-GST_BOILERPLATE (GstAspectRatioCrop, gst_aspect_ratio_crop, GstBin,
- GST_TYPE_BIN);
+#define gst_aspect_ratio_crop_parent_class parent_class
+G_DEFINE_TYPE (GstAspectRatioCrop, gst_aspect_ratio_crop, GST_TYPE_BIN);
static void gst_aspect_ratio_crop_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
@@ -95,8 +79,13 @@ static void gst_aspect_ratio_crop_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_aspect_ratio_crop_set_cropping (GstAspectRatioCrop *
aspect_ratio_crop, gint top, gint right, gint bottom, gint left);
-static GstCaps *gst_aspect_ratio_crop_get_caps (GstPad * pad);
-static gboolean gst_aspect_ratio_crop_set_caps (GstPad * pad, GstCaps * caps);
+static GstCaps *gst_aspect_ratio_crop_get_caps (GstPad * pad, GstCaps * filter);
+static gboolean gst_aspect_ratio_crop_src_query (GstPad * pad,
+ GstObject * parent, GstQuery * query);
+static gboolean gst_aspect_ratio_crop_set_caps (GstAspectRatioCrop *
+ aspect_ratio_crop, GstCaps * caps);
+static gboolean gst_aspect_ratio_crop_sink_event (GstPad * pad,
+ GstObject * parent, GstEvent * evt);
static void gst_aspect_ratio_crop_finalize (GObject * object);
static void gst_aspect_ratio_transform_structure (GstAspectRatioCrop *
aspect_ratio_crop, GstStructure * structure, GstStructure ** new_structure,
@@ -135,15 +124,13 @@ gst_aspect_ratio_crop_set_cropping (GstAspectRatioCrop * aspect_ratio_crop,
}
static gboolean
-gst_aspect_ratio_crop_set_caps (GstPad * pad, GstCaps * caps)
+gst_aspect_ratio_crop_set_caps (GstAspectRatioCrop * aspect_ratio_crop,
+ GstCaps * caps)
{
- GstAspectRatioCrop *aspect_ratio_crop;
GstPad *peer_pad;
GstStructure *structure;
gboolean ret;
- aspect_ratio_crop = GST_ASPECT_RATIO_CROP (gst_pad_get_parent (pad));
-
g_mutex_lock (aspect_ratio_crop->crop_lock);
structure = gst_caps_get_structure (caps, 0);
@@ -154,32 +141,47 @@ gst_aspect_ratio_crop_set_caps (GstPad * pad, GstCaps * caps)
"sink");
ret = gst_pad_set_caps (peer_pad, caps);
gst_object_unref (peer_pad);
- gst_object_unref (aspect_ratio_crop);
g_mutex_unlock (aspect_ratio_crop->crop_lock);
return ret;
}
-static void
-gst_aspect_ratio_crop_base_init (gpointer g_class)
+static gboolean
+gst_aspect_ratio_crop_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * evt)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+ gboolean ret;
+ GstAspectRatioCrop *aspect_ratio_crop = GST_ASPECT_RATIO_CROP (parent);
- gst_element_class_set_details_simple (element_class, "aspectratiocrop",
- "Filter/Effect/Video",
- "Crops video into a user-defined aspect-ratio",
- "Thijs Vermeir <thijsvermeir@gmail.com>");
+ ret =
+ aspect_ratio_crop->sinkpad_old_eventfunc (pad, parent,
+ gst_event_ref (evt));
+
+ switch (GST_EVENT_TYPE (evt)) {
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (evt, &caps);
+ ret = gst_aspect_ratio_crop_set_caps (aspect_ratio_crop, caps);
+ gst_caps_unref (caps);
+ break;
+ }
+ default:
+ break;
+ }
+ gst_event_unref (evt);
- gst_element_class_add_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &src_template);
+ return ret;
}
static void
gst_aspect_ratio_crop_class_init (GstAspectRatioCropClass * klass)
{
GObjectClass *gobject_class;
+ GstElementClass *element_class;
gobject_class = (GObjectClass *) klass;
+ element_class = (GstElementClass *) klass;
gobject_class->set_property = gst_aspect_ratio_crop_set_property;
gobject_class->get_property = gst_aspect_ratio_crop_get_property;
@@ -189,6 +191,16 @@ gst_aspect_ratio_crop_class_init (GstAspectRatioCropClass * klass)
gst_param_spec_fraction ("aspect-ratio", "aspect-ratio",
"Target aspect-ratio of video", 0, 1, G_MAXINT, 1, 0, 1,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ gst_element_class_set_details_simple (element_class, "aspectratiocrop",
+ "Filter/Effect/Video",
+ "Crops video into a user-defined aspect-ratio",
+ "Thijs Vermeir <thijsvermeir@gmail.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));
}
static void
@@ -205,8 +217,7 @@ gst_aspect_ratio_crop_finalize (GObject * object)
}
static void
-gst_aspect_ratio_crop_init (GstAspectRatioCrop * aspect_ratio_crop,
- GstAspectRatioCropClass * klass)
+gst_aspect_ratio_crop_init (GstAspectRatioCrop * aspect_ratio_crop)
{
GstPad *link_pad;
GstPad *src_pad;
@@ -228,8 +239,8 @@ gst_aspect_ratio_crop_init (GstAspectRatioCrop * aspect_ratio_crop,
gst_element_get_static_pad (GST_ELEMENT (aspect_ratio_crop->videocrop),
"src");
src_pad = gst_ghost_pad_new ("src", link_pad);
- gst_pad_set_getcaps_function (src_pad,
- GST_DEBUG_FUNCPTR (gst_aspect_ratio_crop_get_caps));
+ gst_pad_set_query_function (src_pad,
+ GST_DEBUG_FUNCPTR (gst_aspect_ratio_crop_src_query));
gst_element_add_pad (GST_ELEMENT (aspect_ratio_crop), src_pad);
gst_object_unref (link_pad);
/* create ghost pad sink */
@@ -240,8 +251,11 @@ gst_aspect_ratio_crop_init (GstAspectRatioCrop * aspect_ratio_crop,
gst_element_add_pad (GST_ELEMENT (aspect_ratio_crop),
aspect_ratio_crop->sink);
gst_object_unref (link_pad);
- gst_pad_set_setcaps_function (aspect_ratio_crop->sink,
- GST_DEBUG_FUNCPTR (gst_aspect_ratio_crop_set_caps));
+
+ aspect_ratio_crop->sinkpad_old_eventfunc =
+ GST_PAD_EVENTFUNC (aspect_ratio_crop->sink);
+ gst_pad_set_event_function (aspect_ratio_crop->sink,
+ GST_DEBUG_FUNCPTR (gst_aspect_ratio_crop_sink_event));
}
static void
@@ -369,7 +383,7 @@ gst_aspect_ratio_crop_transform_caps (GstAspectRatioCrop * aspect_ratio_crop,
}
static GstCaps *
-gst_aspect_ratio_crop_get_caps (GstPad * pad)
+gst_aspect_ratio_crop_get_caps (GstPad * pad, GstCaps * filter)
{
GstPad *peer;
GstAspectRatioCrop *aspect_ratio_crop;
@@ -386,7 +400,7 @@ gst_aspect_ratio_crop_get_caps (GstPad * pad)
} else {
GstCaps *peer_caps;
- peer_caps = gst_pad_get_caps (peer);
+ peer_caps = gst_pad_query_caps (peer, filter);
return_caps =
gst_aspect_ratio_crop_transform_caps (aspect_ratio_crop, peer_caps);
gst_caps_unref (peer_caps);
@@ -396,9 +410,41 @@ gst_aspect_ratio_crop_get_caps (GstPad * pad)
g_mutex_unlock (aspect_ratio_crop->crop_lock);
gst_object_unref (aspect_ratio_crop);
+ if (return_caps && filter) {
+ GstCaps *tmp =
+ gst_caps_intersect_full (filter, return_caps, GST_CAPS_INTERSECT_FIRST);
+ gst_caps_replace (&return_caps, tmp);
+ gst_caps_unref (tmp);
+ }
+
return return_caps;
}
+static gboolean
+gst_aspect_ratio_crop_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query)
+{
+ gboolean res = FALSE;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
+
+ gst_query_parse_caps (query, &filter);
+ caps = gst_aspect_ratio_crop_get_caps (pad, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_query_default (pad, parent, query);
+ break;
+ }
+ return res;
+}
+
static void
gst_aspect_ratio_crop_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
@@ -415,7 +461,7 @@ gst_aspect_ratio_crop_set_property (GObject * object, guint prop_id,
aspect_ratio_crop->ar_num = gst_value_get_fraction_numerator (value);
aspect_ratio_crop->ar_denom =
gst_value_get_fraction_denominator (value);
- recheck = (GST_PAD_CAPS (aspect_ratio_crop->sink) != NULL);
+ recheck = gst_pad_has_current_caps (aspect_ratio_crop->sink);
}
break;
default:
@@ -425,8 +471,9 @@ gst_aspect_ratio_crop_set_property (GObject * object, guint prop_id,
GST_OBJECT_UNLOCK (aspect_ratio_crop);
if (recheck) {
- gst_aspect_ratio_crop_set_caps (aspect_ratio_crop->sink,
- GST_PAD_CAPS (aspect_ratio_crop->sink));
+ GstCaps *caps = gst_pad_get_current_caps (aspect_ratio_crop->sink);
+ gst_aspect_ratio_crop_set_caps (aspect_ratio_crop, caps);
+ gst_caps_unref (caps);
}
}
diff --git a/gst/videocrop/gstaspectratiocrop.h b/gst/videocrop/gstaspectratiocrop.h
index dc2e7cdc9..d089f17fc 100644
--- a/gst/videocrop/gstaspectratiocrop.h
+++ b/gst/videocrop/gstaspectratiocrop.h
@@ -46,6 +46,7 @@ struct _GstAspectRatioCrop
GstElement *videocrop;
GstPad *sink;
+ GstPadEventFunction sinkpad_old_eventfunc;
/* target aspect ratio */
gint ar_num; /* if < 1 then don't change ar */
diff --git a/gst/videocrop/gstvideocrop.c b/gst/videocrop/gstvideocrop.c
index 04b6e61ce..1c199e080 100644
--- a/gst/videocrop/gstvideocrop.c
+++ b/gst/videocrop/gstvideocrop.c
@@ -77,34 +77,10 @@ enum
ARG_BOTTOM
};
-/* the formats we support */
-#define GST_VIDEO_CAPS_GRAY "video/x-raw-gray, " \
- "bpp = (int) 8, " \
- "width = " GST_VIDEO_SIZE_RANGE ", " \
- "height = " GST_VIDEO_SIZE_RANGE ", " \
- "framerate = " GST_VIDEO_FPS_RANGE
-
-#define VIDEO_CROP_CAPS \
- GST_VIDEO_CAPS_RGBx ";" \
- GST_VIDEO_CAPS_xRGB ";" \
- GST_VIDEO_CAPS_BGRx ";" \
- GST_VIDEO_CAPS_xBGR ";" \
- GST_VIDEO_CAPS_RGBA ";" \
- GST_VIDEO_CAPS_ARGB ";" \
- GST_VIDEO_CAPS_BGRA ";" \
- GST_VIDEO_CAPS_ABGR ";" \
- GST_VIDEO_CAPS_RGB ";" \
- GST_VIDEO_CAPS_BGR ";" \
- GST_VIDEO_CAPS_YUV ("AYUV") ";" \
- GST_VIDEO_CAPS_YUV ("YUY2") ";" \
- GST_VIDEO_CAPS_YUV ("YVYU") ";" \
- GST_VIDEO_CAPS_YUV ("UYVY") ";" \
- GST_VIDEO_CAPS_YUV ("Y800") ";" \
- GST_VIDEO_CAPS_YUV ("I420") ";" \
- GST_VIDEO_CAPS_YUV ("YV12") ";" \
- GST_VIDEO_CAPS_RGB_16 ";" \
- GST_VIDEO_CAPS_RGB_15 ";" \
- GST_VIDEO_CAPS_GRAY
+#define VIDEO_CROP_CAPS \
+ GST_VIDEO_CAPS_MAKE ("{ RGBx, xRGB, BGRx, xBGR, " \
+ "RGBA, ARGB, BGRA, ABGR, RGB, BGR, AYUV, YUY2, " \
+ "YVYU, UYVY, Y800, I420, RGB16, RGB15, GRAY8 }")
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
@@ -118,8 +94,8 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS (VIDEO_CROP_CAPS)
);
-GST_BOILERPLATE (GstVideoCrop, gst_video_crop, GstBaseTransform,
- GST_TYPE_BASE_TRANSFORM);
+#define gst_video_crop_parent_class parent_class
+G_DEFINE_TYPE (GstVideoCrop, gst_video_crop, GST_TYPE_BASE_TRANSFORM);
static void gst_video_crop_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
@@ -127,31 +103,16 @@ static void gst_video_crop_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstCaps *gst_video_crop_transform_caps (GstBaseTransform * trans,
- GstPadDirection direction, GstCaps * caps);
+ GstPadDirection direction, GstCaps * caps, GstCaps * filter_caps);
static GstFlowReturn gst_video_crop_transform (GstBaseTransform * trans,
GstBuffer * inbuf, GstBuffer * outbuf);
static gboolean gst_video_crop_get_unit_size (GstBaseTransform * trans,
- GstCaps * caps, guint * size);
+ GstCaps * caps, gsize * size);
static gboolean gst_video_crop_set_caps (GstBaseTransform * trans,
GstCaps * in_caps, GstCaps * outcaps);
static gboolean gst_video_crop_src_event (GstBaseTransform * trans,
GstEvent * event);
-static void
-gst_video_crop_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details_simple (element_class, "Crop",
- "Filter/Effect/Video",
- "Crops video into a user-defined region",
- "Tim-Philipp Müller <tim centricular net>");
-
- gst_element_class_add_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &src_template);
-}
-
static gboolean
gst_video_crop_src_event (GstBaseTransform * trans, GstEvent * event)
{
@@ -202,11 +163,32 @@ static void
gst_video_crop_class_init (GstVideoCropClass * klass)
{
GObjectClass *gobject_class;
+ GstElementClass *element_class;
GstBaseTransformClass *basetransform_class;
gobject_class = (GObjectClass *) klass;
+ element_class = (GstElementClass *) klass;
basetransform_class = (GstBaseTransformClass *) klass;
+ gst_element_class_set_details_simple (element_class, "Crop",
+ "Filter/Effect/Video",
+ "Crops video into a user-defined region",
+ "Tim-Philipp Müller <tim centricular net>");
+
+ 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, "Crop",
+ "Filter/Effect/Video",
+ "Crops video into a user-defined region",
+ "Tim-Philipp Müller <tim centricular net>");
+
+ 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));
+
gobject_class->set_property = gst_video_crop_set_property;
gobject_class->get_property = gst_video_crop_get_property;
@@ -235,7 +217,7 @@ gst_video_crop_class_init (GstVideoCropClass * klass)
}
static void
-gst_video_crop_init (GstVideoCrop * vcrop, GstVideoCropClass * klass)
+gst_video_crop_init (GstVideoCrop * vcrop)
{
vcrop->crop_right = 0;
vcrop->crop_left = 0;
@@ -247,50 +229,28 @@ static gboolean
gst_video_crop_get_image_details_from_caps (GstVideoCrop * vcrop,
GstVideoCropImageDetails * details, GstCaps * caps)
{
- GstStructure *structure;
- gint width, height;
-
- structure = gst_caps_get_structure (caps, 0);
- if (!gst_structure_get_int (structure, "width", &width) ||
- !gst_structure_get_int (structure, "height", &height)) {
+ gst_video_info_init (&details->info);
+ if (!gst_video_info_from_caps (&details->info, caps)) {
goto incomplete_format;
}
- details->width = width;
- details->height = height;
-
- if (gst_structure_has_name (structure, "video/x-raw-rgb") ||
- gst_structure_has_name (structure, "video/x-raw-gray")) {
- gint bpp = 0;
-
- if (!gst_structure_get_int (structure, "bpp", &bpp) || (bpp & 0x07) != 0)
- goto incomplete_format;
+ if (details->info.width == 0 && details->info.height == 0) {
+ goto incomplete_format;
+ }
+ if (GST_VIDEO_INFO_IS_RGB (&details->info)
+ || GST_VIDEO_INFO_IS_GRAY (&details->info)) {
details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE;
- details->bytes_per_pixel = bpp / 8;
- details->stride = GST_ROUND_UP_4 (width * details->bytes_per_pixel);
- details->size = details->stride * height;
- } else if (gst_structure_has_name (structure, "video/x-raw-yuv")) {
- guint32 format = 0;
-
- if (!gst_structure_get_fourcc (structure, "format", &format))
- goto incomplete_format;
-
- switch (format) {
- case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
+ } else {
+ switch (GST_VIDEO_INFO_FORMAT (&details->info)) {
+ case GST_VIDEO_FORMAT_AYUV:
details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE;
- details->bytes_per_pixel = 4;
- details->stride = GST_ROUND_UP_4 (width * 4);
- details->size = details->stride * height;
break;
- case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
- case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
- case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
+ case GST_VIDEO_FORMAT_YVYU:
+ case GST_VIDEO_FORMAT_YUY2:
+ case GST_VIDEO_FORMAT_UYVY:
details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_COMPLEX;
- details->bytes_per_pixel = 2;
- details->stride = GST_ROUND_UP_4 (width * 2);
- details->size = details->stride * height;
- if (format == GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y')) {
+ if (GST_VIDEO_INFO_FORMAT (&details->info) == GST_VIDEO_FORMAT_UYVY) {
/* UYVY = 4:2:2 - [U0 Y0 V0 Y1] [U2 Y2 V2 Y3] [U4 Y4 V4 Y5] */
details->macro_y_off = 1;
} else {
@@ -298,34 +258,16 @@ gst_video_crop_get_image_details_from_caps (GstVideoCrop * vcrop,
details->macro_y_off = 0;
}
break;
- case GST_MAKE_FOURCC ('Y', '8', '0', '0'):
+ case GST_VIDEO_FORMAT_Y800:
details->packing = VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE;
- details->bytes_per_pixel = 1;
- details->stride = GST_ROUND_UP_4 (width);
- details->size = details->stride * height;
break;
- case GST_MAKE_FOURCC ('I', '4', '2', '0'):
- case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):{
+ case GST_VIDEO_FORMAT_I420:
+ case GST_VIDEO_FORMAT_YV12:
details->packing = VIDEO_CROP_PIXEL_FORMAT_PLANAR;
-
- details->y_stride = GST_ROUND_UP_4 (width);
- details->u_stride = GST_ROUND_UP_8 (width) / 2;
- details->v_stride = GST_ROUND_UP_8 (width) / 2;
-
- /* I420 and YV12 have U/V planes swapped, but doesn't matter for us */
- details->y_off = 0;
- details->u_off = 0 + details->y_stride * GST_ROUND_UP_2 (height);
- details->v_off = details->u_off +
- details->u_stride * (GST_ROUND_UP_2 (height) / 2);
- details->size = details->v_off +
- details->v_stride * (GST_ROUND_UP_2 (height) / 2);
break;
- }
default:
goto unknown_format;
}
- } else {
- goto unknown_format;
}
return TRUE;
@@ -348,7 +290,7 @@ incomplete_format:
static gboolean
gst_video_crop_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
- guint * size)
+ gsize * size)
{
GstVideoCropImageDetails img_details = { 0, };
GstVideoCrop *vcrop = GST_VIDEO_CROP (trans);
@@ -356,7 +298,7 @@ gst_video_crop_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
if (!gst_video_crop_get_image_details_from_caps (vcrop, &img_details, caps))
return FALSE;
- *size = img_details.size;
+ *size = GST_VIDEO_INFO_SIZE (&img_details.info);
return TRUE;
}
@@ -367,42 +309,57 @@ gst_video_crop_transform_packed_complex (GstVideoCrop * vcrop,
GstBuffer * inbuf, GstBuffer * outbuf)
{
guint8 *in_data, *out_data;
+ gpointer in_bufdata, out_bufdata;
+ gsize insize, outsize;
guint i, dx;
+ gint in_stride;
+ gint out_stride;
+
+ in_bufdata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
+ out_bufdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
+
+ in_data = in_bufdata;
+ out_data = out_bufdata;
- in_data = GST_BUFFER_DATA (inbuf);
- out_data = GST_BUFFER_DATA (outbuf);
+ in_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, 0);
+ out_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->out.info, 0);
- in_data += vcrop->crop_top * vcrop->in.stride;
+ in_data += vcrop->crop_top * in_stride;
/* rounding down here so we end up at the start of a macro-pixel and not
* in the middle of one */
- in_data += ROUND_DOWN_2 (vcrop->crop_left) * vcrop->in.bytes_per_pixel;
+ in_data +=
+ ROUND_DOWN_2 (vcrop->crop_left) *
+ GST_VIDEO_INFO_COMP_PSTRIDE (&vcrop->in.info, 0);
- dx = vcrop->out.width * vcrop->out.bytes_per_pixel;
+ dx = GST_VIDEO_INFO_WIDTH (&vcrop->out.info) *
+ GST_VIDEO_INFO_COMP_PSTRIDE (&vcrop->out.info, 0);
/* UYVY = 4:2:2 - [U0 Y0 V0 Y1] [U2 Y2 V2 Y3] [U4 Y4 V4 Y5]
* YUYV = 4:2:2 - [Y0 U0 Y1 V0] [Y2 U2 Y3 V2] [Y4 U4 Y5 V4] = YUY2 */
if ((vcrop->crop_left % 2) != 0) {
- for (i = 0; i < vcrop->out.height; ++i) {
+ for (i = 0; i < GST_VIDEO_INFO_HEIGHT (&vcrop->out.info); ++i) {
gint j;
memcpy (out_data, in_data, dx);
/* move just the Y samples one pixel to the left, don't worry about
* chroma shift */
- for (j = vcrop->in.macro_y_off; j < vcrop->out.stride - 2; j += 2)
+ for (j = vcrop->in.macro_y_off; j < out_stride - 2; j += 2)
out_data[j] = in_data[j + 2];
- in_data += vcrop->in.stride;
- out_data += vcrop->out.stride;
+ in_data += in_stride;
+ out_data += out_stride;
}
} else {
- for (i = 0; i < vcrop->out.height; ++i) {
+ for (i = 0; i < GST_VIDEO_INFO_HEIGHT (&vcrop->out.info); ++i) {
memcpy (out_data, in_data, dx);
- in_data += vcrop->in.stride;
- out_data += vcrop->out.stride;
+ in_data += in_stride;
+ out_data += out_stride;
}
}
+ gst_buffer_unmap (inbuf, in_bufdata, insize);
+ gst_buffer_unmap (outbuf, out_bufdata, outsize);
}
static void
@@ -410,21 +367,34 @@ gst_video_crop_transform_packed_simple (GstVideoCrop * vcrop,
GstBuffer * inbuf, GstBuffer * outbuf)
{
guint8 *in_data, *out_data;
+ gpointer in_bufdata, out_bufdata;
+ gsize insize, outsize;
guint i, dx;
+ gint in_stride, out_stride;
+
+ in_bufdata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
+ out_bufdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
+
+ in_data = in_bufdata;
+ out_data = out_bufdata;
- in_data = GST_BUFFER_DATA (inbuf);
- out_data = GST_BUFFER_DATA (outbuf);
+ in_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, 0);
+ out_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->out.info, 0);
- in_data += vcrop->crop_top * vcrop->in.stride;
- in_data += vcrop->crop_left * vcrop->in.bytes_per_pixel;
+ in_data += vcrop->crop_top * in_stride;
+ in_data +=
+ vcrop->crop_left * GST_VIDEO_INFO_COMP_PSTRIDE (&vcrop->in.info, 0);
- dx = vcrop->out.width * vcrop->out.bytes_per_pixel;
+ dx = GST_VIDEO_INFO_WIDTH (&vcrop->out.info) *
+ GST_VIDEO_INFO_COMP_PSTRIDE (&vcrop->out.info, 0);
- for (i = 0; i < vcrop->out.height; ++i) {
+ for (i = 0; i < GST_VIDEO_INFO_HEIGHT (&vcrop->out.info); ++i) {
memcpy (out_data, in_data, dx);
- in_data += vcrop->in.stride;
- out_data += vcrop->out.stride;
+ in_data += in_stride;
+ out_data += out_stride;
}
+ gst_buffer_unmap (inbuf, in_bufdata, insize);
+ gst_buffer_unmap (outbuf, out_bufdata, outsize);
}
static void
@@ -434,43 +404,62 @@ gst_video_crop_transform_planar (GstVideoCrop * vcrop, GstBuffer * inbuf,
guint8 *y_out, *u_out, *v_out;
guint8 *y_in, *u_in, *v_in;
guint i, dx;
+ gpointer in_bufdata, out_bufdata;
+ gsize insize, outsize;
+
+ in_bufdata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
+ out_bufdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
/* Y plane */
- y_in = GST_BUFFER_DATA (inbuf);
- y_out = GST_BUFFER_DATA (outbuf);
+ y_in = in_bufdata;
+ y_out = out_bufdata;
- y_in += (vcrop->crop_top * vcrop->in.y_stride) + vcrop->crop_left;
- dx = vcrop->out.width * 1;
+ y_in +=
+ (vcrop->crop_top * GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info,
+ 0)) + vcrop->crop_left;
+ dx = GST_VIDEO_INFO_WIDTH (&vcrop->out.info) * 1;
- for (i = 0; i < vcrop->out.height; ++i) {
+ for (i = 0; i < GST_VIDEO_INFO_HEIGHT (&vcrop->out.info); ++i) {
memcpy (y_out, y_in, dx);
- y_in += vcrop->in.y_stride;
- y_out += vcrop->out.y_stride;
+ y_in += GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, 0);
+ y_out += GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->out.info, 0);
}
/* U + V planes */
- u_in = GST_BUFFER_DATA (inbuf) + vcrop->in.u_off;
- u_out = GST_BUFFER_DATA (outbuf) + vcrop->out.u_off;
-
- u_in += (vcrop->crop_top / 2) * vcrop->in.u_stride;
+ u_in =
+ (guint8 *) in_bufdata + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->in.info, 1);
+ u_out =
+ (guint8 *) out_bufdata + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->out.info,
+ 1);
+
+ u_in +=
+ (vcrop->crop_top / 2) * GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, 1);
u_in += vcrop->crop_left / 2;
- v_in = GST_BUFFER_DATA (inbuf) + vcrop->in.v_off;
- v_out = GST_BUFFER_DATA (outbuf) + vcrop->out.v_off;
+ v_in =
+ (guint8 *) in_bufdata + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->in.info, 2);
+ v_out =
+ (guint8 *) out_bufdata + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->out.info,
+ 2);
- v_in += (vcrop->crop_top / 2) * vcrop->in.v_stride;
+ v_in +=
+ (vcrop->crop_top / 2) * GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, 2);
v_in += vcrop->crop_left / 2;
- dx = GST_ROUND_UP_2 (vcrop->out.width) / 2;
+ dx = GST_ROUND_UP_2 (GST_VIDEO_INFO_WIDTH (&vcrop->out.info)) / 2;
- for (i = 0; i < GST_ROUND_UP_2 (vcrop->out.height) / 2; ++i) {
+ for (i = 0; i < GST_ROUND_UP_2 (GST_VIDEO_INFO_HEIGHT (&vcrop->out.info)) / 2;
+ ++i) {
memcpy (u_out, u_in, dx);
memcpy (v_out, v_in, dx);
- u_in += vcrop->in.u_stride;
- u_out += vcrop->out.u_stride;
- v_in += vcrop->in.v_stride;
- v_out += vcrop->out.v_stride;
+ u_in += GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, 1);
+ u_out += GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->out.info, 1);
+ v_in += GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, 2);
+ v_out += GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->out.info, 2);
}
+
+ gst_buffer_unmap (inbuf, in_bufdata, insize);
+ gst_buffer_unmap (outbuf, out_bufdata, outsize);
}
static GstFlowReturn
@@ -551,9 +540,10 @@ gst_video_crop_transform_dimension_value (const GValue * src_val,
return ret;
}
+/* TODO use filter_caps */
static GstCaps *
gst_video_crop_transform_caps (GstBaseTransform * trans,
- GstPadDirection direction, GstCaps * caps)
+ GstPadDirection direction, GstCaps * caps, GstCaps * filter_caps)
{
GstVideoCrop *vcrop;
GstCaps *other_caps;
@@ -617,6 +607,13 @@ gst_video_crop_transform_caps (GstBaseTransform * trans,
other_caps = NULL;
}
+ if (other_caps && filter_caps) {
+ GstCaps *tmp = gst_caps_intersect_full (filter_caps, other_caps,
+ GST_CAPS_INTERSECT_FIRST);
+ gst_caps_replace (&other_caps, tmp);
+ gst_caps_unref (tmp);
+ }
+
return other_caps;
}
@@ -632,8 +629,10 @@ gst_video_crop_set_caps (GstBaseTransform * trans, GstCaps * incaps,
if (!gst_video_crop_get_image_details_from_caps (crop, &crop->out, outcaps))
goto wrong_output;
- if (G_UNLIKELY ((crop->crop_left + crop->crop_right) >= crop->in.width ||
- (crop->crop_top + crop->crop_bottom) >= crop->in.height))
+ if (G_UNLIKELY ((crop->crop_left + crop->crop_right) >=
+ GST_VIDEO_INFO_WIDTH (&crop->in.info)
+ || (crop->crop_top + crop->crop_bottom) >=
+ GST_VIDEO_INFO_HEIGHT (&crop->in.info)))
goto cropping_too_much;
GST_LOG_OBJECT (crop, "incaps = %" GST_PTR_FORMAT ", outcaps = %"
diff --git a/gst/videocrop/gstvideocrop.h b/gst/videocrop/gstvideocrop.h
index 477f21b06..434c556e8 100644
--- a/gst/videocrop/gstvideocrop.h
+++ b/gst/videocrop/gstvideocrop.h
@@ -47,19 +47,10 @@ struct _GstVideoCropImageDetails
/*< private >*/
VideoCropPixelFormat packing;
- guint width;
- guint height;
- guint size;
+ GstVideoInfo info;
/* for packed RGB and YUV */
- guint stride;
- guint bytes_per_pixel;
guint8 macro_y_off; /* for YUY2, YVYU, UYVY, Y offset within macropixel in bytes */
-
- /* for planar YUV */
- guint y_stride, y_off;
- guint u_stride, u_off;
- guint v_stride, v_off;
};
typedef struct _GstVideoCrop GstVideoCrop;
diff --git a/gst/videofilter/Makefile.am b/gst/videofilter/Makefile.am
index 4838c1724..6013f59f0 100644
--- a/gst/videofilter/Makefile.am
+++ b/gst/videofilter/Makefile.am
@@ -9,13 +9,11 @@ libgstvideofilter_la_SOURCES = plugin.c \
gstvideoflip.c \
gstvideobalance.c \
gstgamma.c
-libgstvideofilter_la_CFLAGS = $(GST_CFLAGS) $(GST_CONTROLLER_CFLAGS) \
+libgstvideofilter_la_CFLAGS = $(GST_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS)
libgstvideofilter_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
-lgstvideo-@GST_MAJORMINOR@ \
- -lgstinterfaces-@GST_MAJORMINOR@ \
- $(GST_CONTROLLER_LIBS) \
$(GST_BASE_LIBS) $(GST_LIBS)
libgstvideofilter_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(LIBM)
libgstvideofilter_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/gst/videofilter/gstgamma.c b/gst/videofilter/gstgamma.c
index 76d60b6f5..401aced45 100644
--- a/gst/videofilter/gstgamma.c
+++ b/gst/videofilter/gstgamma.c
@@ -55,7 +55,6 @@
#include <math.h>
#include <gst/video/video.h>
-#include <gst/controller/gstcontroller.h>
GST_DEBUG_CATEGORY_STATIC (gamma_debug);
#define GST_CAT_DEFAULT gamma_debug
@@ -71,49 +70,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 +103,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_static_pad_template (element_class,
- &gst_gamma_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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 +122,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 +138,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 +208,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 +231,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 +270,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;
- 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);
+ 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);
- 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;
+ 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);
+
+ 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 +322,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 +369,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
@@ -427,15 +389,14 @@ gst_gamma_before_transform (GstBaseTransform * base, GstBuffer * outbuf)
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (gamma), stream_time);
+ gst_object_sync_values (GST_OBJECT (gamma), stream_time);
}
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 +404,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:
diff --git a/gst/videofilter/gstgamma.h b/gst/videofilter/gstgamma.h
index 85d2e27db..b76dd973e 100644
--- a/gst/videofilter/gstgamma.h
+++ b/gst/videofilter/gstgamma.h
@@ -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
diff --git a/gst/videofilter/gstvideobalance.c b/gst/videofilter/gstvideobalance.c
index 83a2afdb2..3c5a31e83 100644
--- a/gst/videofilter/gstvideobalance.c
+++ b/gst/videofilter/gstvideobalance.c
@@ -49,8 +49,7 @@
#include "gstvideobalance.h"
#include <string.h>
-#include <gst/controller/gstcontroller.h>
-#include <gst/interfaces/colorbalance.h>
+#include <gst/video/colorbalance.h>
GST_DEBUG_CATEGORY_STATIC (videobalance_debug);
#define GST_CAT_DEFAULT videobalance_debug
@@ -71,78 +70,38 @@ 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_colorbalance_init (GstColorBalanceInterface *
+ iface);
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
@@ -480,15 +429,14 @@ gst_video_balance_before_transform (GstBaseTransform * base, GstBuffer * buf)
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (balance), stream_time);
+ gst_object_sync_values (GST_OBJECT (balance), stream_time);
}
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_static_pad_template (element_class,
- &gst_video_balance_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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)
{
@@ -731,7 +660,7 @@ gst_video_balance_colorbalance_get_value (GstColorBalance * balance,
}
static void
-gst_video_balance_colorbalance_init (GstColorBalanceClass * iface)
+gst_video_balance_colorbalance_init (GstColorBalanceInterface * iface)
{
GST_COLOR_BALANCE_TYPE (iface) = GST_COLOR_BALANCE_SOFTWARE;
iface->list_channels = gst_video_balance_colorbalance_list_channels;
diff --git a/gst/videofilter/gstvideobalance.h b/gst/videofilter/gstvideobalance.h
index c9484e398..1d3375a45 100644
--- a/gst/videofilter/gstvideobalance.h
+++ b/gst/videofilter/gstvideobalance.h
@@ -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 {
diff --git a/gst/videofilter/gstvideoflip.c b/gst/videofilter/gstvideoflip.c
index 713705751..f9bad9aaa 100644
--- a/gst/videofilter/gstvideoflip.c
+++ b/gst/videofilter/gstvideoflip.c
@@ -48,7 +48,6 @@
#include <string.h>
#include <gst/gst.h>
-#include <gst/controller/gstcontroller.h>
#include <gst/video/video.h>
/* GstVideoFlip properties */
@@ -65,40 +64,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 +110,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 +166,81 @@ 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);
+ GST_DEBUG_OBJECT (btrans,
+ "our frame size is %" G_GSIZE_FORMAT " bytes (%dx%d)", *size, 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);
+
+ src_stride = GST_VIDEO_FRAME_PLANE_STRIDE (src, 0);
+ dest_stride = GST_VIDEO_FRAME_PLANE_STRIDE (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);
+ 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:
@@ -890,7 +869,7 @@ gst_video_flip_before_transform (GstBaseTransform * trans, GstBuffer * in)
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (videoflip), stream_time);
+ gst_object_sync_values (GST_OBJECT (videoflip), stream_time);
}
static GstFlowReturn
@@ -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_static_pad_template (element_class,
- &gst_video_flip_sink_template);
- gst_element_class_add_static_pad_template (element_class,
- &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);
diff --git a/gst/videofilter/gstvideoflip.h b/gst/videofilter/gstvideoflip.h
index a998fa721..d520b03a3 100644
--- a/gst/videofilter/gstvideoflip.h
+++ b/gst/videofilter/gstvideoflip.h
@@ -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 {
diff --git a/gst/videofilter/plugin.c b/gst/videofilter/plugin.c
index e0fcede73..9e38173df 100644
--- a/gst/videofilter/plugin.c
+++ b/gst/videofilter/plugin.c
@@ -22,7 +22,6 @@
#endif
#include <gst/gst.h>
-#include <gst/controller/gstcontroller.h>
#include "gstgamma.h"
#include "gstvideoflip.h"
@@ -31,8 +30,6 @@
static gboolean
plugin_init (GstPlugin * plugin)
{
- gst_controller_init (NULL, NULL);
-
return (gst_element_register (plugin, "gamma", GST_RANK_NONE, GST_TYPE_GAMMA)
&& gst_element_register (plugin, "videobalance", GST_RANK_NONE,
GST_TYPE_VIDEO_BALANCE)
diff --git a/gst/videomixer/Makefile.am b/gst/videomixer/Makefile.am
index 0cda8261a..d92a545e4 100644
--- a/gst/videomixer/Makefile.am
+++ b/gst/videomixer/Makefile.am
@@ -10,10 +10,10 @@ libgstvideomixer_la_SOURCES = \
nodist_libgstvideomixer_la_SOURCES = $(ORC_NODIST_SOURCES)
libgstvideomixer_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) $(GST_CONTROLLER_CFLAGS) $(GST_CFLAGS) $(ORC_CFLAGS)
+ $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(ORC_CFLAGS)
libgstvideomixer_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
-lgstvideo-@GST_MAJORMINOR@ \
- $(GST_BASE_LIBS) $(GST_CONTROLLER_LIBS) $(GST_LIBS) $(ORC_LIBS)
+ $(GST_BASE_LIBS) $(GST_LIBS) $(ORC_LIBS)
libgstvideomixer_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstvideomixer_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/gst/videomixer/videomixer.c b/gst/videomixer/videomixer.c
index 2c78c618b..ae0a5383a 100644
--- a/gst/videomixer/videomixer.c
+++ b/gst/videomixer/videomixer.c
@@ -76,7 +76,6 @@
#include <gst/gst.h>
#include <gst/base/gstcollectpads.h>
-#include <gst/controller/gstcontroller.h>
#include <gst/video/video.h>
#ifdef HAVE_STDLIB_H
@@ -566,7 +565,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_BGRx)
);
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%d",
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" GST_VIDEO_CAPS_BGRA ";"
@@ -664,8 +663,10 @@ gst_videomixer_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &sink_factory);
+ 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, "Video mixer",
"Filter/Editor/Video",
@@ -1201,7 +1202,7 @@ gst_videomixer_request_new_pad (GstElement * element,
mix = GST_VIDEO_MIXER (element);
- if (templ == gst_element_class_get_pad_template (klass, "sink_%d")) {
+ if (templ == gst_element_class_get_pad_template (klass, "sink_%u")) {
gint serial = 0;
gchar *name = NULL;
GstVideoMixerCollect *mixcol = NULL;
@@ -1218,7 +1219,7 @@ gst_videomixer_request_new_pad (GstElement * element,
mix->next_sinkpad = serial + 1;
}
/* create new pad with the name */
- name = g_strdup_printf ("sink_%d", serial);
+ name = g_strdup_printf ("sink_%u", serial);
mixpad = g_object_new (GST_TYPE_VIDEO_MIXER_PAD, "name", name, "direction",
templ->direction, "template", templ, NULL);
g_free (name);
@@ -1230,7 +1231,7 @@ gst_videomixer_request_new_pad (GstElement * element,
mixcol = (GstVideoMixerCollect *)
gst_collect_pads_add_pad (mix->collect, GST_PAD (mixpad),
- sizeof (GstVideoMixerCollect));
+ sizeof (GstVideoMixerCollect), NULL);
/* FIXME: hacked way to override/extend the event function of
* GstCollectPads; because it sets its own event function giving the
@@ -1442,7 +1443,7 @@ gst_videomixer_blend_buffers (GstVideoMixer * mix, GstBuffer * outbuf)
/* sync object properties on stream time */
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (pad), stream_time);
+ gst_object_sync_values (GST_OBJECT (pad), stream_time);
blend (GST_BUFFER_DATA (mixcol->buffer),
pad->xpos, pad->ypos, pad->in_width, pad->in_height, pad->alpha,
diff --git a/gst/videomixer/videomixer2.c b/gst/videomixer/videomixer2.c
index fde327a71..4223d7092 100644
--- a/gst/videomixer/videomixer2.c
+++ b/gst/videomixer/videomixer2.c
@@ -91,8 +91,6 @@
#include "videomixer2.h"
#include "videomixer2pad.h"
-#include <gst/controller/gstcontroller.h>
-
#ifdef DISABLE_ORC
#define orc_memset memset
#else
@@ -869,7 +867,7 @@ gst_videomixer2_blend_buffers (GstVideoMixer2 * mix,
/* sync object properties on stream time */
if (GST_CLOCK_TIME_IS_VALID (stream_time))
- gst_object_sync_values (G_OBJECT (pad), stream_time);
+ gst_object_sync_values (GST_OBJECT (pad), stream_time);
composite (GST_BUFFER_DATA (mixcol->buffer),
pad->xpos, pad->ypos, pad->width, pad->height, pad->alpha,
@@ -1931,8 +1929,10 @@ gst_videomixer2_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &sink_factory);
+ 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, "Video mixer 2",
"Filter/Editor/Video",
diff --git a/gst/wavenc/Makefile.am b/gst/wavenc/Makefile.am
index a213b0075..53ef62d2c 100644
--- a/gst/wavenc/Makefile.am
+++ b/gst/wavenc/Makefile.am
@@ -6,6 +6,7 @@ libgstwavenc_la_CFLAGS = \
$(GST_CFLAGS)
libgstwavenc_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) \
+ -lgstaudio-@GST_MAJORMINOR@ \
-lgstriff-@GST_MAJORMINOR@ \
$(GST_LIBS)
libgstwavenc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
diff --git a/gst/wavenc/gstwavenc.c b/gst/wavenc/gstwavenc.c
index e6b06d989..46ff60a49 100644
--- a/gst/wavenc/gstwavenc.c
+++ b/gst/wavenc/gstwavenc.c
@@ -32,6 +32,7 @@
#include <string.h>
#include "gstwavenc.h"
+#include <gst/audio/audio.h>
#include <gst/riff/riff-media.h>
GST_DEBUG_CATEGORY_STATIC (wavenc_debug);
@@ -72,42 +73,11 @@ struct wave_header
/* Max. of two channels, more channels need WAVFORMATEX with
* channel layout, which we do not support yet */
#define SINK_CAPS \
- "audio/x-raw-int, " \
+ "audio/x-raw, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, 2 ], " \
- "endianness = (int) LITTLE_ENDIAN, " \
- "width = (int) 32, " \
- "depth = (int) 32, " \
- "signed = (boolean) true" \
+ "format = (string) { S32LE, S24LE, S16LE, U8, F32LE, F64LE } " \
"; " \
- "audio/x-raw-int, " \
- "rate = (int) [ 1, MAX ], " \
- "channels = (int) [ 1, 2 ], " \
- "endianness = (int) LITTLE_ENDIAN, " \
- "width = (int) 24, " \
- "depth = (int) 24, " \
- "signed = (boolean) true" \
- "; " \
- "audio/x-raw-int, " \
- "rate = (int) [ 1, MAX ], " \
- "channels = (int) [ 1, 2 ], " \
- "endianness = (int) LITTLE_ENDIAN, " \
- "width = (int) 16, " \
- "depth = (int) 16, " \
- "signed = (boolean) true" \
- "; " \
- "audio/x-raw-int, " \
- "rate = (int) [ 1, MAX ], " \
- "channels = (int) [ 1, 2 ], " \
- "width = (int) 8, " \
- "depth = (int) 8, " \
- "signed = (boolean) false" \
- "; " \
- "audio/x-raw-float, " \
- "rate = (int) [ 1, MAX ], " \
- "channels = (int) [ 1, 2 ], " \
- "endianness = (int) LITTLE_ENDIAN, " \
- "width = (int) { 32, 64 }; " \
"audio/x-alaw, " \
"rate = (int) [ 8000, 192000 ], " \
"channels = (int) [ 1, 2 ], " \
@@ -134,49 +104,46 @@ 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);
+static GstFlowReturn gst_wavenc_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buf);
+static gboolean gst_wavenc_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static GstStateChangeReturn gst_wavenc_change_state (GstElement * element,
GstStateChange transition);
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",
"Encode raw audio into WAV", "Iain Holmes <iain@prettypeople.org>");
- gst_element_class_add_static_pad_template (element_class, &src_factory);
- gst_element_class_add_static_pad_template (element_class, &sink_factory);
+ 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_DEBUG_CATEGORY_INIT (wavenc_debug, "wavenc", 0, "WAV encoder element");
}
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);
@@ -197,7 +164,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;
@@ -234,7 +201,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;
}
@@ -244,10 +211,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);
@@ -270,14 +238,19 @@ gst_wavenc_sink_setcaps (GstPad * pad, GstCaps * caps)
GstWavEnc *wavenc;
GstStructure *structure;
const gchar *name;
- gint chans, rate, width;
+ gint chans, rate;
+ 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);
@@ -290,20 +263,20 @@ gst_wavenc_sink_setcaps (GstPad * pad, GstCaps * caps)
goto fail;
}
- if (strcmp (name, "audio/x-raw-int") == 0) {
- if (!gst_structure_get_int (structure, "width", &width)) {
- GST_WARNING_OBJECT (wavenc, "caps incomplete");
+ if (strcmp (name, "audio/x-raw") == 0) {
+ GstAudioInfo info;
+
+ if (!gst_audio_info_from_caps (&info, caps))
goto fail;
- }
- wavenc->format = GST_RIFF_WAVE_FORMAT_PCM;
- wavenc->width = width;
- } else if (strcmp (name, "audio/x-raw-float") == 0) {
- if (!gst_structure_get_int (structure, "width", &width)) {
- GST_WARNING_OBJECT (wavenc, "caps incomplete");
+
+ if (GST_AUDIO_INFO_IS_INTEGER (&info))
+ wavenc->format = GST_RIFF_WAVE_FORMAT_PCM;
+ else if (GST_AUDIO_INFO_IS_FLOAT (&info))
+ wavenc->format = GST_RIFF_WAVE_FORMAT_IEEE_FLOAT;
+ else
goto fail;
- }
- wavenc->format = GST_RIFF_WAVE_FORMAT_IEEE_FLOAT;
- wavenc->width = width;
+
+ wavenc->width = GST_AUDIO_INFO_WIDTH (&info);
} else if (strcmp (name, "audio/x-alaw") == 0) {
wavenc->format = GST_RIFF_WAVE_FORMAT_ALAW;
wavenc->width = 8;
@@ -611,14 +584,25 @@ write_labels (GstWavEnc * wavenc)
#endif
static gboolean
-gst_wavenc_event (GstPad * pad, GstEvent * event)
+gst_wavenc_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
gboolean res = TRUE;
GstWavEnc *wavenc;
- wavenc = GST_WAVENC (gst_pad_get_parent (pad));
+ wavenc = GST_WAVENC (parent);
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
@@ -636,27 +620,26 @@ gst_wavenc_event (GstPad * pad, GstEvent * event)
wavenc->finished_properly = TRUE;
/* and forward the EOS event */
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, 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);
break;
default:
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, parent, event);
break;
}
- gst_object_unref (wavenc);
return res;
}
static GstFlowReturn
-gst_wavenc_chain (GstPad * pad, GstBuffer * buf)
+gst_wavenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
- GstWavEnc *wavenc = GST_WAVENC (GST_PAD_PARENT (pad));
+ GstWavEnc *wavenc = GST_WAVENC (parent);
GstFlowReturn flow = GST_FLOW_OK;
g_return_val_if_fail (wavenc->channels > 0, GST_FLOW_WRONG_STATE);
@@ -676,16 +659,16 @@ gst_wavenc_chain (GstPad * pad, GstBuffer * buf)
wavenc->sent_header = TRUE;
}
- 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_LOG_OBJECT (wavenc,
+ "pushing %" G_GSIZE_FORMAT " bytes raw audio, ts=%" GST_TIME_FORMAT,
+ 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);
@@ -713,7 +696,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;
diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c
index ef222e58e..3758a9b88 100644
--- a/gst/wavparse/gstwavparse.c
+++ b/gst/wavparse/gstwavparse.c
@@ -63,64 +63,48 @@ GST_DEBUG_CATEGORY_STATIC (wavparse_debug);
static void gst_wavparse_dispose (GObject * object);
-static gboolean gst_wavparse_sink_activate (GstPad * sinkpad);
-static gboolean gst_wavparse_sink_activate_pull (GstPad * sinkpad,
- gboolean active);
+static gboolean gst_wavparse_sink_activate (GstPad * sinkpad,
+ GstObject * parent);
+static gboolean gst_wavparse_sink_activate_mode (GstPad * sinkpad,
+ GstObject * parent, GstPadMode mode, gboolean active);
static gboolean gst_wavparse_send_event (GstElement * element,
GstEvent * event);
static GstStateChangeReturn gst_wavparse_change_state (GstElement * element,
GstStateChange transition);
-static const GstQueryType *gst_wavparse_get_query_types (GstPad * pad);
-static gboolean gst_wavparse_pad_query (GstPad * pad, GstQuery * query);
-static gboolean gst_wavparse_pad_convert (GstPad * pad,
- GstFormat src_format,
+static gboolean gst_wavparse_pad_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
+static gboolean gst_wavparse_pad_convert (GstPad * pad, GstFormat src_format,
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
-static GstFlowReturn gst_wavparse_chain (GstPad * pad, GstBuffer * buf);
-static gboolean gst_wavparse_sink_event (GstPad * pad, GstEvent * event);
+static GstFlowReturn gst_wavparse_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buf);
+static gboolean gst_wavparse_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static void gst_wavparse_loop (GstPad * pad);
-static gboolean gst_wavparse_srcpad_event (GstPad * pad, GstEvent * event);
+static gboolean gst_wavparse_srcpad_event (GstPad * pad, GstObject * parent,
+ 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_static_pad_template (element_class,
- &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 +115,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 +169,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 +183,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);
@@ -198,16 +192,24 @@ gst_wavparse_init (GstWavParse * wavparse, GstWavParseClass * g_class)
gst_pad_new_from_static_template (&sink_template_factory, "sink");
gst_pad_set_activate_function (wavparse->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavparse_sink_activate));
- gst_pad_set_activatepull_function (wavparse->sinkpad,
- GST_DEBUG_FUNCPTR (gst_wavparse_sink_activate_pull));
+ gst_pad_set_activatemode_function (wavparse->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_wavparse_sink_activate_mode));
gst_pad_set_chain_function (wavparse->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavparse_chain));
gst_pad_set_event_function (wavparse->sinkpad,
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_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 +221,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 +783,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 +809,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 +867,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 +879,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 +893,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 +922,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_peer_query_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 +939,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 +950,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 +1015,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);
GST_DEBUG ("Next chunk size is %d bytes, type %" GST_FOURCC_FORMAT, *size,
GST_FOURCC_ARGS (*tag));
@@ -1169,7 +1134,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 */
@@ -1304,7 +1268,7 @@ gst_wavparse_stream_headers (GstWavParse * wav)
wav->got_fmt = TRUE;
if (codec_name) {
- wav->tags = gst_tag_list_new ();
+ wav->tags = gst_tag_list_new_empty ();
gst_tag_list_add (wav->tags, GST_TAG_MERGE_REPLACE,
GST_TAG_AUDIO_CODEC, codec_name, NULL);
@@ -1315,8 +1279,7 @@ gst_wavparse_stream_headers (GstWavParse * wav)
}
- bformat = GST_FORMAT_BYTES;
- gst_pad_query_peer_duration (wav->sinkpad, &bformat, &upstream_size);
+ gst_pad_peer_query_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 */
@@ -1325,12 +1288,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,
@@ -1393,8 +1360,9 @@ 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_unmap (wav->adapter);
gst_adapter_flush (wav->adapter, GST_ROUND_UP_2 (size));
} else {
gst_buffer_unref (buf);
@@ -1402,7 +1370,8 @@ gst_wavparse_stream_headers (GstWavParse * wav)
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);
@@ -1419,6 +1388,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) {
@@ -1435,21 +1405,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);
} 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 ();
+ wav->tags = gst_tag_list_new_empty ();
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) {
@@ -1470,15 +1445,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);
} 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:{
@@ -1561,11 +1538,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
@@ -1769,7 +1746,7 @@ gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf)
if (wav->caps) {
s = gst_caps_get_structure (wav->caps, 0);
- if (s && gst_structure_has_name (s, "audio/x-raw-int") && buf != NULL) {
+ if (s && gst_structure_has_name (s, "audio/x-raw") && buf != NULL) {
GstTypeFindProbability prob;
GstCaps *tf_caps;
@@ -1792,19 +1769,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);
@@ -1812,8 +1779,7 @@ gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf)
}
if (wav->tags) {
- gst_element_found_tags_for_pad (GST_ELEMENT_CAST (wav), wav->srcpad,
- wav->tags);
+ gst_pad_push_event (wav->srcpad, gst_event_new_tag (wav->tags));
wav->tags = NULL;
}
}
@@ -1840,7 +1806,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);
@@ -1889,11 +1855,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;
@@ -1901,13 +1869,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;
@@ -1918,11 +1887,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;
@@ -1938,8 +1903,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);
@@ -1957,7 +1921,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 */
@@ -1973,13 +1937,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));
+ ", size:%" G_GSIZE_FORMAT, GST_TIME_ARGS (timestamp),
+ GST_TIME_ARGS (duration), gst_buffer_get_size (buf));
if ((res = gst_pad_push (wav->srcpad, buf)) != GST_FLOW_OK)
goto push_error;
@@ -2069,10 +2030,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;
@@ -2111,12 +2081,13 @@ pause:
}
static GstFlowReturn
-gst_wavparse_chain (GstPad * pad, GstBuffer * buf)
+gst_wavparse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstFlowReturn ret;
- GstWavParse *wav = GST_WAVPARSE (GST_PAD_PARENT (pad));
+ GstWavParse *wav = GST_WAVPARSE (parent);
- GST_LOG_OBJECT (wav, "adapter_push %u bytes", GST_BUFFER_SIZE (buf));
+ GST_LOG_OBJECT (wav, "adapter_push %" G_GSIZE_FORMAT " bytes",
+ gst_buffer_get_size (buf));
gst_adapter_push (wav->adapter, buf);
@@ -2178,30 +2149,28 @@ gst_wavparse_flush_data (GstWavParse * wav)
}
static gboolean
-gst_wavparse_sink_event (GstPad * pad, GstEvent * event)
+gst_wavparse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
- GstWavParse *wav = GST_WAVPARSE (GST_PAD_PARENT (pad));
+ GstWavParse *wav = GST_WAVPARSE (parent);
gboolean ret = TRUE;
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) {
@@ -2211,7 +2180,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;
@@ -2219,8 +2191,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;
@@ -2243,19 +2215,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);
@@ -2288,11 +2263,18 @@ 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);
+ ret = gst_pad_event_default (wav->sinkpad, parent, event);
break;
}
@@ -2424,30 +2406,15 @@ no_bps_fact:
}
}
-static const GstQueryType *
-gst_wavparse_get_query_types (GstPad * pad)
-{
- static const GstQueryType types[] = {
- GST_QUERY_POSITION,
- GST_QUERY_DURATION,
- GST_QUERY_CONVERT,
- GST_QUERY_SEEKING,
- 0
- };
-
- return types;
-}
-
/* handle queries for location and length in requested format */
static gboolean
-gst_wavparse_pad_query (GstPad * pad, GstQuery * query)
+gst_wavparse_pad_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
gboolean res = TRUE;
- GstWavParse *wav = GST_WAVPARSE (gst_pad_get_parent (pad));
+ GstWavParse *wav = GST_WAVPARSE (parent);
/* only if we know */
if (wav->state != GST_WAVPARSE_DATA) {
- gst_object_unref (wav);
return FALSE;
}
@@ -2543,17 +2510,16 @@ gst_wavparse_pad_query (GstPad * pad, GstQuery * query)
break;
}
default:
- res = gst_pad_query_default (pad, query);
+ res = gst_pad_query_default (pad, parent, query);
break;
}
- gst_object_unref (wav);
return res;
}
static gboolean
-gst_wavparse_srcpad_event (GstPad * pad, GstEvent * event)
+gst_wavparse_srcpad_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
- GstWavParse *wavparse = GST_WAVPARSE (gst_pad_get_parent (pad));
+ GstWavParse *wavparse = GST_WAVPARSE (parent);
gboolean res = FALSE;
GST_DEBUG_OBJECT (wavparse, "%s event", GST_EVENT_TYPE_NAME (event));
@@ -2570,15 +2536,15 @@ gst_wavparse_srcpad_event (GstPad * pad, GstEvent * event)
res = gst_pad_push_event (wavparse->sinkpad, event);
break;
}
- gst_object_unref (wavparse);
return res;
}
static gboolean
-gst_wavparse_sink_activate (GstPad * sinkpad)
+gst_wavparse_sink_activate (GstPad * sinkpad, GstObject * parent)
{
- GstWavParse *wav = GST_WAVPARSE (gst_pad_get_parent (sinkpad));
- gboolean res;
+ GstWavParse *wav = GST_WAVPARSE (parent);
+ GstQuery *query;
+ gboolean pull_mode;
if (wav->adapter) {
gst_adapter_clear (wav->adapter);
@@ -2586,36 +2552,58 @@ 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;
+ }
+
+ pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL);
+ gst_query_unref (query);
+
+ if (!pull_mode)
+ goto activate_push;
+
+ GST_DEBUG_OBJECT (sinkpad, "activating pull");
+ wav->streaming = FALSE;
+ return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
+
+activate_push:
+ {
+ GST_DEBUG_OBJECT (sinkpad, "activating push");
wav->streaming = TRUE;
wav->adapter = gst_adapter_new ();
- res = gst_pad_activate_push (sinkpad, TRUE);
+ return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
}
- gst_object_unref (wav);
- return res;
}
static gboolean
-gst_wavparse_sink_activate_pull (GstPad * sinkpad, gboolean active)
+gst_wavparse_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
+ GstPadMode mode, gboolean active)
{
- GstWavParse *wav = GST_WAVPARSE (GST_OBJECT_PARENT (sinkpad));
+ gboolean res;
- 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);
+ switch (mode) {
+ case GST_PAD_MODE_PUSH:
+ res = TRUE;
+ break;
+ case GST_PAD_MODE_PULL:
+ if (active) {
+ /* if we have a scheduler we can start the task */
+ res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_wavparse_loop,
+ sinkpad);
+ } else {
+ res = gst_pad_stop_task (sinkpad);
+ }
+ break;
+ default:
+ res = FALSE;
+ break;
}
-};
+ return res;
+}
static GstStateChangeReturn
gst_wavparse_change_state (GstElement * element, GstStateChange transition)
diff --git a/gst/wavparse/gstwavparse.h b/gst/wavparse/gstwavparse.h
index ecac96881..54d0a0fd5 100644
--- a/gst/wavparse/gstwavparse.h
+++ b/gst/wavparse/gstwavparse.h
@@ -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;
diff --git a/gst/y4m/Makefile.am b/gst/y4m/Makefile.am
index 3548d8d2c..c81703a31 100644
--- a/gst/y4m/Makefile.am
+++ b/gst/y4m/Makefile.am
@@ -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
diff --git a/gst/y4m/gsty4mencode.c b/gst/y4m/gsty4mencode.c
index 7830c95aa..d05a4ae58 100644
--- a/gst/y4m/gsty4mencode.c
+++ b/gst/y4m/gsty4mencode.c
@@ -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,15 @@ 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 GstFlowReturn gst_y4m_encode_chain (GstPad * pad, GstBuffer * buf);
+static gboolean gst_y4m_encode_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static GstFlowReturn gst_y4m_encode_chain (GstPad * pad, GstObject * parent,
+ 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_static_pad_template (element_class,
- &y4mencode_src_factory);
- gst_element_class_add_static_pad_template (element_class,
- &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 +100,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 +140,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));
- /* 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;
+ filter->negotiated = ret;
+
+ 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, GstObject * parent, 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, parent, 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,57 +250,60 @@ 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;
}
static GstFlowReturn
-gst_y4m_encode_chain (GstPad * pad, GstBuffer * buf)
+gst_y4m_encode_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
- GstY4mEncode *filter = GST_Y4M_ENCODE (GST_PAD_PARENT (pad));
+ GstY4mEncode *filter = GST_Y4M_ENCODE (parent);
GstBuffer *outbuf;
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
diff --git a/gst/y4m/gsty4mencode.h b/gst/y4m/gsty4mencode.h
index 624ab37ac..9eb820e48 100644
--- a/gst/y4m/gsty4mencode.h
+++ b/gst/y4m/gsty4mencode.h
@@ -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;
diff --git a/m4/Makefile.am b/m4/Makefile.am
index a2a60f8b8..53032c3b9 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -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
index a66a8c2d9..000000000
--- a/m4/as-arts.m4
+++ /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
index 1812fd027..000000000
--- 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
index 088c93f9a..000000000
--- a/m4/gconf-2.m4
+++ /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)
-])
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 95fc75e37..57e8e43ee 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -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
diff --git a/po/af.po b/po/af.po
index ced1f8418..ac5c07f2b 100644
--- 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-11-26 13:52+0000\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,21 +16,15 @@ 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'"
msgstr ""
-msgid "Internal data stream error."
+msgid "Failed to decode JPEG image"
msgstr ""
-msgid "Failed to decode JPEG image"
+msgid "Internal data stream error."
msgstr ""
#, fuzzy
@@ -548,13 +542,83 @@ 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' is busy"
+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 +690,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 +698,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."
diff --git a/po/az.po b/po/az.po
index 26f77d955..d0b16d906 100644
--- 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-11-26 13:52+0000\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,21 +17,15 @@ 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'"
msgstr ""
-msgid "Internal data stream error."
+msgid "Failed to decode JPEG image"
msgstr ""
-msgid "Failed to decode JPEG image"
+msgid "Internal data stream error."
msgstr ""
#, fuzzy
@@ -549,13 +543,83 @@ 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' is busy"
+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 +691,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 +699,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."
diff --git a/po/bg.po b/po/bg.po
index 59b85c9cc..4d634e6d6 100644
--- 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-11-26 13:52+0000\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,23 +18,17 @@ 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'"
msgstr "„%s“ от „%s“"
-msgid "Internal data stream error."
-msgstr "Вътрешна грешка на потока от данни."
-
msgid "Failed to decode JPEG image"
msgstr "ÐеуÑпешно декодиране на изображение, формат JPEG."
+msgid "Internal data stream error."
+msgstr "Вътрешна грешка на потока от данни."
+
msgid "Could not connect to server"
msgstr "Ðе може да Ñе оÑъщеÑтви връзка към Ñървър."
@@ -539,12 +533,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 ""
+
+#, 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' is busy"
+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 +689,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 +698,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 +705,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 "ÐеуÑпешно запитване за възможноÑтите на Ð·Ð²ÑƒÐºÐ¾Ð²Ð¸Ñ Ñървър."
diff --git a/po/ca.po b/po/ca.po
index 4cb58a9da..99ebacd06 100644
--- 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-11-26 13:52+0000\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,23 +16,17 @@ 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'"
msgstr ""
-msgid "Internal data stream error."
-msgstr "S'ha produït un error intern de flux de dades."
-
msgid "Failed to decode JPEG image"
msgstr ""
+msgid "Internal data stream error."
+msgstr "S'ha produït un error intern de flux de dades."
+
msgid "Could not connect to server"
msgstr ""
@@ -541,121 +535,160 @@ 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' is busy"
msgstr ""
#, c-format
-msgid "Failed getting controls attributes on device '%s'."
+msgid "Device '%s' cannot capture at %dx%d"
msgstr ""
#, c-format
-msgid "Cannot identify device '%s'."
+msgid "Device '%s' cannot capture in the specified format"
msgstr ""
#, c-format
-msgid "This isn't a 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 "Could not open device '%s' for reading and writing."
+msgid "Got unexpected frame size of %u instead of %u."
msgstr ""
#, c-format
-msgid "Device '%s' is not a capture device."
+msgid "Failed trying to get video frames from device '%s'."
msgstr ""
#, c-format
-msgid "Device '%s' is not a output device."
+msgid "Failed after %d tries. device %s. system error: %s"
msgstr ""
#, c-format
-msgid "Failed to set norm for device '%s'."
+msgid "Failed to get settings of tuner %d on device '%s'."
msgstr ""
#, c-format
-msgid "Failed to get current tuner frequency for device '%s'."
+msgid "Error getting capabilities for device '%s'."
msgstr ""
#, c-format
-msgid "Failed to set current tuner frequency for device '%s' to %lu Hz."
+msgid "Device '%s' is not a tuner."
msgstr ""
#, c-format
-msgid "Failed to get signal strength for device '%s'."
+msgid "Failed to get radio input on device '%s'. "
msgstr ""
#, c-format
-msgid "Failed to get value for control %d on device '%s'."
+msgid "Failed to set input %d on device %s."
msgstr ""
#, c-format
-msgid "Failed to set value %d for control %d on device '%s'."
+msgid "Failed to change mute state for device '%s'."
msgstr ""
#, c-format
-msgid "Failed to get current input on device '%s'. May be it is a radio device"
+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 set input %d on device %s."
+msgid "Failed to query attributes of input %d in device %s"
msgstr ""
#, c-format
-msgid ""
-"Failed to get current output on device '%s'. May be it is a radio device"
+msgid "Failed to get setting of tuner %d on device '%s'."
msgstr ""
#, c-format
-msgid "Failed to set output %d on device %s."
+msgid "Failed to query norm on device '%s'."
msgstr ""
#, c-format
-msgid "Could not enqueue buffers in device '%s'."
+msgid "Failed getting controls attributes on device '%s'."
msgstr ""
#, c-format
-msgid "Failed trying to get video frames from device '%s'."
+msgid "Cannot identify device '%s'."
msgstr ""
#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
+msgid "This isn't a device '%s'."
msgstr ""
#, c-format
-msgid "Could not get parameters on device '%s'"
+msgid "Could not open device '%s' for reading and writing."
msgstr ""
-msgid "Video input device did not accept new frame rate setting."
+#, c-format
+msgid "Device '%s' is not a capture device."
msgstr ""
#, c-format
-msgid "Could not map buffers from device '%s'"
+msgid "Device '%s' is not a output device."
+msgstr ""
+
+#, c-format
+msgid "Failed to set norm for device '%s'."
+msgstr ""
+
+#, c-format
+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."
diff --git a/po/cs.po b/po/cs.po
index 9a92b87b9..6b1b29ca2 100644
--- 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-11-26 13:52+0000\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,23 +19,17 @@ 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'"
msgstr "\"%s\" od \"%s\""
-msgid "Internal data stream error."
-msgstr "Vnitřní chyba datového proudu."
-
msgid "Failed to decode JPEG image"
msgstr "Nezdařilo se dekódování obrázku JPEG"
+msgid "Internal data stream error."
+msgstr "Vnitřní chyba datového proudu."
+
msgid "Could not connect to server"
msgstr "Nezdařilo se spojení se serverem"
@@ -543,13 +537,84 @@ 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' is busy"
+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 +694,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 +704,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"
diff --git a/po/da.po b/po/da.po
index 1ee58b3d4..53e8f7941 100644
--- 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-11-26 13:52+0000\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,23 +21,17 @@ 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'"
msgstr "'%s' af '%s'"
-msgid "Internal data stream error."
-msgstr "Intern datastrømsfejl."
-
msgid "Failed to decode JPEG image"
msgstr "Mislykkedes i at afkode JPEG-billede"
+msgid "Internal data stream error."
+msgstr "Intern datastrømsfejl."
+
msgid "Could not connect to server"
msgstr "Kunne ikke forbinde til server"
@@ -550,6 +544,50 @@ 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' is busy"
+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 +595,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 +700,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 +709,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"
diff --git a/po/de.po b/po/de.po
index d02c6d9cf..439270366 100644
--- 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-11-26 13:52+0000\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,23 +26,17 @@ 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'"
msgstr "»%s« durch »%s«"
-msgid "Internal data stream error."
-msgstr "Interner Datenstromfehler."
-
msgid "Failed to decode JPEG image"
msgstr "Dekodieren des JPEG-Bildes schlug fehl"
+msgid "Internal data stream error."
+msgstr "Interner Datenstromfehler."
+
msgid "Could not connect to server"
msgstr "Verbindung zum Server konnte nicht hergestellt werden"
@@ -555,14 +549,93 @@ 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."
+
+#, fuzzy, c-format
+msgid "Device '%s' is busy"
+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 +715,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 +727,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 +734,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 +771,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."
diff --git a/po/el.po b/po/el.po
index 666c90bfd..4b101d232 100644
--- 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-11-26 13:52+0000\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,23 +18,17 @@ 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'"
msgstr "'%s' από '%s'"
-msgid "Internal data stream error."
-msgstr "ΕσωτεÏικό σφάλμα Ïοής δεδομένων."
-
msgid "Failed to decode JPEG image"
msgstr "Αποτυχία αποκωδικοποίησης της εικόνας JPEG"
+msgid "Internal data stream error."
+msgstr "ΕσωτεÏικό σφάλμα Ïοής δεδομένων."
+
msgid "Could not connect to server"
msgstr "Δεν ήταν δυνατή η σÏνδεση με τον διακομιστή"
@@ -545,12 +539,83 @@ 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' is busy"
+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 +695,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 +706,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 +713,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 "ΠεÏιγÏάφει το επιλεγμένο στοιχείο εισαγωγής."
diff --git a/po/en_GB.po b/po/en_GB.po
index 2568d35f1..ab190a2b1 100644
--- a/po/en_GB.po
+++ b/po/en_GB.po
@@ -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-11-26 13:52+0000\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,21 +15,15 @@ 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'"
msgstr ""
-msgid "Internal data stream error."
+msgid "Failed to decode JPEG image"
msgstr ""
-msgid "Failed to decode JPEG image"
+msgid "Internal data stream error."
msgstr ""
#, fuzzy
@@ -548,13 +542,83 @@ 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' is busy"
+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 +690,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 +698,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."
diff --git a/po/es.po b/po/es.po
index 2a66fc96f..58e2913e6 100644
--- 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-11-26 13:52+0000\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,23 +18,17 @@ 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'"
msgstr "«%s» por «%s»"
-msgid "Internal data stream error."
-msgstr "Error interno de flujo de datos."
-
msgid "Failed to decode JPEG image"
msgstr "Falló al decodificar la imagen JPEG"
+msgid "Internal data stream error."
+msgstr "Error interno de flujo de datos."
+
msgid "Could not connect to server"
msgstr "No se pudo conectar con el servidor"
@@ -548,13 +542,93 @@ 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."
+
+#, fuzzy, c-format
+msgid "Device '%s' is busy"
+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 +710,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 +720,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 +761,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»."
diff --git a/po/eu.po b/po/eu.po
index 710d817ce..e56b7bd46 100644
--- 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-11-26 13:52+0000\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,23 +19,17 @@ 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'"
msgstr "'%s' - '%s'"
-msgid "Internal data stream error."
-msgstr "Datu-korrontearen barne-errorea."
-
msgid "Failed to decode JPEG image"
msgstr "Huts egin du JPEG irudia deskodetzean"
+msgid "Internal data stream error."
+msgstr "Datu-korrontearen barne-errorea."
+
msgid "Could not connect to server"
msgstr "Ezin izan da konektatu zerbitzariarekin"
@@ -547,13 +541,89 @@ 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' is busy"
+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 +703,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 +714,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."
diff --git a/po/fi.po b/po/fi.po
index ff809c529..26d0b53aa 100644
--- 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-11-26 13:52+0000\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,23 +21,17 @@ 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'"
msgstr "â€%s†artistilta â€%sâ€"
-msgid "Internal data stream error."
-msgstr "Sisäisen tietovirran virhe."
-
msgid "Failed to decode JPEG image"
msgstr "JPEG-kuvan purku epäonnistui"
+msgid "Internal data stream error."
+msgstr "Sisäisen tietovirran virhe."
+
msgid "Could not connect to server"
msgstr "Palvelimeen ei saatu yhteyttä"
@@ -546,13 +540,84 @@ 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' is busy"
+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 +692,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 +703,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. "
diff --git a/po/fr.po b/po/fr.po
index c3a601310..4d75234bf 100644
--- 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-11-26 13:52+0000\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,24 +18,17 @@ 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'"
msgstr "« %s » par « %s »"
-msgid "Internal data stream error."
-msgstr "Erreur interne de flux de données."
-
msgid "Failed to decode JPEG image"
msgstr "Échec de décodage de l'image JPEG"
+msgid "Internal data stream error."
+msgstr "Erreur interne de flux de données."
+
msgid "Could not connect to server"
msgstr "Impossible de se connecter au serveur"
@@ -549,13 +542,91 @@ 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' is busy"
+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 +708,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 +718,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 +725,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"
diff --git a/po/gl.po b/po/gl.po
index c8f52a63b..0cefae46a 100644
--- 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-11-26 13:52+0000\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,23 +17,17 @@ 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'"
msgstr "«%s» por «%s»"
-msgid "Internal data stream error."
-msgstr "Produciuse un erro no fluxo de datos interno."
-
msgid "Failed to decode JPEG image"
msgstr "Produciuse un erro ao descodificar a imaxe JPEG"
+msgid "Internal data stream error."
+msgstr "Produciuse un erro no fluxo de datos interno."
+
msgid "Could not connect to server"
msgstr "Non foi posíbel conectarse ao servidor"
@@ -545,12 +539,94 @@ 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' is busy"
+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 +714,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 +724,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."
diff --git a/po/hu.po b/po/hu.po
index 10ca58135..be632f050 100644
--- 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-11-26 13:52+0000\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,23 +21,17 @@ 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'"
msgstr "„%s†ettÅ‘l: „%sâ€"
-msgid "Internal data stream error."
-msgstr "Belső adatfolyam-hiba."
-
msgid "Failed to decode JPEG image"
msgstr "A JPEG kép visszafejtése meghiúsult"
+msgid "Internal data stream error."
+msgstr "Belső adatfolyam-hiba."
+
msgid "Could not connect to server"
msgstr "Nem lehet csatlakozni a kiszolgálóhoz"
@@ -545,13 +539,89 @@ 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' is busy"
+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 +700,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 +711,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"
diff --git a/po/id.po b/po/id.po
index 194804bcc..1c6afd757 100644
--- 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-11-26 13:52+0000\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,23 +16,17 @@ 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'"
msgstr "'%s' oleh '%s'"
-msgid "Internal data stream error."
-msgstr "Galat arus data internal."
-
msgid "Failed to decode JPEG image"
msgstr "Gagal untuk mengawasandi citra JPEG"
+msgid "Internal data stream error."
+msgstr "Galat arus data internal."
+
msgid "Could not connect to server"
msgstr "Tak dapat menghubungi server"
@@ -540,12 +534,87 @@ 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."
+
+#, fuzzy, c-format
+msgid "Device '%s' is busy"
+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 +690,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 +699,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 +740,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'."
diff --git a/po/it.po b/po/it.po
index 7b5c907c4..e0452fd0d 100644
--- 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-11-26 13:52+0000\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,23 +16,17 @@ 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'"
msgstr "«%s» di «%s»"
-msgid "Internal data stream error."
-msgstr "Errore interno nello stream dei dati."
-
msgid "Failed to decode JPEG image"
msgstr "Decodifica dell'immagine JPEG non riuscita"
+msgid "Internal data stream error."
+msgstr "Errore interno nello stream dei dati."
+
msgid "Could not connect to server"
msgstr "Impossibile connettersi al server"
@@ -549,12 +543,86 @@ 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' is busy"
+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 +712,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 +723,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"
diff --git a/po/ja.po b/po/ja.po
index 18c09ad94..35b8a87e7 100644
--- 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-11-26 13:52+0000\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,23 +18,17 @@ 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'"
msgstr ""
-msgid "Internal data stream error."
-msgstr "内部データストリームエラー"
-
msgid "Failed to decode JPEG image"
msgstr "JPEGç”»åƒã®ãƒ‡ã‚³ãƒ¼ãƒ‰ã«å¤±æ•—ã—ã¾ã—ãŸ"
+msgid "Internal data stream error."
+msgstr "内部データストリームエラー"
+
msgid "Could not connect to server"
msgstr "サーãƒãƒ¼ã¸æŽ¥ç¶šã§ãã¾ã›ã‚“"
@@ -574,12 +568,88 @@ 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' ã¯å‡ºåŠ›ãƒ‡ãƒã‚¤ã‚¹ã§ã¯ã‚ã‚Šã¾ã›ã‚“"
+
+#, fuzzy, c-format
+msgid "Device '%s' is busy"
+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 +728,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 +739,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 +764,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' ã‹ã‚‰ãƒãƒƒãƒ•ã‚¡ã‚’å–å¾—ã§ãã¾ã›ã‚“ã§ã—ãŸã€‚"
diff --git a/po/lt.po b/po/lt.po
index 78e5013e1..c28564494 100644
--- 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-11-26 13:52+0000\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,23 +19,17 @@ 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'"
msgstr "„%s“ atlieka „%s“"
-msgid "Internal data stream error."
-msgstr "Vidinė duomenų srauto klaida."
-
msgid "Failed to decode JPEG image"
msgstr "Nepavyko dekoduoti JPEG paveikslÄ—lio"
+msgid "Internal data stream error."
+msgstr "Vidinė duomenų srauto klaida."
+
msgid "Could not connect to server"
msgstr "Nepavyko prisijungti prie serverio"
@@ -542,12 +536,83 @@ 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' is busy"
+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 +688,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 +699,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ą."
diff --git a/po/lv.po b/po/lv.po
index ef270e41c..af5e9adcd 100644
--- 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-11-26 13:52+0000\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,23 +19,17 @@ 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'"
msgstr "\"%s\"ko \"%s\""
-msgid "Internal data stream error."
-msgstr "IekÅ¡Ä“jÄs datu plÅ«smas kļūda."
-
msgid "Failed to decode JPEG image"
msgstr "NeizdevÄs atkodÄ“t JPEG attÄ“lu"
+msgid "Internal data stream error."
+msgstr "IekÅ¡Ä“jÄs datu plÅ«smas kļūda."
+
msgid "Could not connect to server"
msgstr "Nevar savienoties ar serveri"
@@ -543,13 +537,86 @@ 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' is busy"
+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 +692,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 +703,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"
diff --git a/po/mt.po b/po/mt.po
index 96935f14c..898592dcf 100644
--- 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-11-26 13:52+0000\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,23 +16,17 @@ 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'"
msgstr ""
-msgid "Internal data stream error."
-msgstr "Problema interna fid-data stream"
-
msgid "Failed to decode JPEG image"
msgstr "Problem fid-decoding tal-istampa JPEG"
+msgid "Internal data stream error."
+msgstr "Problema interna fid-data stream"
+
msgid "Could not connect to server"
msgstr "Mhux possibli naqbad mas-server"
@@ -574,13 +568,87 @@ 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."
+
+#, fuzzy, c-format
+msgid "Device '%s' is busy"
+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 +725,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 +736,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 +767,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 +788,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."
diff --git a/po/nb.po b/po/nb.po
index 595d485b9..525b345ae 100644
--- 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-11-26 13:52+0000\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,23 +15,17 @@ 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'"
msgstr "«%s» av «%s»"
-msgid "Internal data stream error."
-msgstr "Intern feil i datastrøm."
-
msgid "Failed to decode JPEG image"
msgstr "Klarte ikke å dekode JPEG-bilde"
+msgid "Internal data stream error."
+msgstr "Intern feil i datastrøm."
+
msgid "Could not connect to server"
msgstr "Kunne ikke koble til tjener."
@@ -524,11 +518,81 @@ 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' is busy"
+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 "Error reading %d bytes on device '%s'."
+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 "Failed to change mute state for device '%s'."
msgstr "Kunne ikke lukke VFS-fil «%s»."
#, c-format
@@ -602,10 +666,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 +674,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."
diff --git a/po/nl.po b/po/nl.po
index 778380ecc..831353331 100644
--- 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-11-26 13:52+0000\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,23 +17,17 @@ 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'"
msgstr "'%s' door '%s'"
-msgid "Internal data stream error."
-msgstr "Interne fout in gegevensstroom."
-
msgid "Failed to decode JPEG image"
msgstr "Kan de JPEG-afbeelding niet decoderen"
+msgid "Internal data stream error."
+msgstr "Interne fout in gegevensstroom."
+
msgid "Could not connect to server"
msgstr "Kan geen verbinding maken met server"
@@ -543,13 +537,87 @@ 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' is busy"
+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 +694,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 +704,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"
diff --git a/po/or.po b/po/or.po
index 6528dea00..eed7b806a 100644
--- 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-11-26 13:52+0000\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,21 +17,15 @@ 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'"
msgstr ""
-msgid "Internal data stream error."
+msgid "Failed to decode JPEG image"
msgstr ""
-msgid "Failed to decode JPEG image"
+msgid "Internal data stream error."
msgstr ""
#, fuzzy
@@ -550,13 +544,83 @@ 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' is busy"
+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 +692,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 +700,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 +707,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'."
diff --git a/po/pl.po b/po/pl.po
index 64a7f36fc..ac7bc800f 100644
--- 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-11-26 13:52+0000\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,23 +15,17 @@ 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'"
msgstr "'%s' autorstwa '%s'"
-msgid "Internal data stream error."
-msgstr "Błąd wewnętrzny strumienia danych."
-
msgid "Failed to decode JPEG image"
msgstr "Nie udało się zdekodować obrazu JPEG"
+msgid "Internal data stream error."
+msgstr "Błąd wewnętrzny strumienia danych."
+
msgid "Could not connect to server"
msgstr "Nie udało się połączyć z serwerem"
@@ -538,13 +532,88 @@ 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' is busy"
+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 +691,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 +700,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"
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 534a4fb12..14e857ddb 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -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-11-26 13:52+0000\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,23 +21,17 @@ 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'"
msgstr "\"%s\" por \"%s\""
-msgid "Internal data stream error."
-msgstr "Erro interno no fluxo de dados."
-
msgid "Failed to decode JPEG image"
msgstr "Falha ao decodificar a imagem JPEG"
+msgid "Internal data stream error."
+msgstr "Erro interno no fluxo de dados."
+
msgid "Could not connect to server"
msgstr "Não foi possível conectar ao servidor"
@@ -548,12 +542,89 @@ 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' is busy"
+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 +703,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 +713,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"
diff --git a/po/ro.po b/po/ro.po
index dc0db8c18..664848439 100644
--- 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-11-26 13:52+0000\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,23 +18,17 @@ 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'"
msgstr "„%s†de „%sâ€"
-msgid "Internal data stream error."
-msgstr "Eroare internă a fluxului de date."
-
msgid "Failed to decode JPEG image"
msgstr "Nu s-a putut decoda imaginea JPEG"
+msgid "Internal data stream error."
+msgstr "Eroare internă a fluxului de date."
+
msgid "Could not connect to server"
msgstr "Nu se poate stabili o conexiune la server"
@@ -547,12 +541,89 @@ 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' is busy"
+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 +703,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 +714,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"
diff --git a/po/ru.po b/po/ru.po
index 83f867a51..838f3ff8a 100644
--- 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-11-26 13:52+0000\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,23 +20,17 @@ 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'"
msgstr "«%s» иÑполнÑет «%s»"
-msgid "Internal data stream error."
-msgstr "ВнутреннÑÑ Ð¾ÑˆÐ¸Ð±ÐºÐ° потока данных."
-
msgid "Failed to decode JPEG image"
msgstr "Ðе удалоÑÑŒ декодировать JPEG-изображение"
+msgid "Internal data stream error."
+msgstr "ВнутреннÑÑ Ð¾ÑˆÐ¸Ð±ÐºÐ° потока данных."
+
msgid "Could not connect to server"
msgstr "Ðе удалоÑÑŒ ÑоединитьÑÑ Ñ Ñервером"
@@ -545,13 +539,88 @@ 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» не ÑвлÑетÑÑ ÑƒÑтройÑтвом вывода."
+
+#, fuzzy, c-format
+msgid "Device '%s' is busy"
+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 +697,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 +707,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 +715,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 +750,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»"
diff --git a/po/sk.po b/po/sk.po
index d04bc76c7..4433fbbb4 100644
--- 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-11-26 13:52+0000\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,23 +18,17 @@ 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'"
msgstr "'%s' od '%s'"
-msgid "Internal data stream error."
-msgstr "Vnútorná chyba prúdu údajov."
-
msgid "Failed to decode JPEG image"
msgstr "Nepodarilo sa dekódovať obrázok JPEG"
+msgid "Internal data stream error."
+msgstr "Vnútorná chyba prúdu údajov."
+
msgid "Could not connect to server"
msgstr "Nepodarilo sa pripojiť k serveru"
@@ -541,13 +535,89 @@ 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."
+
+#, fuzzy, c-format
+msgid "Device '%s' is busy"
+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 +695,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 +705,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 +749,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'."
diff --git a/po/sl.po b/po/sl.po
index 414796f43..d171468a7 100644
--- 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-11-26 13:52+0000\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,23 +23,17 @@ 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'"
msgstr "'%s' - '%s'"
-msgid "Internal data stream error."
-msgstr "Notranja napaka pretoka podatkov."
-
msgid "Failed to decode JPEG image"
msgstr "Odkodiranje slike JPEG je spodletelo"
+msgid "Internal data stream error."
+msgstr "Notranja napaka pretoka podatkov."
+
msgid "Could not connect to server"
msgstr "S strežnikom se ni mogoÄe povezati"
@@ -546,13 +540,86 @@ 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' is busy"
+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 +698,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 +708,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."
diff --git a/po/sq.po b/po/sq.po
index 309b07223..0350c1e9b 100644
--- 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-11-26 13:52+0000\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,21 +15,15 @@ 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'"
msgstr ""
-msgid "Internal data stream error."
+msgid "Failed to decode JPEG image"
msgstr ""
-msgid "Failed to decode JPEG image"
+msgid "Internal data stream error."
msgstr ""
#, fuzzy
@@ -548,13 +542,83 @@ 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' is busy"
+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 +690,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 +698,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."
diff --git a/po/sr.po b/po/sr.po
index 2aec60b30..448287ca3 100644
--- 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-11-26 13:52+0000\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,21 +17,15 @@ 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'"
msgstr ""
-msgid "Internal data stream error."
+msgid "Failed to decode JPEG image"
msgstr ""
-msgid "Failed to decode JPEG image"
+msgid "Internal data stream error."
msgstr ""
#, fuzzy
@@ -549,13 +543,83 @@ 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' is busy"
+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 +691,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 +699,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“ ради упиÑа."
diff --git a/po/sv.po b/po/sv.po
index 1eca3918a..9ee41698e 100644
--- 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-11-26 13:52+0000\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,23 +17,17 @@ 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'"
msgstr "\"%s\" av \"%s\""
-msgid "Internal data stream error."
-msgstr "Internt fel i dataström."
-
msgid "Failed to decode JPEG image"
msgstr "Misslyckades med att avkoda JPEG-bild"
+msgid "Internal data stream error."
+msgstr "Internt fel i dataström."
+
msgid "Could not connect to server"
msgstr "Kunde inte ansluta till servern"
@@ -542,12 +536,87 @@ 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."
+
+#, fuzzy, c-format
+msgid "Device '%s' is busy"
+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 +699,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 +709,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 +748,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\"."
diff --git a/po/tr.po b/po/tr.po
index 747b3e465..1f8fdccd2 100644
--- 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-11-26 13:52+0000\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,23 +15,17 @@ 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'"
msgstr "'%s' tarafından '%s'"
-msgid "Internal data stream error."
-msgstr "İç veri akım hatası."
-
msgid "Failed to decode JPEG image"
msgstr "JPEG görüntüsünü çözümlenemedi"
+msgid "Internal data stream error."
+msgstr "İç veri akım hatası."
+
msgid "Could not connect to server"
msgstr "Sunucuya bağlanamıyor"
@@ -535,12 +529,87 @@ 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."
+
+#, fuzzy, c-format
+msgid "Device '%s' is busy"
+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 +685,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 +694,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 +732,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."
diff --git a/po/uk.po b/po/uk.po
index 3bc721d79..26fb592e9 100644
--- 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-11-26 13:52+0000\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,23 +19,17 @@ 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'"
msgstr "«%s» виконує %s"
-msgid "Internal data stream error."
-msgstr "Ð’Ð½ÑƒÑ‚Ñ€Ñ–ÑˆÐ½Ñ Ð¿Ð¾Ð¼Ð¸Ð»ÐºÐ° потоку даних."
-
msgid "Failed to decode JPEG image"
msgstr "Помилка при декодуванні Ð·Ð¾Ð±Ñ€Ð°Ð¶ÐµÐ½Ð½Ñ JPEG"
+msgid "Internal data stream error."
+msgstr "Ð’Ð½ÑƒÑ‚Ñ€Ñ–ÑˆÐ½Ñ Ð¿Ð¾Ð¼Ð¸Ð»ÐºÐ° потоку даних."
+
msgid "Could not connect to server"
msgstr "Ðе вдалоÑÑ Ð·'єднатиÑÑŒ з Ñервером"
@@ -546,12 +540,86 @@ 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» не Ñ” приÑтроєм Ð²Ð¸Ð²ÐµÐ´ÐµÐ½Ð½Ñ Ð´Ð°Ð½Ð¸Ñ…."
+
+#, fuzzy, c-format
+msgid "Device '%s' is busy"
+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 +697,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 +707,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 +737,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 +759,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\"."
diff --git a/po/vi.po b/po/vi.po
index 1bce35d27..075be60ac 100644
--- 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-11-26 13:52+0000\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,23 +18,17 @@ 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'"
msgstr "« %s » bởi « %s »"
-msgid "Internal data stream error."
-msgstr "Lỗi luồng dữ liệu nội bộ."
-
msgid "Failed to decode JPEG image"
msgstr "Lỗi giải mã ảnh JPEG"
+msgid "Internal data stream error."
+msgstr "Lỗi luồng dữ liệu nội bộ."
+
msgid "Could not connect to server"
msgstr "Không thể kết nối tới máy phục vụ"
@@ -543,12 +537,87 @@ 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' is busy"
+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 +694,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 +704,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"
diff --git a/po/zh_CN.po b/po/zh_CN.po
index 4c053e9f7..d1cc3afed 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -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-11-26 13:52+0000\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,23 +16,17 @@ 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'"
msgstr "‘%s’ 由 ‘%s’"
-msgid "Internal data stream error."
-msgstr "内部数æ®æµé”™è¯¯ã€‚"
-
msgid "Failed to decode JPEG image"
msgstr "è§£ç  JPEG 图åƒå‡ºé”™"
+msgid "Internal data stream error."
+msgstr "内部数æ®æµé”™è¯¯ã€‚"
+
msgid "Could not connect to server"
msgstr "无法连接至æœåŠ¡å™¨"
@@ -555,12 +549,83 @@ 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’ä¸æ˜¯è¾“出设备。"
+
+#, fuzzy, c-format
+msgid "Device '%s' is busy"
+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 +697,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 +706,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 +742,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’中获å–缓冲区。"
diff --git a/po/zh_HK.po b/po/zh_HK.po
index 78913ad8c..39cda3c31 100644
--- a/po/zh_HK.po
+++ b/po/zh_HK.po
@@ -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-11-26 13:52+0000\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,23 +15,17 @@ 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'"
msgstr ""
-msgid "Internal data stream error."
-msgstr "內部資料串æµç™¼ç”ŸéŒ¯èª¤ã€‚"
-
msgid "Failed to decode JPEG image"
msgstr ""
+msgid "Internal data stream error."
+msgstr "內部資料串æµç™¼ç”ŸéŒ¯èª¤ã€‚"
+
msgid "Could not connect to server"
msgstr ""
@@ -545,121 +539,160 @@ 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' is busy"
msgstr ""
#, c-format
-msgid "Failed getting controls attributes on device '%s'."
+msgid "Device '%s' cannot capture at %dx%d"
msgstr ""
#, c-format
-msgid "Cannot identify device '%s'."
+msgid "Device '%s' cannot capture in the specified format"
msgstr ""
#, c-format
-msgid "This isn't a 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 "Could not open device '%s' for reading and writing."
+msgid "Got unexpected frame size of %u instead of %u."
msgstr ""
#, c-format
-msgid "Device '%s' is not a capture device."
+msgid "Failed trying to get video frames from device '%s'."
msgstr ""
#, c-format
-msgid "Device '%s' is not a output device."
+msgid "Failed after %d tries. device %s. system error: %s"
msgstr ""
#, c-format
-msgid "Failed to set norm for device '%s'."
+msgid "Failed to get settings of tuner %d on device '%s'."
msgstr ""
#, c-format
-msgid "Failed to get current tuner frequency for device '%s'."
+msgid "Error getting capabilities for device '%s'."
msgstr ""
#, c-format
-msgid "Failed to set current tuner frequency for device '%s' to %lu Hz."
+msgid "Device '%s' is not a tuner."
msgstr ""
#, c-format
-msgid "Failed to get signal strength for device '%s'."
+msgid "Failed to get radio input on device '%s'. "
msgstr ""
#, c-format
-msgid "Failed to get value for control %d on device '%s'."
+msgid "Failed to set input %d on device %s."
msgstr ""
#, c-format
-msgid "Failed to set value %d for control %d on device '%s'."
+msgid "Failed to change mute state for device '%s'."
msgstr ""
#, c-format
-msgid "Failed to get current input on device '%s'. May be it is a radio device"
+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 set input %d on device %s."
+msgid "Failed to query attributes of input %d in device %s"
msgstr ""
#, c-format
-msgid ""
-"Failed to get current output on device '%s'. May be it is a radio device"
+msgid "Failed to get setting of tuner %d on device '%s'."
msgstr ""
#, c-format
-msgid "Failed to set output %d on device %s."
+msgid "Failed to query norm on device '%s'."
msgstr ""
#, c-format
-msgid "Could not enqueue buffers in device '%s'."
+msgid "Failed getting controls attributes on device '%s'."
msgstr ""
#, c-format
-msgid "Failed trying to get video frames from device '%s'."
+msgid "Cannot identify device '%s'."
msgstr ""
#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
+msgid "This isn't a device '%s'."
msgstr ""
#, c-format
-msgid "Could not get parameters on device '%s'"
+msgid "Could not open device '%s' for reading and writing."
msgstr ""
-msgid "Video input device did not accept new frame rate setting."
+#, c-format
+msgid "Device '%s' is not a capture device."
msgstr ""
#, c-format
-msgid "Could not map buffers from device '%s'"
+msgid "Device '%s' is not a output device."
+msgstr ""
+
+#, c-format
+msgid "Failed to set norm for device '%s'."
+msgstr ""
+
+#, c-format
+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."
diff --git a/po/zh_TW.po b/po/zh_TW.po
index f87df80d2..99f9b899b 100644
--- a/po/zh_TW.po
+++ b/po/zh_TW.po
@@ -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-11-26 13:52+0000\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,23 +15,17 @@ 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'"
msgstr ""
-msgid "Internal data stream error."
-msgstr "內部資料串æµç™¼ç”ŸéŒ¯èª¤ã€‚"
-
msgid "Failed to decode JPEG image"
msgstr ""
+msgid "Internal data stream error."
+msgstr "內部資料串æµç™¼ç”ŸéŒ¯èª¤ã€‚"
+
msgid "Could not connect to server"
msgstr ""
@@ -545,121 +539,160 @@ 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' is busy"
msgstr ""
#, c-format
-msgid "Failed getting controls attributes on device '%s'."
+msgid "Device '%s' cannot capture at %dx%d"
msgstr ""
#, c-format
-msgid "Cannot identify device '%s'."
+msgid "Device '%s' cannot capture in the specified format"
msgstr ""
#, c-format
-msgid "This isn't a 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 "Could not open device '%s' for reading and writing."
+msgid "Got unexpected frame size of %u instead of %u."
msgstr ""
#, c-format
-msgid "Device '%s' is not a capture device."
+msgid "Failed trying to get video frames from device '%s'."
msgstr ""
#, c-format
-msgid "Device '%s' is not a output device."
+msgid "Failed after %d tries. device %s. system error: %s"
msgstr ""
#, c-format
-msgid "Failed to set norm for device '%s'."
+msgid "Failed to get settings of tuner %d on device '%s'."
msgstr ""
#, c-format
-msgid "Failed to get current tuner frequency for device '%s'."
+msgid "Error getting capabilities for device '%s'."
msgstr ""
#, c-format
-msgid "Failed to set current tuner frequency for device '%s' to %lu Hz."
+msgid "Device '%s' is not a tuner."
msgstr ""
#, c-format
-msgid "Failed to get signal strength for device '%s'."
+msgid "Failed to get radio input on device '%s'. "
msgstr ""
#, c-format
-msgid "Failed to get value for control %d on device '%s'."
+msgid "Failed to set input %d on device %s."
msgstr ""
#, c-format
-msgid "Failed to set value %d for control %d on device '%s'."
+msgid "Failed to change mute state for device '%s'."
msgstr ""
#, c-format
-msgid "Failed to get current input on device '%s'. May be it is a radio device"
+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 set input %d on device %s."
+msgid "Failed to query attributes of input %d in device %s"
msgstr ""
#, c-format
-msgid ""
-"Failed to get current output on device '%s'. May be it is a radio device"
+msgid "Failed to get setting of tuner %d on device '%s'."
msgstr ""
#, c-format
-msgid "Failed to set output %d on device %s."
+msgid "Failed to query norm on device '%s'."
msgstr ""
#, c-format
-msgid "Could not enqueue buffers in device '%s'."
+msgid "Failed getting controls attributes on device '%s'."
msgstr ""
#, c-format
-msgid "Failed trying to get video frames from device '%s'."
+msgid "Cannot identify device '%s'."
msgstr ""
#, c-format
-msgid "Failed after %d tries. device %s. system error: %s"
+msgid "This isn't a device '%s'."
msgstr ""
#, c-format
-msgid "Could not get parameters on device '%s'"
+msgid "Could not open device '%s' for reading and writing."
msgstr ""
-msgid "Video input device did not accept new frame rate setting."
+#, c-format
+msgid "Device '%s' is not a capture device."
msgstr ""
#, c-format
-msgid "Could not map buffers from device '%s'"
+msgid "Device '%s' is not a output device."
+msgstr ""
+
+#, c-format
+msgid "Failed to set norm for device '%s'."
+msgstr ""
+
+#, c-format
+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."
diff --git a/sys/directsound/gstdirectsoundsink.c b/sys/directsound/gstdirectsoundsink.c
index 2f9a04c65..fc766e5a1 100644
--- a/sys/directsound/gstdirectsoundsink.c
+++ b/sys/directsound/gstdirectsoundsink.c
@@ -92,7 +92,8 @@ static void gst_directsound_sink_interfaces_init (GType type);
static void
gst_directsound_sink_implements_interface_init (GstImplementsInterfaceClass *
iface);
-static void gst_directsound_sink_mixer_interface_init (GstMixerClass * iface);
+static void gst_directsound_sink_mixer_interface_init (GstMixerInterface *
+ iface);
static GstStaticPadTemplate directsoundsink_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink",
@@ -223,7 +224,7 @@ gst_directsound_sink_mixer_get_volume (GstMixer * mixer,
}
static void
-gst_directsound_sink_mixer_interface_init (GstMixerClass * iface)
+gst_directsound_sink_mixer_interface_init (GstMixerInterface * iface)
{
/* the mixer interface requires a definition of the mixer type:
* hardware or software? */
@@ -260,8 +261,8 @@ gst_directsound_sink_base_init (gpointer g_class)
"Direct Sound Audio Sink", "Sink/Audio",
"Output to a sound card via Direct Sound",
"Sebastien Moutte <sebastien@moutte.net>");
- gst_element_class_add_static_pad_template (element_class,
- &directsoundsink_sink_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&directsoundsink_sink_factory));
}
static void
diff --git a/sys/oss/gstosshelper.c b/sys/oss/gstosshelper.c
index 6d7e6bd3e..639ee9d8f 100644
--- a/sys/oss/gstosshelper.c
+++ b/sys/oss/gstosshelper.c
@@ -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;
}
diff --git a/sys/oss/gstossmixer.h b/sys/oss/gstossmixer.h
index d2e06fed9..4ae888aba 100644
--- a/sys/oss/gstossmixer.h
+++ b/sys/oss/gstossmixer.h
@@ -152,16 +152,16 @@ interface_as_function ## _set_mute (GstMixer * mixer, GstMixerTrack * track,
} \
\
static void \
-interface_as_function ## _interface_init (GstMixerClass * klass) \
+interface_as_function ## _interface_init (GstMixerInterface * iface) \
{ \
- GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE; \
+ GST_MIXER_TYPE (iface) = GST_MIXER_HARDWARE; \
\
/* set up the interface hooks */ \
- klass->list_tracks = interface_as_function ## _list_tracks; \
- klass->set_volume = interface_as_function ## _set_volume; \
- klass->get_volume = interface_as_function ## _get_volume; \
- klass->set_mute = interface_as_function ## _set_mute; \
- klass->set_record = interface_as_function ## _set_record; \
+ iface->list_tracks = interface_as_function ## _list_tracks; \
+ iface->set_volume = interface_as_function ## _set_volume; \
+ iface->get_volume = interface_as_function ## _get_volume; \
+ iface->set_mute = interface_as_function ## _set_mute; \
+ iface->set_record = interface_as_function ## _set_record; \
}
diff --git a/sys/oss/gstosssink.c b/sys/oss/gstosssink.c
index a604d9c3a..6a8046d07 100644
--- a/sys/oss/gstosssink.c
+++ b/sys/oss/gstosssink.c
@@ -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 ]")
);
@@ -181,8 +175,8 @@ gst_oss_sink_base_init (gpointer g_class)
"Erik Walthinsen <omega@cse.ogi.edu>, "
"Wim Taymans <wim.taymans@chello.be>");
- gst_element_class_add_static_pad_template (element_class,
- &osssink_sink_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&osssink_sink_factory));
}
static void
diff --git a/sys/oss/gstosssrc.c b/sys/oss/gstosssrc.c
index 2bd931b1b..bdadbbc8d 100644
--- a/sys/oss/gstosssrc.c
+++ b/sys/oss/gstosssrc.c
@@ -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)
{
@@ -136,8 +127,8 @@ gst_oss_src_base_init (gpointer g_class)
"Capture from a sound card via OSS",
"Erik Walthinsen <omega@cse.ogi.edu>, " "Wim Taymans <wim@fluendo.com>");
- gst_element_class_add_static_pad_template (element_class,
- &osssrc_src_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&osssrc_src_factory));
}
static void
diff --git a/sys/oss4/oss4-mixer-slider.c b/sys/oss4/oss4-mixer-slider.c
index ea2bc8cb2..e71d1348f 100644
--- a/sys/oss4/oss4-mixer-slider.c
+++ b/sys/oss4/oss4-mixer-slider.c
@@ -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 */
diff --git a/sys/oss4/oss4-mixer.c b/sys/oss4/oss4-mixer.c
index fa81eccca..e190987d6 100644
--- a/sys/oss4/oss4-mixer.c
+++ b/sys/oss4/oss4-mixer.c
@@ -1800,18 +1800,18 @@ gst_oss4_mixer_get_mixer_flags (GstMixer * mixer)
}
static void
-gst_oss4_mixer_interface_init (GstMixerClass * klass)
+gst_oss4_mixer_interface_init (GstMixerInterface * iface)
{
- GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE;
-
- klass->list_tracks = gst_oss4_mixer_list_tracks;
- klass->set_volume = gst_oss4_mixer_set_volume;
- klass->get_volume = gst_oss4_mixer_get_volume;
- klass->set_mute = gst_oss4_mixer_set_mute;
- klass->set_record = gst_oss4_mixer_set_record;
- klass->set_option = gst_oss4_mixer_set_option;
- klass->get_option = gst_oss4_mixer_get_option;
- klass->get_mixer_flags = gst_oss4_mixer_get_mixer_flags;
+ GST_MIXER_TYPE (iface) = GST_MIXER_HARDWARE;
+
+ iface->list_tracks = gst_oss4_mixer_list_tracks;
+ iface->set_volume = gst_oss4_mixer_set_volume;
+ iface->get_volume = gst_oss4_mixer_get_volume;
+ iface->set_mute = gst_oss4_mixer_set_mute;
+ iface->set_record = gst_oss4_mixer_set_record;
+ iface->set_option = gst_oss4_mixer_set_option;
+ iface->get_option = gst_oss4_mixer_get_option;
+ iface->get_mixer_flags = gst_oss4_mixer_get_mixer_flags;
}
/* Implement the horror that is GstImplementsInterface */
diff --git a/sys/oss4/oss4-sink.c b/sys/oss4/oss4-sink.c
index de2d8a99d..1d2220b4b 100644
--- a/sys/oss4/oss4-sink.c
+++ b/sys/oss4/oss4-sink.c
@@ -134,7 +134,6 @@ gst_oss4_sink_base_init (gpointer g_class)
templ = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
gst_oss4_audio_get_template_caps ());
gst_element_class_add_pad_template (element_class, templ);
- gst_object_unref (templ);
}
static void
diff --git a/sys/oss4/oss4-source.c b/sys/oss4/oss4-source.c
index bb6459399..41e1f852e 100644
--- a/sys/oss4/oss4-source.c
+++ b/sys/oss4/oss4-source.c
@@ -115,7 +115,6 @@ gst_oss4_source_base_init (gpointer g_class)
templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
gst_oss4_audio_get_template_caps ());
gst_element_class_add_pad_template (element_class, templ);
- gst_object_unref (templ);
}
static void
@@ -936,15 +935,15 @@ gst_oss4_source_mixer_set_mute (GstMixer * mixer, GstMixerTrack * track,
}
static void
-gst_oss4_source_mixer_interface_init (GstMixerClass * klass)
+gst_oss4_source_mixer_interface_init (GstMixerInterface * iface)
{
- GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE;
+ GST_MIXER_TYPE (iface) = GST_MIXER_HARDWARE;
- klass->list_tracks = gst_oss4_source_mixer_list_tracks;
- klass->set_volume = gst_oss4_source_mixer_set_volume;
- klass->get_volume = gst_oss4_source_mixer_get_volume;
- klass->set_mute = gst_oss4_source_mixer_set_mute;
- klass->set_record = gst_oss4_source_mixer_set_record;
+ iface->list_tracks = gst_oss4_source_mixer_list_tracks;
+ iface->set_volume = gst_oss4_source_mixer_set_volume;
+ iface->get_volume = gst_oss4_source_mixer_get_volume;
+ iface->set_mute = gst_oss4_source_mixer_set_mute;
+ iface->set_record = gst_oss4_source_mixer_set_record;
}
/* Implement the horror that is GstImplementsInterface */
diff --git a/sys/osxaudio/gstosxaudioelement.c b/sys/osxaudio/gstosxaudioelement.c
index a41f4b877..16cee0fd0 100644
--- a/sys/osxaudio/gstosxaudioelement.c
+++ b/sys/osxaudio/gstosxaudioelement.c
@@ -50,7 +50,7 @@
#include "gstosxaudioelement.h"
static void
-gst_osx_audio_element_class_init (GstOsxAudioElementInterface * klass);
+gst_osx_audio_element_interface_init (GstOsxAudioElementInterface * iface);
GType
gst_osx_audio_element_get_type (void)
@@ -60,7 +60,7 @@ gst_osx_audio_element_get_type (void)
if (!gst_osxaudioelement_type) {
static const GTypeInfo gst_osxaudioelement_info = {
sizeof (GstOsxAudioElementInterface),
- (GBaseInitFunc) gst_osx_audio_element_class_init,
+ (GBaseInitFunc) gst_osx_audio_element_interface_init,
NULL,
NULL,
NULL,
@@ -79,7 +79,7 @@ gst_osx_audio_element_get_type (void)
}
static void
-gst_osx_audio_element_class_init (GstOsxAudioElementInterface * klass)
+gst_osx_audio_element_interface_init (GstOsxAudioElementInterface * iface)
{
static gboolean initialized = FALSE;
@@ -88,5 +88,5 @@ gst_osx_audio_element_class_init (GstOsxAudioElementInterface * klass)
}
/* default virtual functions */
- klass->io_proc = NULL;
+ iface->io_proc = NULL;
}
diff --git a/sys/osxaudio/gstosxaudiosink.c b/sys/osxaudio/gstosxaudiosink.c
index cd456e597..e3ade7011 100644
--- a/sys/osxaudio/gstosxaudiosink.c
+++ b/sys/osxaudio/gstosxaudiosink.c
@@ -142,7 +142,8 @@ gst_osx_audio_sink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class, &sink_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_factory));
gst_element_class_set_details_simple (element_class, "Audio Sink (OSX)",
"Sink/Audio",
diff --git a/sys/osxaudio/gstosxaudiosrc.c b/sys/osxaudio/gstosxaudiosrc.c
index 7e9ad245b..2bb21a79b 100644
--- a/sys/osxaudio/gstosxaudiosrc.c
+++ b/sys/osxaudio/gstosxaudiosrc.c
@@ -133,7 +133,8 @@ gst_osx_audio_src_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class, &src_factory);
+ 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 (OSX)",
"Source/Audio",
diff --git a/sys/osxvideo/osxvideosink.m b/sys/osxvideo/osxvideosink.m
index 59145503e..4c325278f 100644
--- a/sys/osxvideo/osxvideosink.m
+++ b/sys/osxvideo/osxvideosink.m
@@ -354,8 +354,8 @@ gst_osx_video_sink_base_init (gpointer g_class)
"Sink/Video", "OSX native videosink",
"Zaheer Abbas Merali <zaheerabbas at merali dot org>");
- gst_element_class_add_static_pad_template (element_class,
- &gst_osx_video_sink_sink_template_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_osx_video_sink_sink_template_factory));
}
static void
diff --git a/sys/sunaudio/gstsunaudiomixerctrl.h b/sys/sunaudio/gstsunaudiomixerctrl.h
index d38f02f25..2ca17f0ed 100644
--- a/sys/sunaudio/gstsunaudiomixerctrl.h
+++ b/sys/sunaudio/gstsunaudiomixerctrl.h
@@ -169,19 +169,19 @@ interface_as_function ## _get_mixer_flags (GstMixer * mixer)
} \
\
static void \
-interface_as_function ## _interface_init (GstMixerClass * klass) \
+interface_as_function ## _interface_init (GstMixerInterface * iface) \
{ \
- GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE; \
+ GST_MIXER_TYPE (iface) = GST_MIXER_HARDWARE; \
\
/* set up the interface hooks */ \
- klass->list_tracks = interface_as_function ## _list_tracks; \
- klass->set_volume = interface_as_function ## _set_volume; \
- klass->get_volume = interface_as_function ## _get_volume; \
- klass->set_mute = interface_as_function ## _set_mute; \
- klass->set_record = interface_as_function ## _set_record; \
- klass->get_option = interface_as_function ## _get_option; \
- klass->set_option = interface_as_function ## _set_option; \
- klass->get_mixer_flags = interface_as_function ## _get_mixer_flags; \
+ iface->list_tracks = interface_as_function ## _list_tracks; \
+ iface->set_volume = interface_as_function ## _set_volume; \
+ iface->get_volume = interface_as_function ## _get_volume; \
+ iface->set_mute = interface_as_function ## _set_mute; \
+ iface->set_record = interface_as_function ## _set_record; \
+ iface->get_option = interface_as_function ## _get_option; \
+ iface->set_option = interface_as_function ## _set_option; \
+ iface->get_mixer_flags = interface_as_function ## _get_mixer_flags; \
}
G_END_DECLS
diff --git a/sys/sunaudio/gstsunaudiosink.c b/sys/sunaudio/gstsunaudiosink.c
index 2a3cf1928..0110b26fa 100644
--- a/sys/sunaudio/gstsunaudiosink.c
+++ b/sys/sunaudio/gstsunaudiosink.c
@@ -146,8 +146,8 @@ gst_sunaudiosink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class,
- &gst_sunaudiosink_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_sunaudiosink_factory));
gst_element_class_set_details_simple (element_class, "Sun Audio Sink",
"Sink/Audio",
"Audio sink for Sun Audio devices",
diff --git a/sys/sunaudio/gstsunaudiosrc.c b/sys/sunaudio/gstsunaudiosrc.c
index 08282cf02..f0529be93 100644
--- a/sys/sunaudio/gstsunaudiosrc.c
+++ b/sys/sunaudio/gstsunaudiosrc.c
@@ -108,8 +108,8 @@ gst_sunaudiosrc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_static_pad_template (element_class,
- &gst_sunaudiosrc_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_sunaudiosrc_factory));
gst_element_class_set_details_simple (element_class, "Sun Audio Source",
"Source/Audio",
"Audio source for Sun Audio devices",
diff --git a/sys/v4l2/Makefile.am b/sys/v4l2/Makefile.am
index a7a99dea3..86f4fd2d0 100644
--- a/sys/v4l2/Makefile.am
+++ b/sys/v4l2/Makefile.am
@@ -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,16 +17,11 @@ 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) \
- $(GST_CONTROLLER_CFLAGS) \
$(GST_CFLAGS) \
$(X_CFLAGS) \
$(LIBV4L2_CFLAGS) \
@@ -37,7 +32,6 @@ libgstvideo4linux2_la_LIBTOOLFLAGS = --tag=disable-static
libgstvideo4linux2_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
$(GST_BASE_LIBS) \
- $(GST_CONTROLLER_LIBS) \
$(GST_PLUGINS_BASE_LIBS) \
-lgstvideo-$(GST_MAJORMINOR) \
-lgstinterfaces-$(GST_MAJORMINOR) \
@@ -55,6 +49,5 @@ noinst_HEADERS = \
gstv4l2radio.h \
gstv4l2tuner.h \
gstv4l2vidorient.h \
- gstv4l2xoverlay.h \
- v4l2_calls.h \
- v4l2src_calls.h
+ gstv4l2videooverlay.h \
+ v4l2_calls.h
diff --git a/sys/v4l2/gstv4l2.c b/sys/v4l2/gstv4l2.c
index 95f64db78..22959c663 100644
--- a/sys/v4l2/gstv4l2.c
+++ b/sys/v4l2/gstv4l2.c
@@ -28,13 +28,10 @@
#include "gst/gst-i18n-plugin.h"
#include <gst/gst.h>
-#include <gst/controller/gstcontroller.h>
#include "gstv4l2object.h"
#include "gstv4l2src.h"
-#ifdef HAVE_EXPERIMENTAL
#include "gstv4l2sink.h"
-#endif
#include "gstv4l2radio.h"
/* #include "gstv4l2jpegsrc.h" */
/* #include "gstv4l2mjpegsrc.h" */
@@ -50,15 +47,10 @@ plugin_init (GstPlugin * plugin)
GST_DEBUG_CATEGORY_INIT (v4l2_debug, "v4l2", 0, "V4L2 API calls");
GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
- /* initialize gst controller library */
- gst_controller_init (NULL, NULL);
-
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", */
diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
index e976ec507..21454ec75 100644
--- a/sys/v4l2/gstv4l2bufferpool.c
+++ b/sys/v4l2/gstv4l2bufferpool.c
@@ -31,12 +31,13 @@
#include <unistd.h>
#include "gst/video/video.h"
+#include "gst/video/gstvideometa.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"
@@ -52,151 +53,154 @@
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_v4l2_meta_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 ("GstV4l2Meta", "GstV4l2Meta",
+ sizeof (GstV4l2Meta), (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:
+ {
+ GstV4l2Meta *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_V4L2_META_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;
+ GstV4l2Meta *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_V4L2_META_ADD (newbuf);
+
+ index = pool->num_allocated;
+
+ GST_LOG_OBJECT (pool, "creating buffer %u, %p", index, newbuf);
+
+ 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_video_meta_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_VIDEO_META);
-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)
+{
+ GstV4l2Meta *meta;
+ gint index;
+
+ meta = GST_V4L2_META_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:
+ {
+ GstV4l2Meta *meta;
+
+ meta = GST_V4L2_META_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_VIDEO_META);
+ 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;
+ }
}
diff --git a/sys/v4l2/gstv4l2bufferpool.h b/sys/v4l2/gstv4l2bufferpool.h
index caad9ac2f..12d3ccc7d 100644
--- a/sys/v4l2/gstv4l2bufferpool.h
+++ b/sys/v4l2/gstv4l2bufferpool.h
@@ -22,76 +22,73 @@
* 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 _GstV4l2Meta GstV4l2Meta;
+
+#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 _GstV4l2Meta {
+ 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_v4l2_meta_get_info (void);
+#define GST_V4L2_META_GET(buf) ((GstV4l2Meta *)gst_buffer_get_meta(buf,gst_v4l2_meta_get_info()))
+#define GST_V4L2_META_ADD(buf) ((GstV4l2Meta *)gst_buffer_add_meta(buf,gst_v4l2_meta_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__ */
diff --git a/sys/v4l2/gstv4l2colorbalance.c b/sys/v4l2/gstv4l2colorbalance.c
index f5cde096f..a07c9be31 100644
--- a/sys/v4l2/gstv4l2colorbalance.c
+++ b/sys/v4l2/gstv4l2colorbalance.c
@@ -29,14 +29,9 @@
#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;
}
diff --git a/sys/v4l2/gstv4l2colorbalance.h b/sys/v4l2/gstv4l2colorbalance.h
index 9e183f014..4e6a75e36 100644
--- a/sys/v4l2/gstv4l2colorbalance.h
+++ b/sys/v4l2/gstv4l2colorbalance.h
@@ -25,7 +25,7 @@
#define __GST_V4L2_COLOR_BALANCE_H__
#include <gst/gst.h>
-#include <gst/interfaces/colorbalance.h>
+#include <gst/video/colorbalance.h>
#include "v4l2_calls.h"
G_BEGIN_DECLS
@@ -91,14 +91,14 @@ interface_as_function ## _color_balance_get_value (GstColorBalance * balance,
} \
\
static void \
-interface_as_function ## _color_balance_interface_init (GstColorBalanceClass * klass) \
+interface_as_function ## _color_balance_interface_init (GstColorBalanceInterface * iface) \
{ \
- GST_COLOR_BALANCE_TYPE (klass) = GST_COLOR_BALANCE_HARDWARE; \
+ GST_COLOR_BALANCE_TYPE (iface) = GST_COLOR_BALANCE_HARDWARE; \
\
/* default virtual functions */ \
- klass->list_channels = interface_as_function ## _color_balance_list_channels; \
- klass->set_value = interface_as_function ## _color_balance_set_value; \
- klass->get_value = interface_as_function ## _color_balance_get_value; \
+ iface->list_channels = interface_as_function ## _color_balance_list_channels; \
+ iface->set_value = interface_as_function ## _color_balance_set_value; \
+ iface->get_value = interface_as_function ## _color_balance_get_value; \
} \
#endif /* __GST_V4L2_COLOR_BALANCE_H__ */
diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c
index 81d1cb782..42c65e8e0 100644
--- a/sys/v4l2/gstv4l2object.c
+++ b/sys/v4l2/gstv4l2object.c
@@ -35,12 +35,14 @@
#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) */
@@ -50,15 +52,16 @@
#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
{
@@ -74,8 +77,6 @@ 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? */
G_LOCK (probe_lock);
if (!list) {
@@ -370,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)
@@ -451,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 *
@@ -478,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;
@@ -612,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;
@@ -685,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;
@@ -751,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);
@@ -759,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))
@@ -1149,99 +1187,24 @@ gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc)
case V4L2_PIX_FMT_PJPG: /* Progressive-JPEG */
#endif
case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */
- structure = gst_structure_new ("image/jpeg", NULL);
+ structure = gst_structure_new_empty ("image/jpeg");
+ 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:
@@ -1250,59 +1213,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:
@@ -1311,28 +1299,28 @@ gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc)
NULL);
break;
case V4L2_PIX_FMT_MPEG: /* MPEG */
- structure = gst_structure_new ("video/mpegts", NULL);
+ structure = gst_structure_new_empty ("video/mpegts");
break;
case V4L2_PIX_FMT_WNVA: /* Winnov hw compres */
break;
#ifdef V4L2_PIX_FMT_SBGGR8
case V4L2_PIX_FMT_SBGGR8:
- structure = gst_structure_new ("video/x-raw-bayer", NULL);
+ structure = gst_structure_new_empty ("video/x-raw-bayer");
break;
#endif
#ifdef V4L2_PIX_FMT_SN9C10X
case V4L2_PIX_FMT_SN9C10X:
- structure = gst_structure_new ("video/x-sonix", NULL);
+ structure = gst_structure_new_empty ("video/x-sonix");
break;
#endif
#ifdef V4L2_PIX_FMT_PWC1
case V4L2_PIX_FMT_PWC1:
- structure = gst_structure_new ("video/x-pwc1", NULL);
+ structure = gst_structure_new_empty ("video/x-pwc1");
break;
#endif
#ifdef V4L2_PIX_FMT_PWC2
case V4L2_PIX_FMT_PWC2:
- structure = gst_structure_new ("video/x-pwc2", NULL);
+ structure = gst_structure_new_empty ("video/x-pwc2");
break;
#endif
default:
@@ -1383,160 +1371,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;
-
- 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 (g_str_equal (mimetype, "video/x-raw")) {
+ /* raw caps, parse into video info */
+ if (!gst_video_info_from_caps (info, caps))
+ goto invalid_format;
- 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 15:
- fourcc = (endianness == G_LITTLE_ENDIAN) ?
- V4L2_PIX_FMT_RGB555 : V4L2_PIX_FMT_RGB555X;
+ case GST_VIDEO_FORMAT_RGB16:
+ fourcc = V4L2_PIX_FMT_RGB565;
break;
- case 16:
- fourcc = (endianness == G_LITTLE_ENDIAN) ?
- V4L2_PIX_FMT_RGB565 : V4L2_PIX_FMT_RGB565X;
+ case GST_VIDEO_FORMAT_RGB:
+ fourcc = V4L2_PIX_FMT_RGB24;
break;
- case 24:
- fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR24 : V4L2_PIX_FMT_RGB24;
+ case GST_VIDEO_FORMAT_BGR:
+ fourcc = V4L2_PIX_FMT_BGR24;
break;
- case 32:
- fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR32 : V4L2_PIX_FMT_RGB32;
+ case GST_VIDEO_FORMAT_RGBx:
+ case GST_VIDEO_FORMAT_RGBA:
+ fourcc = V4L2_PIX_FMT_RGB32;
+ break;
+ 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;
+ }
}
@@ -1786,7 +1794,7 @@ gst_v4l2_object_probe_caps_for_format (GstV4l2Object * v4l2object,
guint32 w, h;
if (pixelformat == GST_MAKE_FOURCC ('M', 'P', 'E', 'G'))
- return gst_caps_new_simple ("video/mpegts", NULL);
+ return gst_caps_new_empty_simple ("video/mpegts");
memset (&size, 0, sizeof (struct v4l2_frmsizeenum));
size.index = 0;
@@ -2099,16 +2107,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..
@@ -2119,8 +2213,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);
@@ -2128,7 +2223,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;
@@ -2136,42 +2231,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;
+
+ /* some cheap USB cam's won't accept any change */
+ if (v4l2_ioctl (fd, VIDIOC_S_PARM, &streamparm) < 0)
+ goto set_parm_failed;
- if (v4l2_ioctl (fd, VIDIOC_S_FMT, &format) < 0) {
- goto set_fmt_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,
@@ -2218,30 +2399,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;
+ }
}
diff --git a/sys/v4l2/gstv4l2object.h b/sys/v4l2/gstv4l2object.h
index a7b590d9b..8134818f8 100644
--- a/sys/v4l2/gstv4l2object.h
+++ b/sys/v4l2/gstv4l2object.h
@@ -49,10 +49,15 @@
#include <gst/gst.h>
#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
@@ -61,35 +66,66 @@
/* 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 +174,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 +196,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 +216,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) \
diff --git a/sys/v4l2/gstv4l2radio.c b/sys/v4l2/gstv4l2radio.c
index 63a2fed17..d6f7c8f2b 100644
--- a/sys/v4l2/gstv4l2radio.c
+++ b/sys/v4l2/gstv4l2radio.c
@@ -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_reinit (GstTunerInterface * 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,19 +507,20 @@ 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)
+static const gchar *const *
+gst_v4l2radio_uri_get_protocols (GType type)
{
- static gchar *protocols[] = { (char *) "radio", NULL };
+ static const gchar *protocols[] = { "radio", NULL };
+
return protocols;
}
-static const gchar *
+static gchar *
gst_v4l2radio_uri_get_uri (GstURIHandler * handler)
{
GstV4l2Radio *radio = GST_V4L2RADIO (handler);
@@ -583,19 +528,17 @@ gst_v4l2radio_uri_get_uri (GstURIHandler * handler)
if (radio->v4l2object->videodev != NULL) {
if (gst_v4l2_get_frequency (radio->v4l2object,
0, &(radio->v4l2object->frequency))) {
- gchar uri[20];
- gchar freq[6];
- g_ascii_formatd (freq, 6, "%4.1f", radio->v4l2object->frequency / 1e6);
- g_snprintf (uri, sizeof (uri), "radio://%s", freq);
- return g_intern_string (uri);
+ return g_strdup_printf ("radio://%4.1f",
+ radio->v4l2object->frequency / 1e6);
}
}
- return "radio://";
+ return g_strdup ("radio://");
}
static gboolean
-gst_v4l2radio_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_v4l2radio_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
GstV4l2Radio *radio = GST_V4L2RADIO (handler);
gdouble dfreq;
@@ -620,6 +563,8 @@ gst_v4l2radio_uri_set_uri (GstURIHandler * handler, const gchar * uri)
return TRUE;
uri_failed:
+ g_set_error_literal (error, GST_URI_ERROR, GST_URI_ERROR_BAD_REFERENCE,
+ "Bad radio URI, could not parse frequency");
return FALSE;
}
diff --git a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c
index f6aba2455..e80f5b965 100644
--- a/sys/v4l2/gstv4l2sink.c
+++ b/sys/v4l2/gstv4l2sink.c
@@ -53,11 +53,12 @@
#include <config.h>
#endif
+#include "gst/video/gstvideometa.h"
#include "gstv4l2colorbalance.h"
#include "gstv4l2tuner.h"
#ifdef HAVE_XVIDEO
-#include "gstv4l2xoverlay.h"
+#include "gstv4l2videooverlay.h"
#endif
#include "gstv4l2vidorient.h"
@@ -69,16 +70,12 @@
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,42 +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);
- GstPadTemplate *pad_template;
-
- 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>,");
-
- pad_template =
- gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
- gst_v4l2_object_get_all_caps ());
- gst_element_class_add_pad_template (gstelement_class, pad_template);
- gst_object_unref (pad_template);
-}
-
-static void
gst_v4l2sink_class_init (GstV4l2SinkClass * klass)
{
GObjectClass *gobject_class;
@@ -273,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",
@@ -318,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,
@@ -338,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;
}
@@ -360,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);
}
@@ -378,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)
*/
@@ -497,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;
@@ -560,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;
@@ -610,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:
@@ -621,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;
@@ -646,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;
@@ -661,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);
- }
-
- formats = gst_v4l2_object_get_format_list (v4l2sink->v4l2object);
+ if (v4l2sink->probed_caps == NULL) {
+ 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);
@@ -706,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);
@@ -719,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) {
-
- /* initialize the buffer pool if not initialized yet (first buffer): */
- if (G_UNLIKELY (!v4l2sink->pool)) {
-
- /* set_caps() might not be called yet.. so just to make sure: */
- if (!gst_v4l2sink_set_caps (bsink, caps)) {
- return GST_FLOW_ERROR;
- }
-
- GST_V4L2_CHECK_OPEN (v4l2sink->v4l2object);
+ GstV4l2Object *obj = v4l2sink->v4l2object;
+ GstBufferPool *pool;
+ guint size = 0;
+ GstCaps *caps;
+ gboolean need_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;
- }
+ gst_query_parse_allocation (query, &caps, &need_pool);
- gst_v4l2sink_sync_overlay_fields (v4l2sink);
- gst_v4l2sink_sync_crop_fields (v4l2sink);
+ if (caps == NULL)
+ goto no_caps;
-#ifdef HAVE_XVIDEO
- gst_v4l2_xoverlay_prepare_xwindow_id (v4l2sink->v4l2object, TRUE);
-#endif
+ if ((pool = obj->pool))
+ gst_object_ref (pool);
- v4l2sink->state = STATE_PENDING_STREAMON;
+ if (pool != NULL) {
+ const GstCaps *pcaps;
+ GstStructure *config;
- GST_INFO_OBJECT (v4l2sink, "outputting buffers via mmap()");
+ /* 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);
- 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_VIDEO_META_API);
+ gst_query_add_allocation_meta (query, GST_VIDEO_CROP_META_API);
- 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;
}
}
@@ -838,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
@@ -942,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.
diff --git a/sys/v4l2/gstv4l2sink.h b/sys/v4l2/gstv4l2sink.h
index 8fe82221a..b461e2c92 100644
--- a/sys/v4l2/gstv4l2sink.h
+++ b/sys/v4l2/gstv4l2sink.h
@@ -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 {
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c
index 023e77bee..e2464f581 100644
--- a/sys/v4l2/gstv4l2src.c
+++ b/sys/v4l2/gstv4l2src.c
@@ -48,9 +48,13 @@
#include <string.h>
#include <sys/time.h>
-#include "v4l2src_calls.h"
#include <unistd.h>
+#include "gst/video/gstvideometa.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;
-
-#ifdef HAVE_XVIDEO
- if (iface_type == GST_TYPE_X_OVERLAY && !GST_V4L2_IS_OVERLAY (v4l2object))
- return FALSE;
-#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);
+#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
- g_type_add_interface_static (type, GST_TYPE_X_OVERLAY, &v4l2_xoverlay_info);
+ /* FIXME: does GstXOverlay for v4l2src make sense in a GStreamer context? */
+ G_IMPLEMENT_INTERFACE (GST_TYPE_X_OVERLAY,
+ gst_v4l2src_xoverlay_interface_init);
#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,36 +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);
- GstPadTemplate *pad_template;
-
- 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>");
-
- pad_template =
- gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- gst_v4l2_object_get_all_caps ());
- gst_element_class_add_pad_template (gstelement_class, pad_template);
- gst_object_unref (pad_template);
-}
-
static void
gst_v4l2src_class_init (GstV4l2SrcClass * klass)
{
@@ -262,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",
@@ -283,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);
@@ -292,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)
{
@@ -351,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);
@@ -367,7 +260,6 @@ gst_v4l2src_set_property (GObject * object,
}
}
-
static void
gst_v4l2src_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
@@ -377,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);
@@ -393,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)
@@ -404,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);
}
@@ -443,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_query_caps (GST_BASE_SRC_PAD (basesrc), NULL);
GST_DEBUG_OBJECT (basesrc, "caps of src: %" GST_PTR_FORMAT, thiscaps);
LOG_CAPS (basesrc, thiscaps);
@@ -452,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_query_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)) {
@@ -484,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)
@@ -499,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)
@@ -531,7 +402,7 @@ gst_v4l2src_negotiate (GstBaseSrc * basesrc)
/* now fixate */
if (!gst_caps_is_empty (caps)) {
- gst_pad_fixate_caps (GST_BASE_SRC_PAD (basesrc), caps);
+ gst_v4l2src_fixate (basesrc, caps);
GST_DEBUG_OBJECT (basesrc, "fixated to: %" GST_PTR_FORMAT, caps);
LOG_CAPS (basesrc, caps);
@@ -541,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);
@@ -559,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
@@ -576,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;
@@ -593,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);
@@ -615,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;
- if (v4l2src->use_mmap) {
- v4l2src->get_frame = gst_v4l2src_get_mmap;
+ gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
+ &alignment, &pool);
+
+ 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;
+ }
+
+ if (pool) {
+ GstStructure *config;
+ const GstCaps *caps;
- /* now store the expected output size */
- v4l2src->frame_byte_size = size;
+ 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_VIDEO_META_API))
+ gst_buffer_pool_config_add_option (config,
+ GST_BUFFER_POOL_OPTION_VIDEO_META);
+
+ gst_buffer_pool_set_config (pool, config);
+ }
+
+ gst_query_set_allocation_params (query, size, min, max, prefix,
+ alignment, pool);
return TRUE;
}
@@ -674,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,
@@ -738,7 +659,7 @@ gst_v4l2src_start (GstBaseSrc * src)
/* activate settings for first frame */
v4l2src->ctrl_time = 0;
- gst_object_sync_values (G_OBJECT (src), v4l2src->ctrl_time);
+ gst_object_sync_values (GST_OBJECT (src), v4l2src->ctrl_time);
return TRUE;
}
@@ -747,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;
}
@@ -790,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:
@@ -806,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) {
@@ -822,228 +729,123 @@ 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;
-
- /* 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;
- }
-}
+ duration = obj->duration;
-static GstFlowReturn
-gst_v4l2src_create (GstPushSrc * src, GstBuffer ** buf)
-{
- GstV4l2Src *v4l2src = GST_V4L2SRC (src);
- int i;
- GstFlowReturn ret;
+ 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);
- 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 (GST_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)
+static const gchar *const *
+gst_v4l2src_uri_get_protocols (GType type)
{
- static gchar *protocols[] = { (char *) "v4l2", NULL };
+ static const gchar *protocols[] = { "v4l2", NULL };
return protocols;
}
-static const gchar *
+static gchar *
gst_v4l2src_uri_get_uri (GstURIHandler * handler)
{
GstV4l2Src *v4l2src = GST_V4L2SRC (handler);
if (v4l2src->v4l2object->videodev != NULL) {
- gchar uri[256];
-
- /* need to return a const string, but also don't want to leak the generated
- * string, so just intern it - there's a limited number of video devices
- * after all */
- g_snprintf (uri, sizeof (uri), "v4l2://%s", v4l2src->v4l2object->videodev);
- return g_intern_string (uri);
+ return g_strdup_printf ("v4l2://%s", v4l2src->v4l2object->videodev);
}
- return "v4l2://";
+ return g_strdup ("v4l2://");
}
static gboolean
-gst_v4l2src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_v4l2src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
GstV4l2Src *v4l2src = GST_V4L2SRC (handler);
const gchar *device = DEFAULT_PROP_DEVICE;
diff --git a/sys/v4l2/gstv4l2src.h b/sys/v4l2/gstv4l2src.h
index 0dd794a71..8ebaa5769 100644
--- a/sys/v4l2/gstv4l2src.h
+++ b/sys/v4l2/gstv4l2src.h
@@ -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
diff --git a/sys/v4l2/gstv4l2tuner.c b/sys/v4l2/gstv4l2tuner.c
index a805396ca..c885dc674 100644
--- a/sys/v4l2/gstv4l2tuner.c
+++ b/sys/v4l2/gstv4l2tuner.c
@@ -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);
diff --git a/sys/v4l2/gstv4l2tuner.h b/sys/v4l2/gstv4l2tuner.h
index 699ca87e1..75d4559e0 100644
--- a/sys/v4l2/gstv4l2tuner.h
+++ b/sys/v4l2/gstv4l2tuner.h
@@ -179,20 +179,20 @@ interface_as_function ## _tuner_signal_strength (GstTuner * mixer,
} \
\
static void \
-interface_as_function ## _tuner_interface_init (GstTunerClass * klass) \
+interface_as_function ## _tuner_interface_init (GstTunerInterface * iface) \
{ \
/* default virtual functions */ \
- klass->list_channels = interface_as_function ## _tuner_list_channels; \
- klass->set_channel = interface_as_function ## _tuner_set_channel; \
- klass->get_channel = interface_as_function ## _tuner_get_channel; \
+ iface->list_channels = interface_as_function ## _tuner_list_channels; \
+ iface->set_channel = interface_as_function ## _tuner_set_channel; \
+ iface->get_channel = interface_as_function ## _tuner_get_channel; \
\
- klass->list_norms = interface_as_function ## _tuner_list_norms; \
- klass->set_norm = interface_as_function ## _tuner_set_norm_and_notify; \
- klass->get_norm = interface_as_function ## _tuner_get_norm; \
+ iface->list_norms = interface_as_function ## _tuner_list_norms; \
+ iface->set_norm = interface_as_function ## _tuner_set_norm_and_notify; \
+ iface->get_norm = interface_as_function ## _tuner_get_norm; \
\
- klass->set_frequency = interface_as_function ## _tuner_set_frequency_and_notify; \
- klass->get_frequency = interface_as_function ## _tuner_get_frequency; \
- klass->signal_strength = interface_as_function ## _tuner_signal_strength; \
+ iface->set_frequency = interface_as_function ## _tuner_set_frequency_and_notify; \
+ iface->get_frequency = interface_as_function ## _tuner_get_frequency; \
+ iface->signal_strength = interface_as_function ## _tuner_signal_strength; \
} \
#endif /* __GST_V4L2_TUNER_H__ */
diff --git a/sys/v4l2/gstv4l2xoverlay.c b/sys/v4l2/gstv4l2videooverlay.c
index 80f114d20..3f28fdcd8 100644
--- a/sys/v4l2/gstv4l2xoverlay.c
+++ b/sys/v4l2/gstv4l2videooverlay.c
@@ -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 (GstVideoOverlayInterface * iface)
{
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);
}
}
diff --git a/sys/v4l2/gstv4l2xoverlay.h b/sys/v4l2/gstv4l2videooverlay.h
index 1a0930683..7c044e71d 100644
--- a/sys/v4l2/gstv4l2xoverlay.h
+++ b/sys/v4l2/gstv4l2videooverlay.h
@@ -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
@@ -21,50 +20,50 @@
* 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/navigation.h>
#include <gst/video/gstvideosink.h> /* for GstVideoRectange */
+#include <gst/video/videooverlay.h>
#include "gstv4l2object.h"
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 (GstVideoOverlayInterface * 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 (GstVideoOverlayInterface * 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__ */
diff --git a/sys/v4l2/gstv4l2vidorient.c b/sys/v4l2/gstv4l2vidorient.c
index 1fa47e794..4dc0da73f 100644
--- a/sys/v4l2/gstv4l2vidorient.c
+++ b/sys/v4l2/gstv4l2vidorient.c
@@ -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
@@ -43,7 +42,7 @@ GST_DEBUG_CATEGORY_STATIC (v4l2vo_debug);
#endif
void
-gst_v4l2_video_orientation_interface_init (GstVideoOrientationInterface * klass)
+gst_v4l2_video_orientation_interface_init (GstVideoOrientationInterface * iface)
{
GST_DEBUG_CATEGORY_INIT (v4l2vo_debug, "v4l2vo", 0,
"V4L2 VideoOrientation interface debugging");
diff --git a/sys/v4l2/gstv4l2vidorient.h b/sys/v4l2/gstv4l2vidorient.h
index 39682e2f1..bf3736f9b 100644
--- a/sys/v4l2/gstv4l2vidorient.h
+++ b/sys/v4l2/gstv4l2vidorient.h
@@ -24,13 +24,13 @@
#define __GST_V4L2_VIDORIENT_H__
#include <gst/gst.h>
-#include <gst/interfaces/videoorientation.h>
+#include <gst/video/videoorientation.h>
#include "gstv4l2object.h"
G_BEGIN_DECLS
-void gst_v4l2_video_orientation_interface_init (GstVideoOrientationInterface * klass);
+void gst_v4l2_video_orientation_interface_init (GstVideoOrientationInterface * iface);
gboolean gst_v4l2_video_orientation_get_hflip (GstV4l2Object *v4l2object, gboolean *flip);
gboolean gst_v4l2_video_orientation_get_vflip (GstV4l2Object *v4l2object, gboolean *flip);
@@ -101,17 +101,17 @@ gboolean gst_v4l2_video_orientation_set_vcenter (GstV4l2Object *v4l2object, gint
} \
\
static void \
- interface_as_function ## _video_orientation_interface_init (GstVideoOrientationInterface * klass) \
+ interface_as_function ## _video_orientation_interface_init (GstVideoOrientationInterface * iface) \
{ \
/* default virtual functions */ \
- klass->get_hflip = interface_as_function ## _video_orientation_get_hflip; \
- klass->get_vflip = interface_as_function ## _video_orientation_get_vflip; \
- klass->get_hcenter = interface_as_function ## _video_orientation_get_hcenter; \
- klass->get_vcenter = interface_as_function ## _video_orientation_get_vcenter; \
- klass->set_hflip = interface_as_function ## _video_orientation_set_hflip; \
- klass->set_vflip = interface_as_function ## _video_orientation_set_vflip; \
- klass->set_hcenter = interface_as_function ## _video_orientation_set_hcenter; \
- klass->set_vcenter = interface_as_function ## _video_orientation_set_vcenter; \
+ iface->get_hflip = interface_as_function ## _video_orientation_get_hflip; \
+ iface->get_vflip = interface_as_function ## _video_orientation_get_vflip; \
+ iface->get_hcenter = interface_as_function ## _video_orientation_get_hcenter; \
+ iface->get_vcenter = interface_as_function ## _video_orientation_get_vcenter; \
+ iface->set_hflip = interface_as_function ## _video_orientation_set_hflip; \
+ iface->set_vflip = interface_as_function ## _video_orientation_set_vflip; \
+ iface->set_hcenter = interface_as_function ## _video_orientation_set_hcenter; \
+ iface->set_vcenter = interface_as_function ## _video_orientation_set_vcenter; \
}
#endif /* __GST_V4L2_VIDORIENT_H__ */
diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
index 3808d8e62..74b2e0adf 100644
--- a/sys/v4l2/v4l2_calls.c
+++ b/sys/v4l2/v4l2_calls.c
@@ -46,10 +46,7 @@
#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)) {
diff --git a/sys/v4l2/v4l2_calls.h b/sys/v4l2/v4l2_calls.h
index d2e2c723e..36cf0f3a9 100644
--- a/sys/v4l2/v4l2_calls.h
+++ b/sys/v4l2/v4l2_calls.h
@@ -40,14 +40,6 @@
# 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
index bfa558960..000000000
--- a/sys/v4l2/v4l2src_calls.c
+++ /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
index 709191870..000000000
--- a/sys/v4l2/v4l2src_calls.h
+++ /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__ */
diff --git a/sys/waveform/gstwaveformsink.c b/sys/waveform/gstwaveformsink.c
index 492742b1d..36542c182 100644
--- a/sys/waveform/gstwaveformsink.c
+++ b/sys/waveform/gstwaveformsink.c
@@ -110,8 +110,8 @@ gst_waveform_sink_base_init (gpointer g_class)
"Sink/Audio",
"Output to a sound card via WaveForm API",
"Sebastien Moutte <sebastien@moutte.net>");
- gst_element_class_add_static_pad_template (element_class,
- &waveformsink_sink_factory);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&waveformsink_sink_factory));
}
static void
diff --git a/sys/ximage/gstximagesrc.c b/sys/ximage/gstximagesrc.c
index b0d99ad6a..91e3f1dbe 100644
--- a/sys/ximage/gstximagesrc.c
+++ b/sys/ximage/gstximagesrc.c
@@ -75,23 +75,23 @@ enum
PROP_XNAME,
};
-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_fixate (GstBaseSrc * bsrc, 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);
@@ -99,7 +99,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);
@@ -431,19 +431,35 @@ composite_pixel (GstXContext * xcontext, guchar * dest, guchar * src)
}
#endif
+#ifdef HAVE_XDAMAGE
+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);
+}
+#endif
+
/* 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);
}
@@ -473,7 +489,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,
@@ -488,13 +503,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) {
@@ -524,11 +541,9 @@ 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)));
+ "Copying from last frame ximage->size: %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (ximage));
+ copy_buffer (ximage, ximagesrc->last_ximage);
have_frame = TRUE;
}
for (i = 0; i < nrects; i++) {
@@ -567,7 +582,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 {
@@ -579,7 +594,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);
@@ -588,11 +603,9 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
} while (XPending (ximagesrc->xcontext->disp));
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)));
+ "Copying from last frame ximage->size: %" G_GSIZE_FORMAT,
+ 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
@@ -641,14 +654,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
@@ -661,7 +674,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 */
@@ -670,9 +683,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);
@@ -752,7 +765,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)]);
@@ -768,9 +781,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");
@@ -783,7 +796,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;
@@ -867,7 +880,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;
@@ -985,7 +998,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);
@@ -996,20 +1009,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_static_pad_template (ec, &t);
-}
-
-static void
gst_ximage_src_dispose (GObject * object)
{
/* Drop references in the buffer_pool */
@@ -1034,7 +1033,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;
@@ -1134,7 +1133,7 @@ gst_ximage_src_set_caps (GstBaseSrc * bs, GstCaps * caps)
}
static void
-gst_ximage_src_fixate (GstPad * pad, GstCaps * caps)
+gst_ximage_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
{
gint i;
GstStructure *structure;
@@ -1144,12 +1143,14 @@ gst_ximage_src_fixate (GstPad * pad, GstCaps * caps)
gst_structure_fixate_field_nearest_fraction (structure, "framerate", 25, 1);
}
+ GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps);
}
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);
@@ -1240,7 +1241,6 @@ gst_ximage_src_class_init (GstXImageSrcClass * klass)
g_param_spec_boolean ("remote", "Remote dispay",
"Whether the display is remote", FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
/**
* GstXImageSrc:xid
*
@@ -1252,7 +1252,6 @@ gst_ximage_src_class_init (GstXImageSrcClass * klass)
g_param_spec_uint64 ("xid", "Window XID",
"Window XID to capture from", 0, G_MAXUINT64, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
/**
* GstXImageSrc:xname
*
@@ -1265,23 +1264,28 @@ gst_ximage_src_class_init (GstXImageSrcClass * klass)
"Window name to capture from", NULL,
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->fixate = gst_ximage_src_fixate;
bc->get_caps = gst_ximage_src_get_caps;
bc->set_caps = gst_ximage_src_set_caps;
bc->start = gst_ximage_src_start;
bc->stop = gst_ximage_src_stop;
bc->unlock = gst_ximage_src_unlock;
+ push_class->create = gst_ximage_src_create;
}
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);
- gst_pad_set_fixatecaps_function (GST_BASE_SRC_PAD (ximagesrc),
- gst_ximage_src_fixate);
ximagesrc->pool_lock = g_mutex_new ();
ximagesrc->x_lock = g_mutex_new ();
diff --git a/sys/ximage/gstximagesrc.h b/sys/ximage/gstximagesrc.h
index e58513c1e..a5f9d7920 100644
--- a/sys/ximage/gstximagesrc.h
+++ b/sys/ximage/gstximagesrc.h
@@ -99,7 +99,7 @@ struct _GstXImageSrc
int damage_event_base;
XserverRegion damage_region;
GC damage_copy_gc;
- GstXImageSrcBuffer *last_ximage;
+ GstBuffer *last_ximage;
#endif
};
diff --git a/sys/ximage/ximageutil.c b/sys/ximage/ximageutil.c
index 2fac09a23..d3dee2bc0 100644
--- a/sys/ximage/ximageutil.c
+++ b/sys/ximage/ximageutil.c
@@ -23,6 +23,21 @@
#include "ximageutil.h"
+const GstMetaInfo *
+gst_meta_ximage_get_info (void)
+{
+ static const GstMetaInfo *meta_ximage_info = NULL;
+
+ if (meta_ximage_info == NULL) {
+ meta_ximage_info =
+ gst_meta_register ("GstMetaXImageSrc", "GstMetaXImageSrc",
+ sizeof (GstMetaXImage), (GstMetaInitFunction) NULL,
+ (GstMetaFreeFunction) NULL, (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;
diff --git a/sys/ximage/ximageutil.h b/sys/ximage/ximageutil.h
index 517fc8e06..aa674de8f 100644
--- a/sys/ximage/ximageutil.h
+++ b/sys/ximage/ximageutil.h
@@ -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
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index 27dde40f0..f438c5e40 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -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 \
@@ -168,13 +169,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)
@@ -191,7 +187,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)
@@ -206,6 +202,21 @@ elements_mpegaudioparse_LDADD = libparser.la $(LDADD)
elements_aspectratiocrop_LDADD = $(LDADD)
elements_aspectratiocrop_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
+elements_audioamplify_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
+elements_audioamplify_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
+
+elements_audiochebband_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
+elements_audiochebband_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
+
+elements_audiocheblimit_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
+elements_audiocheblimit_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
+
+elements_audiodynamic_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
+elements_audiodynamic_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
+
+elements_audioecho_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
+elements_audioecho_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
+
elements_audiopanorama_LDADD = \
$(GST_BASE_LIBS) $(GST_CONTROLLER_LIBS) \
$(LDADD)
diff --git a/tests/check/elements/alphacolor.c b/tests/check/elements/alphacolor.c
index abe182d0f..1b68e664d 100644
--- a/tests/check/elements/alphacolor.c
+++ b/tests/check/elements/alphacolor.c
@@ -29,12 +29,12 @@ GstPad *mysrcpad, *mysinkpad;
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV"))
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("AYUV"))
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_RGB)
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ RGBA, RGB }"))
);
static GstElement *
@@ -43,8 +43,8 @@ setup_alphacolor (void)
GstElement *alphacolor;
alphacolor = gst_check_setup_element ("alphacolor");
- mysrcpad = gst_check_setup_src_pad (alphacolor, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (alphacolor, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (alphacolor, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (alphacolor, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
@@ -106,6 +106,13 @@ create_caps_rgba32 (void)
return caps;
}
+static void
+push_caps (GstCaps * caps)
+{
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
+ gst_caps_unref (caps);
+}
+
static GstBuffer *
create_buffer_rgb24_3x4 (void)
{
@@ -118,15 +125,15 @@ create_buffer_rgb24_3x4 (void)
};
guint rowstride = GST_ROUND_UP_4 (WIDTH * 3);
GstBuffer *buf;
- GstCaps *caps;
+ gpointer buf_data;
+ gsize size;
buf = gst_buffer_new_and_alloc (HEIGHT * rowstride);
- fail_unless_equals_int (GST_BUFFER_SIZE (buf), sizeof (rgb24_3x4_img));
- memcpy (GST_BUFFER_DATA (buf), rgb24_3x4_img, sizeof (rgb24_3x4_img));
+ buf_data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+ fail_unless_equals_int (size, sizeof (rgb24_3x4_img));
+ memcpy (buf_data, rgb24_3x4_img, sizeof (rgb24_3x4_img));
- caps = create_caps_rgb24 ();
- gst_buffer_set_caps (buf, caps);
- gst_caps_unref (caps);
+ gst_buffer_unmap (buf, buf_data, size);
return buf;
}
@@ -148,15 +155,15 @@ create_buffer_rgba32_3x4 (void)
};
guint rowstride = WIDTH * 4;
GstBuffer *buf;
- GstCaps *caps;
+ gpointer buf_data;
+ gsize size;
buf = gst_buffer_new_and_alloc (HEIGHT * rowstride);
- fail_unless_equals_int (GST_BUFFER_SIZE (buf), sizeof (rgba32_3x4_img));
- memcpy (GST_BUFFER_DATA (buf), rgba32_3x4_img, sizeof (rgba32_3x4_img));
+ buf_data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+ fail_unless_equals_int (size, sizeof (rgba32_3x4_img));
+ memcpy (buf_data, rgba32_3x4_img, sizeof (rgba32_3x4_img));
- caps = create_caps_rgba32 ();
- gst_buffer_set_caps (buf, caps);
- gst_caps_unref (caps);
+ gst_buffer_unmap (buf, buf_data, size);
return buf;
}
@@ -173,6 +180,8 @@ GST_START_TEST (test_rgb24)
fail_unless_equals_int (gst_element_set_state (alphacolor, GST_STATE_PLAYING),
GST_STATE_CHANGE_SUCCESS);
+ push_caps (create_caps_rgb24 ());
+
inbuffer = create_buffer_rgb24_3x4 ();
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -214,6 +223,8 @@ GST_START_TEST (test_rgba32)
GstCaps *incaps;
guint8 *ayuv;
guint outlength;
+ gpointer buf_data;
+ gsize size;
incaps = create_caps_rgba32 ();
alphacolor = setup_alphacolor ();
@@ -221,8 +232,10 @@ GST_START_TEST (test_rgba32)
fail_unless_equals_int (gst_element_set_state (alphacolor, GST_STATE_PLAYING),
GST_STATE_CHANGE_SUCCESS);
+ push_caps (create_caps_rgba32 ());
+
inbuffer = create_buffer_rgba32_3x4 ();
- GST_DEBUG ("Created buffer of %d bytes", GST_BUFFER_SIZE (inbuffer));
+ GST_DEBUG ("Created buffer of %d bytes", gst_buffer_get_size (inbuffer));
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away reference */
@@ -238,9 +251,10 @@ GST_START_TEST (test_rgba32)
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
outlength = WIDTH * HEIGHT * 4; /* output is AYUV */
- fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), outlength);
+ buf_data = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ fail_unless_equals_int (size, outlength);
- ayuv = GST_BUFFER_DATA (outbuffer);
+ ayuv = buf_data;
/* check alpha values (0x00 = totally transparent, 0xff = totally opaque) */
fail_unless_ayuv_pixel_has_alpha (ayuv, 0, 0, 0xff);
@@ -259,6 +273,8 @@ GST_START_TEST (test_rgba32)
/* we don't check the YUV data, because apparently results differ slightly
* depending on whether we run in valgrind or not */
+ gst_buffer_unmap (outbuffer, buf_data, size);
+
buffers = g_list_remove (buffers, outbuffer);
gst_buffer_unref (outbuffer);
diff --git a/tests/check/elements/aspectratiocrop.c b/tests/check/elements/aspectratiocrop.c
index 5d42bfb89..2d2b8fed6 100644
--- a/tests/check/elements/aspectratiocrop.c
+++ b/tests/check/elements/aspectratiocrop.c
@@ -25,42 +25,17 @@
#include <gst/video/video.h>
#include <gst/check/gstcheck.h>
-#define ASPECT_RATIO_CROP_CAPS \
- GST_VIDEO_CAPS_RGBx ";" \
- GST_VIDEO_CAPS_xRGB ";" \
- GST_VIDEO_CAPS_BGRx ";" \
- GST_VIDEO_CAPS_xBGR ";" \
- GST_VIDEO_CAPS_RGBA ";" \
- GST_VIDEO_CAPS_ARGB ";" \
- GST_VIDEO_CAPS_BGRA ";" \
- GST_VIDEO_CAPS_ABGR ";" \
- GST_VIDEO_CAPS_RGB ";" \
- GST_VIDEO_CAPS_BGR ";" \
- GST_VIDEO_CAPS_YUV ("AYUV") ";" \
- GST_VIDEO_CAPS_YUV ("YUY2") ";" \
- GST_VIDEO_CAPS_YUV ("YVYU") ";" \
- GST_VIDEO_CAPS_YUV ("UYVY") ";" \
- GST_VIDEO_CAPS_YUV ("Y800") ";" \
- GST_VIDEO_CAPS_YUV ("I420") ";" \
- GST_VIDEO_CAPS_YUV ("YV12") ";" \
- GST_VIDEO_CAPS_RGB_16 ";" \
- GST_VIDEO_CAPS_RGB_15
-
-static GstBuffer *
-make_buffer_with_caps (const gchar * caps_string, int buffer_size)
-{
- GstCaps *caps;
- GstBuffer *temp;
-
- caps = gst_caps_from_string (caps_string);
- temp = gst_buffer_new_and_alloc (buffer_size);
- fail_if (caps == NULL);
- fail_if (temp == NULL);
- gst_buffer_set_caps (temp, caps);
- gst_caps_unref (caps);
-
- return temp;
-}
+#define ASPECT_RATIO_CROP_CAPS \
+ GST_VIDEO_CAPS_MAKE ("{ RGBx, xRGB, BGRx, xBGR, " \
+ "RGBA, ARGB, BGRA, ABGR, RGB, BGR, AYUV, " \
+ "YUY2, YVYU, UYVY, Y800, I420, YV12, RGB16 " \
+ "RGB15 }")
+
+static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (ASPECT_RATIO_CROP_CAPS)
+ );
static void
check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
@@ -73,10 +48,13 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
GstBuffer *new;
GstBuffer *buffer;
GstBuffer *buffer_out;
- GstCaps *sink_caps;
+ GstCaps *incaps;
+ GstCaps *outcaps;
- buffer = make_buffer_with_caps (in_string, in_size);
- buffer_out = make_buffer_with_caps (out_string, out_size);
+ incaps = gst_caps_from_string (in_string);
+ buffer = gst_buffer_new_and_alloc (in_size);
+ outcaps = gst_caps_from_string (out_string);
+ buffer_out = gst_buffer_new_and_alloc (out_size);
/* check that there are no buffers waiting */
gst_check_drop_buffers ();
@@ -89,7 +67,6 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
/* create the src pad */
src_pad = gst_pad_new (NULL, GST_PAD_SRC);
- gst_pad_set_caps (src_pad, GST_BUFFER_CAPS (buffer));
pad_peer = gst_element_get_static_pad (element, "sink");
fail_if (pad_peer == NULL);
fail_unless (gst_pad_link (src_pad, pad_peer) == GST_PAD_LINK_OK,
@@ -99,9 +76,7 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
/* create the sink pad */
pad_peer = gst_element_get_static_pad (element, "src");
- sink_caps = gst_caps_from_string (ASPECT_RATIO_CROP_CAPS);
- sink_pad = gst_pad_new (NULL, GST_PAD_SINK);
- GST_PAD_CAPS (sink_pad) = sink_caps;
+ sink_pad = gst_pad_new_from_static_template (&sinktemplate, "sink");
fail_unless (gst_pad_link (pad_peer, sink_pad) == GST_PAD_LINK_OK,
"Could not link sink and %s source pads", GST_ELEMENT_NAME (element));
gst_object_unref (pad_peer);
@@ -112,6 +87,10 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
fail_unless (gst_element_set_state (element,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
+
+ fail_unless (gst_pad_set_caps (src_pad, incaps),
+ "Couldn't set input caps %" GST_PTR_FORMAT, incaps);
+
fail_unless (gst_pad_push (src_pad, buffer) == GST_FLOW_OK,
"Failed to push buffer");
fail_unless (gst_element_set_state (element,
@@ -121,11 +100,21 @@ check_aspectratiocrop (const gchar * in_string, const gchar * out_string,
fail_unless (g_list_length (buffers) == 1);
new = GST_BUFFER (buffers->data);
buffers = g_list_remove (buffers, new);
- fail_unless (GST_BUFFER_SIZE (buffer_out) == GST_BUFFER_SIZE (new),
+ fail_unless (gst_buffer_get_size (buffer_out) == gst_buffer_get_size (new),
"size of the buffers are not the same");
- gst_check_caps_equal (GST_BUFFER_CAPS (buffer_out), GST_BUFFER_CAPS (new));
+ {
+ GstCaps *sinkpad_caps;
+
+ sinkpad_caps = gst_pad_get_current_caps (sink_pad);
+
+ gst_check_caps_equal (sinkpad_caps, outcaps);
+
+ gst_caps_unref (sinkpad_caps);
+ }
gst_buffer_unref (new);
gst_buffer_unref (buffer_out);
+ gst_caps_unref (outcaps);
+ gst_caps_unref (incaps);
/* teardown the element and pads */
gst_pad_set_active (src_pad, FALSE);
diff --git a/tests/check/elements/audioamplify.c b/tests/check/elements/audioamplify.c
index 48ce8ffbd..de4394851 100644
--- a/tests/check/elements/audioamplify.c
+++ b/tests/check/elements/audioamplify.c
@@ -27,6 +27,7 @@
#include <gst/base/gstbasetransform.h>
#include <gst/check/gstcheck.h>
+#include <gst/audio/audio.h>
gboolean have_eos = FALSE;
@@ -37,32 +38,25 @@ GstPad *mysrcpad, *mysinkpad;
#define AMPLIFY_CAPS_STRING \
- "audio/x-raw-int, " \
+ "audio/x-raw, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 16, " \
- "depth = (int) 16, " \
- "signed = (bool) TRUE"
+ "format = (string) " GST_AUDIO_NE(S16)
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
- );
+ "format = (string) " GST_AUDIO_NE(S16)));
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
- );
+ "format = (string) " GST_AUDIO_NE(S16)));
static GstElement *
setup_amplify (void)
@@ -71,8 +65,8 @@ setup_amplify (void)
GST_DEBUG ("setup_amplify");
amplify = gst_check_setup_element ("audioamplify");
- mysrcpad = gst_check_setup_src_pad (amplify, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (amplify, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (amplify, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (amplify, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
@@ -101,19 +95,19 @@ GST_START_TEST (test_passthrough)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
- gint16 *res;
+ gint16 res[6];
amplify = setup_amplify ();
fail_unless (gst_element_set_state (amplify,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (12);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -122,12 +116,12 @@ GST_START_TEST (test_passthrough)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
in[0], in[1], in[2], in[3], in[4], in[5], res[0], res[1], res[2], res[3],
res[4], res[5]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), in, 12) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, in, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
@@ -142,7 +136,7 @@ GST_START_TEST (test_zero)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { 0, 0, 0, 0, 0, 0 };
- gint16 *res;
+ gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 0.0, NULL);
@@ -150,12 +144,12 @@ GST_START_TEST (test_zero)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (12);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -164,12 +158,12 @@ GST_START_TEST (test_zero)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
@@ -184,7 +178,7 @@ GST_START_TEST (test_050_clip)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { 12288, -8192, 128, -64, 0, -12288 };
- gint16 *res;
+ gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 0.5, NULL);
@@ -192,12 +186,12 @@ GST_START_TEST (test_050_clip)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (12);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -206,12 +200,12 @@ GST_START_TEST (test_050_clip)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
@@ -226,7 +220,7 @@ GST_START_TEST (test_200_clip)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { G_MAXINT16, -32768, 512, -256, 0, G_MININT16 };
- gint16 *res;
+ gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 2.0, NULL);
@@ -234,12 +228,12 @@ GST_START_TEST (test_200_clip)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (12);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -248,12 +242,12 @@ GST_START_TEST (test_200_clip)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
@@ -268,7 +262,7 @@ GST_START_TEST (test_050_wrap_negative)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { 12288, -8192, 128, -64, 0, -12288 };
- gint16 *res;
+ gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 0.5, NULL);
@@ -277,12 +271,12 @@ GST_START_TEST (test_050_wrap_negative)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (12);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -291,12 +285,12 @@ GST_START_TEST (test_050_wrap_negative)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
@@ -311,7 +305,7 @@ GST_START_TEST (test_200_wrap_negative)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { -16384, -32768, 512, -256, 0, 16384 };
- gint16 *res;
+ gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 2.0, NULL);
@@ -320,12 +314,12 @@ GST_START_TEST (test_200_wrap_negative)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (12);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -334,12 +328,12 @@ GST_START_TEST (test_200_wrap_negative)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
@@ -354,7 +348,7 @@ GST_START_TEST (test_050_wrap_positive)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { 12288, -8192, 128, -64, 0, -12288 };
- gint16 *res;
+ gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 0.5, NULL);
@@ -363,12 +357,12 @@ GST_START_TEST (test_050_wrap_positive)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (12);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -377,12 +371,12 @@ GST_START_TEST (test_050_wrap_positive)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
@@ -397,7 +391,7 @@ GST_START_TEST (test_200_wrap_positive)
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
gint16 out[6] = { 16382, -32768, 512, -256, 0, -16384 };
- gint16 *res;
+ gint16 res[6];
amplify = setup_amplify ();
g_object_set (G_OBJECT (amplify), "amplification", 2.0, NULL);
@@ -406,12 +400,12 @@ GST_START_TEST (test_200_wrap_positive)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (12);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
caps = gst_caps_from_string (AMPLIFY_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -420,12 +414,12 @@ GST_START_TEST (test_200_wrap_positive)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], out[4], out[5], res[0], res[1], res[2],
res[3], res[4], res[5]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 12) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 12) == 0);
/* cleanup */
cleanup_amplify (amplify);
diff --git a/tests/check/elements/audiochebband.c b/tests/check/elements/audiochebband.c
index 73a8b15d7..0b2d70fa6 100644
--- a/tests/check/elements/audiochebband.c
+++ b/tests/check/elements/audiochebband.c
@@ -22,6 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
+#include <gst/audio/audio.h>
#include <gst/check/gstcheck.h>
#include <math.h>
@@ -32,35 +33,35 @@
GstPad *mysrcpad, *mysinkpad;
#define BUFFER_CAPS_STRING_32 \
- "audio/x-raw-float, " \
+ "audio/x-raw, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 32" \
+ "format = (string) " GST_AUDIO_NE(F32)
#define BUFFER_CAPS_STRING_64 \
- "audio/x-raw-float, " \
+ "audio/x-raw, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 64" \
+ "format = (string) " GST_AUDIO_NE(F64)
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-float, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
- );
+ "format = (string) { "
+ GST_AUDIO_NE(F32) ", "
+ GST_AUDIO_NE(F64) " }"));
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-float, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
- );
+ "format = (string) { "
+ GST_AUDIO_NE(F32) ", "
+ GST_AUDIO_NE(F64) " }"));
static GstElement *
setup_audiochebband (void)
@@ -69,8 +70,8 @@ setup_audiochebband (void)
GST_DEBUG ("setup_audiochebband");
audiochebband = gst_check_setup_element ("audiochebband");
- mysrcpad = gst_check_setup_src_pad (audiochebband, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (audiochebband, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (audiochebband, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (audiochebband, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
@@ -119,13 +120,14 @@ GST_START_TEST (test_type1_32_bp_0hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -135,7 +137,7 @@ GST_START_TEST (test_type1_32_bp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -143,6 +145,8 @@ GST_START_TEST (test_type1_32_bp_0hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -175,17 +179,18 @@ GST_START_TEST (test_type1_32_bp_11025hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
in[i + 1] = 1.0;
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -195,7 +200,7 @@ GST_START_TEST (test_type1_32_bp_11025hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -203,6 +208,8 @@ GST_START_TEST (test_type1_32_bp_11025hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.6);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -235,15 +242,16 @@ GST_START_TEST (test_type1_32_bp_22050hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -253,7 +261,7 @@ GST_START_TEST (test_type1_32_bp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -261,6 +269,8 @@ GST_START_TEST (test_type1_32_bp_22050hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -293,13 +303,14 @@ GST_START_TEST (test_type1_32_br_0hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -309,7 +320,7 @@ GST_START_TEST (test_type1_32_br_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -317,6 +328,8 @@ GST_START_TEST (test_type1_32_br_0hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -349,17 +362,18 @@ GST_START_TEST (test_type1_32_br_11025hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
in[i + 1] = 1.0;
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -369,7 +383,7 @@ GST_START_TEST (test_type1_32_br_11025hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -377,6 +391,8 @@ GST_START_TEST (test_type1_32_br_11025hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -409,15 +425,16 @@ GST_START_TEST (test_type1_32_br_22050hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -427,7 +444,7 @@ GST_START_TEST (test_type1_32_br_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -435,6 +452,8 @@ GST_START_TEST (test_type1_32_br_22050hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -468,12 +487,13 @@ GST_START_TEST (test_type1_64_bp_0hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -483,7 +503,7 @@ GST_START_TEST (test_type1_64_bp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -491,6 +511,8 @@ GST_START_TEST (test_type1_64_bp_0hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -524,16 +546,17 @@ GST_START_TEST (test_type1_64_bp_11025hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
in[i + 1] = 1.0;
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -543,7 +566,7 @@ GST_START_TEST (test_type1_64_bp_11025hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -551,6 +574,8 @@ GST_START_TEST (test_type1_64_bp_11025hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.6);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -584,14 +609,15 @@ GST_START_TEST (test_type1_64_bp_22050hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -601,7 +627,7 @@ GST_START_TEST (test_type1_64_bp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -609,6 +635,8 @@ GST_START_TEST (test_type1_64_bp_22050hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -642,12 +670,13 @@ GST_START_TEST (test_type1_64_br_0hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -657,7 +686,7 @@ GST_START_TEST (test_type1_64_br_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -665,6 +694,8 @@ GST_START_TEST (test_type1_64_br_0hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -698,16 +729,17 @@ GST_START_TEST (test_type1_64_br_11025hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
in[i + 1] = 1.0;
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -717,7 +749,7 @@ GST_START_TEST (test_type1_64_br_11025hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -725,6 +757,8 @@ GST_START_TEST (test_type1_64_br_11025hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -758,14 +792,15 @@ GST_START_TEST (test_type1_64_br_22050hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -775,7 +810,7 @@ GST_START_TEST (test_type1_64_br_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -783,6 +818,8 @@ GST_START_TEST (test_type1_64_br_22050hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -815,13 +852,14 @@ GST_START_TEST (test_type2_32_bp_0hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -831,7 +869,7 @@ GST_START_TEST (test_type2_32_bp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -839,6 +877,8 @@ GST_START_TEST (test_type2_32_bp_0hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -871,17 +911,18 @@ GST_START_TEST (test_type2_32_bp_11025hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
in[i + 1] = 1.0;
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -891,7 +932,7 @@ GST_START_TEST (test_type2_32_bp_11025hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -899,6 +940,8 @@ GST_START_TEST (test_type2_32_bp_11025hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.6);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -931,15 +974,16 @@ GST_START_TEST (test_type2_32_bp_22050hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -949,7 +993,7 @@ GST_START_TEST (test_type2_32_bp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -957,6 +1001,8 @@ GST_START_TEST (test_type2_32_bp_22050hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -989,13 +1035,14 @@ GST_START_TEST (test_type2_32_br_0hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -1005,7 +1052,7 @@ GST_START_TEST (test_type2_32_br_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -1013,6 +1060,8 @@ GST_START_TEST (test_type2_32_br_0hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -1045,17 +1094,18 @@ GST_START_TEST (test_type2_32_br_11025hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
in[i + 1] = 1.0;
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -1065,7 +1115,7 @@ GST_START_TEST (test_type2_32_br_11025hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -1073,6 +1123,8 @@ GST_START_TEST (test_type2_32_br_11025hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -1105,15 +1157,16 @@ GST_START_TEST (test_type2_32_br_22050hz)
44100 / 4.0 - 1000, NULL);
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
- inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -1123,7 +1176,7 @@ GST_START_TEST (test_type2_32_br_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -1131,6 +1184,8 @@ GST_START_TEST (test_type2_32_br_22050hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -1164,12 +1219,13 @@ GST_START_TEST (test_type2_64_bp_0hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -1179,7 +1235,7 @@ GST_START_TEST (test_type2_64_bp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -1187,6 +1243,8 @@ GST_START_TEST (test_type2_64_bp_0hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -1220,16 +1278,17 @@ GST_START_TEST (test_type2_64_bp_11025hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
in[i + 1] = 1.0;
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -1239,7 +1298,7 @@ GST_START_TEST (test_type2_64_bp_11025hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -1247,6 +1306,8 @@ GST_START_TEST (test_type2_64_bp_11025hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.6);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -1280,14 +1341,15 @@ GST_START_TEST (test_type2_64_bp_22050hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -1297,7 +1359,7 @@ GST_START_TEST (test_type2_64_bp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -1305,6 +1367,8 @@ GST_START_TEST (test_type2_64_bp_22050hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -1338,12 +1402,13 @@ GST_START_TEST (test_type2_64_br_0hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -1353,7 +1418,7 @@ GST_START_TEST (test_type2_64_br_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -1361,6 +1426,8 @@ GST_START_TEST (test_type2_64_br_0hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -1394,16 +1461,17 @@ GST_START_TEST (test_type2_64_br_11025hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 4) {
in[i] = 0.0;
in[i + 1] = 1.0;
in[i + 2] = 0.0;
in[i + 3] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -1413,7 +1481,7 @@ GST_START_TEST (test_type2_64_br_11025hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -1421,6 +1489,8 @@ GST_START_TEST (test_type2_64_br_11025hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
@@ -1454,14 +1524,15 @@ GST_START_TEST (test_type2_64_br_22050hz)
g_object_set (G_OBJECT (audiochebband), "upper-frequency",
44100 / 4.0 + 1000, NULL);
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 1024; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -1471,7 +1542,7 @@ GST_START_TEST (test_type2_64_br_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 1024; i++)
@@ -1479,6 +1550,8 @@ GST_START_TEST (test_type2_64_br_22050hz)
rms = sqrt (rms / 1024.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiochebband (audiochebband);
}
diff --git a/tests/check/elements/audiocheblimit.c b/tests/check/elements/audiocheblimit.c
index 3b4650471..9cdf63cb4 100644
--- a/tests/check/elements/audiocheblimit.c
+++ b/tests/check/elements/audiocheblimit.c
@@ -21,6 +21,7 @@
*/
#include <gst/gst.h>
+#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
#include <gst/check/gstcheck.h>
@@ -32,35 +33,35 @@
GstPad *mysrcpad, *mysinkpad;
#define BUFFER_CAPS_STRING_32 \
- "audio/x-raw-float, " \
+ "audio/x-raw, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 32" \
+ "format = (string) " GST_AUDIO_NE(F32)
#define BUFFER_CAPS_STRING_64 \
- "audio/x-raw-float, " \
+ "audio/x-raw, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 64" \
+ "format = (string) " GST_AUDIO_NE(F64)
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-float, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
- );
+ "format = (string) { "
+ GST_AUDIO_NE(F32) ", "
+ GST_AUDIO_NE(F64) " }"));
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-float, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
- );
+ "format = (string) { "
+ GST_AUDIO_NE(F32) ", "
+ GST_AUDIO_NE(F64) " }"));
static GstElement *
setup_audiocheblimit (void)
@@ -69,8 +70,8 @@ setup_audiocheblimit (void)
GST_DEBUG ("setup_audiocheblimit");
audiocheblimit = gst_check_setup_element ("audiocheblimit");
- mysrcpad = gst_check_setup_src_pad (audiocheblimit, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (audiocheblimit, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (audiocheblimit, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (audiocheblimit, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
@@ -116,13 +117,14 @@ GST_START_TEST (test_type1_32_lp_0hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -132,7 +134,7 @@ GST_START_TEST (test_type1_32_lp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -140,6 +142,8 @@ GST_START_TEST (test_type1_32_lp_0hz)
rms = sqrt (rms / 128.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -169,15 +173,16 @@ GST_START_TEST (test_type1_32_lp_22050hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -187,7 +192,7 @@ GST_START_TEST (test_type1_32_lp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -195,6 +200,8 @@ GST_START_TEST (test_type1_32_lp_22050hz)
rms = sqrt (rms / 128.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -224,13 +231,14 @@ GST_START_TEST (test_type1_32_hp_0hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -240,7 +248,7 @@ GST_START_TEST (test_type1_32_hp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -248,6 +256,8 @@ GST_START_TEST (test_type1_32_hp_0hz)
rms = sqrt (rms / 128.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -277,15 +287,16 @@ GST_START_TEST (test_type1_32_hp_22050hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -295,7 +306,7 @@ GST_START_TEST (test_type1_32_hp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -303,6 +314,8 @@ GST_START_TEST (test_type1_32_hp_22050hz)
rms = sqrt (rms / 128.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -332,13 +345,14 @@ GST_START_TEST (test_type1_64_lp_0hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gdouble), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -348,7 +362,7 @@ GST_START_TEST (test_type1_64_lp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -356,6 +370,8 @@ GST_START_TEST (test_type1_64_lp_0hz)
rms = sqrt (rms / 128.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -385,15 +401,16 @@ GST_START_TEST (test_type1_64_lp_22050hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gdouble), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -403,7 +420,7 @@ GST_START_TEST (test_type1_64_lp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -411,6 +428,8 @@ GST_START_TEST (test_type1_64_lp_22050hz)
rms = sqrt (rms / 128.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -440,13 +459,14 @@ GST_START_TEST (test_type1_64_hp_0hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gdouble), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -456,7 +476,7 @@ GST_START_TEST (test_type1_64_hp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -464,6 +484,8 @@ GST_START_TEST (test_type1_64_hp_0hz)
rms = sqrt (rms / 128.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -493,15 +515,16 @@ GST_START_TEST (test_type1_64_hp_22050hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gdouble), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -511,7 +534,7 @@ GST_START_TEST (test_type1_64_hp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -519,6 +542,8 @@ GST_START_TEST (test_type1_64_hp_22050hz)
rms = sqrt (rms / 128.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -548,13 +573,14 @@ GST_START_TEST (test_type2_32_lp_0hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -564,7 +590,7 @@ GST_START_TEST (test_type2_32_lp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -572,6 +598,8 @@ GST_START_TEST (test_type2_32_lp_0hz)
rms = sqrt (rms / 128.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -601,15 +629,16 @@ GST_START_TEST (test_type2_32_lp_22050hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -619,7 +648,7 @@ GST_START_TEST (test_type2_32_lp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -627,6 +656,8 @@ GST_START_TEST (test_type2_32_lp_22050hz)
rms = sqrt (rms / 128.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -656,13 +687,14 @@ GST_START_TEST (test_type2_32_hp_0hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -672,7 +704,7 @@ GST_START_TEST (test_type2_32_hp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -680,6 +712,8 @@ GST_START_TEST (test_type2_32_hp_0hz)
rms = sqrt (rms / 128.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -709,15 +743,16 @@ GST_START_TEST (test_type2_32_hp_22050hz)
"could not set to playing");
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
- inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
- in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 128 * sizeof (gfloat), 0);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -727,7 +762,7 @@ GST_START_TEST (test_type2_32_hp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -735,6 +770,8 @@ GST_START_TEST (test_type2_32_hp_22050hz)
rms = sqrt (rms / 128.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -765,12 +802,13 @@ GST_START_TEST (test_type2_64_lp_0hz)
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -780,7 +818,7 @@ GST_START_TEST (test_type2_64_lp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -788,6 +826,8 @@ GST_START_TEST (test_type2_64_lp_0hz)
rms = sqrt (rms / 128.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -818,14 +858,15 @@ GST_START_TEST (test_type2_64_lp_22050hz)
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -835,7 +876,7 @@ GST_START_TEST (test_type2_64_lp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -843,6 +884,8 @@ GST_START_TEST (test_type2_64_lp_22050hz)
rms = sqrt (rms / 128.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -873,12 +916,13 @@ GST_START_TEST (test_type2_64_hp_0hz)
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i++)
in[i] = 1.0;
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -888,7 +932,7 @@ GST_START_TEST (test_type2_64_hp_0hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -896,6 +940,8 @@ GST_START_TEST (test_type2_64_hp_0hz)
rms = sqrt (rms / 128.0);
fail_unless (rms <= 0.1);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
@@ -926,14 +972,15 @@ GST_START_TEST (test_type2_64_hp_22050hz)
g_object_set (G_OBJECT (audiocheblimit), "cutoff", 44100 / 4.0, NULL);
inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
- in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 128; i += 2) {
in[i] = 1.0;
in[i + 1] = -1.0;
}
+ gst_buffer_unmap (inbuffer, in, -1);
caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -943,7 +990,7 @@ GST_START_TEST (test_type2_64_hp_22050hz)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ res = gst_buffer_map (outbuffer, NULL, NULL, GST_MAP_READ);
rms = 0.0;
for (i = 0; i < 128; i++)
@@ -951,6 +998,8 @@ GST_START_TEST (test_type2_64_hp_22050hz)
rms = sqrt (rms / 128.0);
fail_unless (rms >= 0.9);
+ gst_buffer_unmap (outbuffer, res, -1);
+
/* cleanup */
cleanup_audiocheblimit (audiocheblimit);
}
diff --git a/tests/check/elements/audiodynamic.c b/tests/check/elements/audiodynamic.c
index 111977940..d31a46404 100644
--- a/tests/check/elements/audiodynamic.c
+++ b/tests/check/elements/audiodynamic.c
@@ -25,6 +25,7 @@
#include <unistd.h>
+#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
#include <gst/check/gstcheck.h>
@@ -37,32 +38,25 @@ GstPad *mysrcpad, *mysinkpad;
#define DYNAMIC_CAPS_STRING \
- "audio/x-raw-int, " \
+ "audio/x-raw, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 16, " \
- "depth = (int) 16, " \
- "signed = (bool) TRUE"
+ "format = (string) " GST_AUDIO_NE(S16)
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
- );
+ "format = (string)" GST_AUDIO_NE(S16)));
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
- );
+ "format = (string) " GST_AUDIO_NE(S16)));
static GstElement *
setup_dynamic (void)
@@ -71,8 +65,8 @@ setup_dynamic (void)
GST_DEBUG ("setup_dynamic");
dynamic = gst_check_setup_element ("audiodynamic");
- mysrcpad = gst_check_setup_src_pad (dynamic, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (dynamic, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (dynamic, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (dynamic, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
@@ -101,18 +95,17 @@ GST_START_TEST (test_passthrough)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
- gint16 *res;
+ gint16 res[6];
dynamic = setup_dynamic ();
fail_unless (gst_element_set_state (dynamic,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (12);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -122,12 +115,12 @@ GST_START_TEST (test_passthrough)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
in[0], in[1], in[2], in[3], in[4], in[5], res[0], res[1], res[2], res[3],
res[4], res[5]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), in, 12) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, in, 12) == 0);
/* cleanup */
cleanup_dynamic (dynamic);
@@ -141,7 +134,7 @@ GST_START_TEST (test_compress_hard_50_50)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16384, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 0, NULL);
@@ -152,11 +145,10 @@ GST_START_TEST (test_compress_hard_50_50)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -166,7 +158,7 @@ GST_START_TEST (test_compress_hard_50_50)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] > in[0]);
fail_unless (res[1] < in[1]);
@@ -189,7 +181,7 @@ GST_START_TEST (test_compress_soft_50_50)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16384, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 0, NULL);
@@ -200,11 +192,10 @@ GST_START_TEST (test_compress_soft_50_50)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -214,7 +205,7 @@ GST_START_TEST (test_compress_soft_50_50)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] > in[0]);
fail_unless (res[1] < in[1]);
@@ -237,7 +228,7 @@ GST_START_TEST (test_compress_hard_100_50)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16384, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 0, NULL);
@@ -248,11 +239,10 @@ GST_START_TEST (test_compress_hard_100_50)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -262,7 +252,7 @@ GST_START_TEST (test_compress_hard_100_50)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] == in[0]);
fail_unless (res[1] == in[1]);
@@ -286,7 +276,7 @@ GST_START_TEST (test_expand_hard_50_200)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16383, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 1, NULL);
@@ -297,11 +287,10 @@ GST_START_TEST (test_expand_hard_50_200)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -311,7 +300,7 @@ GST_START_TEST (test_expand_hard_50_200)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] == in[0]);
fail_unless (res[1] == in[1]);
@@ -334,7 +323,7 @@ GST_START_TEST (test_expand_soft_50_200)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16383, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 1, NULL);
@@ -345,11 +334,10 @@ GST_START_TEST (test_expand_soft_50_200)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -359,7 +347,7 @@ GST_START_TEST (test_expand_soft_50_200)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] == in[0]);
fail_unless (res[1] == in[1]);
@@ -382,7 +370,7 @@ GST_START_TEST (test_expand_hard_0_200)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16383, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 1, NULL);
@@ -393,11 +381,10 @@ GST_START_TEST (test_expand_hard_0_200)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -407,7 +394,7 @@ GST_START_TEST (test_expand_hard_0_200)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] == in[0]);
fail_unless (res[1] == in[1]);
diff --git a/tests/check/elements/audioecho.c b/tests/check/elements/audioecho.c
index fa88c3ffa..5c17234a7 100644
--- a/tests/check/elements/audioecho.c
+++ b/tests/check/elements/audioecho.c
@@ -19,6 +19,7 @@
*/
#include <gst/check/gstcheck.h>
+#include <gst/audio/audio.h>
gboolean have_eos = FALSE;
@@ -28,28 +29,29 @@ gboolean have_eos = FALSE;
GstPad *mysrcpad, *mysinkpad;
#define ECHO_CAPS_STRING \
- "audio/x-raw-float, " \
+ "audio/x-raw, " \
"channels = (int) 2, " \
"rate = (int) 100000, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 64"
+ "format = (string) " GST_AUDIO_NE(F64)
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-float, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) [ 1, 2 ], "
"rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
- );
+ "format = (string) { "
+ GST_AUDIO_NE(F32) ", "
+ GST_AUDIO_NE(F64) " }"));
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-float, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) [ 1, 2 ], "
"rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
- );
+ "format = (string) { "
+ GST_AUDIO_NE(F32) ", "
+ GST_AUDIO_NE(F64) " }"));
static GstElement *
setup_echo (void)
@@ -58,8 +60,8 @@ setup_echo (void)
GST_DEBUG ("setup_echo");
echo = gst_check_setup_element ("audioecho");
- mysrcpad = gst_check_setup_src_pad (echo, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (echo, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (echo, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (echo, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
@@ -88,7 +90,7 @@ GST_START_TEST (test_passthrough)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gdouble in[] = { 1.0, -1.0, 0.0, 0.5, -0.5, 0.0 };
- gdouble *res;
+ gdouble res[6];
echo = setup_echo ();
g_object_set (G_OBJECT (echo), "delay", (GstClockTime) 1, "intensity", 0.0,
@@ -97,12 +99,12 @@ GST_START_TEST (test_passthrough)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (sizeof (in));
- memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in));
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0);
caps = gst_caps_from_string (ECHO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, sizeof (in));
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, sizeof (in)) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -111,12 +113,12 @@ GST_START_TEST (test_passthrough)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, sizeof (res)) == sizeof (res));
GST_INFO
("expected %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf",
in[0], in[1], in[2], in[3], in[4], in[5], res[0], res[1], res[2], res[3],
res[4], res[5]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), in, sizeof (in)) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, in, sizeof (in)) == 0);
/* cleanup */
cleanup_echo (echo);
@@ -131,7 +133,7 @@ GST_START_TEST (test_echo)
GstCaps *caps;
gdouble in[] = { 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, };
gdouble out[] = { 1.0, -1.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0 };
- gdouble *res;
+ gdouble res[10];
echo = setup_echo ();
g_object_set (G_OBJECT (echo), "delay", (GstClockTime) 20000, "intensity",
@@ -140,12 +142,12 @@ GST_START_TEST (test_echo)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (sizeof (in));
- memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in));
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0);
caps = gst_caps_from_string (ECHO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, sizeof (in));
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, sizeof (in)) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -154,13 +156,13 @@ GST_START_TEST (test_echo)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, sizeof (res)) == sizeof (res));
GST_INFO
("expected %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf",
out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8],
out[9], res[0], res[1], res[2], res[3], res[4], res[5], res[6], res[7],
res[8], res[9]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, sizeof (out)) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, sizeof (out)) == 0);
/* cleanup */
cleanup_echo (echo);
@@ -175,7 +177,7 @@ GST_START_TEST (test_feedback)
GstCaps *caps;
gdouble in[] = { 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, };
gdouble out[] = { 1.0, -1.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0, 1.0, -1.0 };
- gdouble *res;
+ gdouble res[10];
echo = setup_echo ();
g_object_set (G_OBJECT (echo), "delay", (GstClockTime) 20000, "intensity",
@@ -184,12 +186,12 @@ GST_START_TEST (test_feedback)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (sizeof (in));
- memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in));
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0);
caps = gst_caps_from_string (ECHO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, sizeof (in));
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, sizeof (in)) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -198,13 +200,13 @@ GST_START_TEST (test_feedback)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, sizeof (res)) == sizeof (res));
GST_INFO
("expected %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf",
out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8],
out[9], res[0], res[1], res[2], res[3], res[4], res[5], res[6], res[7],
res[8], res[9]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, sizeof (out)) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, sizeof (out)) == 0);
/* cleanup */
cleanup_echo (echo);
diff --git a/tests/check/elements/audioinvert.c b/tests/check/elements/audioinvert.c
index 39ff80e09..b04178694 100644
--- a/tests/check/elements/audioinvert.c
+++ b/tests/check/elements/audioinvert.c
@@ -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 *
@@ -71,8 +64,8 @@ setup_invert (void)
GST_DEBUG ("setup_invert");
invert = gst_check_setup_element ("audioinvert");
- mysrcpad = gst_check_setup_src_pad (invert, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (invert, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (invert, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (invert, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
diff --git a/tests/check/elements/audiopanorama.c b/tests/check/elements/audiopanorama.c
index 07abca737..42fce976d 100644
--- a/tests/check/elements/audiopanorama.c
+++ b/tests/check/elements/audiopanorama.c
@@ -22,6 +22,7 @@
#include <unistd.h>
+#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
#include <gst/check/gstcheck.h>
@@ -34,59 +35,47 @@ GstPad *mysrcpad, *mysinkpad;
#define PANORAMA_MONO_CAPS_STRING \
- "audio/x-raw-int, " \
+ "audio/x-raw, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 16, " \
- "depth = (int) 16, " \
- "signed = (bool) TRUE"
+ "format = (string) " GST_AUDIO_NE(S16)
#define PANORAMA_STEREO_CAPS_STRING \
- "audio/x-raw-int, " \
+ "audio/x-raw, " \
"channels = (int) 2, " \
"rate = (int) 44100, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 16, " \
- "depth = (int) 16, " \
- "signed = (bool) TRUE"
+ "format = (string) " GST_AUDIO_NE(S16)
#define PANORAMA_WRONG_CAPS_STRING \
- "audio/x-raw-int, " \
+ "audio/x-raw, " \
"channels = (int) 5, " \
"rate = (int) 44100, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 16, " \
- "depth = (int) 16, " \
- "signed = (bool) FALSE"
+ "format = (string) " GST_AUDIO_NE(U16)
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 2, "
"rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
+ "format = (string) " GST_AUDIO_NE(S16))
);
static GstStaticPadTemplate msrctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
+ "format = (string) " GST_AUDIO_NE(S16))
);
static GstStaticPadTemplate ssrctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 2, "
"rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
+ "format = (string) " GST_AUDIO_NE(S16))
);
static GstElement *
@@ -96,8 +85,8 @@ setup_panorama_m (void)
GST_DEBUG ("setup_panorama");
panorama = gst_check_setup_element ("audiopanorama");
- mysrcpad = gst_check_setup_src_pad (panorama, &msrctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (panorama, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (panorama, &msrctemplate);
+ mysinkpad = gst_check_setup_sink_pad (panorama, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
@@ -111,8 +100,8 @@ setup_panorama_s (void)
GST_DEBUG ("setup_panorama");
panorama = gst_check_setup_element ("audiopanorama");
- mysrcpad = gst_check_setup_src_pad (panorama, &ssrctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (panorama, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (panorama, &ssrctemplate);
+ mysinkpad = gst_check_setup_sink_pad (panorama, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
@@ -142,18 +131,18 @@ GST_START_TEST (test_mono_middle)
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 out[4] = { 8192, 8192, -128, -128 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_m ();
fail_unless (gst_element_set_state (panorama,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (4);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
caps = gst_caps_from_string (PANORAMA_MONO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 4);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -162,10 +151,10 @@ GST_START_TEST (test_mono_middle)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8) == 8);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_panorama (panorama);
@@ -180,7 +169,7 @@ GST_START_TEST (test_mono_left)
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 out[4] = { 16384, 0, -256, 0 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_m ();
g_object_set (G_OBJECT (panorama), "panorama", -1.0, NULL);
@@ -188,12 +177,12 @@ GST_START_TEST (test_mono_left)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (4);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
caps = gst_caps_from_string (PANORAMA_MONO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 4);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 4) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -202,10 +191,10 @@ GST_START_TEST (test_mono_left)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8) == 8);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_panorama (panorama);
@@ -220,7 +209,7 @@ GST_START_TEST (test_mono_right)
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 out[4] = { 0, 16384, 0, -256 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_m ();
g_object_set (G_OBJECT (panorama), "panorama", 1.0, NULL);
@@ -228,12 +217,12 @@ GST_START_TEST (test_mono_right)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (4);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
caps = gst_caps_from_string (PANORAMA_MONO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 4);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 4) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -242,10 +231,10 @@ GST_START_TEST (test_mono_right)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8) == 8);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_panorama (panorama);
@@ -259,35 +248,32 @@ GST_START_TEST (test_stereo_middle)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[4] = { 16384, -256, 8192, 128 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_s ();
fail_unless (gst_element_set_state (panorama,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (8);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
caps = gst_caps_from_string (PANORAMA_STEREO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
- ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
- /* pushing gives away my reference ... so keep an extra one */
- gst_buffer_ref (inbuffer);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 8);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+ /* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
/* ... but it ends up being collected on the global buffer list */
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (inbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8) == 8);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
in[0], in[1], in[2], in[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), in, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, in, 8) == 0);
/* cleanup */
- gst_buffer_unref (inbuffer);
cleanup_panorama (panorama);
}
@@ -300,7 +286,7 @@ GST_START_TEST (test_stereo_left)
GstCaps *caps;
gint16 in[4] = { 16384, -256, 8192, 128 };
gint16 out[4] = { 16384 - 256, 0, 8192 + 128, 0 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_s ();
g_object_set (G_OBJECT (panorama), "panorama", -1.0, NULL);
@@ -308,12 +294,12 @@ GST_START_TEST (test_stereo_left)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (8);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
caps = gst_caps_from_string (PANORAMA_STEREO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 8);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -322,10 +308,10 @@ GST_START_TEST (test_stereo_left)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8) == 8);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_panorama (panorama);
@@ -340,7 +326,7 @@ GST_START_TEST (test_stereo_right)
GstCaps *caps;
gint16 in[4] = { 16384, -256, 8192, 128 };
gint16 out[4] = { 0, -256 + 16384, 0, 128 + 8192 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_s ();
g_object_set (G_OBJECT (panorama), "panorama", 1.0, NULL);
@@ -348,12 +334,12 @@ GST_START_TEST (test_stereo_right)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (8);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
caps = gst_caps_from_string (PANORAMA_STEREO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 8);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
@@ -362,10 +348,10 @@ GST_START_TEST (test_stereo_right)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8));
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_panorama (panorama);
@@ -380,7 +366,7 @@ GST_START_TEST (test_mono_middle_simple)
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 out[4] = { 16384, 16384, -256, -256 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_m ();
g_object_set (G_OBJECT (panorama), "method", 1, NULL);
@@ -388,10 +374,9 @@ GST_START_TEST (test_mono_middle_simple)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (4);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 4);
caps = gst_caps_from_string (PANORAMA_MONO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -401,10 +386,10 @@ GST_START_TEST (test_mono_middle_simple)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8) == 8);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_panorama (panorama);
@@ -419,7 +404,7 @@ GST_START_TEST (test_mono_left_simple)
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 out[4] = { 16384, 0, -256, 0 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_m ();
g_object_set (G_OBJECT (panorama), "method", 1, NULL);
@@ -428,11 +413,10 @@ GST_START_TEST (test_mono_left_simple)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (4);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 4);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 4) == 0);
caps = gst_caps_from_string (PANORAMA_MONO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -442,10 +426,10 @@ GST_START_TEST (test_mono_left_simple)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8) == 8);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_panorama (panorama);
@@ -460,7 +444,7 @@ GST_START_TEST (test_mono_right_simple)
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 out[4] = { 0, 16384, 0, -256 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_m ();
g_object_set (G_OBJECT (panorama), "method", 1, NULL);
@@ -469,11 +453,10 @@ GST_START_TEST (test_mono_right_simple)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (4);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 4);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 4) == 0);
caps = gst_caps_from_string (PANORAMA_MONO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -483,10 +466,10 @@ GST_START_TEST (test_mono_right_simple)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8) == 8);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_panorama (panorama);
@@ -500,7 +483,7 @@ GST_START_TEST (test_stereo_middle_simple)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[4] = { 16384, -256, 8192, 128 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_s ();
g_object_set (G_OBJECT (panorama), "method", 1, NULL);
@@ -508,28 +491,24 @@ GST_START_TEST (test_stereo_middle_simple)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (8);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 8);
caps = gst_caps_from_string (PANORAMA_STEREO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
- /* pushing gives away my reference ... so keep an extra one */
- gst_buffer_ref (inbuffer);
-
+ /* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
/* ... but it ends up being collected on the global buffer list */
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (inbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8) == 8);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
in[0], in[1], in[2], in[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), in, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, in, 8) == 0);
/* cleanup */
- gst_buffer_unref (inbuffer);
cleanup_panorama (panorama);
}
@@ -542,7 +521,7 @@ GST_START_TEST (test_stereo_left_simple)
GstCaps *caps;
gint16 in[4] = { 16384, -256, 8192, 128 };
gint16 out[4] = { 16384, 0, 8192, 0 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_s ();
g_object_set (G_OBJECT (panorama), "method", 1, NULL);
@@ -551,11 +530,10 @@ GST_START_TEST (test_stereo_left_simple)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (8);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 8);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
caps = gst_caps_from_string (PANORAMA_STEREO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -565,10 +543,10 @@ GST_START_TEST (test_stereo_left_simple)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8) == 8);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_panorama (panorama);
@@ -583,7 +561,7 @@ GST_START_TEST (test_stereo_right_simple)
GstCaps *caps;
gint16 in[4] = { 16384, -256, 8192, 128 };
gint16 out[4] = { 0, -256, 0, 128 };
- gint16 *res;
+ gint16 res[4];
panorama = setup_panorama_s ();
g_object_set (G_OBJECT (panorama), "method", 1, NULL);
@@ -592,11 +570,10 @@ GST_START_TEST (test_stereo_right_simple)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (8);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 8);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
caps = gst_caps_from_string (PANORAMA_STEREO_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -606,10 +583,10 @@ GST_START_TEST (test_stereo_right_simple)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 8) == 8);
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d",
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, out, 8) == 0);
/* cleanup */
cleanup_panorama (panorama);
@@ -633,17 +610,18 @@ GST_START_TEST (test_wrong_caps)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (4);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
- caps = gst_caps_from_string (PANORAMA_WRONG_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
- gst_caps_unref (caps);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 4);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
gst_buffer_ref (inbuffer);
/* set a bus here so we avoid getting state change messages */
gst_element_set_bus (panorama, bus);
+ caps = gst_caps_from_string (PANORAMA_WRONG_CAPS_STRING);
+ /* this actually succeeds, because the caps event is sticky */
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
+ gst_caps_unref (caps);
+
/* pushing gives an error because it can't negotiate with wrong caps */
fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer),
GST_FLOW_NOT_NEGOTIATED);
diff --git a/tests/check/elements/audiowsincband.c b/tests/check/elements/audiowsincband.c
index 137f425fa..75bbfd876 100644
--- a/tests/check/elements/audiowsincband.c
+++ b/tests/check/elements/audiowsincband.c
@@ -69,8 +69,8 @@ setup_audiowsincband (void)
GST_DEBUG ("setup_audiowsincband");
audiowsincband = gst_check_setup_element ("audiowsincband");
- mysrcpad = gst_check_setup_src_pad (audiowsincband, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (audiowsincband, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (audiowsincband, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (audiowsincband, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
diff --git a/tests/check/elements/audiowsinclimit.c b/tests/check/elements/audiowsinclimit.c
index a5f029131..abd2c7e9b 100644
--- a/tests/check/elements/audiowsinclimit.c
+++ b/tests/check/elements/audiowsinclimit.c
@@ -69,8 +69,8 @@ setup_audiowsinclimit (void)
GST_DEBUG ("setup_audiowsinclimit");
audiowsinclimit = gst_check_setup_element ("audiowsinclimit");
- mysrcpad = gst_check_setup_src_pad (audiowsinclimit, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (audiowsinclimit, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (audiowsinclimit, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (audiowsinclimit, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
diff --git a/tests/check/elements/autodetect.c b/tests/check/elements/autodetect.c
index 0eb798b1e..b4ab60e95 100644
--- a/tests/check/elements/autodetect.c
+++ b/tests/check/elements/autodetect.c
@@ -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);
diff --git a/tests/check/elements/avimux.c b/tests/check/elements/avimux.c
index be06a6b2e..128af6a2f 100644
--- a/tests/check/elements/avimux.c
+++ b/tests/check/elements/avimux.c
@@ -123,7 +123,7 @@ setup_avimux (GstStaticPadTemplate * srctemplate, const gchar * sinkname)
GST_DEBUG ("setup_avimux");
avimux = gst_check_setup_element ("avimux");
mysrcpad = setup_src_pad (avimux, srctemplate, NULL, sinkname);
- mysinkpad = gst_check_setup_sink_pad (avimux, &sinktemplate, NULL);
+ mysinkpad = gst_check_setup_sink_pad (avimux, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
@@ -231,7 +231,7 @@ check_avimux_pad (GstStaticPadTemplate * srctemplate,
GST_START_TEST (test_video_pad)
{
- check_avimux_pad (&srcvideotemplate, VIDEO_CAPS_STRING, "00db", "video_%d");
+ check_avimux_pad (&srcvideotemplate, VIDEO_CAPS_STRING, "00db", "video_%u");
}
GST_END_TEST;
@@ -239,7 +239,7 @@ GST_END_TEST;
GST_START_TEST (test_audio_pad)
{
- check_avimux_pad (&srcaudiotemplate, AUDIO_CAPS_STRING, "00wb", "audio_%d");
+ check_avimux_pad (&srcaudiotemplate, AUDIO_CAPS_STRING, "00wb", "audio_%u");
}
GST_END_TEST;
diff --git a/tests/check/elements/avisubtitle.c b/tests/check/elements/avisubtitle.c
index 06598ac31..d2d980dcd 100644
--- a/tests/check/elements/avisubtitle.c
+++ b/tests/check/elements/avisubtitle.c
@@ -70,18 +70,20 @@ static GstElement *
setup_avisubtitle (void)
{
GstElement *avisubtitle;
- GstCaps *caps;
+ GstCaps *sinkcaps, *srccaps;
GST_DEBUG ("setup_avisubtitle");
avisubtitle = gst_check_setup_element ("avisubtitle");
- caps = gst_caps_new_simple ("application/x-subtitle", NULL);
- mysinkpad = gst_check_setup_sink_pad (avisubtitle, &sink_template, caps);
- gst_caps_unref (caps);
- caps = gst_caps_new_simple ("application/x-subtitle-avi", NULL);
- mysrcpad = gst_check_setup_src_pad (avisubtitle, &src_template, caps);
- gst_caps_unref (caps);
+ sinkcaps = gst_caps_new_empty_simple ("application/x-subtitle");
+ mysinkpad = gst_check_setup_sink_pad (avisubtitle, &sink_template);
+ srccaps = gst_caps_new_empty_simple ("application/x-subtitle-avi");
+ mysrcpad = gst_check_setup_src_pad (avisubtitle, &src_template);
gst_pad_set_active (mysinkpad, TRUE);
gst_pad_set_active (mysrcpad, TRUE);
+ fail_unless (gst_pad_set_caps (mysinkpad, sinkcaps));
+ fail_unless (gst_pad_set_caps (mysrcpad, srccaps));
+ gst_caps_unref (sinkcaps);
+ gst_caps_unref (srccaps);
return avisubtitle;
}
diff --git a/tests/check/elements/capssetter.c b/tests/check/elements/capssetter.c
index 0a6986bed..d302d65ee 100644
--- a/tests/check/elements/capssetter.c
+++ b/tests/check/elements/capssetter.c
@@ -48,8 +48,8 @@ setup_capssetter (void)
GST_DEBUG ("setup_capssetter");
capssetter = gst_check_setup_element ("capssetter");
- mysrcpad = gst_check_setup_src_pad (capssetter, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (capssetter, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (capssetter, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (capssetter, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
diff --git a/tests/check/elements/cmmldec.c b/tests/check/elements/cmmldec.c
index a6b8559d5..90438783c 100644
--- a/tests/check/elements/cmmldec.c
+++ b/tests/check/elements/cmmldec.c
@@ -116,14 +116,12 @@ static GstBuffer *
buffer_new (const gchar * buffer_data, guint size)
{
GstBuffer *buffer;
+ guint8 *data;
- GstCaps *caps;
+ data = g_malloc (size);
+ memcpy (data, buffer_data, size);
- buffer = gst_buffer_new_and_alloc (size);
- memcpy (GST_BUFFER_DATA (buffer), buffer_data, size);
- caps = gst_caps_from_string (SRC_CAPS);
- gst_buffer_set_caps (buffer, caps);
- gst_caps_unref (caps);
+ buffer = gst_buffer_new_wrapped (data, size);
return buffer;
}
@@ -140,8 +138,8 @@ setup_cmmldec (void)
{
GST_DEBUG ("setup_cmmldec");
cmmldec = gst_check_setup_element ("cmmldec");
- srcpad = gst_check_setup_src_pad (cmmldec, &srctemplate, NULL);
- sinkpad = gst_check_setup_sink_pad (cmmldec, &sinktemplate, NULL);
+ srcpad = gst_check_setup_src_pad (cmmldec, &srctemplate);
+ sinkpad = gst_check_setup_sink_pad (cmmldec, &sinktemplate);
gst_pad_set_active (srcpad, TRUE);
gst_pad_set_active (sinkpad, TRUE);
@@ -181,6 +179,8 @@ check_output_buffer_is_equal (const gchar * name,
const gchar * data, gint refcount)
{
GstBuffer *buffer;
+ gpointer buf_data;
+ gsize size;
if (current_buf == NULL)
current_buf = buffers;
@@ -190,11 +190,13 @@ check_output_buffer_is_equal (const gchar * name,
fail_unless (current_buf != NULL);
buffer = GST_BUFFER (current_buf->data);
+ buf_data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
ASSERT_OBJECT_REFCOUNT (buffer, name, refcount);
- fail_unless (memcmp (GST_BUFFER_DATA (buffer), data,
- GST_BUFFER_SIZE (buffer)) == 0,
- "'%s' (%s) is not equal to (%s)", name, GST_BUFFER_DATA (buffer), data);
+ fail_unless (memcmp (buf_data, data, size) == 0,
+ "'%s' (%s) is not equal to (%s)", name, buf_data, data);
+
+ gst_buffer_unmap (buffer, buf_data, size);
}
static GstFlowReturn
@@ -207,6 +209,16 @@ push_data (const gchar * name, const gchar * data, gint size, gint64 granulepos)
return gst_pad_push (srcpad, buffer);
}
+static void
+push_caps (void)
+{
+ GstCaps *caps;
+
+ caps = gst_caps_from_string (SRC_CAPS);
+ fail_unless (gst_pad_set_caps (srcpad, caps));
+ gst_caps_unref (caps);
+}
+
static GObject *
cmml_tag_message_pop (GstBus * bus, const gchar * tag)
{
@@ -246,6 +258,8 @@ check_headers (void)
GValueArray *meta;
+ push_caps ();
+
/* push the ident header */
flow = push_data ("ident-header", IDENT_HEADER, IDENT_HEADER_SIZE, 0);
fail_unless_equals_flow_return (flow, GST_FLOW_OK);
@@ -371,6 +385,8 @@ GST_END_TEST;
GST_START_TEST (test_preamble_no_pi)
{
+ push_caps ();
+
flow = push_data ("ident-header", IDENT_HEADER, IDENT_HEADER_SIZE, 0);
fail_unless_equals_flow_return (flow, GST_FLOW_OK);
fail_unless_equals_int (g_list_length (buffers), 0);
@@ -531,6 +547,8 @@ GST_START_TEST (test_weird_input)
{
const gchar *bad_xml = "<?xml version=\"1.0\"?><a><b></a>";
+ push_caps ();
+
/* malformed ident header */
flow = push_data ("bad-ident-header", "CMML\0\0\0\0garbage", 15, 0);
fail_unless_equals_flow_return (flow, GST_FLOW_ERROR);
@@ -569,7 +587,7 @@ GST_START_TEST (test_sink_query_convert)
granulepos = keyindex + keyoffset;
fail_unless (gst_pad_query_convert (GST_PAD_PEER (srcpad),
- GST_FORMAT_DEFAULT, granulepos, &dstfmt, &dstval));
+ GST_FORMAT_DEFAULT, granulepos, dstfmt, &dstval));
fail_unless (dstfmt == GST_FORMAT_TIME);
/* fail unless dstval == index + offset */
diff --git a/tests/check/elements/cmmlenc.c b/tests/check/elements/cmmlenc.c
index 4b95d713e..30c9d270d 100644
--- a/tests/check/elements/cmmlenc.c
+++ b/tests/check/elements/cmmlenc.c
@@ -133,13 +133,12 @@ static GstBuffer *
buffer_new (const gchar * buffer_data, guint size)
{
GstBuffer *buffer;
- GstCaps *caps;
+ guint8 *data;
- buffer = gst_buffer_new_and_alloc (size);
- memcpy (GST_BUFFER_DATA (buffer), buffer_data, size);
- caps = gst_caps_from_string (SRC_CAPS);
- gst_buffer_set_caps (buffer, caps);
- gst_caps_unref (caps);
+ data = g_malloc (size);
+ memcpy (data, buffer_data, size);
+
+ buffer = gst_buffer_new_wrapped (data, size);
return buffer;
}
@@ -158,8 +157,8 @@ setup_cmmlenc (void)
GST_DEBUG ("setup_cmmlenc");
cmmlenc = gst_check_setup_element ("cmmlenc");
- srcpad = gst_check_setup_src_pad (cmmlenc, &srctemplate, NULL);
- sinkpad = gst_check_setup_sink_pad (cmmlenc, &sinktemplate, NULL);
+ srcpad = gst_check_setup_src_pad (cmmlenc, &srctemplate);
+ sinkpad = gst_check_setup_sink_pad (cmmlenc, &sinktemplate);
gst_pad_set_active (srcpad, TRUE);
gst_pad_set_active (sinkpad, TRUE);
@@ -202,6 +201,8 @@ check_output_buffer_is_equal (const gchar * name,
const gchar * data, gint refcount)
{
GstBuffer *buffer;
+ gpointer buf_data;
+ gsize size;
if (current_buf == NULL)
current_buf = buffers;
@@ -210,11 +211,13 @@ check_output_buffer_is_equal (const gchar * name,
fail_unless (current_buf != NULL);
buffer = GST_BUFFER (current_buf->data);
+ buf_data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
ASSERT_OBJECT_REFCOUNT (buffer, name, refcount);
- fail_unless (memcmp (GST_BUFFER_DATA (buffer), data,
- GST_BUFFER_SIZE (buffer)) == 0,
- "'%s' (%s) is not equal to (%s)", name, GST_BUFFER_DATA (buffer), data);
+ fail_unless (memcmp (buf_data, data, size) == 0,
+ "'%s' (%s) is not equal to (%s)", name, buf_data, data);
+
+ gst_buffer_unmap (buffer, buf_data, size);
}
static GstFlowReturn
@@ -230,8 +233,20 @@ push_data (const gchar * name, const gchar * data, gint size)
}
static void
+push_caps (void)
+{
+ GstCaps *caps;
+
+ caps = gst_caps_from_string (SRC_CAPS);
+ fail_unless (gst_pad_set_caps (srcpad, caps));
+ gst_caps_unref (caps);
+}
+
+static void
check_headers (void)
{
+ push_caps ();
+
/* push the cmml start tag */
flow = push_data ("preamble", PREAMBLE, strlen (PREAMBLE));
fail_unless_equals_flow_return (flow, GST_FLOW_OK);
diff --git a/tests/check/elements/equalizer.c b/tests/check/elements/equalizer.c
index 29b2e3862..22fdb302e 100644
--- a/tests/check/elements/equalizer.c
+++ b/tests/check/elements/equalizer.c
@@ -62,8 +62,8 @@ setup_equalizer (void)
GST_DEBUG ("setup_equalizer");
equalizer = gst_check_setup_element ("equalizer-nbands");
- mysrcpad = gst_check_setup_src_pad (equalizer, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (equalizer, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (equalizer, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (equalizer, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
diff --git a/tests/check/elements/icydemux.c b/tests/check/elements/icydemux.c
index e1686c8a1..2412441a7 100644
--- a/tests/check/elements/icydemux.c
+++ b/tests/check/elements/icydemux.c
@@ -103,7 +103,7 @@ static GstElement *
create_icydemux (void)
{
icydemux = gst_check_setup_element ("icydemux");
- srcpad = gst_check_setup_src_pad (icydemux, &srctemplate, NULL);
+ srcpad = gst_check_setup_src_pad (icydemux, &srctemplate);
g_signal_connect (icydemux, "pad-added", G_CALLBACK (icydemux_found_pad),
NULL);
diff --git a/tests/check/elements/id3demux.c b/tests/check/elements/id3demux.c
index 724461bd1..6793b1939 100644
--- a/tests/check/elements/id3demux.c
+++ b/tests/check/elements/id3demux.c
@@ -231,10 +231,13 @@ static void
check_unsync_v24 (const GstTagList * tags, const gchar * file)
{
const GValue *val;
+ GstSample *sample;
GstBuffer *buf;
gchar *album = NULL;
gchar *title = NULL;
gchar *artist = NULL;
+ guint8 *data;
+ gsize size;
fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &title));
fail_unless (title != NULL);
@@ -253,16 +256,20 @@ check_unsync_v24 (const GstTagList * tags, const gchar * file)
val = gst_tag_list_get_value_index (tags, GST_TAG_IMAGE, 0);
fail_unless (val != NULL);
- fail_unless (GST_VALUE_HOLDS_BUFFER (val));
- buf = gst_value_get_buffer (val);
+ fail_unless (GST_VALUE_HOLDS_SAMPLE (val));
+ sample = gst_value_get_sample (val);
+ fail_unless (sample != NULL);
+ fail_unless (gst_sample_get_caps (sample) != NULL);
+ buf = gst_sample_get_buffer (sample);
fail_unless (buf != NULL);
- fail_unless (GST_BUFFER_CAPS (buf) != NULL);
- fail_unless_equals_int (GST_BUFFER_SIZE (buf), 38022);
+ data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ fail_unless_equals_int (size, 38022);
/* check for jpeg start/end markers */
- fail_unless_equals_int (GST_BUFFER_DATA (buf)[0], 0xff);
- fail_unless_equals_int (GST_BUFFER_DATA (buf)[1], 0xd8);
- fail_unless_equals_int (GST_BUFFER_DATA (buf)[38020], 0xff);
- fail_unless_equals_int (GST_BUFFER_DATA (buf)[38021], 0xd9);
+ fail_unless_equals_int (data[0], 0xff);
+ fail_unless_equals_int (data[1], 0xd8);
+ fail_unless_equals_int (data[38020], 0xff);
+ fail_unless_equals_int (data[38021], 0xd9);
+ gst_buffer_unmap (buf, data, size);
}
GST_START_TEST (test_unsync_v24)
diff --git a/tests/check/elements/interleave.c b/tests/check/elements/interleave.c
index 1497a49c9..ee342cd62 100644
--- a/tests/check/elements/interleave.c
+++ b/tests/check/elements/interleave.c
@@ -46,13 +46,13 @@ GST_START_TEST (test_request_pads)
interleave = gst_element_factory_make ("interleave", NULL);
fail_unless (interleave != NULL);
- pad1 = gst_element_get_request_pad (interleave, "sink%d");
+ pad1 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (pad1 != NULL);
- fail_unless_equals_string (GST_OBJECT_NAME (pad1), "sink0");
+ fail_unless_equals_string (GST_OBJECT_NAME (pad1), "sink_0");
- pad2 = gst_element_get_request_pad (interleave, "sink%d");
+ pad2 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (pad2 != NULL);
- fail_unless_equals_string (GST_OBJECT_NAME (pad2), "sink1");
+ fail_unless_equals_string (GST_OBJECT_NAME (pad2), "sink_1");
gst_element_release_request_pad (interleave, pad2);
gst_object_unref (pad2);
@@ -138,13 +138,13 @@ GST_START_TEST (test_interleave_2ch)
queue = gst_element_factory_make ("queue", "queue");
fail_unless (queue != NULL);
- sink0 = gst_element_get_request_pad (interleave, "sink%d");
+ sink0 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (sink0 != NULL);
- fail_unless_equals_string (GST_OBJECT_NAME (sink0), "sink0");
+ fail_unless_equals_string (GST_OBJECT_NAME (sink0), "sink_0");
- sink1 = gst_element_get_request_pad (interleave, "sink%d");
+ sink1 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (sink1 != NULL);
- fail_unless_equals_string (GST_OBJECT_NAME (sink1), "sink1");
+ fail_unless_equals_string (GST_OBJECT_NAME (sink1), "sink_1");
mysrcpads[0] = gst_pad_new_from_static_template (&srctemplate, "src0");
fail_unless (mysrcpads[0] != NULL);
@@ -259,13 +259,13 @@ GST_START_TEST (test_interleave_2ch_1eos)
queue = gst_element_factory_make ("queue", "queue");
fail_unless (queue != NULL);
- sink0 = gst_element_get_request_pad (interleave, "sink%d");
+ sink0 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (sink0 != NULL);
- fail_unless_equals_string (GST_OBJECT_NAME (sink0), "sink0");
+ fail_unless_equals_string (GST_OBJECT_NAME (sink0), "sink_0");
- sink1 = gst_element_get_request_pad (interleave, "sink%d");
+ sink1 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (sink1 != NULL);
- fail_unless_equals_string (GST_OBJECT_NAME (sink1), "sink1");
+ fail_unless_equals_string (GST_OBJECT_NAME (sink1), "sink_1");
mysrcpads[0] = gst_pad_new_from_static_template (&srctemplate, "src0");
fail_unless (mysrcpads[0] != NULL);
@@ -486,13 +486,13 @@ GST_START_TEST (test_interleave_2ch_pipeline)
fail_unless (interleave != NULL);
gst_bin_add (GST_BIN (pipeline), gst_object_ref (interleave));
- sinkpad0 = gst_element_get_request_pad (interleave, "sink%d");
+ sinkpad0 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (sinkpad0 != NULL);
tmp = gst_element_get_static_pad (src1, "src");
fail_unless (gst_pad_link (tmp, sinkpad0) == GST_PAD_LINK_OK);
gst_object_unref (tmp);
- sinkpad1 = gst_element_get_request_pad (interleave, "sink%d");
+ sinkpad1 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (sinkpad1 != NULL);
tmp = gst_element_get_static_pad (src2, "src");
tmp2 = gst_element_get_static_pad (queue, "sink");
@@ -569,13 +569,13 @@ GST_START_TEST (test_interleave_2ch_pipeline_input_chanpos)
g_object_set (interleave, "channel-positions-from-input", TRUE, NULL);
gst_bin_add (GST_BIN (pipeline), gst_object_ref (interleave));
- sinkpad0 = gst_element_get_request_pad (interleave, "sink%d");
+ sinkpad0 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (sinkpad0 != NULL);
tmp = gst_element_get_static_pad (src1, "src");
fail_unless (gst_pad_link (tmp, sinkpad0) == GST_PAD_LINK_OK);
gst_object_unref (tmp);
- sinkpad1 = gst_element_get_request_pad (interleave, "sink%d");
+ sinkpad1 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (sinkpad1 != NULL);
tmp = gst_element_get_static_pad (src2, "src");
tmp2 = gst_element_get_static_pad (queue, "sink");
@@ -664,13 +664,13 @@ GST_START_TEST (test_interleave_2ch_pipeline_custom_chanpos)
g_value_array_free (arr);
gst_bin_add (GST_BIN (pipeline), gst_object_ref (interleave));
- sinkpad0 = gst_element_get_request_pad (interleave, "sink%d");
+ sinkpad0 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (sinkpad0 != NULL);
tmp = gst_element_get_static_pad (src1, "src");
fail_unless (gst_pad_link (tmp, sinkpad0) == GST_PAD_LINK_OK);
gst_object_unref (tmp);
- sinkpad1 = gst_element_get_request_pad (interleave, "sink%d");
+ sinkpad1 = gst_element_get_request_pad (interleave, "sink_%u");
fail_unless (sinkpad1 != NULL);
tmp = gst_element_get_static_pad (src2, "src");
tmp2 = gst_element_get_static_pad (queue, "sink");
diff --git a/tests/check/elements/jpegenc.c b/tests/check/elements/jpegenc.c
index 2c992f77b..71fc82da0 100644
--- a/tests/check/elements/jpegenc.c
+++ b/tests/check/elements/jpegenc.c
@@ -67,8 +67,8 @@ setup_jpegenc (GstStaticPadTemplate * sinktemplate)
GST_DEBUG ("setup_jpegenc");
jpegenc = gst_check_setup_element ("jpegenc");
- mysinkpad = gst_check_setup_sink_pad (jpegenc, sinktemplate, NULL);
- mysrcpad = gst_check_setup_src_pad (jpegenc, &any_srctemplate, NULL);
+ mysinkpad = gst_check_setup_sink_pad (jpegenc, sinktemplate);
+ mysrcpad = gst_check_setup_src_pad (jpegenc, &any_srctemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
diff --git a/tests/check/elements/level.c b/tests/check/elements/level.c
index 2bb4eb7d8..76bb39ce3 100644
--- a/tests/check/elements/level.c
+++ b/tests/check/elements/level.c
@@ -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,
@@ -70,8 +63,8 @@ setup_level (void)
GST_DEBUG ("setup_level");
level = gst_check_setup_element ("level");
- mysrcpad = gst_check_setup_src_pad (level, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (level, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (level, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (level, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
diff --git a/tests/check/elements/matroskamux.c b/tests/check/elements/matroskamux.c
index bbc1862e3..887f91f58 100644
--- a/tests/check/elements/matroskamux.c
+++ b/tests/check/elements/matroskamux.c
@@ -66,8 +66,8 @@ setup_src_pad (GstElement * element,
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1);
gst_pad_set_active (srcpad, TRUE);
- if (!(sinkpad = gst_element_get_static_pad (element, "audio_%d")))
- sinkpad = gst_element_get_request_pad (element, "audio_%d");
+ if (!(sinkpad = gst_element_get_static_pad (element, "audio_%u")))
+ sinkpad = gst_element_get_request_pad (element, "audio_%u");
fail_if (sinkpad == NULL, "Could not get sink pad from %s",
GST_ELEMENT_NAME (element));
/* references are owned by: 1) us, 2) matroskamux, 3) collect pads */
@@ -163,6 +163,7 @@ static GstElement *
setup_matroskamux (GstStaticPadTemplate * srctemplate)
{
GstElement *matroskamux;
+ GstSegment segment;
GST_DEBUG ("setup_matroskamux");
matroskamux = gst_check_setup_element ("matroskamux");
@@ -170,6 +171,14 @@ setup_matroskamux (GstStaticPadTemplate * srctemplate)
mysrcpad = setup_src_pad (matroskamux, srctemplate, NULL);
mysinkpad = setup_sink_pad (matroskamux, &sinktemplate, NULL);
+ fail_unless (gst_element_set_state (matroskamux,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ fail_unless (gst_pad_push_event (mysrcpad,
+ gst_event_new_segment (&segment)), "Segment event rejected");
+
return matroskamux;
}
@@ -187,8 +196,8 @@ cleanup_matroskamux (GstElement * matroskamux)
static void
check_buffer_data (GstBuffer * buffer, void *data, size_t data_size)
{
- fail_unless (GST_BUFFER_SIZE (buffer) == data_size);
- fail_unless (memcmp (data, GST_BUFFER_DATA (buffer), data_size) == 0);
+ fail_unless (gst_buffer_get_size (buffer) == data_size);
+ fail_unless (gst_buffer_memcmp (buffer, 0, data, data_size) == 0);
}
GST_START_TEST (test_ebml_header)
@@ -207,11 +216,8 @@ GST_START_TEST (test_ebml_header)
};
matroskamux = setup_matroskamux (&srcac3template);
- fail_unless (gst_element_set_state (matroskamux,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (1);
+ inbuffer = gst_buffer_new_allocate (NULL, 1, 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
num_buffers = g_list_length (buffers);
@@ -259,14 +265,12 @@ GST_START_TEST (test_vorbis_header)
};
matroskamux = setup_matroskamux (&srcvorbistemplate);
- fail_unless (gst_element_set_state (matroskamux,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (1);
caps = gst_caps_from_string (VORBIS_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ inbuffer = gst_buffer_new_allocate (NULL, 1, 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
@@ -274,14 +278,16 @@ GST_START_TEST (test_vorbis_header)
for (i = 0; i < num_buffers; ++i) {
gint j;
+ gsize buffer_size;
outbuffer = GST_BUFFER (buffers->data);
fail_if (outbuffer == NULL);
+ buffer_size = gst_buffer_get_size (outbuffer);
buffers = g_list_remove (buffers, outbuffer);
- if (!vorbis_header_found && GST_BUFFER_SIZE (outbuffer) >= sizeof (data)) {
- for (j = 0; j <= GST_BUFFER_SIZE (outbuffer) - sizeof (data); j++) {
- if (memcmp (GST_BUFFER_DATA (outbuffer) + j, data, sizeof (data)) == 0) {
+ if (!vorbis_header_found && buffer_size >= sizeof (data)) {
+ for (j = 0; j <= buffer_size - sizeof (data); j++) {
+ if (gst_buffer_memcmp (outbuffer, j, data, sizeof (data)) == 0) {
vorbis_header_found = TRUE;
break;
}
@@ -307,6 +313,7 @@ GST_START_TEST (test_block_group)
{
GstElement *matroskamux;
GstBuffer *inbuffer, *outbuffer;
+ guint8 *indata;
GstCaps *caps;
int num_buffers;
int i;
@@ -317,16 +324,14 @@ GST_START_TEST (test_block_group)
guint8 data1[] = { 0x42 };
matroskamux = setup_matroskamux (&srcac3template);
- fail_unless (gst_element_set_state (matroskamux,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
- /* Generate the header */
- inbuffer = gst_buffer_new_and_alloc (1);
- GST_BUFFER_TIMESTAMP (inbuffer) = 0;
caps = gst_caps_from_string (AC3_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
+
+ /* Generate the header */
+ inbuffer = gst_buffer_new_allocate (NULL, 1, 0);
+ GST_BUFFER_TIMESTAMP (inbuffer) = 0;
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
@@ -346,12 +351,10 @@ GST_START_TEST (test_block_group)
buffers = NULL;
/* Now push a buffer */
- inbuffer = gst_buffer_new_and_alloc (1);
- GST_BUFFER_DATA (inbuffer)[0] = 0x42;
+ indata = g_malloc (1);
+ inbuffer = gst_buffer_new_wrapped (indata, 1);
+ indata[0] = 0x42;
GST_BUFFER_TIMESTAMP (inbuffer) = 1000000;
- caps = gst_caps_from_string (AC3_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
- gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
@@ -396,11 +399,8 @@ GST_START_TEST (test_reset)
int i;
matroskamux = setup_matroskamux (&srcac3template);
- fail_unless (gst_element_set_state (matroskamux,
- GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
- "could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (1);
+ inbuffer = gst_buffer_new_allocate (NULL, 1, 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
num_buffers = g_list_length (buffers);
@@ -414,7 +414,7 @@ GST_START_TEST (test_reset)
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (1);
+ inbuffer = gst_buffer_new_allocate (NULL, 1, 0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
num_buffers = g_list_length (buffers);
diff --git a/tests/check/elements/parser.c b/tests/check/elements/parser.c
index 4da658b95..7b47c033a 100644
--- a/tests/check/elements/parser.c
+++ b/tests/check/elements/parser.c
@@ -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++;
}
@@ -151,10 +150,12 @@ setup_element (const gchar * factory, GstStaticPadTemplate * sink_template,
GstBus *bus;
element = gst_check_setup_element (factory);
- srcpad = gst_check_setup_src_pad (element, src_template, src_caps);
- sinkpad = gst_check_setup_sink_pad (element, sink_template, sink_caps);
+ srcpad = gst_check_setup_src_pad (element, src_template);
+ sinkpad = gst_check_setup_sink_pad (element, sink_template);
gst_pad_set_active (srcpad, TRUE);
gst_pad_set_active (sinkpad, TRUE);
+ fail_unless (gst_pad_set_caps (srcpad, src_caps));
+ fail_unless (gst_pad_set_caps (sinkpad, sink_caps));
bus = gst_bus_new ();
gst_element_set_bus (element, bus);
@@ -247,14 +248,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 +288,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) {
diff --git a/tests/check/elements/qtmux.c b/tests/check/elements/qtmux.c
index 484296bad..d934a631a 100644
--- a/tests/check/elements/qtmux.c
+++ b/tests/check/elements/qtmux.c
@@ -161,7 +161,7 @@ setup_qtmux (GstStaticPadTemplate * srctemplate, const gchar * sinkname)
GST_DEBUG ("setup_qtmux");
qtmux = gst_check_setup_element ("qtmux");
mysrcpad = setup_src_pad (qtmux, srctemplate, NULL, sinkname);
- mysinkpad = gst_check_setup_sink_pad (qtmux, &sinktemplate, NULL);
+ mysinkpad = gst_check_setup_sink_pad (qtmux, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
@@ -358,14 +358,14 @@ check_qtmux_pad_fragmented (GstStaticPadTemplate * srctemplate,
GST_START_TEST (test_video_pad_dd)
{
- check_qtmux_pad (&srcvideotemplate, "video_%d", 0);
+ check_qtmux_pad (&srcvideotemplate, "video_%u", 0);
}
GST_END_TEST;
GST_START_TEST (test_audio_pad_dd)
{
- check_qtmux_pad (&srcaudiotemplate, "audio_%d", 0);
+ check_qtmux_pad (&srcaudiotemplate, "audio_%u", 0);
}
GST_END_TEST;
@@ -373,14 +373,14 @@ GST_END_TEST;
GST_START_TEST (test_video_pad_frag_dd)
{
- check_qtmux_pad_fragmented (&srcvideotemplate, "video_%d", 0, FALSE);
+ check_qtmux_pad_fragmented (&srcvideotemplate, "video_%u", 0, FALSE);
}
GST_END_TEST;
GST_START_TEST (test_audio_pad_frag_dd)
{
- check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%d", 0, FALSE);
+ check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%u", 0, FALSE);
}
GST_END_TEST;
@@ -388,7 +388,7 @@ GST_END_TEST;
GST_START_TEST (test_video_pad_frag_dd_streamable)
{
- check_qtmux_pad_fragmented (&srcvideotemplate, "video_%d", 0, TRUE);
+ check_qtmux_pad_fragmented (&srcvideotemplate, "video_%u", 0, TRUE);
}
GST_END_TEST;
@@ -396,7 +396,7 @@ GST_END_TEST;
GST_START_TEST (test_audio_pad_frag_dd_streamable)
{
- check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%d", 0, TRUE);
+ check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%u", 0, TRUE);
}
GST_END_TEST;
@@ -405,14 +405,14 @@ GST_END_TEST;
GST_START_TEST (test_video_pad_reorder)
{
- check_qtmux_pad (&srcvideotemplate, "video_%d", 1);
+ check_qtmux_pad (&srcvideotemplate, "video_%u", 1);
}
GST_END_TEST;
GST_START_TEST (test_audio_pad_reorder)
{
- check_qtmux_pad (&srcaudiotemplate, "audio_%d", 1);
+ check_qtmux_pad (&srcaudiotemplate, "audio_%u", 1);
}
GST_END_TEST;
@@ -420,14 +420,14 @@ GST_END_TEST;
GST_START_TEST (test_video_pad_frag_reorder)
{
- check_qtmux_pad_fragmented (&srcvideotemplate, "video_%d", 1, FALSE);
+ check_qtmux_pad_fragmented (&srcvideotemplate, "video_%u", 1, FALSE);
}
GST_END_TEST;
GST_START_TEST (test_audio_pad_frag_reorder)
{
- check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%d", 1, FALSE);
+ check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%u", 1, FALSE);
}
GST_END_TEST;
@@ -435,7 +435,7 @@ GST_END_TEST;
GST_START_TEST (test_video_pad_frag_reorder_streamable)
{
- check_qtmux_pad_fragmented (&srcvideotemplate, "video_%d", 1, TRUE);
+ check_qtmux_pad_fragmented (&srcvideotemplate, "video_%u", 1, TRUE);
}
GST_END_TEST;
@@ -443,7 +443,7 @@ GST_END_TEST;
GST_START_TEST (test_audio_pad_frag_reorder_streamable)
{
- check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%d", 1, TRUE);
+ check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%u", 1, TRUE);
}
GST_END_TEST;
@@ -452,14 +452,14 @@ GST_END_TEST;
GST_START_TEST (test_video_pad_asc)
{
- check_qtmux_pad (&srcvideotemplate, "video_%d", 2);
+ check_qtmux_pad (&srcvideotemplate, "video_%u", 2);
}
GST_END_TEST;
GST_START_TEST (test_audio_pad_asc)
{
- check_qtmux_pad (&srcaudiotemplate, "audio_%d", 2);
+ check_qtmux_pad (&srcaudiotemplate, "audio_%u", 2);
}
GST_END_TEST;
@@ -467,14 +467,14 @@ GST_END_TEST;
GST_START_TEST (test_video_pad_frag_asc)
{
- check_qtmux_pad_fragmented (&srcvideotemplate, "video_%d", 2, FALSE);
+ check_qtmux_pad_fragmented (&srcvideotemplate, "video_%u", 2, FALSE);
}
GST_END_TEST;
GST_START_TEST (test_audio_pad_frag_asc)
{
- check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%d", 2, FALSE);
+ check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%u", 2, FALSE);
}
GST_END_TEST;
@@ -482,7 +482,7 @@ GST_END_TEST;
GST_START_TEST (test_video_pad_frag_asc_streamable)
{
- check_qtmux_pad_fragmented (&srcvideotemplate, "video_%d", 2, TRUE);
+ check_qtmux_pad_fragmented (&srcvideotemplate, "video_%u", 2, TRUE);
}
GST_END_TEST;
@@ -490,14 +490,14 @@ GST_END_TEST;
GST_START_TEST (test_audio_pad_frag_asc_streamable)
{
- check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%d", 2, TRUE);
+ check_qtmux_pad_fragmented (&srcaudiotemplate, "audio_%u", 2, TRUE);
}
GST_END_TEST;
GST_START_TEST (test_reuse)
{
- GstElement *qtmux = setup_qtmux (&srcvideotemplate, "video_%d");
+ GstElement *qtmux = setup_qtmux (&srcvideotemplate, "video_%u");
GstBuffer *inbuffer;
GstCaps *caps;
@@ -520,7 +520,7 @@ GST_START_TEST (test_reuse)
/* send eos to have all written */
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()) == TRUE);
- cleanup_qtmux (qtmux, "video_%d");
+ cleanup_qtmux (qtmux, "video_%u");
}
GST_END_TEST;
@@ -614,9 +614,10 @@ test_mp3_enc_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_static_pad_template (element_class,
- &sink_template);
- gst_element_class_add_static_pad_template (element_class, &src_template);
+ 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 Encoder",
"Codec/Encoder/Audio", "Pretends to encode mp3", "Foo Bar <foo@bar.com>");
@@ -843,11 +844,11 @@ test_average_bitrate_custom (const gchar * elementname,
GST_START_TEST (test_average_bitrate)
{
- test_average_bitrate_custom ("mp4mux", &srcaudioaactemplate, "audio_%d");
- test_average_bitrate_custom ("mp4mux", &srcvideoh264template, "video_%d");
+ test_average_bitrate_custom ("mp4mux", &srcaudioaactemplate, "audio_%u");
+ test_average_bitrate_custom ("mp4mux", &srcvideoh264template, "video_%u");
- test_average_bitrate_custom ("qtmux", &srcaudioaactemplate, "audio_%d");
- test_average_bitrate_custom ("qtmux", &srcvideoh264template, "video_%d");
+ test_average_bitrate_custom ("qtmux", &srcaudioaactemplate, "audio_%u");
+ test_average_bitrate_custom ("qtmux", &srcvideoh264template, "video_%u");
}
GST_END_TEST;
diff --git a/tests/check/elements/rganalysis.c b/tests/check/elements/rganalysis.c
index 8c26cf3e8..e60dac13e 100644
--- a/tests/check/elements/rganalysis.c
+++ b/tests/check/elements/rganalysis.c
@@ -155,8 +155,8 @@ setup_rganalysis (void)
GST_DEBUG ("setup_rganalysis");
analysis = gst_check_setup_element ("rganalysis");
- mysrcpad = gst_check_setup_src_pad (analysis, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (analysis, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (analysis, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (analysis, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
diff --git a/tests/check/elements/rglimiter.c b/tests/check/elements/rglimiter.c
index 6b4b96a25..218e65d0a 100644
--- a/tests/check/elements/rglimiter.c
+++ b/tests/check/elements/rglimiter.c
@@ -54,8 +54,8 @@ setup_rglimiter (void)
GST_DEBUG ("setup_rglimiter");
element = gst_check_setup_element ("rglimiter");
- mysrcpad = gst_check_setup_src_pad (element, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (element, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (element, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (element, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
diff --git a/tests/check/elements/rgvolume.c b/tests/check/elements/rgvolume.c
index 3add27a72..fd80971d6 100644
--- a/tests/check/elements/rgvolume.c
+++ b/tests/check/elements/rgvolume.c
@@ -66,8 +66,8 @@ setup_rgvolume (void)
GST_DEBUG ("setup_rgvolume");
element = gst_check_setup_element ("rgvolume");
- mysrcpad = gst_check_setup_src_pad (element, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (element, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (element, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (element, &sinktemplate);
/* Capture events, to test tag filtering behavior: */
gst_pad_set_event_function (mysinkpad, event_func);
diff --git a/tests/check/elements/rtp-payloading.c b/tests/check/elements/rtp-payloading.c
index b2160f4a5..9025ab441 100644
--- a/tests/check/elements/rtp-payloading.c
+++ b/tests/check/elements/rtp-payloading.c
@@ -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);
}
diff --git a/tests/check/elements/rtpbin.c b/tests/check/elements/rtpbin.c
index 63c6ae766..f4393d71a 100644
--- a/tests/check/elements/rtpbin.c
+++ b/tests/check/elements/rtpbin.c
@@ -29,7 +29,7 @@ GST_START_TEST (test_cleanup_send)
GObject *session;
gint count = 2;
- rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
+ rtpbin = gst_element_factory_make ("rtpbin", "rtpbin");
while (count--) {
/* request session 0 */
@@ -231,7 +231,7 @@ GST_START_TEST (test_cleanup_recv)
init_data (&data);
- rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
+ rtpbin = gst_element_factory_make ("rtpbin", "rtpbin");
g_signal_connect (rtpbin, "pad-added", (GCallback) pad_added_cb, &data);
g_signal_connect (rtpbin, "pad-removed", (GCallback) pad_removed_cb, &data);
@@ -306,7 +306,7 @@ GST_START_TEST (test_cleanup_recv2)
init_data (&data);
- rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
+ rtpbin = gst_element_factory_make ("rtpbin", "rtpbin");
g_signal_connect (rtpbin, "pad-added", (GCallback) pad_added_cb, &data);
g_signal_connect (rtpbin, "pad-removed", (GCallback) pad_removed_cb, &data);
@@ -382,18 +382,18 @@ GST_START_TEST (test_request_pad_by_template_name)
GstElement *rtpbin;
GstPad *rtp_sink1, *rtp_sink2, *rtp_sink3;
- rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
- rtp_sink1 = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_%d");
+ rtpbin = gst_element_factory_make ("rtpbin", "rtpbin");
+ rtp_sink1 = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_%u");
fail_unless (rtp_sink1 != NULL);
fail_unless_equals_string (GST_PAD_NAME (rtp_sink1), "recv_rtp_sink_0");
ASSERT_OBJECT_REFCOUNT (rtp_sink1, "rtp_sink1", 2);
- rtp_sink2 = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_%d");
+ rtp_sink2 = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_%u");
fail_unless (rtp_sink2 != NULL);
fail_unless_equals_string (GST_PAD_NAME (rtp_sink2), "recv_rtp_sink_1");
ASSERT_OBJECT_REFCOUNT (rtp_sink2, "rtp_sink2", 2);
- rtp_sink3 = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_%d");
+ rtp_sink3 = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_%u");
fail_unless (rtp_sink3 != NULL);
fail_unless_equals_string (GST_PAD_NAME (rtp_sink3), "recv_rtp_sink_2");
ASSERT_OBJECT_REFCOUNT (rtp_sink3, "rtp_sink3", 2);
@@ -417,7 +417,7 @@ GST_END_TEST;
static Suite *
gstrtpbin_suite (void)
{
- Suite *s = suite_create ("gstrtpbin");
+ Suite *s = suite_create ("rtpbin");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
diff --git a/tests/check/elements/rtpjitterbuffer.c b/tests/check/elements/rtpjitterbuffer.c
index a8eaa61ec..64d1b2d0a 100644
--- a/tests/check/elements/rtpjitterbuffer.c
+++ b/tests/check/elements/rtpjitterbuffer.c
@@ -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 */
@@ -94,8 +94,8 @@ setup_jitterbuffer (gint num_buffers)
GST_INFO_OBJECT (jitterbuffer, "set latency to %u ms", latency);
*/
- mysrcpad = gst_check_setup_src_pad (jitterbuffer, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (jitterbuffer, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (jitterbuffer, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (jitterbuffer, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
diff --git a/tests/check/elements/souphttpsrc.c b/tests/check/elements/souphttpsrc.c
index ba1574594..a3cb3fdb6 100644
--- a/tests/check/elements/souphttpsrc.c
+++ b/tests/check/elements/souphttpsrc.c
@@ -364,7 +364,6 @@ GST_START_TEST (test_icy_stream)
src = gst_element_factory_make ("souphttpsrc", NULL);
fail_unless (src != NULL);
- g_object_set (src, "iradio-mode", TRUE, NULL);
sink = gst_element_factory_make ("fakesink", NULL);
fail_unless (sink != NULL);
diff --git a/tests/check/elements/spectrum.c b/tests/check/elements/spectrum.c
index 0eed1dc00..2fa1273f5 100644
--- a/tests/check/elements/spectrum.c
+++ b/tests/check/elements/spectrum.c
@@ -22,6 +22,7 @@
#include <unistd.h>
+#include <gst/audio/audio.h>
#include <gst/check/gstcheck.h>
gboolean have_eos = FALSE;
@@ -32,57 +33,38 @@ gboolean have_eos = FALSE;
GstPad *mysrcpad, *mysinkpad;
#define SPECT_CAPS_TEMPLATE_STRING \
- "audio/x-raw-int, " \
- " width = (int) 16, " \
- " depth = (int) 16, " \
- " signed = (boolean) true, " \
- " endianness = (int) BYTE_ORDER, " \
+ "audio/x-raw, " \
" rate = (int) [ 1, MAX ], " \
- " channels = (int) [ 1, MAX ]; " \
- "audio/x-raw-int, " \
- " width = (int) 32, " \
- " depth = (int) 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 ]"
+ " channels = (int) [ 1, MAX ], " \
+ " format = (string) { " \
+ GST_AUDIO_NE(S16) ", " \
+ GST_AUDIO_NE(S32) ", " \
+ GST_AUDIO_NE(F32) ", " \
+ GST_AUDIO_NE(F64) " }"
#define SPECT_CAPS_STRING_S16 \
- "audio/x-raw-int, " \
+ "audio/x-raw, " \
"rate = (int) 44100, " \
"channels = (int) 1, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 16, " \
- "depth = (int) 16, " \
- "signed = (boolean) true"
+ "format = (string) " GST_AUDIO_NE(S16)
#define SPECT_CAPS_STRING_S32 \
- "audio/x-raw-int, " \
+ "audio/x-raw, " \
"rate = (int) 44100, " \
"channels = (int) 1, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 32, " \
- "depth = (int) 32, " \
- "signed = (boolean) true"
+ "format = (string) " GST_AUDIO_NE(S32)
#define SPECT_CAPS_STRING_F32 \
- "audio/x-raw-float, " \
- " width = (int) 32, " \
- " endianness = (int) BYTE_ORDER, " \
+ "audio/x-raw, " \
" rate = (int) 44100, " \
- " channels = (int) 1"
+ " channels = (int) 1, " \
+ " format = (string) " GST_AUDIO_NE(F32)
#define SPECT_CAPS_STRING_F64 \
- "audio/x-raw-float, " \
- " width = (int) 64, " \
- " endianness = (int) BYTE_ORDER, " \
+ "audio/x-raw, " \
" rate = (int) 44100, " \
- " channels = (int) 1"
+ " channels = (int) 1, " \
+ " format = (string) " GST_AUDIO_NE(F64)
#define SPECT_BANDS 256
@@ -105,8 +87,8 @@ setup_spectrum (void)
GST_DEBUG ("setup_spectrum");
spectrum = gst_check_setup_element ("spectrum");
- mysrcpad = gst_check_setup_src_pad (spectrum, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (spectrum, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (spectrum, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (spectrum, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
@@ -139,13 +121,13 @@ GST_START_TEST (test_int16)
GstMessage *message;
const GstStructure *structure;
int i, j;
- gint16 *data;
+ gint16 *buf_data, *data;
const GValue *list, *value;
GstClockTime endtime;
gfloat level;
spectrum = setup_spectrum ();
- g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
+ g_object_set (spectrum, "post-messages", TRUE, "interval", GST_SECOND / 100,
"bands", SPECT_BANDS, "threshold", -80, NULL);
fail_unless (gst_element_set_state (spectrum,
@@ -153,9 +135,9 @@ GST_START_TEST (test_int16)
"could not set to playing");
/* create a 1 sec buffer with an 11025 Hz sine wave */
- inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gint16));
- data = (gint16 *) GST_BUFFER_DATA (inbuffer);
-
+ inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gint16), 0);
+ buf_data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+ data = buf_data;
for (j = 0; j < 44100; j += 4) {
*data = 0;
++data;
@@ -166,9 +148,10 @@ GST_START_TEST (test_int16)
*data = -32767;
++data;
}
+ gst_buffer_unmap (inbuffer, buf_data, -1);
caps = gst_caps_from_string (SPECT_CAPS_STRING_S16);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -242,13 +225,13 @@ GST_START_TEST (test_int32)
GstMessage *message;
const GstStructure *structure;
int i, j;
- gint32 *data;
+ gint32 *buf_data, *data;
const GValue *list, *value;
GstClockTime endtime;
gfloat level;
spectrum = setup_spectrum ();
- g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
+ g_object_set (spectrum, "post-messages", TRUE, "interval", GST_SECOND / 100,
"bands", SPECT_BANDS, "threshold", -80, NULL);
fail_unless (gst_element_set_state (spectrum,
@@ -256,8 +239,9 @@ GST_START_TEST (test_int32)
"could not set to playing");
/* create a 1 sec buffer with an 11025 Hz sine wave */
- inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gint32));
- data = (gint32 *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gint32), 0);
+ buf_data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+ data = buf_data;
for (j = 0; j < 44100; j += 4) {
*data = 0;
++data;
@@ -268,8 +252,10 @@ GST_START_TEST (test_int32)
*data = -2147483647;
++data;
}
+ gst_buffer_unmap (inbuffer, buf_data, -1);
+
caps = gst_caps_from_string (SPECT_CAPS_STRING_S32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -343,13 +329,13 @@ GST_START_TEST (test_float32)
GstMessage *message;
const GstStructure *structure;
int i, j;
- gfloat *data;
+ gfloat *buf_data, *data;
const GValue *list, *value;
GstClockTime endtime;
gfloat level;
spectrum = setup_spectrum ();
- g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
+ g_object_set (spectrum, "post-messages", TRUE, "interval", GST_SECOND / 100,
"bands", SPECT_BANDS, "threshold", -80, NULL);
fail_unless (gst_element_set_state (spectrum,
@@ -357,8 +343,9 @@ GST_START_TEST (test_float32)
"could not set to playing");
/* create a 1 sec buffer with an 11025 Hz sine wave */
- inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gfloat));
- data = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gfloat), 0);
+ buf_data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+ data = buf_data;
for (j = 0; j < 44100; j += 4) {
*data = 0.0;
++data;
@@ -369,8 +356,10 @@ GST_START_TEST (test_float32)
*data = -1.0;
++data;
}
+ gst_buffer_unmap (inbuffer, buf_data, -1);
+
caps = gst_caps_from_string (SPECT_CAPS_STRING_F32);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -444,13 +433,13 @@ GST_START_TEST (test_float64)
GstMessage *message;
const GstStructure *structure;
int i, j;
- gdouble *data;
+ gdouble *buf_data, *data;
const GValue *list, *value;
GstClockTime endtime;
gfloat level;
spectrum = setup_spectrum ();
- g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
+ g_object_set (spectrum, "post-messages", TRUE, "interval", GST_SECOND / 100,
"bands", SPECT_BANDS, "threshold", -80, NULL);
fail_unless (gst_element_set_state (spectrum,
@@ -458,8 +447,9 @@ GST_START_TEST (test_float64)
"could not set to playing");
/* create a 1 sec buffer with an 11025 Hz sine wave */
- inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gdouble));
- data = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gdouble), 0);
+ buf_data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+ data = buf_data;
for (j = 0; j < 44100; j += 4) {
*data = 0.0;
++data;
@@ -470,8 +460,10 @@ GST_START_TEST (test_float64)
*data = -1.0;
++data;
}
+ gst_buffer_unmap (inbuffer, buf_data, -1);
+
caps = gst_caps_from_string (SPECT_CAPS_STRING_F64);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
diff --git a/tests/check/elements/videofilter.c b/tests/check/elements/videofilter.c
index 7389478c0..150cb4c2b 100644
--- a/tests/check/elements/videofilter.c
+++ b/tests/check/elements/videofilter.c
@@ -61,9 +61,9 @@ setup_filter (const gchar * name, const gchar * prop, va_list var_args)
GST_DEBUG ("setup_element");
element = gst_check_setup_element (name);
g_object_set_valist (G_OBJECT (element), prop, var_args);
- mysrcpad = gst_check_setup_src_pad (element, &srctemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (element, &srctemplate);
gst_pad_set_active (mysrcpad, TRUE);
- mysinkpad = gst_check_setup_sink_pad (element, &sinktemplate, NULL);
+ mysinkpad = gst_check_setup_sink_pad (element, &sinktemplate);
gst_pad_set_active (mysinkpad, TRUE);
return element;
diff --git a/tests/check/elements/y4menc.c b/tests/check/elements/y4menc.c
index 3b7c9b453..14a6495f1 100644
--- a/tests/check/elements/y4menc.c
+++ b/tests/check/elements/y4menc.c
@@ -57,8 +57,8 @@ setup_y4menc (void)
GST_DEBUG ("setup_y4menc");
y4menc = gst_check_setup_element ("y4menc");
- mysrcpad = gst_check_setup_src_pad (y4menc, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (y4menc, &sinktemplate, NULL);
+ mysrcpad = gst_check_setup_src_pad (y4menc, &srctemplate);
+ mysinkpad = gst_check_setup_sink_pad (y4menc, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
diff --git a/tests/examples/level/level-example.c b/tests/examples/level/level-example.c
index a85d751b6..1ce625fb6 100644
--- a/tests/examples/level/level-example.c
+++ b/tests/examples/level/level-example.c
@@ -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);
diff --git a/tests/examples/pulse/Makefile.am b/tests/examples/pulse/Makefile.am
index 5d35e6189..e9a2d9683 100644
--- a/tests/examples/pulse/Makefile.am
+++ b/tests/examples/pulse/Makefile.am
@@ -1,5 +1,5 @@
noinst_PROGRAMS = pulse
pulse_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
-pulse_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-0.10 $(GST_BASE_LIBS) $(GST_LIBS)
+pulse_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR) $(GST_BASE_LIBS) $(GST_LIBS)
diff --git a/tests/examples/rtp/client-PCMA.c b/tests/examples/rtp/client-PCMA.c
index 885b8264e..6b6989e45 100644
--- a/tests/examples/rtp/client-PCMA.c
+++ b/tests/examples/rtp/client-PCMA.c
@@ -184,7 +184,7 @@ main (int argc, char *argv[])
g_assert (res == TRUE);
/* the rtpbin element */
- rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
+ rtpbin = gst_element_factory_make ("rtpbin", "rtpbin");
g_assert (rtpbin);
gst_bin_add (GST_BIN (pipeline), rtpbin);
diff --git a/tests/examples/rtp/client-PCMA.py b/tests/examples/rtp/client-PCMA.py
index f6230f969..5830b1081 100755
--- a/tests/examples/rtp/client-PCMA.py
+++ b/tests/examples/rtp/client-PCMA.py
@@ -35,7 +35,7 @@ RTP_RECV_PORT = 5002
RTCP_RECV_PORT = 5003
RTCP_SEND_PORT = 5007
-#gst-launch -v gstrtpbin name=rtpbin \
+#gst-launch -v rtpbin name=rtpbin \
# udpsrc caps=$AUDIO_CAPS port=$RTP_RECV_PORT ! rtpbin.recv_rtp_sink_0 \
# rtpbin. ! rtppcmadepay ! alawdec ! audioconvert ! audioresample ! autoaudiosink \
# udpsrc port=$RTCP_RECV_PORT ! rtpbin.recv_rtcp_sink_0 \
@@ -84,7 +84,7 @@ pipeline.add(audiodepay, audiodec, audioconv, audiores, audiosink)
res = gst.element_link_many(audiodepay, audiodec, audioconv, audiores, audiosink)
# the rtpbin element
-rtpbin = gst.element_factory_make('gstrtpbin', 'rtpbin')
+rtpbin = gst.element_factory_make('rtpbin', 'rtpbin')
pipeline.add(rtpbin)
diff --git a/tests/examples/rtp/server-alsasrc-PCMA.c b/tests/examples/rtp/server-alsasrc-PCMA.c
index d61ec30cb..85647993e 100644
--- a/tests/examples/rtp/server-alsasrc-PCMA.c
+++ b/tests/examples/rtp/server-alsasrc-PCMA.c
@@ -104,7 +104,7 @@ print_stats (GstElement * rtpbin)
/* build a pipeline equivalent to:
*
- * gst-launch -v gstrtpbin name=rtpbin \
+ * gst-launch -v rtpbin name=rtpbin \
* $AUDIO_SRC ! audioconvert ! audioresample ! $AUDIO_ENC ! $AUDIO_PAY ! rtpbin.send_rtp_sink_0 \
* rtpbin.send_rtp_src_0 ! udpsink port=5002 host=$DEST \
* rtpbin.send_rtcp_src_0 ! udpsink port=5003 host=$DEST sync=false async=false \
@@ -150,7 +150,7 @@ main (int argc, char *argv[])
}
/* the rtpbin element */
- rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
+ rtpbin = gst_element_factory_make ("rtpbin", "rtpbin");
g_assert (rtpbin);
gst_bin_add (GST_BIN (pipeline), rtpbin);
diff --git a/tests/examples/rtp/server-alsasrc-PCMA.py b/tests/examples/rtp/server-alsasrc-PCMA.py
index 099d79e49..2caf0b985 100755
--- a/tests/examples/rtp/server-alsasrc-PCMA.py
+++ b/tests/examples/rtp/server-alsasrc-PCMA.py
@@ -4,7 +4,7 @@ import gobject, pygst
pygst.require("0.10")
import gst
-#gst-launch -v gstrtpbin name=rtpbin audiotestsrc ! audioconvert ! alawenc ! rtppcmapay ! rtpbin.send_rtp_sink_0 \
+#gst-launch -v rtpbin name=rtpbin audiotestsrc ! audioconvert ! alawenc ! rtppcmapay ! rtpbin.send_rtp_sink_0 \
# rtpbin.send_rtp_src_0 ! udpsink port=10000 host=xxx.xxx.xxx.xxx \
# rtpbin.send_rtcp_src_0 ! udpsink port=10001 host=xxx.xxx.xxx.xxx sync=false async=false \
# udpsrc port=10002 ! rtpbin.recv_rtcp_sink_0
@@ -37,7 +37,7 @@ pipeline.add(audiosrc, audioconv, audiores, audioenc, audiopay)
res = gst.element_link_many(audiosrc, audioconv, audiores, audioenc, audiopay)
# the rtpbin element
-rtpbin = gst.element_factory_make('gstrtpbin', 'rtpbin')
+rtpbin = gst.element_factory_make('rtpbin', 'rtpbin')
pipeline.add(rtpbin)
diff --git a/tests/examples/shapewipe/shapewipe-example.c b/tests/examples/shapewipe/shapewipe-example.c
index e3b49fea8..dfd4b6e4d 100644
--- a/tests/examples/shapewipe/shapewipe-example.c
+++ b/tests/examples/shapewipe/shapewipe-example.c
@@ -18,7 +18,6 @@
*/
#include <gst/gst.h>
-#include <gst/controller/gstcontroller.h>
#include <gst/controller/gstlfocontrolsource.h>
#include <stdlib.h>
@@ -64,7 +63,6 @@ main (gint argc, gchar ** argv)
{
GstElement *pipeline;
GstElement *shapewipe;
- GstController *ctrl;
GstLFOControlSource *csource;
GValue val = { 0, };
GMainLoop *loop;
@@ -78,7 +76,6 @@ main (gint argc, gchar ** argv)
}
gst_init (&argc, &argv);
- gst_controller_init (&argc, &argv);
if (argc > 2) {
border = atof (argv[2]);
@@ -99,14 +96,9 @@ main (gint argc, gchar ** argv)
shapewipe = gst_bin_get_by_name (GST_BIN (pipeline), "shape");
- if (!(ctrl = gst_controller_new (G_OBJECT (shapewipe), "position", NULL))) {
- g_print ("can't control shapewipe element\n");
- return -3;
- }
-
csource = gst_lfo_control_source_new ();
- gst_controller_set_control_source (ctrl, "position",
+ gst_object_set_control_source (GST_OBJECT (shapewipe), "position",
GST_CONTROL_SOURCE (csource));
g_value_init (&val, G_TYPE_FLOAT);
@@ -140,7 +132,6 @@ main (gint argc, gchar ** argv)
g_main_loop_unref (loop);
- g_object_unref (G_OBJECT (ctrl));
gst_object_unref (G_OBJECT (pipeline));
return 0;
diff --git a/tests/examples/spectrum/spectrum-example.c b/tests/examples/spectrum/spectrum-example.c
index b5529218a..c843d0c35 100644
--- a/tests/examples/spectrum/spectrum-example.c
+++ b/tests/examples/spectrum/spectrum-example.c
@@ -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) ||
diff --git a/tests/examples/v4l2/Makefile.am b/tests/examples/v4l2/Makefile.am
index 4fdb7e363..7db85d4e5 100644
--- a/tests/examples/v4l2/Makefile.am
+++ b/tests/examples/v4l2/Makefile.am
@@ -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)
diff --git a/tests/examples/v4l2/camctrl.c b/tests/examples/v4l2/camctrl.c
index 3c7262ab9..a252b5d04 100644
--- a/tests/examples/v4l2/camctrl.c
+++ b/tests/examples/v4l2/camctrl.c
@@ -31,7 +31,6 @@
*/
#include <gst/gst.h>
-#include <gst/controller/gstcontroller.h>
#include <gst/controller/gstinterpolationcontrolsource.h>
static void
@@ -69,7 +68,7 @@ event_loop (GstElement * bin)
}
static void
-set_program (GstController * ctrl, GstStructure * prog)
+set_program (GstObject * elem, GstStructure * prog)
{
const GstStructure *s;
GstInterpolationControlSource *cs;
@@ -100,7 +99,7 @@ set_program (GstController * ctrl, GstStructure * prog)
cs = g_hash_table_lookup (css, name);
if (!cs) {
cs = gst_interpolation_control_source_new ();
- gst_controller_set_control_source (ctrl, name, GST_CONTROL_SOURCE (cs));
+ gst_object_set_control_source (elem, name, GST_CONTROL_SOURCE (cs));
gst_interpolation_control_source_set_interpolation_mode (cs,
GST_INTERPOLATE_NONE);
g_hash_table_insert (css, (gpointer) name, cs);
@@ -125,12 +124,10 @@ main (gint argc, gchar ** argv)
GstElement *bin;
GstElement *src, *fmt, *enc, *sink;
GstCaps *caps;
- GstController *ctrl;
GstStructure *prog;
/* init gstreamer */
gst_init (&argc, &argv);
- gst_controller_init (&argc, &argv);
/* create a new bin to hold the elements */
bin = gst_pipeline_new ("camera");
@@ -171,13 +168,6 @@ main (gint argc, gchar ** argv)
return -1;
}
- /* get the controller */
- if (!(ctrl = gst_controller_new (G_OBJECT (src), "brightness", "contrast",
- "saturation", NULL))) {
- GST_WARNING ("can't control source element");
- return -1;
- }
-
/* programm a pattern of events */
#if 0
prog = gst_structure_from_string ("program"
@@ -194,7 +184,7 @@ main (gint argc, gchar ** argv)
", image03=(structure)\"image\\,brightness\\=0\\,contrast\\=15\\;\";",
NULL);
#endif
- set_program (ctrl, prog);
+ set_program (GST_OBJECT (src), prog);
g_object_set (src, "num-buffers", gst_structure_n_fields (prog), NULL);
/* prepare playback */
diff --git a/tests/icles/Makefile.am b/tests/icles/Makefile.am
index 5b1eb22b6..5678294fd 100644
--- a/tests/icles/Makefile.am
+++ b/tests/icles/Makefile.am
@@ -12,7 +12,9 @@ V4L2_TESTS = v4l2src-test
v4l2src_test_SOURCES = v4l2src-test.c
v4l2src_test_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-v4l2src_test_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR) $(GST_LIBS)
+v4l2src_test_LDADD = $(GST_PLUGINS_BASE_LIBS) \
+ -lgstvideo-$(GST_MAJORMINOR) \
+ -lgstinterfaces-$(GST_MAJORMINOR) $(GST_LIBS)
else
V4L2_TESTS =
@@ -23,7 +25,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=
diff --git a/tests/icles/gdkpixbufsink-test.c b/tests/icles/gdkpixbufsink-test.c
index b09fe09a2..c334326e0 100644
--- a/tests/icles/gdkpixbufsink-test.c
+++ b/tests/icles/gdkpixbufsink-test.c
@@ -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_query_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;
}
diff --git a/tests/icles/v4l2src-test.c b/tests/icles/v4l2src-test.c
index 4fcf48b72..02d005dca 100644
--- a/tests/icles/v4l2src-test.c
+++ b/tests/icles/v4l2src-test.c
@@ -25,8 +25,8 @@
#include <gst/gst.h>
#include <gst/interfaces/tuner.h>
-#include <gst/interfaces/colorbalance.h>
-#include <gst/interfaces/videoorientation.h>
+#include <gst/video/colorbalance.h>
+#include <gst/video/videoorientation.h>
GstElement *pipeline, *source, *sink;
GMainLoop *loop;
diff --git a/tests/icles/videocrop-test.c b/tests/icles/videocrop-test.c
index a4874e160..0106e6d41 100644
--- a/tests/icles/videocrop-test.c
+++ b/tests/icles/videocrop-test.c
@@ -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,