From 6b670d701ccd1df7e178546f1aebbdd9ed6d3107 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 11 Sep 2012 01:31:54 +0100 Subject: [PATCH] gdp: move gdp plugin to -bad It needs to be reworked for 1.0 --- Makefile.am | 4 + configure.ac | 2 - docs/plugins/Makefile.am | 2 - docs/plugins/gst-plugins-base-plugins-docs.sgml | 4 - docs/plugins/gst-plugins-base-plugins-sections.txt | 35 - docs/plugins/gst-plugins-base-plugins.hierarchy | 2 - docs/plugins/inspect/plugin-decodebin.xml | 34 - docs/plugins/inspect/plugin-gdp.xml | 55 -- docs/plugins/inspect/plugin-ogg.xml | 2 +- gst/gdp/Makefile.am | 32 - gst/gdp/README | 22 - gst/gdp/dataprotocol.c | 742 ------------------ gst/gdp/dataprotocol.h | 175 ----- gst/gdp/dp-private.h | 53 -- gst/gdp/gstgdp.c | 46 -- gst/gdp/gstgdpdepay.c | 479 ------------ gst/gdp/gstgdpdepay.h | 82 -- gst/gdp/gstgdppay.c | 864 --------------------- gst/gdp/gstgdppay.h | 81 -- tests/check/Makefile.am | 9 - tests/check/elements/.gitignore | 2 - tests/check/elements/gdpdepay.c | 399 ---------- tests/check/elements/gdppay.c | 571 -------------- tests/check/pipelines/.gitignore | 1 - tests/check/pipelines/streamheader.c | 269 ------- 25 files changed, 5 insertions(+), 3962 deletions(-) delete mode 100644 docs/plugins/inspect/plugin-decodebin.xml delete mode 100644 docs/plugins/inspect/plugin-gdp.xml delete mode 100644 gst/gdp/Makefile.am delete mode 100644 gst/gdp/README delete mode 100644 gst/gdp/dataprotocol.c delete mode 100644 gst/gdp/dataprotocol.h delete mode 100644 gst/gdp/dp-private.h delete mode 100644 gst/gdp/gstgdp.c delete mode 100644 gst/gdp/gstgdpdepay.c delete mode 100644 gst/gdp/gstgdpdepay.h delete mode 100644 gst/gdp/gstgdppay.c delete mode 100644 gst/gdp/gstgdppay.h delete mode 100644 tests/check/elements/gdpdepay.c delete mode 100644 tests/check/elements/gdppay.c delete mode 100644 tests/check/pipelines/streamheader.c diff --git a/Makefile.am b/Makefile.am index 828f2e3..8cb3333 100644 --- a/Makefile.am +++ b/Makefile.am @@ -77,12 +77,16 @@ CRUFT_FILES = \ $(top_builddir)/common/shave \ $(top_builddir)/common/shave-libtool \ $(top_builddir)/gst-libs/gst/audio/testchannels \ + $(top_builddir)/tests/check/elements/gdppay \ + $(top_builddir)/tests/check/elements/gdpdepay \ + $(top_builddir)/tests/check/pipelines/streamheader \ $(top_builddir)/tests/examples/audio/testchannels \ $(top_builddir)/tests/examples/volume/volume \ $(top_builddir)/tools/gst-discoverer CRUFT_DIRS = \ $(top_srcdir)/ext/gio \ + $(top_srcdir)/gst/gdp \ $(top_srcdir)/sys/v4l \ $(top_srcdir)/tests/examples/v4l diff --git a/configure.ac b/configure.ac index a2b24d8..828f223 100644 --- a/configure.ac +++ b/configure.ac @@ -390,7 +390,6 @@ AG_GST_CHECK_PLUGIN(audiorate) AG_GST_CHECK_PLUGIN(audiotestsrc) AG_GST_CHECK_PLUGIN(encoding) AG_GST_CHECK_PLUGIN(videoconvert) -AG_GST_CHECK_PLUGIN(gdp) AG_GST_CHECK_PLUGIN(gio) AG_GST_CHECK_PLUGIN(playback) AG_GST_CHECK_PLUGIN(audioresample) @@ -818,7 +817,6 @@ gst/audiorate/Makefile gst/audiotestsrc/Makefile gst/encoding/Makefile gst/videoconvert/Makefile -gst/gdp/Makefile gst/gio/Makefile gst/playback/Makefile gst/audioresample/Makefile diff --git a/docs/plugins/Makefile.am b/docs/plugins/Makefile.am index 4745e2c..c923edf 100644 --- a/docs/plugins/Makefile.am +++ b/docs/plugins/Makefile.am @@ -71,8 +71,6 @@ EXTRA_HFILES = \ $(top_srcdir)/gst/audioconvert/gstaudioconvert.h \ $(top_srcdir)/gst/audiotestsrc/gstaudiotestsrc.h \ $(top_srcdir)/gst/encoding/gstencodebin.h \ - $(top_srcdir)/gst/gdp/gstgdpdepay.h \ - $(top_srcdir)/gst/gdp/gstgdppay.h \ $(top_srcdir)/gst/gio/gstgiosink.h \ $(top_srcdir)/gst/gio/gstgiosrc.h \ $(top_srcdir)/gst/gio/gstgiostreamsink.h \ diff --git a/docs/plugins/gst-plugins-base-plugins-docs.sgml b/docs/plugins/gst-plugins-base-plugins-docs.sgml index 8281329..2b1591c 100644 --- a/docs/plugins/gst-plugins-base-plugins-docs.sgml +++ b/docs/plugins/gst-plugins-base-plugins-docs.sgml @@ -31,8 +31,6 @@ - - @@ -76,10 +74,8 @@ - - diff --git a/docs/plugins/gst-plugins-base-plugins-sections.txt b/docs/plugins/gst-plugins-base-plugins-sections.txt index 9f1a252..81eaacb 100644 --- a/docs/plugins/gst-plugins-base-plugins-sections.txt +++ b/docs/plugins/gst-plugins-base-plugins-sections.txt @@ -275,35 +275,6 @@ GstVideoConvertClass
-element-gdpdepay -gdpdepay -GstGDPDepay - -GstGDPDepayClass -GstGDPDepayState -GST_GDP_DEPAY -GST_GDP_DEPAY_CLASS -GST_IS_GDP_DEPAY -GST_IS_GDP_DEPAY_CLASS -GST_TYPE_GDP_DEPAY -gst_gdp_depay_plugin_init -
- -
-element-gdppay -gdppay -GstGDPPay - -GstGDPPayClass -GST_GDP_PAY -GST_GDP_PAY_CLASS -GST_IS_GDP_PAY -GST_IS_GDP_PAY_CLASS -GST_TYPE_GDP_PAY -gst_gdp_pay_plugin_init -
- -
element-giosink giosink GstGioSink @@ -562,12 +533,6 @@ GST_IS_TCP_SERVER_SINK TCP_DEFAULT_HOST TCP_DEFAULT_PORT TCP_HIGHEST_PORT -gst_tcp_gdp_read_buffer -gst_tcp_gdp_read_caps -gst_tcp_gdp_read_event -gst_tcp_gdp_write_buffer -gst_tcp_gdp_write_caps -gst_tcp_gdp_write_event gst_tcp_host_to_ip gst_tcp_read_buffer gst_tcp_socket_close diff --git a/docs/plugins/gst-plugins-base-plugins.hierarchy b/docs/plugins/gst-plugins-base-plugins.hierarchy index 151f65a..6f75194 100644 --- a/docs/plugins/gst-plugins-base-plugins.hierarchy +++ b/docs/plugins/gst-plugins-base-plugins.hierarchy @@ -82,8 +82,6 @@ GObject GstPlaySink GstSubtitleOverlay GstURIDecodeBin - GstGDPDepay - GstGDPPay GstOggAviParse GstOggDemux GstOggMux diff --git a/docs/plugins/inspect/plugin-decodebin.xml b/docs/plugins/inspect/plugin-decodebin.xml deleted file mode 100644 index e8f7814..0000000 --- a/docs/plugins/inspect/plugin-decodebin.xml +++ /dev/null @@ -1,34 +0,0 @@ - - decodebin - decoder bin - ../../gst/playback/.libs/libgstdecodebin.so - libgstdecodebin.so - 0.10.35.1 - LGPL - gst-plugins-base - GStreamer Base Plug-ins git - Unknown package origin - - - decodebin - Decoder Bin - Generic/Bin/Decoder - Autoplug and decode to raw media - Wim Taymans <wim.taymans@gmail.com> - - - sink - sink - always -
ANY
-
- - src%d - source - sometimes -
ANY
-
-
-
-
-
diff --git a/docs/plugins/inspect/plugin-gdp.xml b/docs/plugins/inspect/plugin-gdp.xml deleted file mode 100644 index 0ead55e..0000000 --- a/docs/plugins/inspect/plugin-gdp.xml +++ /dev/null @@ -1,55 +0,0 @@ - - gdp - Payload/depayload GDP packets - ../../gst/gdp/.libs/libgstgdp.so - libgstgdp.so - 0.11.93.1 - LGPL - gst-plugins-base - GStreamer Base Plug-ins git - Unknown package origin - - - gdpdepay - GDP Depayloader - GDP/Depayloader - Depayloads GStreamer Data Protocol buffers - Thomas Vander Stichele <thomas at apestaart dot org> - - - sink - sink - always -
application/x-gdp
-
- - src - source - always -
ANY
-
-
-
- - gdppay - GDP Payloader - GDP/Payloader - Payloads GStreamer Data Protocol buffers - Thomas Vander Stichele <thomas at apestaart dot org> - - - sink - sink - always -
ANY
-
- - src - source - always -
application/x-gdp
-
-
-
-
-
\ No newline at end of file diff --git a/docs/plugins/inspect/plugin-ogg.xml b/docs/plugins/inspect/plugin-ogg.xml index e6a04e5..9eddca8 100644 --- a/docs/plugins/inspect/plugin-ogg.xml +++ b/docs/plugins/inspect/plugin-ogg.xml @@ -164,7 +164,7 @@ src source sometimes -
video/x-3ivx, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-asus, asusversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-asus, asusversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-cirrus-logic-accupak, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-camstudio, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-compressed-yuv, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string){ RGB8_PALETTED, BGR, BGRx }, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)3, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-truemotion, trueversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dv, systemstream=(boolean)false, dvversion=(int)25, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dv, systemstream=(boolean)false, dvversion=(int)50, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)5, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-flash-video, flvversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp6-flash, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)itu, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)lucent, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h264, variant=(string)itu, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-huffyuv, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-intel-h263, variant=(string)intel, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)I420, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-indeo, indeoversion=(int)3, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-indeo, indeoversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-indeo, indeoversion=(int)5, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)lead, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h264, variant=(string)lead, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)microsoft, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; image/jpeg, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)42, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)43, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, systemstream=(boolean)false, mpegversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, systemstream=(boolean)false, mpegversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)41, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-mszh, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; image/png, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-rle, layout=(string)microsoft, depth=(int)[ 1, 64 ], framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-indeo, indeoversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/sp5x, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-truemotion, trueversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-camtasia, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-ultimotion, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)UYVY, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-ati-vcr, vcrversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-ati-vcr, vcrversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)vdolive, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)vivo, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vmnc, version=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp3, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h264, variant=(string)videosoft, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-wmv, wmvversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-wmv, wmvversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-wmv, wmvversion=(int)3, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-xan, wcversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)YUY2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)YVU9, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-zlib, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-cinepak, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h264, variant=(string)itu, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msvideocodec, msvideoversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)xirlink, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dirac, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-ffv, ffvversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-kmvc, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp5, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp6, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp6-flash, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp7, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp8, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-mimic, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-apple-video, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-theora, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-fraps, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-aasc, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)YV12, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-loco, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-zmbv, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)v210, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)r210, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]
+
video/mpeg, mpegversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-asus, asusversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-asus, asusversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-cirrus-logic-accupak, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-camstudio, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-compressed-yuv, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string){ RGB8_PALETTED, BGR, BGRx }, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)3, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-truemotion, trueversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dv, systemstream=(boolean)false, dvversion=(int)25, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dv, systemstream=(boolean)false, dvversion=(int)50, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)5, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-flash-video, flvversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp6-flash, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)itu, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)lucent, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h264, variant=(string)itu, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-huffyuv, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-intel-h263, variant=(string)intel, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)I420, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-indeo, indeoversion=(int)3, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-indeo, indeoversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-indeo, indeoversion=(int)5, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)lead, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h264, variant=(string)lead, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)microsoft, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; image/jpeg, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)42, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)43, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, systemstream=(boolean)false, mpegversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, systemstream=(boolean)false, mpegversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)41, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-mszh, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; image/png, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-rle, layout=(string)microsoft, depth=(int)[ 1, 64 ], framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-indeo, indeoversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/sp5x, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-truemotion, trueversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-camtasia, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-ultimotion, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)UYVY, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-ati-vcr, vcrversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-ati-vcr, vcrversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)vdolive, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)vivo, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vmnc, version=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp3, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h264, variant=(string)videosoft, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-wmv, wmvversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-wmv, wmvversion=(int)2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-wmv, wmvversion=(int)3, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-xan, wcversion=(int)4, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)YUY2, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)YVU9, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-zlib, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-cinepak, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h264, variant=(string)itu, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msvideocodec, msvideoversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, variant=(string)xirlink, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dirac, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-ffv, ffvversion=(int)1, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-kmvc, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp5, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp6, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp6-flash, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp7, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-vp8, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-mimic, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-apple-video, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-theora, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-fraps, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-aasc, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)YV12, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-loco, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-zmbv, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)v210, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-raw, format=(string)r210, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]
diff --git a/gst/gdp/Makefile.am b/gst/gdp/Makefile.am deleted file mode 100644 index 990f967..0000000 --- a/gst/gdp/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -plugin_LTLIBRARIES = libgstgdp.la - -libgstgdp_la_SOURCES = \ - dataprotocol.c \ - gstgdp.c \ - gstgdppay.c \ - gstgdpdepay.c - -libgstgdp_la_CFLAGS = $(GST_BASE_CFLAGS) $(GST_CFLAGS) -libgstgdp_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) -libgstgdp_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -libgstgdp_la_LIBTOOLFLAGS = --tag=disable-static - -noinst_HEADERS = \ - dataprotocol.h \ - dp-private.h \ - gstgdppay.h \ - gstgdpdepay.h - -Android.mk: Makefile.am $(BUILT_SOURCES) - androgenizer \ - -:PROJECT libgstgdp -:SHARED libgstgdp \ - -:TAGS eng debug \ - -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ - -:SOURCES $(libgstgdp_la_SOURCES) \ - -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstgdp_la_CFLAGS) \ - -:LDFLAGS $(libgstgdp_la_LDFLAGS) \ - $(libgstgdp_la_LIBADD) \ - -ldl \ - -:PASSTHROUGH LOCAL_ARM_MODE:=arm \ - LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \ - > $@ diff --git a/gst/gdp/README b/gst/gdp/README deleted file mode 100644 index 6b84afc..0000000 --- a/gst/gdp/README +++ /dev/null @@ -1,22 +0,0 @@ -Sample pipelines: -- replacing tcpserversink protocol=gdp with gdppay ! tcpserversink: - - raw audio: - - server: - gst-launch -v audiotestsrc ! gdppay version=0.2 ! tcpserversink - - client: - gst-launch -v tcpclientsrc protocol=gdp ! alsasink sync=FALSE - - - vorbis packets: - - server: - gst-launch -v audiotestsrc ! audioconvert ! vorbisenc ! gdppay version=0.2 ! tcpserversink - - client: - gst-launch -v tcpclientsrc protocol=gdp ! vorbisdec ! audioconvert ! alsasink sync=FALSE - - - ogg packets: - - server: - gst-launch -v audiotestsrc ! audioconvert ! vorbisenc ! oggmux ! gdppay version=0.2 ! tcpserversink - - client: - gst-launch -v tcpclientsrc protocol=gdp ! oggdemux ! vorbisdec ! audioconvert ! alsasink sync=FALSE - - In all the client pipelines, tcpclientsrc protocol=gdp can be replaced with - tcpclientsrc ! gdpdepay diff --git a/gst/gdp/dataprotocol.c b/gst/gdp/dataprotocol.c deleted file mode 100644 index 160c791..0000000 --- a/gst/gdp/dataprotocol.c +++ /dev/null @@ -1,742 +0,0 @@ -/* GStreamer - * Copyright (C) <1999> Erik Walthinsen - * Copyright (C) 2004,2006 Thomas Vander Stichele - * - * dataprotocol.c: Functions implementing the GStreamer Data Protocol - * - * 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:gstdataprotocol - * @short_description: Serialization of caps, buffers and events. - * @see_also: #GstCaps, #GstEvent, #GstBuffer - * - * This helper library provides serialization of GstBuffer, GstCaps and - * GstEvent structures. - * - * This serialization is useful when GStreamer needs to interface with - * the outside world to transport data between distinct GStreamer pipelines. - * The connections with the outside world generally don't have mechanisms - * to transport properties of these structures. - * - * For example, transporting buffers across named pipes or network connections - * doesn't maintain the buffer size and separation. - * - * This data protocol assumes a reliable connection-oriented transport, such as - * TCP, a pipe, or a file. The protocol does not serialize the caps for - * each buffer; instead, it transport the caps only when they change in the - * stream. This implies that there will always be a caps packet before any - * buffer packets. - * - * The versioning of the protocol is independent of GStreamer's version. - * The major number gets incremented, and the minor reset, for incompatible - * changes. The minor number gets incremented for compatible changes that - * allow clients who do not completely understand the newer protocol version - * to still decode what they do understand. - * - * Version 0.2 serializes only a small subset of all events, with a custom - * payload for each type. Also, all GDP streams start with the initial caps - * packet. - * - * Version 1.0 serializes all events by taking the string representation of - * the event as the payload. In addition, GDP streams can now start with - * events as well, as required by the new data stream model in GStreamer 0.10. - * - * Converting buffers, caps and events to GDP buffers is done using a - * #GstDPPacketizer object and invoking its packetizer functions. - * For backwards-compatibility reasons, the old 0.2 methods are still - * available but deprecated. - * - * For reference, this image shows the byte layout of the GDP header: - * - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "dataprotocol.h" -#include /* g_sprintf */ -#include /* strlen */ -#include "dp-private.h" - -/* debug category */ -GST_DEBUG_CATEGORY_STATIC (data_protocol_debug); - -/* helper macros */ - -/* write first 6 bytes of header */ -#define GST_DP_INIT_HEADER(h, version, flags, type) \ -G_STMT_START { \ - gint maj = 0, min = 0; \ - switch (version) { \ - case GST_DP_VERSION_0_2: maj = 0; min = 2; break; \ - case GST_DP_VERSION_1_0: maj = 1; min = 0; break; \ - } \ - h[0] = (guint8) maj; \ - h[1] = (guint8) min; \ - h[2] = (guint8) flags; \ - h[3] = 0; /* padding byte */ \ - GST_WRITE_UINT16_BE (h + 4, type); \ -} G_STMT_END - -#define GST_DP_SET_CRC(h, flags, payload, length); \ -G_STMT_START { \ - guint16 crc = 0; \ - if (flags & GST_DP_HEADER_FLAG_CRC_HEADER) \ - /* we don't crc the last four bytes since they are crc's */ \ - crc = gst_dp_crc (h, 58); \ - GST_WRITE_UINT16_BE (h + 58, crc); \ - \ - crc = 0; \ - if (length && (flags & GST_DP_HEADER_FLAG_CRC_PAYLOAD)) \ - crc = gst_dp_crc (payload, length); \ - GST_WRITE_UINT16_BE (h + 60, crc); \ -} G_STMT_END - -/* calculate a CCITT 16 bit CRC check value for a given byte array */ -/* - * this code snippet is adapted from a web page I found - * it is identical except for cleanups, and a final XOR with 0xffff - * as outlined in the uecp spec - * - * XMODEM x^16 + x^12 + x^5 + 1 - */ - -#define POLY 0x1021 -#define CRC_INIT 0xFFFF - -/*** HELPER FUNCTIONS ***/ - -static gboolean -gst_dp_header_from_buffer_any (const GstBuffer * buffer, GstDPHeaderFlag flags, - guint * length, guint8 ** header, GstDPVersion version) -{ - guint8 *h; - guint16 flags_mask; - GstMapInfo map; - - g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE); - g_return_val_if_fail (length, FALSE); - g_return_val_if_fail (header, FALSE); - - *length = GST_DP_HEADER_LENGTH; - h = g_malloc0 (GST_DP_HEADER_LENGTH); - - /* version, flags, type */ - GST_DP_INIT_HEADER (h, version, flags, GST_DP_PAYLOAD_BUFFER); - - gst_buffer_map ((GstBuffer *) buffer, &map, GST_MAP_READ); - - /* buffer properties */ - GST_WRITE_UINT32_BE (h + 6, map.size); - GST_WRITE_UINT64_BE (h + 10, GST_BUFFER_TIMESTAMP (buffer)); - GST_WRITE_UINT64_BE (h + 18, GST_BUFFER_DURATION (buffer)); - GST_WRITE_UINT64_BE (h + 26, GST_BUFFER_OFFSET (buffer)); - GST_WRITE_UINT64_BE (h + 34, GST_BUFFER_OFFSET_END (buffer)); - - /* data flags; eats two bytes from the ABI area */ - /* we copy everything but the read-only flags */ - flags_mask = GST_BUFFER_FLAG_LIVE | GST_BUFFER_FLAG_DISCONT | - GST_BUFFER_FLAG_HEADER | GST_BUFFER_FLAG_GAP | GST_BUFFER_FLAG_DELTA_UNIT; - - GST_WRITE_UINT16_BE (h + 42, GST_BUFFER_FLAGS (buffer) & flags_mask); - - GST_DP_SET_CRC (h, flags, map.data, map.size); - - gst_buffer_unmap ((GstBuffer *) buffer, &map); - - GST_MEMDUMP ("created header from buffer", h, GST_DP_HEADER_LENGTH); - *header = h; - return TRUE; -} - -static gboolean -gst_dp_packet_from_caps_any (const GstCaps * caps, GstDPHeaderFlag flags, - guint * length, guint8 ** header, guint8 ** payload, GstDPVersion version) -{ - guint8 *h; - guchar *string; - guint payload_length; - - g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); - g_return_val_if_fail (length, FALSE); - g_return_val_if_fail (header, FALSE); - g_return_val_if_fail (payload, FALSE); - - *length = GST_DP_HEADER_LENGTH; - h = g_malloc0 (GST_DP_HEADER_LENGTH); - - string = (guchar *) gst_caps_to_string (caps); - payload_length = strlen ((gchar *) string) + 1; /* include trailing 0 */ - - /* version, flags, type */ - GST_DP_INIT_HEADER (h, version, flags, GST_DP_PAYLOAD_CAPS); - - /* buffer properties */ - GST_WRITE_UINT32_BE (h + 6, payload_length); - GST_WRITE_UINT64_BE (h + 10, (guint64) 0); - GST_WRITE_UINT64_BE (h + 18, (guint64) 0); - GST_WRITE_UINT64_BE (h + 26, (guint64) 0); - GST_WRITE_UINT64_BE (h + 34, (guint64) 0); - - GST_DP_SET_CRC (h, flags, string, payload_length); - - GST_MEMDUMP ("created header from caps", h, GST_DP_HEADER_LENGTH); - *header = h; - *payload = string; - return TRUE; -} - - -/*** PUBLIC FUNCTIONS ***/ - -static const guint16 gst_dp_crc_table[256] = { - 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, - 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, - 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, - 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, - 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, - 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, - 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, - 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, - 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, - 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, - 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, - 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, - 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, - 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, - 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, - 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, - 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, - 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, - 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, - 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, - 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, - 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, - 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, - 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, - 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, - 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, - 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, - 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, - 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, - 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, - 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, - 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 -}; - -/** - * gst_dp_crc: - * @buffer: array of bytes - * @length: the length of @buffer - * - * Calculate a CRC for the given buffer over the given number of bytes. - * This is only provided for verification purposes; typical GDP users - * will not need this function. - * - * Returns: a two-byte CRC checksum. - */ -guint16 -gst_dp_crc (const guint8 * buffer, guint length) -{ - guint16 crc_register = CRC_INIT; - - g_return_val_if_fail (buffer != NULL || length == 0, 0); - - /* calc CRC */ - for (; length--;) { - crc_register = (guint16) ((crc_register << 8) ^ - gst_dp_crc_table[((crc_register >> 8) & 0x00ff) ^ *buffer++]); - } - return (0xffff ^ crc_register); -} - -GType -gst_dp_version_get_type (void) -{ - static gsize gst_dp_version_type = 0; - static const GEnumValue gst_dp_version[] = { - {GST_DP_VERSION_0_2, "GST_DP_VERSION_0_2", "0.2"}, - {GST_DP_VERSION_1_0, "GST_DP_VERSION_1_0", "1.0"}, - {0, NULL, NULL}, - }; - - if (g_once_init_enter (&gst_dp_version_type)) { - GType tmp = g_enum_register_static ("GstDPVersion", gst_dp_version); - g_once_init_leave (&gst_dp_version_type, tmp); - } - - return (GType) gst_dp_version_type; -}; - -/** - * gst_dp_init: - * - * Initialize GStreamer Data Protocol library. - * - * Should be called before using these functions from source linking - * to this source file. - */ -void -gst_dp_init (void) -{ - static gboolean _gst_dp_initialized = FALSE; - - if (_gst_dp_initialized) - return; - - _gst_dp_initialized = TRUE; - - g_type_class_ref (gst_dp_version_get_type ()); - - GST_DEBUG_CATEGORY_INIT (data_protocol_debug, "gdp", 0, - "GStreamer Data Protocol"); -} - -/** - * gst_dp_header_payload_length: - * @header: the byte header of the packet array - * - * Get the length of the payload described by @header. - * - * Returns: the length of the payload this header describes. - */ -guint32 -gst_dp_header_payload_length (const guint8 * header) -{ - g_return_val_if_fail (header != NULL, 0); - - return GST_DP_HEADER_PAYLOAD_LENGTH (header); -} - -/** - * gst_dp_header_payload_type: - * @header: the byte header of the packet array - * - * Get the type of the payload described by @header. - * - * Returns: the #GstDPPayloadType the payload this header describes. - */ -GstDPPayloadType -gst_dp_header_payload_type (const guint8 * header) -{ - g_return_val_if_fail (header != NULL, GST_DP_PAYLOAD_NONE); - - return GST_DP_HEADER_PAYLOAD_TYPE (header); -} - -/*** PACKETIZER FUNCTIONS ***/ - -static gboolean -gst_dp_header_from_buffer_1_0 (const GstBuffer * buffer, GstDPHeaderFlag flags, - guint * length, guint8 ** header) -{ - return gst_dp_header_from_buffer_any (buffer, flags, length, header, - GST_DP_VERSION_1_0); -} - -static gboolean -gst_dp_packet_from_caps_1_0 (const GstCaps * caps, GstDPHeaderFlag flags, - guint * length, guint8 ** header, guint8 ** payload) -{ - return gst_dp_packet_from_caps_any (caps, flags, length, header, payload, - GST_DP_VERSION_1_0); -} - -static gboolean -gst_dp_packet_from_event_1_0 (const GstEvent * event, GstDPHeaderFlag flags, - guint * length, guint8 ** header, guint8 ** payload) -{ - guint8 *h; - guint32 pl_length; /* length of payload */ - guchar *string = NULL; - const GstStructure *structure; - - g_return_val_if_fail (GST_IS_EVENT (event), FALSE); - g_return_val_if_fail (length, FALSE); - g_return_val_if_fail (header, FALSE); - g_return_val_if_fail (payload, FALSE); - - *length = GST_DP_HEADER_LENGTH; - h = g_malloc0 (GST_DP_HEADER_LENGTH); - - structure = gst_event_get_structure ((GstEvent *) event); - if (structure) { - string = (guchar *) gst_structure_to_string (structure); - GST_LOG ("event %p has structure, string %s", event, string); - pl_length = strlen ((gchar *) string) + 1; /* include trailing 0 */ - } else { - GST_LOG ("event %p has no structure", event); - pl_length = 0; - } - - /* version, flags, type */ - GST_DP_INIT_HEADER (h, GST_DP_VERSION_1_0, flags, - GST_DP_PAYLOAD_EVENT_NONE + GST_EVENT_TYPE (event)); - - /* length */ - GST_WRITE_UINT32_BE (h + 6, pl_length); - /* timestamp */ - GST_WRITE_UINT64_BE (h + 10, GST_EVENT_TIMESTAMP (event)); - - GST_DP_SET_CRC (h, flags, string, pl_length); - - GST_MEMDUMP ("created header from event", h, GST_DP_HEADER_LENGTH); - *header = h; - *payload = string; - return TRUE; -} - -/*** DEPACKETIZING FUNCTIONS ***/ - -/** - * gst_dp_buffer_from_header: - * @header_length: the length of the packet header - * @header: the byte array of the packet header - * - * Creates a newly allocated #GstBuffer from the given header. - * The buffer data needs to be copied into it before validating. - * - * Use this function if you want to pre-allocate a buffer based on the - * packet header to read the packet payload in to. - * - * This function does not check the header passed to it, use - * gst_dp_validate_header() first if the header data is unchecked. - * - * Returns: A #GstBuffer if the buffer was successfully created, or NULL. - */ -GstBuffer * -gst_dp_buffer_from_header (guint header_length, const guint8 * header) -{ - GstBuffer *buffer; - - g_return_val_if_fail (header != NULL, NULL); - g_return_val_if_fail (header_length >= GST_DP_HEADER_LENGTH, NULL); - g_return_val_if_fail (GST_DP_HEADER_PAYLOAD_TYPE (header) == - GST_DP_PAYLOAD_BUFFER, NULL); - - buffer = - gst_buffer_new_allocate (NULL, - (guint) GST_DP_HEADER_PAYLOAD_LENGTH (header), NULL); - - GST_BUFFER_TIMESTAMP (buffer) = GST_DP_HEADER_TIMESTAMP (header); - GST_BUFFER_DURATION (buffer) = GST_DP_HEADER_DURATION (header); - GST_BUFFER_OFFSET (buffer) = GST_DP_HEADER_OFFSET (header); - GST_BUFFER_OFFSET_END (buffer) = GST_DP_HEADER_OFFSET_END (header); - GST_BUFFER_FLAGS (buffer) = GST_DP_HEADER_BUFFER_FLAGS (header); - - return buffer; -} - -/** - * gst_dp_caps_from_packet: - * @header_length: the length of the packet header - * @header: the byte array of the packet header - * @payload: the byte array of the packet payload - * - * Creates a newly allocated #GstCaps from the given packet. - * - * This function does not check the arguments passed to it, use - * gst_dp_validate_packet() first if the header and payload data are - * unchecked. - * - * Returns: A #GstCaps containing the caps represented in the packet, - * or NULL if the packet could not be converted. - */ -GstCaps * -gst_dp_caps_from_packet (guint header_length, const guint8 * header, - const guint8 * payload) -{ - GstCaps *caps; - gchar *string; - - g_return_val_if_fail (header, NULL); - g_return_val_if_fail (header_length >= GST_DP_HEADER_LENGTH, NULL); - g_return_val_if_fail (GST_DP_HEADER_PAYLOAD_TYPE (header) == - GST_DP_PAYLOAD_CAPS, NULL); - g_return_val_if_fail (payload, NULL); - - /* 0 sized payload length will work create NULL string */ - string = g_strndup ((gchar *) payload, GST_DP_HEADER_PAYLOAD_LENGTH (header)); - caps = gst_caps_from_string (string); - g_free (string); - - return caps; -} - -static GstEvent * -gst_dp_event_from_packet_0_2 (guint header_length, const guint8 * header, - const guint8 * payload) -{ - GstEvent *event = NULL; - GstEventType type; - - type = GST_DP_HEADER_PAYLOAD_TYPE (header) - GST_DP_PAYLOAD_EVENT_NONE; - switch (type) { - case GST_EVENT_UNKNOWN: - GST_WARNING ("Unknown event, ignoring"); - return NULL; - case GST_EVENT_EOS: - case GST_EVENT_FLUSH_START: - case GST_EVENT_FLUSH_STOP: - case GST_EVENT_SEGMENT: - event = gst_event_new_custom (type, NULL); - GST_EVENT_TIMESTAMP (event) = GST_DP_HEADER_TIMESTAMP (header); - break; - case GST_EVENT_SEEK: - { - gdouble rate; - GstFormat format; - GstSeekFlags flags; - GstSeekType start_type, stop_type; - gint64 start, stop; - - g_return_val_if_fail (payload != NULL, NULL); - - /* FIXME, read rate */ - rate = 1.0; - format = (GstFormat) GST_READ_UINT32_BE (payload); - flags = (GstSeekFlags) GST_READ_UINT32_BE (payload + 4); - start_type = (GstSeekType) GST_READ_UINT32_BE (payload + 8); - start = (gint64) GST_READ_UINT64_BE (payload + 12); - stop_type = (GstSeekType) GST_READ_UINT32_BE (payload + 20); - stop = (gint64) GST_READ_UINT64_BE (payload + 24); - - event = gst_event_new_seek (rate, format, flags, start_type, start, - stop_type, stop); - GST_EVENT_TIMESTAMP (event) = GST_DP_HEADER_TIMESTAMP (header); - break; - } - case GST_EVENT_QOS: - case GST_EVENT_NAVIGATION: - case GST_EVENT_TAG: - GST_WARNING ("Unhandled event type %d, ignoring", type); - return NULL; - default: - GST_WARNING ("Unknown event type %d, ignoring", type); - return NULL; - } - - return event; -} - -static GstEvent * -gst_dp_event_from_packet_1_0 (guint header_length, const guint8 * header, - const guint8 * payload) -{ - GstEvent *event = NULL; - GstEventType type; - gchar *string = NULL; - GstStructure *s = NULL; - - type = GST_DP_HEADER_PAYLOAD_TYPE (header) - GST_DP_PAYLOAD_EVENT_NONE; - if (payload) { - string = - g_strndup ((gchar *) payload, GST_DP_HEADER_PAYLOAD_LENGTH (header)); - s = gst_structure_from_string (string, NULL); - g_free (string); - } - GST_LOG ("Creating event of type 0x%x with structure '%" GST_PTR_FORMAT "'", - type, s); - event = gst_event_new_custom (type, s); - return event; -} - - -/** - * gst_dp_event_from_packet: - * @header_length: the length of the packet header - * @header: the byte array of the packet header - * @payload: the byte array of the packet payload - * - * Creates a newly allocated #GstEvent from the given packet. - * - * This function does not check the arguments passed to it, use - * gst_dp_validate_packet() first if the header and payload data are - * unchecked. - * - * Returns: A #GstEvent if the event was successfully created, - * or NULL if an event could not be read from the payload. - */ -GstEvent * -gst_dp_event_from_packet (guint header_length, const guint8 * header, - const guint8 * payload) -{ - guint8 major, minor; - - g_return_val_if_fail (header, NULL); - g_return_val_if_fail (header_length >= GST_DP_HEADER_LENGTH, NULL); - - major = GST_DP_HEADER_MAJOR_VERSION (header); - minor = GST_DP_HEADER_MINOR_VERSION (header); - - if (major == 0 && minor == 2) - return gst_dp_event_from_packet_0_2 (header_length, header, payload); - else if (major == 1 && minor == 0) - return gst_dp_event_from_packet_1_0 (header_length, header, payload); - else { - GST_ERROR ("Unknown GDP version %d.%d", major, minor); - return NULL; - } -} - -/** - * gst_dp_validate_header: - * @header_length: the length of the packet header - * @header: the byte array of the packet header - * - * Validates the given packet header by checking the CRC checksum. - * - * Returns: %TRUE if the CRC matches, or no CRC checksum is present. - */ -gboolean -gst_dp_validate_header (guint header_length, const guint8 * header) -{ - guint16 crc_read, crc_calculated; - - g_return_val_if_fail (header != NULL, FALSE); - g_return_val_if_fail (header_length >= GST_DP_HEADER_LENGTH, FALSE); - - if (!(GST_DP_HEADER_FLAGS (header) & GST_DP_HEADER_FLAG_CRC_HEADER)) - return TRUE; - - crc_read = GST_DP_HEADER_CRC_HEADER (header); - - /* don't include the last two crc fields for the crc check */ - crc_calculated = gst_dp_crc (header, header_length - 4); - if (crc_read != crc_calculated) - goto crc_error; - - GST_LOG ("header crc validation: %02x", crc_read); - return TRUE; - - /* ERRORS */ -crc_error: - { - GST_WARNING ("header crc mismatch: read %02x, calculated %02x", crc_read, - crc_calculated); - return FALSE; - } -} - -/** - * gst_dp_validate_payload: - * @header_length: the length of the packet header - * @header: the byte array of the packet header - * @payload: the byte array of the packet payload - * - * Validates the given packet payload using the given packet header - * by checking the CRC checksum. - * - * Returns: %TRUE if the CRC matches, or no CRC checksum is present. - */ -gboolean -gst_dp_validate_payload (guint header_length, const guint8 * header, - const guint8 * payload) -{ - guint16 crc_read, crc_calculated; - - g_return_val_if_fail (header != NULL, FALSE); - g_return_val_if_fail (header_length >= GST_DP_HEADER_LENGTH, FALSE); - - if (!(GST_DP_HEADER_FLAGS (header) & GST_DP_HEADER_FLAG_CRC_PAYLOAD)) - return TRUE; - - crc_read = GST_DP_HEADER_CRC_PAYLOAD (header); - crc_calculated = gst_dp_crc (payload, GST_DP_HEADER_PAYLOAD_LENGTH (header)); - if (crc_read != crc_calculated) - goto crc_error; - - GST_LOG ("payload crc validation: %02x", crc_read); - return TRUE; - - /* ERRORS */ -crc_error: - { - GST_WARNING ("payload crc mismatch: read %02x, calculated %02x", crc_read, - crc_calculated); - return FALSE; - } -} - -/** - * gst_dp_validate_packet: - * @header_length: the length of the packet header - * @header: the byte array of the packet header - * @payload: the byte array of the packet payload - * - * Validates the given packet by checking version information and checksums. - * - * Returns: %TRUE if the packet validates. - */ -gboolean -gst_dp_validate_packet (guint header_length, const guint8 * header, - const guint8 * payload) -{ - if (!gst_dp_validate_header (header_length, header)) - return FALSE; - if (!gst_dp_validate_payload (header_length, header, payload)) - return FALSE; - - return TRUE; -} - -/** - * gst_dp_packetizer_new: - * @version: the #GstDPVersion of the protocol to packetize for. - * - * Creates a new packetizer. - * - * Returns: a newly allocated #GstDPPacketizer - */ -GstDPPacketizer * -gst_dp_packetizer_new (GstDPVersion version) -{ - GstDPPacketizer *ret; - - ret = g_malloc0 (sizeof (GstDPPacketizer)); - ret->version = version; - - switch (version) { - case GST_DP_VERSION_1_0: - ret->header_from_buffer = gst_dp_header_from_buffer_1_0; - ret->packet_from_caps = gst_dp_packet_from_caps_1_0; - ret->packet_from_event = gst_dp_packet_from_event_1_0; - break; - default: - g_free (ret); - ret = NULL; - break; - } - - return ret; -} - -/** - * gst_dp_packetizer_free: - * @packetizer: the #GstDPPacketizer to free. - * - * Free the given packetizer. - */ -void -gst_dp_packetizer_free (GstDPPacketizer * packetizer) -{ - g_free (packetizer); -} diff --git a/gst/gdp/dataprotocol.h b/gst/gdp/dataprotocol.h deleted file mode 100644 index d2b2114..0000000 --- a/gst/gdp/dataprotocol.h +++ /dev/null @@ -1,175 +0,0 @@ -/* GStreamer - * Copyright (C) 1999 Erik Walthinsen - * Copyright (C) 2004,2006 Thomas Vander Stichele - * - * dataprotocol.h: Functions implementing the GStreamer Data Protocol - * - * 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_DATA_PROTOCOL_H__ -#define __GST_DATA_PROTOCOL_H__ - -#include -#include -#include - -G_BEGIN_DECLS - -/** - * GstDPVersion: - * @GST_DP_VERSION_0_2: protocol version 0.2 - * @GST_DP_VERSION_1_0: protocol version 1.0 - * - * The version of the GDP protocol being used. - */ -typedef enum { - GST_DP_VERSION_0_2 = 1, - GST_DP_VERSION_1_0, -} GstDPVersion; - -GType gst_dp_version_get_type (void); -#define GST_TYPE_DP_VERSION (gst_dp_version_get_type ()) - -/** - * GST_DP_VERSION_MAJOR: - * - * The major version number of the GStreamer Data Protocol. - */ -#define GST_DP_VERSION_MAJOR 0 -/** - * GST_DP_VERSION_MINOR: - * - * The minor version number of the GStreamer Data Protocol. - */ -#define GST_DP_VERSION_MINOR 2 - -/** - * GST_DP_HEADER_LENGTH: - * - * The header size in bytes. - */ -#define GST_DP_HEADER_LENGTH 62 - -/** - * GstDPHeaderFlag: - * @GST_DP_HEADER_FLAG_NONE: No flag present. - * @GST_DP_HEADER_FLAG_CRC_HEADER: a header CRC field is present. - * @GST_DP_HEADER_FLAG_CRC_PAYLOAD: a payload CRC field is present. - * @GST_DP_HEADER_FLAG_CRC: a CRC for header and payload is present. - * - * header flags for the dataprotocol. - */ -typedef enum { - GST_DP_HEADER_FLAG_NONE = 0, - GST_DP_HEADER_FLAG_CRC_HEADER = (1 << 0), - GST_DP_HEADER_FLAG_CRC_PAYLOAD = (1 << 1), - GST_DP_HEADER_FLAG_CRC = (1 << 1) | (1 << 0), -} GstDPHeaderFlag; - -/** - * GstDPPayloadType: - * @GST_DP_PAYLOAD_NONE: Invalid payload type. - * @GST_DP_PAYLOAD_BUFFER: #GstBuffer payload packet. - * @GST_DP_PAYLOAD_CAPS: #GstCaps payload packet. - * @GST_DP_PAYLOAD_EVENT_NONE: First value of #GstEvent payload packets. - * - * The GDP payload types. a #GstEvent payload type is encoded with the - * event type number starting from @GST_DP_PAYLOAD_EVENT_NONE. - */ -typedef enum { - GST_DP_PAYLOAD_NONE = 0, - GST_DP_PAYLOAD_BUFFER, - GST_DP_PAYLOAD_CAPS, - GST_DP_PAYLOAD_EVENT_NONE = 64, -} GstDPPayloadType; - -typedef gboolean (*GstDPHeaderFromBufferFunction) (const GstBuffer * buffer, - GstDPHeaderFlag flags, - guint * length, - guint8 ** header); -typedef gboolean (*GstDPPacketFromCapsFunction) (const GstCaps * caps, - GstDPHeaderFlag flags, - guint * length, - guint8 ** header, - guint8 ** payload); -typedef gboolean (*GstDPPacketFromEventFunction) (const GstEvent * event, - GstDPHeaderFlag flags, - guint * length, - guint8 ** header, - guint8 ** payload); - -/** - * GstDPPacketizer: - * @version: the #GstDPVersion of the protocol to be used - * @header_from_buffer: buffer serializer function - * @packet_from_caps: caps serializer function - * @packet_from_event: event serializer function - * - * Data protocol packetizer handle. - */ -typedef struct { - GstDPVersion version; - - GstDPHeaderFromBufferFunction header_from_buffer; - GstDPPacketFromCapsFunction packet_from_caps; - GstDPPacketFromEventFunction packet_from_event; - - /*< private >*/ - gpointer _gst_reserved[GST_PADDING]; -} GstDPPacketizer; - - -void gst_dp_init (void); - -/* packetizer */ -GstDPPacketizer * - gst_dp_packetizer_new (GstDPVersion version); -void gst_dp_packetizer_free (GstDPPacketizer *packetizer); - -/* crc checksum */ -guint16 gst_dp_crc (const guint8 * buffer, - guint length); - -/* payload information from header */ -guint32 gst_dp_header_payload_length (const guint8 * header); -GstDPPayloadType - gst_dp_header_payload_type (const guint8 * header); - -/* converting to GstBuffer/GstEvent/GstCaps */ -GstBuffer * gst_dp_buffer_from_header (guint header_length, - const guint8 * header); -GstCaps * gst_dp_caps_from_packet (guint header_length, - const guint8 * header, - const guint8 * payload); -GstEvent * gst_dp_event_from_packet (guint header_length, - const guint8 * header, - const guint8 * payload); - -/* validation */ -gboolean gst_dp_validate_header (guint header_length, - const guint8 * header); -gboolean gst_dp_validate_payload (guint header_length, - const guint8 * header, - const guint8 * payload); -gboolean gst_dp_validate_packet (guint header_length, - const guint8 * header, - const guint8 * payload); - -G_END_DECLS - -#endif /* __GST_DATA_PROTOCOL_H__ */ - diff --git a/gst/gdp/dp-private.h b/gst/gdp/dp-private.h deleted file mode 100644 index 8b5214e..0000000 --- a/gst/gdp/dp-private.h +++ /dev/null @@ -1,53 +0,0 @@ -/* GStreamer - * Copyright (C) <1999> Erik Walthinsen - * Copyright (C) <2004> Thomas Vander Stichele - * - * dp-private.h: private defines/macros for dataprotocol implementation - * - * 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_DP_PRIVATE_H__ -#define __GST_DP_PRIVATE_H__ - -#include -#include -#include - -G_BEGIN_DECLS - -/* FIXME: please make the dataprotocol format typefindable in new versions */ - -/* accessor defines */ -#define GST_DP_HEADER_MAJOR_VERSION(x) ((x)[0]) -#define GST_DP_HEADER_MINOR_VERSION(x) ((x)[1]) -#define GST_DP_HEADER_FLAGS(x) ((x)[2]) -/* free byte here to align */ -#define GST_DP_HEADER_PAYLOAD_TYPE(x) GST_READ_UINT16_BE (x + 4) -#define GST_DP_HEADER_PAYLOAD_LENGTH(x) GST_READ_UINT32_BE (x + 6) -#define GST_DP_HEADER_TIMESTAMP(x) GST_READ_UINT64_BE (x + 10) -#define GST_DP_HEADER_DURATION(x) GST_READ_UINT64_BE (x + 18) -#define GST_DP_HEADER_OFFSET(x) GST_READ_UINT64_BE (x + 26) -#define GST_DP_HEADER_OFFSET_END(x) GST_READ_UINT64_BE (x + 34) -#define GST_DP_HEADER_BUFFER_FLAGS(x) GST_READ_UINT16_BE (x + 42) -#define GST_DP_HEADER_CRC_HEADER(x) GST_READ_UINT16_BE (x + 58) -#define GST_DP_HEADER_CRC_PAYLOAD(x) GST_READ_UINT16_BE (x + 60) - -void gst_dp_dump_byte_array (guint8 *array, guint length); - -G_END_DECLS - -#endif /* __GST_DP_PRIVATE_H__ */ diff --git a/gst/gdp/gstgdp.c b/gst/gdp/gstgdp.c deleted file mode 100644 index a05b0bf..0000000 --- a/gst/gdp/gstgdp.c +++ /dev/null @@ -1,46 +0,0 @@ -/* GStreamer - * Copyright (C) 2006 Thomas Vander Stichele - * - * 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 -#endif - -#include "dataprotocol.h" - -#include "gstgdppay.h" -#include "gstgdpdepay.h" - -static gboolean -plugin_init (GstPlugin * plugin) -{ - gst_dp_init (); - - if (!gst_gdp_depay_plugin_init (plugin)) - return FALSE; - - if (!gst_gdp_pay_plugin_init (plugin)) - return FALSE; - - return TRUE; -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, - gdp, - "Payload/depayload GDP packets", plugin_init, - VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN); diff --git a/gst/gdp/gstgdpdepay.c b/gst/gdp/gstgdpdepay.c deleted file mode 100644 index 4d03082..0000000 --- a/gst/gdp/gstgdpdepay.c +++ /dev/null @@ -1,479 +0,0 @@ -/* GStreamer - * Copyright (C) 2006 Thomas Vander Stichele - * - * 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-gdpdepay - * @see_also: gdppay - * - * This element depayloads GStreamer Data Protocol buffers back to deserialized - * buffers and events. - * - * - * |[ - * gst-launch -v -m filesrc location=test.gdp ! gdpdepay ! xvimagesink - * ]| This pipeline plays back a serialized video stream as created in the - * example for gdppay. - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include "dataprotocol.h" - -#include "gstgdpdepay.h" - -enum -{ - PROP_0, -}; - -static GstStaticPadTemplate gdp_depay_sink_template = -GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("application/x-gdp")); - -static GstStaticPadTemplate gdp_depay_src_template = -GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY); - -GST_DEBUG_CATEGORY_STATIC (gst_gdp_depay_debug); -#define GST_CAT_DEFAULT gst_gdp_depay_debug - -#define _do_init \ - GST_DEBUG_CATEGORY_INIT (gst_gdp_depay_debug, "gdpdepay", 0, \ - "GDP depayloader"); -#define gst_gdp_depay_parent_class parent_class -G_DEFINE_TYPE_WITH_CODE (GstGDPDepay, gst_gdp_depay, - GST_TYPE_ELEMENT, _do_init); - -static gboolean gst_gdp_depay_sink_event (GstPad * pad, GstObject * parent, - GstEvent * event); -static gboolean gst_gdp_depay_src_event (GstPad * pad, GstObject * parent, - GstEvent * event); - -static GstFlowReturn gst_gdp_depay_chain (GstPad * pad, GstObject * parent, - GstBuffer * buffer); - -static GstStateChangeReturn gst_gdp_depay_change_state (GstElement * - element, GstStateChange transition); - -static void gst_gdp_depay_finalize (GObject * object); - -static void -gst_gdp_depay_class_init (GstGDPDepayClass * klass) -{ - GObjectClass *gobject_class; - GstElementClass *gstelement_class; - - gobject_class = (GObjectClass *) klass; - gstelement_class = (GstElementClass *) klass; - - gst_element_class_set_static_metadata (gstelement_class, - "GDP Depayloader", "GDP/Depayloader", - "Depayloads GStreamer Data Protocol buffers", - "Thomas Vander Stichele "); - - gst_element_class_add_pad_template (gstelement_class, - gst_static_pad_template_get (&gdp_depay_sink_template)); - gst_element_class_add_pad_template (gstelement_class, - gst_static_pad_template_get (&gdp_depay_src_template)); - - gstelement_class->change_state = - GST_DEBUG_FUNCPTR (gst_gdp_depay_change_state); - gobject_class->finalize = gst_gdp_depay_finalize; -} - -static void -gst_gdp_depay_init (GstGDPDepay * gdpdepay) -{ - gdpdepay->sinkpad = - gst_pad_new_from_static_template (&gdp_depay_sink_template, "sink"); - gst_pad_set_chain_function (gdpdepay->sinkpad, - GST_DEBUG_FUNCPTR (gst_gdp_depay_chain)); - gst_pad_set_event_function (gdpdepay->sinkpad, - GST_DEBUG_FUNCPTR (gst_gdp_depay_sink_event)); - gst_element_add_pad (GST_ELEMENT (gdpdepay), gdpdepay->sinkpad); - - gdpdepay->srcpad = - gst_pad_new_from_static_template (&gdp_depay_src_template, "src"); - gst_pad_set_event_function (gdpdepay->srcpad, - GST_DEBUG_FUNCPTR (gst_gdp_depay_src_event)); - /* our caps will always be decided by the incoming GDP caps buffers */ - gst_pad_use_fixed_caps (gdpdepay->srcpad); - gst_element_add_pad (GST_ELEMENT (gdpdepay), gdpdepay->srcpad); - - gdpdepay->adapter = gst_adapter_new (); -} - -static void -gst_gdp_depay_finalize (GObject * gobject) -{ - GstGDPDepay *this; - - this = GST_GDP_DEPAY (gobject); - if (this->caps) - gst_caps_unref (this->caps); - g_free (this->header); - gst_adapter_clear (this->adapter); - g_object_unref (this->adapter); - - GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (gobject)); -} - -static gboolean -gst_gdp_depay_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) -{ - GstGDPDepay *this; - gboolean res = TRUE; - - this = GST_GDP_DEPAY (parent); - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_FLUSH_START: - /* forward flush start */ - res = gst_pad_push_event (this->srcpad, event); - break; - case GST_EVENT_FLUSH_STOP: - /* clear adapter on flush */ - gst_adapter_clear (this->adapter); - /* forward flush stop */ - res = gst_pad_push_event (this->srcpad, event); - break; - case GST_EVENT_EOS: - /* after EOS, we don't expect to output anything anymore */ - res = gst_pad_push_event (this->srcpad, event); - break; - case GST_EVENT_SEGMENT: - case GST_EVENT_TAG: - case GST_EVENT_BUFFERSIZE: - default: - /* we unref most events as we take them from the datastream */ - gst_event_unref (event); - break; - } - - return res; -} - -static gboolean -gst_gdp_depay_src_event (GstPad * pad, GstObject * parent, GstEvent * event) -{ - GstGDPDepay *this; - gboolean res = TRUE; - - this = GST_GDP_DEPAY (parent); - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_SEEK: - /* we refuse seek for now. */ - gst_event_unref (event); - res = FALSE; - break; - case GST_EVENT_QOS: - case GST_EVENT_NAVIGATION: - default: - /* everything else is passed */ - res = gst_pad_push_event (this->sinkpad, event); - break; - } - - return res; -} - -static GstFlowReturn -gst_gdp_depay_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) -{ - GstGDPDepay *this; - GstFlowReturn ret = GST_FLOW_OK; - GstCaps *caps; - GstBuffer *buf; - GstEvent *event; - guint available; - - this = GST_GDP_DEPAY (parent); - - /* On DISCONT, get rid of accumulated data. We assume a buffer after the - * DISCONT contains (part of) a new valid header, if not we error because we - * lost sync */ - if (GST_BUFFER_IS_DISCONT (buffer)) { - gst_adapter_clear (this->adapter); - this->state = GST_GDP_DEPAY_STATE_HEADER; - } - gst_adapter_push (this->adapter, buffer); - - while (TRUE) { - switch (this->state) { - case GST_GDP_DEPAY_STATE_HEADER: - { - guint8 *header; - - /* collect a complete header, validate and store the header. Figure out - * the payload length and switch to the PAYLOAD state */ - available = gst_adapter_available (this->adapter); - if (available < GST_DP_HEADER_LENGTH) - goto done; - - GST_LOG_OBJECT (this, "reading GDP header from adapter"); - header = gst_adapter_take (this->adapter, GST_DP_HEADER_LENGTH); - if (!gst_dp_validate_header (GST_DP_HEADER_LENGTH, header)) { - g_free (header); - goto header_validate_error; - } - - /* store types and payload length. Also store the header, which we need - * to make the payload. */ - this->payload_length = gst_dp_header_payload_length (header); - this->payload_type = gst_dp_header_payload_type (header); - /* free previous header and store new one. */ - g_free (this->header); - this->header = header; - - GST_LOG_OBJECT (this, - "read GDP header, payload size %d, payload type %d, switching to state PAYLOAD", - this->payload_length, this->payload_type); - this->state = GST_GDP_DEPAY_STATE_PAYLOAD; - break; - } - case GST_GDP_DEPAY_STATE_PAYLOAD: - { - /* in this state we wait for all the payload data to be available in the - * adapter. Then we switch to the state where we actually process the - * payload. */ - available = gst_adapter_available (this->adapter); - if (available < this->payload_length) - goto done; - - /* change state based on type */ - if (this->payload_type == GST_DP_PAYLOAD_BUFFER) { - GST_LOG_OBJECT (this, "switching to state BUFFER"); - this->state = GST_GDP_DEPAY_STATE_BUFFER; - } else if (this->payload_type == GST_DP_PAYLOAD_CAPS) { - GST_LOG_OBJECT (this, "switching to state CAPS"); - this->state = GST_GDP_DEPAY_STATE_CAPS; - } else if (this->payload_type >= GST_DP_PAYLOAD_EVENT_NONE) { - GST_LOG_OBJECT (this, "switching to state EVENT"); - this->state = GST_GDP_DEPAY_STATE_EVENT; - } else { - goto wrong_type; - } - - if (this->payload_length) { - const guint8 *data; - gboolean res; - - data = gst_adapter_map (this->adapter, this->payload_length); - res = gst_dp_validate_payload (GST_DP_HEADER_LENGTH, this->header, - data); - gst_adapter_unmap (this->adapter); - - if (!res) - goto payload_validate_error; - } - - break; - } - case GST_GDP_DEPAY_STATE_BUFFER: - { - /* if we receive a buffer without caps first, we error out */ - if (!this->caps) - goto no_caps; - - GST_LOG_OBJECT (this, "reading GDP buffer from adapter"); - buf = gst_dp_buffer_from_header (GST_DP_HEADER_LENGTH, this->header); - if (!buf) - goto buffer_failed; - - /* now take the payload if there is any */ - if (this->payload_length > 0) { - GstMapInfo map; - - gst_buffer_map (buf, &map, GST_MAP_WRITE); - gst_adapter_copy (this->adapter, map.data, 0, this->payload_length); - gst_buffer_unmap (buf, &map); - - gst_adapter_flush (this->adapter, this->payload_length); - } - - /* set caps and push */ - GST_LOG_OBJECT (this, "deserialized buffer %p, pushing, timestamp %" - GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT - ", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT - ", size %" G_GSIZE_FORMAT ", flags 0x%x", - buf, - GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), - GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), - GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), - gst_buffer_get_size (buf), GST_BUFFER_FLAGS (buf)); - ret = gst_pad_push (this->srcpad, buf); - if (ret != GST_FLOW_OK) - goto push_error; - - GST_LOG_OBJECT (this, "switching to state HEADER"); - this->state = GST_GDP_DEPAY_STATE_HEADER; - break; - } - case GST_GDP_DEPAY_STATE_CAPS: - { - guint8 *payload; - - /* take the payload of the caps */ - GST_LOG_OBJECT (this, "reading GDP caps from adapter"); - payload = gst_adapter_take (this->adapter, this->payload_length); - caps = gst_dp_caps_from_packet (GST_DP_HEADER_LENGTH, this->header, - payload); - g_free (payload); - if (!caps) - goto caps_failed; - - GST_DEBUG_OBJECT (this, "deserialized caps %" GST_PTR_FORMAT, caps); - gst_caps_replace (&(this->caps), caps); - gst_pad_set_caps (this->srcpad, caps); - /* drop the creation ref we still have */ - gst_caps_unref (caps); - - GST_LOG_OBJECT (this, "switching to state HEADER"); - this->state = GST_GDP_DEPAY_STATE_HEADER; - break; - } - case GST_GDP_DEPAY_STATE_EVENT: - { - guint8 *payload; - - GST_LOG_OBJECT (this, "reading GDP event from adapter"); - - /* adapter doesn't like 0 length payload */ - if (this->payload_length > 0) - payload = gst_adapter_take (this->adapter, this->payload_length); - else - payload = NULL; - event = gst_dp_event_from_packet (GST_DP_HEADER_LENGTH, this->header, - payload); - g_free (payload); - if (!event) - goto event_failed; - - GST_DEBUG_OBJECT (this, "deserialized event %p of type %s, pushing", - event, gst_event_type_get_name (event->type)); - gst_pad_push_event (this->srcpad, event); - - GST_LOG_OBJECT (this, "switching to state HEADER"); - this->state = GST_GDP_DEPAY_STATE_HEADER; - break; - } - } - } - -done: - return ret; - - /* ERRORS */ -header_validate_error: - { - GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL), - ("GDP packet header does not validate")); - ret = GST_FLOW_ERROR; - goto done; - } -payload_validate_error: - { - GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL), - ("GDP packet payload does not validate")); - ret = GST_FLOW_ERROR; - goto done; - } -wrong_type: - { - GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL), - ("GDP packet header is of wrong type")); - ret = GST_FLOW_ERROR; - goto done; - } -no_caps: - { - GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL), - ("Received a buffer without first receiving caps")); - ret = GST_FLOW_NOT_NEGOTIATED; - goto done; - } -buffer_failed: - { - GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL), - ("could not create buffer from GDP packet")); - ret = GST_FLOW_ERROR; - goto done; - } -push_error: - { - GST_WARNING_OBJECT (this, "pushing depayloaded buffer returned %d", ret); - goto done; - } -caps_failed: - { - GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL), - ("could not create caps from GDP packet")); - ret = GST_FLOW_ERROR; - goto done; - } -event_failed: - { - GST_ELEMENT_ERROR (this, STREAM, DECODE, (NULL), - ("could not create event from GDP packet")); - ret = GST_FLOW_ERROR; - goto done; - } -} - -static GstStateChangeReturn -gst_gdp_depay_change_state (GstElement * element, GstStateChange transition) -{ - GstStateChangeReturn ret; - GstGDPDepay *this = GST_GDP_DEPAY (element); - - ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); - - switch (transition) { - case GST_STATE_CHANGE_PAUSED_TO_READY: - if (this->caps) { - gst_caps_unref (this->caps); - this->caps = NULL; - } - gst_adapter_clear (this->adapter); - break; - default: - break; - } - return ret; -} - -gboolean -gst_gdp_depay_plugin_init (GstPlugin * plugin) -{ - if (!gst_element_register (plugin, "gdpdepay", GST_RANK_NONE, - GST_TYPE_GDP_DEPAY)) - return FALSE; - - return TRUE; -} diff --git a/gst/gdp/gstgdpdepay.h b/gst/gdp/gstgdpdepay.h deleted file mode 100644 index 64b7db2..0000000 --- a/gst/gdp/gstgdpdepay.h +++ /dev/null @@ -1,82 +0,0 @@ -/* GStreamer - * Copyright (C) 2006 Thomas Vander Stichele - * - * 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_GDP_DEPAY_H__ -#define __GST_GDP_DEPAY_H__ - -#include -#include - -G_BEGIN_DECLS - -#define GST_TYPE_GDP_DEPAY \ - (gst_gdp_depay_get_type()) -#define GST_GDP_DEPAY(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GDP_DEPAY,GstGDPDepay)) -#define GST_GDP_DEPAY_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GDP_DEPAY,GstGDPDepayClass)) -#define GST_IS_GDP_DEPAY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GDP_DEPAY)) -#define GST_IS_GDP_DEPAY_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GDP_DEPAY)) - -typedef enum { - GST_GDP_DEPAY_STATE_HEADER = 0, - GST_GDP_DEPAY_STATE_PAYLOAD, - GST_GDP_DEPAY_STATE_BUFFER, - GST_GDP_DEPAY_STATE_CAPS, - GST_GDP_DEPAY_STATE_EVENT, -} GstGDPDepayState; - - -typedef struct _GstGDPDepay GstGDPDepay; -typedef struct _GstGDPDepayClass GstGDPDepayClass; - -/** - * GstGDPDepay: - * - * Private gdpdepay element structure. - */ -struct _GstGDPDepay -{ - GstElement element; - GstPad *sinkpad; - GstPad *srcpad; - - GstAdapter *adapter; - GstGDPDepayState state; - GstCaps *caps; - - guint8 *header; - guint32 payload_length; - GstDPPayloadType payload_type; -}; - -struct _GstGDPDepayClass -{ - GstElementClass parent_class; -}; - -gboolean gst_gdp_depay_plugin_init (GstPlugin * plugin); - -GType gst_gdp_depay_get_type (void); - -G_END_DECLS - -#endif /* __GST_GDP_DEPAY_H__ */ diff --git a/gst/gdp/gstgdppay.c b/gst/gdp/gstgdppay.c deleted file mode 100644 index d26c0a3..0000000 --- a/gst/gdp/gstgdppay.c +++ /dev/null @@ -1,864 +0,0 @@ -/* GStreamer - * Copyright (C) 2006 Thomas Vander Stichele - * - * 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-gdppay - * @see_also: gdpdepay - * - * This element payloads GStreamer buffers and events using the - * GStreamer Data Protocol. - * - * - * |[ - * gst-launch -v -m videotestsrc num-buffers=50 ! gdppay ! filesink location=test.gdp - * ]| This pipeline creates a serialized video stream that can be played back - * with the example shown in gdpdepay. - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "dataprotocol.h" - -#include "gstgdppay.h" - -static GstStaticPadTemplate gdp_pay_sink_template = -GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY); - -static GstStaticPadTemplate gdp_pay_src_template = -GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("application/x-gdp")); - -GST_DEBUG_CATEGORY_STATIC (gst_gdp_pay_debug); -#define GST_CAT_DEFAULT gst_gdp_pay_debug - -#define DEFAULT_CRC_HEADER TRUE -#define DEFAULT_CRC_PAYLOAD FALSE -#define DEFAULT_VERSION GST_DP_VERSION_1_0 - -enum -{ - PROP_0, - PROP_CRC_HEADER, - PROP_CRC_PAYLOAD, - PROP_VERSION, -}; - -#define _do_init \ - GST_DEBUG_CATEGORY_INIT (gst_gdp_pay_debug, "gdppay", 0, \ - "GDP payloader"); -#define gst_gdp_pay_parent_class parent_class -G_DEFINE_TYPE_WITH_CODE (GstGDPPay, gst_gdp_pay, GST_TYPE_ELEMENT, _do_init); - -static void gst_gdp_pay_reset (GstGDPPay * this); - -static GstFlowReturn gst_gdp_pay_chain (GstPad * pad, GstObject * parent, - GstBuffer * buffer); -static gboolean gst_gdp_pay_src_event (GstPad * pad, GstObject * parent, - GstEvent * event); -static gboolean gst_gdp_pay_sink_event (GstPad * pad, GstObject * parent, - GstEvent * event); - -static GstStateChangeReturn gst_gdp_pay_change_state (GstElement * - element, GstStateChange transition); - -static void gst_gdp_pay_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec); -static void gst_gdp_pay_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec); - -static void gst_gdp_pay_finalize (GObject * gobject); - -static void -gst_gdp_pay_class_init (GstGDPPayClass * klass) -{ - GObjectClass *gobject_class; - GstElementClass *gstelement_class; - - gobject_class = (GObjectClass *) klass; - gstelement_class = (GstElementClass *) klass; - - gobject_class->set_property = gst_gdp_pay_set_property; - gobject_class->get_property = gst_gdp_pay_get_property; - gobject_class->finalize = gst_gdp_pay_finalize; - - g_object_class_install_property (gobject_class, PROP_CRC_HEADER, - g_param_spec_boolean ("crc-header", "CRC Header", - "Calculate and store a CRC checksum on the header", - DEFAULT_CRC_HEADER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (gobject_class, PROP_CRC_PAYLOAD, - g_param_spec_boolean ("crc-payload", "CRC Payload", - "Calculate and store a CRC checksum on the payload", - DEFAULT_CRC_PAYLOAD, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (gobject_class, PROP_VERSION, - g_param_spec_enum ("version", "Version", - "Version of the GStreamer Data Protocol", - GST_TYPE_DP_VERSION, DEFAULT_VERSION, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - gst_element_class_set_static_metadata (gstelement_class, - "GDP Payloader", "GDP/Payloader", - "Payloads GStreamer Data Protocol buffers", - "Thomas Vander Stichele "); - - gst_element_class_add_pad_template (gstelement_class, - gst_static_pad_template_get (&gdp_pay_sink_template)); - gst_element_class_add_pad_template (gstelement_class, - gst_static_pad_template_get (&gdp_pay_src_template)); - - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_gdp_pay_change_state); -} - -static void -gst_gdp_pay_init (GstGDPPay * gdppay) -{ - gdppay->sinkpad = - gst_pad_new_from_static_template (&gdp_pay_sink_template, "sink"); - gst_pad_set_chain_function (gdppay->sinkpad, - GST_DEBUG_FUNCPTR (gst_gdp_pay_chain)); - gst_pad_set_event_function (gdppay->sinkpad, - GST_DEBUG_FUNCPTR (gst_gdp_pay_sink_event)); - gst_element_add_pad (GST_ELEMENT (gdppay), gdppay->sinkpad); - - gdppay->srcpad = - gst_pad_new_from_static_template (&gdp_pay_src_template, "src"); - gst_pad_set_event_function (gdppay->srcpad, - GST_DEBUG_FUNCPTR (gst_gdp_pay_src_event)); - gst_element_add_pad (GST_ELEMENT (gdppay), gdppay->srcpad); - - gdppay->crc_header = DEFAULT_CRC_HEADER; - gdppay->crc_payload = DEFAULT_CRC_PAYLOAD; - gdppay->header_flag = gdppay->crc_header | gdppay->crc_payload; - gdppay->version = DEFAULT_VERSION; - gdppay->offset = 0; - - gdppay->packetizer = gst_dp_packetizer_new (gdppay->version); -} - -static void -gst_gdp_pay_finalize (GObject * gobject) -{ - GstGDPPay *this = GST_GDP_PAY (gobject); - - gst_gdp_pay_reset (this); - gst_dp_packetizer_free (this->packetizer); - - GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (gobject)); -} - -static void -gst_gdp_pay_reset (GstGDPPay * this) -{ - GST_DEBUG_OBJECT (this, "Resetting GDP object"); - /* clear the queued buffers */ - while (this->queue) { - GstBuffer *buffer; - - buffer = GST_BUFFER_CAST (this->queue->data); - - /* delete buffer from queue now */ - this->queue = g_list_delete_link (this->queue, this->queue); - - gst_buffer_unref (buffer); - } - if (this->caps) { - gst_caps_unref (this->caps); - this->caps = NULL; - } - if (this->caps_buf) { - gst_buffer_unref (this->caps_buf); - this->caps_buf = NULL; - } - if (this->tag_buf) { - gst_buffer_unref (this->tag_buf); - this->tag_buf = NULL; - } - if (this->new_segment_buf) { - gst_buffer_unref (this->new_segment_buf); - this->new_segment_buf = NULL; - } - this->sent_streamheader = FALSE; - this->offset = 0; -} - -/* set OFFSET and OFFSET_END with running count */ -static void -gst_gdp_stamp_buffer (GstGDPPay * this, GstBuffer * buffer) -{ - GST_BUFFER_OFFSET (buffer) = this->offset; - GST_BUFFER_OFFSET_END (buffer) = this->offset + gst_buffer_get_size (buffer); - this->offset = GST_BUFFER_OFFSET_END (buffer); -} - -static GstBuffer * -gst_gdp_buffer_from_caps (GstGDPPay * this, GstCaps * caps) -{ - GstBuffer *headerbuf; - GstBuffer *payloadbuf; - guint8 *header, *payload; - guint len, plen; - - if (!this->packetizer->packet_from_caps (caps, this->header_flag, &len, - &header, &payload)) - goto packet_failed; - - GST_LOG_OBJECT (this, "creating GDP header and payload buffer from caps"); - headerbuf = gst_buffer_new_wrapped (header, len); - - plen = gst_dp_header_payload_length (header); - payloadbuf = gst_buffer_new_wrapped (payload, plen); - - return gst_buffer_append (headerbuf, payloadbuf); - - /* ERRORS */ -packet_failed: - { - GST_WARNING_OBJECT (this, "could not create GDP header from caps"); - return NULL; - } -} - -static GstBuffer * -gst_gdp_pay_buffer_from_buffer (GstGDPPay * this, GstBuffer * buffer) -{ - GstBuffer *headerbuf; - guint8 *header; - guint len; - - if (!this->packetizer->header_from_buffer (buffer, this->header_flag, &len, - &header)) - goto no_buffer; - - GST_LOG_OBJECT (this, "creating GDP header and payload buffer from buffer"); - headerbuf = gst_buffer_new_wrapped (header, len); - - /* we do not want to lose the ref on the incoming buffer */ - gst_buffer_ref (buffer); - - return gst_buffer_append (headerbuf, buffer); - - /* ERRORS */ -no_buffer: - { - GST_WARNING_OBJECT (this, "could not create GDP header from buffer"); - return NULL; - } -} - -static GstBuffer * -gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event) -{ - GstBuffer *headerbuf; - GstBuffer *payloadbuf; - guint8 *header, *payload; - guint len, plen; - gboolean ret; - - ret = - this->packetizer->packet_from_event (event, this->header_flag, &len, - &header, &payload); - if (!ret) - goto no_event; - - GST_LOG_OBJECT (this, "creating GDP header and payload buffer from event"); - headerbuf = gst_buffer_new_wrapped (header, len); - - payloadbuf = gst_buffer_new (); - plen = gst_dp_header_payload_length (header); - if (plen && payload != NULL) { - gst_buffer_append_memory (payloadbuf, - gst_memory_new_wrapped (0, payload, plen, 0, plen, payload, g_free)); - } - - return gst_buffer_append (headerbuf, payloadbuf); - - /* ERRORS */ -no_event: - { - GST_WARNING_OBJECT (this, "could not create GDP header from event %s (%d)", - gst_event_type_get_name (event->type), event->type); - return NULL; - } -} - - -/* set our caps with streamheader, based on the latest newsegment and caps, - * and (possibly) GDP-serialized buffers of the streamheaders on the src pad */ -static GstFlowReturn -gst_gdp_pay_reset_streamheader (GstGDPPay * this) -{ - GstCaps *caps; - /* We use copies of these to avoid circular refcounts */ - GstBuffer *new_segment_buf, *caps_buf, *tag_buf; - GstStructure *structure; - GstFlowReturn r = GST_FLOW_OK; - gboolean version_one_zero = TRUE; - - GValue array = { 0 }; - GValue value = { 0 }; - - GST_DEBUG_OBJECT (this, "start"); - /* In version 0.2, we didn't need or send new segment or tags */ - if (this->version == GST_DP_VERSION_0_2) - version_one_zero = FALSE; - - if (version_one_zero) { - if (!this->new_segment_buf || !this->caps_buf) { - GST_DEBUG_OBJECT (this, "1.0, missing new_segment or caps, returning"); - return GST_FLOW_OK; - } - } else { - if (!this->caps_buf) { - GST_DEBUG_OBJECT (this, "0.2, missing caps, returning"); - return GST_FLOW_OK; - } - } - - /* put copies of the buffers in a fixed list - * Stamp the buffers with offset and offset_end as well. - * We do this here so the offsets match the order the buffers go out in */ - g_value_init (&array, GST_TYPE_ARRAY); - - if (version_one_zero) { - gst_gdp_stamp_buffer (this, this->new_segment_buf); - GST_DEBUG_OBJECT (this, "1.0, appending copy of new segment buffer %p", - this->new_segment_buf); - new_segment_buf = gst_buffer_copy (this->new_segment_buf); - g_value_init (&value, GST_TYPE_BUFFER); - gst_value_set_buffer (&value, new_segment_buf); - gst_value_array_append_value (&array, &value); - g_value_unset (&value); - gst_buffer_unref (new_segment_buf); - - if (this->tag_buf) { - gst_gdp_stamp_buffer (this, this->tag_buf); - GST_DEBUG_OBJECT (this, "1.0, appending current tags buffer %p", - this->tag_buf); - tag_buf = this->tag_buf; - this->tag_buf = NULL; - - g_value_init (&value, GST_TYPE_BUFFER); - gst_value_set_buffer (&value, tag_buf); - gst_value_array_append_value (&array, &value); - g_value_unset (&value); - gst_buffer_unref (tag_buf); - } - } - - gst_gdp_stamp_buffer (this, this->caps_buf); - GST_DEBUG_OBJECT (this, "appending copy of caps buffer %p", this->caps_buf); - caps_buf = gst_buffer_copy (this->caps_buf); - g_value_init (&value, GST_TYPE_BUFFER); - gst_value_set_buffer (&value, caps_buf); - gst_value_array_append_value (&array, &value); - g_value_unset (&value); - gst_buffer_unref (caps_buf); - - /* we also need to add GDP serializations of the streamheaders of the - * incoming caps */ - structure = gst_caps_get_structure (this->caps, 0); - if (gst_structure_has_field (structure, "streamheader")) { - const GValue *sh; - - GArray *buffers; - - GstBuffer *buffer; - - int i; - - sh = gst_structure_get_value (structure, "streamheader"); - buffers = g_value_peek_pointer (sh); - GST_DEBUG_OBJECT (this, - "Need to serialize %d incoming streamheader buffers on ours", - buffers->len); - for (i = 0; i < buffers->len; ++i) { - GValue *bufval; - - GstBuffer *outbuffer; - - bufval = &g_array_index (buffers, GValue, i); - buffer = g_value_peek_pointer (bufval); - /* this buffer is deserialized by gdpdepay as a regular buffer, - it needs HEADER, because it's a streamheader - otherwise it - is mixed with regular data buffers */ - GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_HEADER); - GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE; - GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE; - GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE; - - outbuffer = gst_gdp_pay_buffer_from_buffer (this, buffer); - if (!outbuffer) { - g_value_unset (&array); - goto no_buffer; - } - - /* Setting HEADER as other GDP event buffers */ - GST_DEBUG_OBJECT (this, - "Setting HEADER flag on outgoing buffer %" GST_PTR_FORMAT, outbuffer); - GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_HEADER); - GST_BUFFER_OFFSET (outbuffer) = GST_BUFFER_OFFSET_NONE; - GST_BUFFER_OFFSET_END (outbuffer) = GST_BUFFER_OFFSET_NONE; - GST_BUFFER_TIMESTAMP (outbuffer) = GST_CLOCK_TIME_NONE; - - g_value_init (&value, GST_TYPE_BUFFER); - gst_value_set_buffer (&value, outbuffer); - gst_value_array_append_value (&array, &value); - g_value_unset (&value); - - gst_buffer_unref (outbuffer); - } - } else { - GST_DEBUG_OBJECT (this, "no streamheader to serialize"); - } - - GST_DEBUG_OBJECT (this, "%d serialized buffers on streamheaders", - gst_value_array_get_size (&array)); - caps = gst_caps_from_string ("application/x-gdp"); - structure = gst_caps_get_structure (caps, 0); - - gst_structure_set_value (structure, "streamheader", &array); - g_value_unset (&array); - - GST_DEBUG_OBJECT (this, "Setting caps on src pad %" GST_PTR_FORMAT, caps); - gst_pad_set_caps (this->srcpad, caps); - - /* if these are our first ever buffers, send out new_segment first */ - if (!this->sent_streamheader) { - GstEvent *event; - GstSegment segment; - - gst_segment_init (&segment, GST_FORMAT_BYTES); - event = gst_event_new_segment (&segment); - - GST_DEBUG_OBJECT (this, "Sending out new_segment event %p", event); - if (!gst_pad_push_event (this->srcpad, event)) { - GST_WARNING_OBJECT (this, "pushing new segment failed"); - r = GST_FLOW_ERROR; - goto done; - } - } - - /* push out these streamheader buffers, then flush our internal queue */ - GST_DEBUG_OBJECT (this, "Pushing GDP new_segment buffer %p with offset %" - G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT, this->new_segment_buf, - GST_BUFFER_OFFSET (this->new_segment_buf), - GST_BUFFER_OFFSET_END (this->new_segment_buf)); - /* we stored these bufs with refcount 1, so make sure we keep a ref */ - r = gst_pad_push (this->srcpad, gst_buffer_ref (this->new_segment_buf)); - if (r != GST_FLOW_OK) { - GST_WARNING_OBJECT (this, "pushing GDP newsegment buffer returned %d", r); - goto done; - } - if (this->tag_buf) { - GST_DEBUG_OBJECT (this, "Pushing GDP tag buffer %p", this->tag_buf); - /* we stored these bufs with refcount 1, so make sure we keep a ref */ - r = gst_pad_push (this->srcpad, gst_buffer_ref (this->tag_buf)); - if (r != GST_FLOW_OK) { - GST_WARNING_OBJECT (this, "pushing GDP tag buffer returned %d", r); - goto done; - } - } - GST_DEBUG_OBJECT (this, "Pushing GDP caps buffer %p", this->caps_buf); - r = gst_pad_push (this->srcpad, gst_buffer_ref (this->caps_buf)); - if (r != GST_FLOW_OK) { - GST_WARNING_OBJECT (this, "pushing GDP caps buffer returned %d", r); - goto done; - } - this->sent_streamheader = TRUE; - GST_DEBUG_OBJECT (this, "need to push %d queued buffers", - g_list_length (this->queue)); - while (this->queue) { - GstBuffer *buffer; - - buffer = GST_BUFFER_CAST (this->queue->data); - GST_DEBUG_OBJECT (this, "Pushing queued GDP buffer %p", buffer); - - /* delete buffer from queue now */ - this->queue = g_list_delete_link (this->queue, this->queue); - - /* set caps and push */ - r = gst_pad_push (this->srcpad, buffer); - if (r != GST_FLOW_OK) { - GST_WARNING_OBJECT (this, "pushing queued GDP buffer returned %d", r); - goto done; - } - } - -done: - gst_caps_unref (caps); - GST_DEBUG_OBJECT (this, "stop"); - return r; - - /* ERRORS */ -no_buffer: - { - GST_ELEMENT_ERROR (this, STREAM, FORMAT, (NULL), - ("failed to create GDP buffer from streamheader")); - return GST_FLOW_ERROR; - } -} - -/* queue a buffer internally if we haven't sent streamheader buffers yet; - * otherwise, just push on, this takes ownership of the buffer. */ -static GstFlowReturn -gst_gdp_queue_buffer (GstGDPPay * this, GstBuffer * buffer) -{ - if (this->sent_streamheader) { - GST_LOG_OBJECT (this, "Pushing GDP buffer %p, caps %" GST_PTR_FORMAT, - buffer, this->caps); - return gst_pad_push (this->srcpad, buffer); - } - - /* store it on an internal queue. buffer remains reffed. */ - this->queue = g_list_append (this->queue, buffer); - GST_DEBUG_OBJECT (this, "streamheader not sent yet, " - "queued buffer %p, now %d buffers queued", - buffer, g_list_length (this->queue)); - - gst_gdp_pay_reset_streamheader (this); - - return GST_FLOW_OK; -} - -static GstFlowReturn -gst_gdp_pay_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) -{ - GstGDPPay *this; -#if 0 - GstCaps *caps; -#endif - GstBuffer *outbuffer; - GstFlowReturn ret; - - this = GST_GDP_PAY (parent); - - /* we should have received a new_segment before, otherwise it's a bug. - * fake one in that case */ - if (!this->new_segment_buf) { - GstEvent *event; - GstSegment segment; - - GST_WARNING_OBJECT (this, - "did not receive new-segment before first buffer"); - gst_segment_init (&segment, GST_FORMAT_BYTES); - event = gst_event_new_segment (&segment); - outbuffer = gst_gdp_buffer_from_event (this, event); - gst_event_unref (event); - - /* GDP 0.2 doesn't know about new-segment, so this is not fatal */ - if (!outbuffer) { - GST_ELEMENT_WARNING (this, STREAM, ENCODE, (NULL), - ("Could not create GDP buffer from new segment event")); - } else { - GST_BUFFER_TIMESTAMP (outbuffer) = GST_BUFFER_TIMESTAMP (buffer); - GST_BUFFER_DURATION (outbuffer) = 0; - GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_HEADER); - GST_DEBUG_OBJECT (this, "Storing buffer %p as new_segment_buf", - outbuffer); - this->new_segment_buf = outbuffer; - } - } - /* make sure we've received caps before */ - if (!this->caps) - goto no_caps; - - /* create a GDP header packet, - * then create a GST buffer of the header packet and the buffer contents */ - outbuffer = gst_gdp_pay_buffer_from_buffer (this, buffer); - if (!outbuffer) - goto no_buffer; - - /* If the incoming buffer is HEADER, that means we have it on the caps - * as streamheader, and we have serialized a GDP version of it and put it - * on our caps */ - if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_HEADER)) { - GST_DEBUG_OBJECT (this, "Setting HEADER flag on outgoing buffer %p", - outbuffer); - GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_HEADER); - } - - gst_gdp_stamp_buffer (this, outbuffer); - GST_BUFFER_TIMESTAMP (outbuffer) = GST_BUFFER_TIMESTAMP (buffer); - GST_BUFFER_DURATION (outbuffer) = GST_BUFFER_DURATION (buffer); - - ret = gst_gdp_queue_buffer (this, outbuffer); - -done: - gst_buffer_unref (buffer); - - return ret; - - /* ERRORS */ -no_caps: - { - /* when returning a fatal error as a GstFlowReturn we must post an error - * message */ - GST_ELEMENT_ERROR (this, STREAM, FORMAT, (NULL), - ("first received buffer does not have caps set")); - ret = GST_FLOW_NOT_NEGOTIATED; - goto done; - } -#if 0 -no_caps_buffer: - { - GST_ELEMENT_ERROR (this, STREAM, ENCODE, (NULL), - ("Could not create GDP buffer from caps %" GST_PTR_FORMAT, caps)); - gst_caps_unref (caps); - ret = GST_FLOW_ERROR; - goto done; - } -#endif -no_buffer: - { - GST_ELEMENT_ERROR (this, STREAM, ENCODE, (NULL), - ("Could not create GDP buffer from buffer")); - ret = GST_FLOW_ERROR; - goto done; - } -} - -static gboolean -gst_gdp_pay_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) -{ - GstBuffer *outbuffer; - GstGDPPay *this = GST_GDP_PAY (parent); - GstFlowReturn flowret; - GstCaps *caps; - gboolean ret = TRUE; - - GST_DEBUG_OBJECT (this, "received event %p of type %s (%d)", - event, gst_event_type_get_name (event->type), event->type); - - /* now turn the event into a buffer */ - outbuffer = gst_gdp_buffer_from_event (this, event); - if (!outbuffer) - goto no_outbuffer; - - GST_BUFFER_TIMESTAMP (outbuffer) = GST_EVENT_TIMESTAMP (event); - GST_BUFFER_DURATION (outbuffer) = 0; - - /* if we got a new segment or tag event, we should put it on our streamheader, - * and not send it on */ - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_SEGMENT: - GST_DEBUG_OBJECT (this, "Storing in caps buffer %p as new_segment_buf", - outbuffer); - - if (this->new_segment_buf) - gst_buffer_unref (this->new_segment_buf); - this->new_segment_buf = outbuffer; - - GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_HEADER); - gst_gdp_pay_reset_streamheader (this); - break; - case GST_EVENT_CAPS:{ - gst_event_parse_caps (event, &caps); - if (this->caps == NULL || !gst_caps_is_equal (this->caps, caps)) { - GST_INFO_OBJECT (pad, "caps changed to %" GST_PTR_FORMAT, caps); - gst_buffer_replace (&outbuffer, NULL); - gst_caps_replace (&this->caps, caps); - outbuffer = gst_gdp_buffer_from_caps (this, caps); - if (outbuffer == NULL) - goto no_buffer_from_caps; - - GST_BUFFER_DURATION (outbuffer) = 0; - GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_HEADER); - if (this->caps_buf) - gst_buffer_unref (this->caps_buf); - this->caps_buf = outbuffer; - gst_gdp_pay_reset_streamheader (this); - } - break; - } - case GST_EVENT_TAG: - GST_DEBUG_OBJECT (this, "Storing in caps buffer %p as tag_buf", - outbuffer); - - if (this->tag_buf) - gst_buffer_unref (this->tag_buf); - this->tag_buf = outbuffer; - - GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_HEADER); - gst_gdp_pay_reset_streamheader (this); - break; - default: - GST_DEBUG_OBJECT (this, "queuing GDP buffer %p of event %p", outbuffer, - event); - flowret = gst_gdp_queue_buffer (this, outbuffer); - if (flowret != GST_FLOW_OK) - goto push_error; - break; - } - - /* if we have EOS, we should send on EOS ourselves */ - if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) { - GST_DEBUG_OBJECT (this, "Sending on EOS event %p", event); - /* ref, we unref later again */ - ret = gst_pad_push_event (this->srcpad, gst_event_ref (event)); - } - -done: - gst_event_unref (event); - - return ret; - - /* ERRORS */ -no_outbuffer: - { - GST_ELEMENT_WARNING (this, STREAM, ENCODE, (NULL), - ("Could not create GDP buffer from received event (type %s)", - gst_event_type_get_name (event->type))); - ret = FALSE; - goto done; - } -no_buffer_from_caps: - { - GST_ELEMENT_ERROR (this, STREAM, ENCODE, (NULL), - ("Could not create GDP buffer from caps %" GST_PTR_FORMAT, caps)); - ret = FALSE; - goto done; - } -push_error: - { - GST_WARNING_OBJECT (this, "queueing GDP event buffer returned %d", flowret); - ret = FALSE; - goto done; - } -} - -static gboolean -gst_gdp_pay_src_event (GstPad * pad, GstObject * parent, GstEvent * event) -{ - GstGDPPay *this; - gboolean res = TRUE; - - this = GST_GDP_PAY (parent); - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_SEEK: - /* we refuse seek for now. */ - gst_event_unref (event); - res = FALSE; - break; - case GST_EVENT_QOS: - case GST_EVENT_NAVIGATION: - default: - /* everything else is passed */ - res = gst_pad_push_event (this->sinkpad, event); - break; - } - - return res; -} - -static void -gst_gdp_pay_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) -{ - GstGDPPay *this; - - g_return_if_fail (GST_IS_GDP_PAY (object)); - this = GST_GDP_PAY (object); - - switch (prop_id) { - case PROP_CRC_HEADER: - this->crc_header = - g_value_get_boolean (value) ? GST_DP_HEADER_FLAG_CRC_HEADER : 0; - this->header_flag = this->crc_header | this->crc_payload; - break; - case PROP_CRC_PAYLOAD: - this->crc_payload = - g_value_get_boolean (value) ? GST_DP_HEADER_FLAG_CRC_PAYLOAD : 0; - this->header_flag = this->crc_header | this->crc_payload; - break; - case PROP_VERSION: - this->version = g_value_get_enum (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_gdp_pay_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) -{ - GstGDPPay *this; - - g_return_if_fail (GST_IS_GDP_PAY (object)); - this = GST_GDP_PAY (object); - - switch (prop_id) { - case PROP_CRC_HEADER: - g_value_set_boolean (value, this->crc_header); - break; - case PROP_CRC_PAYLOAD: - g_value_set_boolean (value, this->crc_payload); - break; - case PROP_VERSION: - g_value_set_enum (value, this->version); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static GstStateChangeReturn -gst_gdp_pay_change_state (GstElement * element, GstStateChange transition) -{ - GstStateChangeReturn ret; - GstGDPPay *this = GST_GDP_PAY (element); - - switch (transition) { - case GST_STATE_CHANGE_READY_TO_PAUSED: - break; - default: - break; - } - - ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); - - switch (transition) { - case GST_STATE_CHANGE_PAUSED_TO_READY: - gst_gdp_pay_reset (this); - break; - default: - break; - } - - return ret; -} - -gboolean -gst_gdp_pay_plugin_init (GstPlugin * plugin) -{ - if (!gst_element_register (plugin, "gdppay", GST_RANK_NONE, GST_TYPE_GDP_PAY)) - return FALSE; - - return TRUE; -} diff --git a/gst/gdp/gstgdppay.h b/gst/gdp/gstgdppay.h deleted file mode 100644 index 3e280b5..0000000 --- a/gst/gdp/gstgdppay.h +++ /dev/null @@ -1,81 +0,0 @@ -/* GStreamer - * Copyright (C) 2006 Thomas Vander Stichele - * - * 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_GDP_PAY_H__ -#define __GST_GDP_PAY_H__ - -#include - -G_BEGIN_DECLS - -#define GST_TYPE_GDP_PAY \ - (gst_gdp_pay_get_type()) -#define GST_GDP_PAY(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GDP_PAY,GstGDPPay)) -#define GST_GDP_PAY_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GDP_PAY,GstGDPPayClass)) -#define GST_IS_GDP_PAY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GDP_PAY)) -#define GST_IS_GDP_PAY_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GDP_PAY)) - -typedef struct _GstGDPPay GstGDPPay; -typedef struct _GstGDPPayClass GstGDPPayClass; - -/** - * GstGDPPay: - * - * Private gdppay element structure. - */ -struct _GstGDPPay -{ - GstElement element; - - GstPad *sinkpad; - GstPad *srcpad; - - GstCaps *caps; /* incoming caps */ - - GstBuffer *caps_buf; - GstBuffer *new_segment_buf; - GstBuffer *tag_buf; - - gboolean sent_streamheader; /* TRUE after the first streamheaders are sent */ - GList *queue; /* list of queued buffers before streamheaders are sent */ - guint64 offset; - - gboolean crc_header; - gboolean crc_payload; - GstDPHeaderFlag header_flag; - GstDPVersion version; - GstDPPacketizer *packetizer; -}; - -struct _GstGDPPayClass -{ - GstElementClass parent_class; -}; - -gboolean gst_gdp_pay_plugin_init (GstPlugin * plugin); - -GType gst_gdp_pay_get_type (void); - -G_END_DECLS - -#endif /* __GST_GDP_PAY_H__ */ diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index cd0a279..3d9c5a5 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -115,7 +115,6 @@ check_PROGRAMS = \ $(cxx_checks) \ $(check_orc) \ pipelines/simple-launch-lines \ - pipelines/streamheader \ pipelines/basetime \ pipelines/capsfilter-renegotiation \ pipelines/gio \ @@ -123,8 +122,6 @@ check_PROGRAMS = \ elements/appsrc \ elements/audiorate \ elements/audioresample \ - elements/gdpdepay \ - elements/gdppay \ elements/multifdsink \ elements/multisocketsink \ elements/playbin \ @@ -321,9 +318,6 @@ elements_audiorate_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS) elements_libvisual_LDADD = $(LDADD) elements_libvisual_CFLAGS = $(CFLAGS) $(AM_CFLAGS) -elements_gdpdepay_LDADD = $(LDADD) -elements_gdppay_LDADD = $(LDADD) - elements_playbin_LDADD = $(GST_BASE_LIBS) $(LDADD) elements_playbin_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS) @@ -425,9 +419,6 @@ elements_multisocketsink_LDADD = $(GIO_LIBS) $(LDADD) pipelines_gio_CFLAGS = $(GIO_CFLAGS) $(AM_CFLAGS) pipelines_gio_LDADD = $(GIO_LIBS) $(LDADD) -pipelines_streamheader_CFLAGS = $(GIO_CFLAGS) $(AM_CFLAGS) -pipelines_streamheader_LDADD = $(GIO_LIBS) $(LDADD) - pipelines_vorbisenc_CFLAGS = \ $(GST_PLUGINS_BASE_CFLAGS) \ $(AM_CFLAGS) diff --git a/tests/check/elements/.gitignore b/tests/check/elements/.gitignore index c021a26..21a671b 100644 --- a/tests/check/elements/.gitignore +++ b/tests/check/elements/.gitignore @@ -9,8 +9,6 @@ audioresample audiotestsrc decodebin encodebin -gdpdepay -gdppay libvisual multifdsink multisocketsink diff --git a/tests/check/elements/gdpdepay.c b/tests/check/elements/gdpdepay.c deleted file mode 100644 index 5ee6e5f..0000000 --- a/tests/check/elements/gdpdepay.c +++ /dev/null @@ -1,399 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2006 Thomas Vander Stichele - * - * 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. - */ - -#include "config.h" -#include -#include - -#include -#include -#include "../../gst/gdp/dataprotocol.c" - -/* For ease of programming we use globals to keep refs for our floating - * src and sink pads we create; otherwise we always have to do get_pad, - * get_peer, and then remove references in every test function */ -static GstPad *mysrcpad, *mysinkpad, *myshsinkpad; - -#define FORMATS "{ S8, "GST_AUDIO_NE(S16)" }" - -#define AUDIO_CAPS_TEMPLATE_STRING \ - "audio/x-raw, " \ - "format = (string) "FORMATS", " \ - "rate = (int) [ 1, MAX ], " \ - "channels = (int) [ 1, 8 ]" - -#define AUDIO_CAPS_STRING \ - "audio/x-raw, " \ - "format = (string) "GST_AUDIO_NE(S16)", " \ - "rate = (int) 1000, " \ - "channels = (int) 2" - -static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS (AUDIO_CAPS_TEMPLATE_STRING) - ); -static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("application/x-gdp") - ); - -/* takes over reference for outcaps */ -static GstElement * -setup_gdpdepay (void) -{ - GstElement *gdpdepay; - - GST_DEBUG ("setup_gdpdepay"); - gdpdepay = gst_check_setup_element ("gdpdepay"); - mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate); - mysinkpad = gst_check_setup_sink_pad (gdpdepay, &sinktemplate); - gst_pad_set_active (mysrcpad, TRUE); - gst_pad_set_active (mysinkpad, TRUE); - - return gdpdepay; -} - -static void -cleanup_gdpdepay (GstElement * gdpdepay) -{ - GST_DEBUG ("cleanup_gdpdepay"); - - gst_pad_set_active (mysrcpad, FALSE); - if (mysinkpad) - gst_pad_set_active (mysinkpad, FALSE); - if (myshsinkpad) - gst_pad_set_active (myshsinkpad, FALSE); - gst_check_teardown_src_pad (gdpdepay); - gst_check_teardown_sink_pad (gdpdepay); - gst_check_teardown_element (gdpdepay); - mysinkpad = NULL; - myshsinkpad = NULL; -} - -static void -gdpdepay_push_per_byte (const gchar * reason, const guint8 * bytes, - guint length) -{ - int i; - GstBuffer *inbuffer; - - for (i = 0; i < length; ++i) { - inbuffer = gst_buffer_new_and_alloc (1); - gst_buffer_fill (inbuffer, 0, &bytes[i], 1); - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK, - "%s: failed pushing byte buffer", reason); - } -} - -GST_START_TEST (test_audio_per_byte) -{ - GstCaps *caps; - GstPad *srcpad; - GstElement *gdpdepay; - GstBuffer *buffer, *outbuffer; - guint8 *header, *payload; - guint len; - GstDPPacketizer *pk; - - pk = gst_dp_packetizer_new (GST_DP_VERSION_1_0); - - gdpdepay = setup_gdpdepay (); - srcpad = gst_element_get_static_pad (gdpdepay, "src"); - - fail_unless (gst_element_set_state (gdpdepay, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - caps = gst_pad_query_caps (srcpad, NULL); - fail_unless (gst_caps_is_any (caps)); - gst_caps_unref (caps); - fail_if (gst_pad_get_current_caps (srcpad)); - - /* create caps and buffer packets and push them */ - caps = gst_caps_from_string (AUDIO_CAPS_STRING); - fail_unless (pk->packet_from_caps (caps, 0, &len, &header, &payload)); - gst_caps_unref (caps); - gdpdepay_push_per_byte ("caps header", header, len); - fail_unless_equals_int (g_list_length (buffers), 0); - gdpdepay_push_per_byte ("caps payload", payload, - gst_dp_header_payload_length (header)); - fail_unless_equals_int (g_list_length (buffers), 0); - caps = gst_pad_query_caps (srcpad, NULL); - fail_if (gst_caps_is_any (caps)); - gst_caps_unref (caps); - - g_free (header); - g_free (payload); - - buffer = gst_buffer_new_and_alloc (4); - gst_buffer_fill (buffer, 0, "f00d", 4); - GST_BUFFER_TIMESTAMP (buffer) = GST_SECOND; - GST_BUFFER_DURATION (buffer) = GST_SECOND / 10; - fail_unless (pk->header_from_buffer (buffer, 0, &len, &header)); - gdpdepay_push_per_byte ("buffer header", header, len); - fail_unless_equals_int (g_list_length (buffers), 0); - gdpdepay_push_per_byte ("buffer payload", (const guint8 *) "f00d", - gst_dp_header_payload_length (header)); - g_free (header); - gst_buffer_unref (buffer); - - fail_unless_equals_int (g_list_length (buffers), 1); - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (outbuffer), GST_SECOND); - fail_unless_equals_uint64 (GST_BUFFER_DURATION (outbuffer), GST_SECOND / 10); - - buffers = g_list_remove (buffers, outbuffer); - gst_buffer_unref (outbuffer); - - fail_unless (gst_element_set_state (gdpdepay, - GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); - - ASSERT_OBJECT_REFCOUNT (gdpdepay, "gdpdepay", 1); - g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); - g_list_free (buffers); - buffers = NULL; - gst_object_unref (srcpad); - cleanup_gdpdepay (gdpdepay); - - gst_dp_packetizer_free (pk); -} - -GST_END_TEST; - -GST_START_TEST (test_audio_in_one_buffer) -{ - GstCaps *caps; - GstPad *srcpad; - GstElement *gdpdepay; - GstBuffer *buffer, *inbuffer; - guint8 *caps_header, *caps_payload, *buf_header; - guint header_len, payload_len; - guint i; - GstDPPacketizer *pk; - - pk = gst_dp_packetizer_new (GST_DP_VERSION_1_0); - - gdpdepay = setup_gdpdepay (); - srcpad = gst_element_get_static_pad (gdpdepay, "src"); - - fail_unless (gst_element_set_state (gdpdepay, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - /* make sure no caps are set yet */ - caps = gst_pad_query_caps (srcpad, NULL); - fail_unless (gst_caps_is_any (caps)); - gst_caps_unref (caps); - fail_if (gst_pad_get_current_caps (srcpad)); - - /* create caps and buffer packets and push them as one buffer */ - caps = gst_caps_from_string (AUDIO_CAPS_STRING); - fail_unless (pk->packet_from_caps (caps, 0, &header_len, &caps_header, - &caps_payload)); - - buffer = gst_buffer_new_and_alloc (4); - gst_buffer_fill (buffer, 0, "f00d", 4); - fail_unless (pk->header_from_buffer (buffer, 0, &header_len, &buf_header)); - - payload_len = gst_dp_header_payload_length (caps_header); - - inbuffer = gst_buffer_new_and_alloc (2 * GST_DP_HEADER_LENGTH + - payload_len + gst_buffer_get_size (buffer)); - gst_buffer_fill (inbuffer, 0, caps_header, GST_DP_HEADER_LENGTH); - i = GST_DP_HEADER_LENGTH; - gst_buffer_fill (inbuffer, i, caps_payload, payload_len); - i += payload_len; - gst_buffer_fill (inbuffer, i, buf_header, GST_DP_HEADER_LENGTH); - i += GST_DP_HEADER_LENGTH; - gst_buffer_fill (inbuffer, i, "f00d", 4); - - gst_caps_unref (caps); - gst_buffer_unref (buffer); - - g_free (caps_header); - g_free (caps_payload); - g_free (buf_header); - - /* now push it */ - gst_pad_push (mysrcpad, inbuffer); - - /* the buffer is still queued */ - fail_unless_equals_int (g_list_length (buffers), 1); - - fail_unless (gst_element_set_state (gdpdepay, - GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); - - gst_object_unref (srcpad); - g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); - g_list_free (buffers); - buffers = NULL; - ASSERT_OBJECT_REFCOUNT (gdpdepay, "gdpdepay", 1); - cleanup_gdpdepay (gdpdepay); - - gst_dp_packetizer_free (pk); -} - -GST_END_TEST; - -static GstStaticPadTemplate shsinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("application/x-gst-test-streamheader") - ); - -static GstElement * -setup_gdpdepay_streamheader (void) -{ - GstElement *gdpdepay; - - GST_DEBUG ("setup_gdpdepay"); - gdpdepay = gst_check_setup_element ("gdpdepay"); - mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate); - myshsinkpad = gst_check_setup_sink_pad (gdpdepay, &shsinktemplate); - gst_pad_set_active (mysrcpad, TRUE); - gst_pad_set_active (myshsinkpad, TRUE); - - return gdpdepay; -} - -/* this tests deserialization of a GDP stream where the serialized caps - * have a streamheader set */ -GST_START_TEST (test_streamheader) -{ - GstCaps *caps; - GstPad *srcpad; - GstElement *gdpdepay; - GstBuffer *buffer, *inbuffer, *outbuffer, *shbuffer; - guint8 *caps_header, *caps_payload, *buf_header; - GstMapInfo map; - guint header_len, payload_len; - guint i; - GstStructure *structure; - GValue array = { 0 }; - GValue value = { 0 }; - GstDPPacketizer *pk; - - pk = gst_dp_packetizer_new (GST_DP_VERSION_1_0); - - gdpdepay = setup_gdpdepay_streamheader (); - srcpad = gst_element_get_static_pad (gdpdepay, "src"); - ASSERT_OBJECT_REFCOUNT (gdpdepay, "gdpdepay", 1); - - fail_unless (gst_element_set_state (gdpdepay, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - /* make sure no caps are set yet */ - caps = gst_pad_query_caps (srcpad, NULL); - fail_unless (gst_caps_is_any (caps)); - gst_caps_unref (caps); - fail_if (gst_pad_get_current_caps (srcpad)); - - /* create a streamheader buffer and the caps containing it */ - caps = gst_caps_from_string ("application/x-gst-test-streamheader"); - structure = gst_caps_get_structure (caps, 0); - buffer = gst_buffer_new_and_alloc (4); - gst_buffer_fill (buffer, 0, "f00d", 4); - GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_HEADER); - g_value_init (&array, GST_TYPE_ARRAY); - g_value_init (&value, GST_TYPE_BUFFER); - shbuffer = gst_buffer_copy (buffer); - gst_value_set_buffer (&value, shbuffer); - gst_buffer_unref (shbuffer); - gst_value_array_append_value (&array, &value); - g_value_unset (&value); - gst_structure_set_value (structure, "streamheader", &array); - g_value_unset (&array); - - /* create GDP packets for the caps and the buffer, and put them in one - * GDP buffer */ - fail_unless (pk->packet_from_caps (caps, 0, &header_len, &caps_header, - &caps_payload)); - - fail_unless (pk->header_from_buffer (buffer, 0, &header_len, &buf_header)); - - payload_len = gst_dp_header_payload_length (caps_header); - - gst_buffer_map (buffer, &map, GST_MAP_READ); - inbuffer = gst_buffer_new_and_alloc (2 * GST_DP_HEADER_LENGTH + - payload_len + map.size); - gst_buffer_fill (inbuffer, 0, caps_header, GST_DP_HEADER_LENGTH); - i = GST_DP_HEADER_LENGTH; - gst_buffer_fill (inbuffer, i, caps_payload, payload_len); - i += payload_len; - gst_buffer_fill (inbuffer, i, buf_header, GST_DP_HEADER_LENGTH); - i += GST_DP_HEADER_LENGTH; - gst_buffer_fill (inbuffer, i, map.data, map.size); - gst_buffer_unmap (buffer, &map); - - gst_caps_unref (caps); - gst_buffer_unref (buffer); - - g_free (caps_header); - g_free (caps_payload); - g_free (buf_header); - - /* now push it */ - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - gst_pad_push (mysrcpad, inbuffer); - - /* our only output buffer is the streamheader buffer */ - fail_unless_equals_int (g_list_length (buffers), 1); - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - fail_unless (GST_BUFFER_FLAG_IS_SET (outbuffer, GST_BUFFER_FLAG_HEADER)); - - /* FIXME: get streamheader, compare data with buffer */ - gst_buffer_unref (outbuffer); - - /* clean up */ - fail_unless (gst_element_set_state (gdpdepay, - GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); - - gst_object_unref (srcpad); - g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); - g_list_free (buffers); - buffers = NULL; - ASSERT_OBJECT_REFCOUNT (gdpdepay, "gdpdepay", 1); - cleanup_gdpdepay (gdpdepay); - - gst_dp_packetizer_free (pk); -} - -GST_END_TEST; - -static Suite * -gdpdepay_suite (void) -{ - Suite *s = suite_create ("gdpdepay"); - TCase *tc_chain = tcase_create ("general"); - - suite_add_tcase (s, tc_chain); - tcase_add_test (tc_chain, test_audio_per_byte); - tcase_add_test (tc_chain, test_audio_in_one_buffer); - tcase_add_test (tc_chain, test_streamheader); - - return s; -} - -GST_CHECK_MAIN (gdpdepay); diff --git a/tests/check/elements/gdppay.c b/tests/check/elements/gdppay.c deleted file mode 100644 index 451a0c5..0000000 --- a/tests/check/elements/gdppay.c +++ /dev/null @@ -1,571 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2006 Thomas Vander Stichele - * - * 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. - */ - -#include "config.h" -#include -#include - -#include -#include -#include "../../gst/gdp/dataprotocol.c" - -/* For ease of programming we use globals to keep refs for our floating - * src and sink pads we create; otherwise we always have to do get_pad, - * get_peer, and then remove references in every test function */ -static GstPad *mysrcpad, *myshsrcpad, *mysinkpad; - -#define FORMATS "{ S8, "GST_AUDIO_NE(S16)" }" - -#define AUDIO_CAPS_TEMPLATE_STRING \ - "audio/x-raw, " \ - "format = (string) "FORMATS", " \ - "rate = (int) [ 1, MAX ], " \ - "channels = (int) [ 1, 8 ]" - -#define AUDIO_CAPS_STRING \ - "audio/x-raw, " \ - "format = (string) "GST_AUDIO_NE(S16)", " \ - "rate = (int) 1000, " \ - "channels = (int) 2" - - -static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("application/x-gdp") - ); -static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS (AUDIO_CAPS_TEMPLATE_STRING) - ); - -/* takes over reference for outcaps */ -static GstElement * -setup_gdppay (void) -{ - GstElement *gdppay; - - GST_DEBUG ("setup_gdppay"); - gdppay = gst_check_setup_element ("gdppay"); - mysrcpad = gst_check_setup_src_pad (gdppay, &srctemplate); - mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate); - gst_pad_set_active (mysrcpad, TRUE); - gst_pad_set_active (mysinkpad, TRUE); - - return gdppay; -} - -static void -cleanup_gdppay (GstElement * gdppay) -{ - GST_DEBUG ("cleanup_gdppay"); - - if (mysrcpad) - gst_pad_set_active (mysrcpad, FALSE); - if (myshsrcpad) - gst_pad_set_active (myshsrcpad, FALSE); - gst_pad_set_active (mysinkpad, FALSE); - gst_check_teardown_src_pad (gdppay); - gst_check_teardown_sink_pad (gdppay); - gst_check_teardown_element (gdppay); - mysrcpad = NULL; - myshsrcpad = NULL; -} - -GST_START_TEST (test_audio) -{ - GstCaps *caps; - GstElement *gdppay; - GstBuffer *inbuffer, *outbuffer; - GstSegment segment; - GstEvent *event; - gchar *caps_string; - gint length; - - gdppay = setup_gdppay (); - - fail_unless (gst_element_set_state (gdppay, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - GST_DEBUG ("new segment"); - gst_segment_init (&segment, GST_FORMAT_TIME); - segment.stop = GST_SECOND; - event = gst_event_new_segment (&segment); - fail_unless (gst_pad_push_event (mysrcpad, event)); - - /* no buffer should be pushed yet, waiting for caps */ - fail_unless_equals_int (g_list_length (buffers), 0); - - GST_DEBUG ("first buffer"); - inbuffer = gst_buffer_new_and_alloc (4); - caps = gst_caps_from_string (AUDIO_CAPS_STRING); - gst_pad_set_caps (mysrcpad, caps); - caps_string = gst_caps_to_string (caps); - - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - - /* we should have three buffers now */ - fail_unless_equals_int (g_list_length (buffers), 3); - - /* first buffer is the serialized new_segment event; - * the element also holds a ref to it */ - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2); - gst_buffer_unref (outbuffer); - - /* second buffer is the serialized caps; - * the element also holds a ref to it */ - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2); - length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1); - fail_unless_equals_int (gst_buffer_get_size (outbuffer), length); - gst_buffer_unref (outbuffer); - - /* the third buffer is the GDP buffer for our pushed buffer */ - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - length = GST_DP_HEADER_LENGTH + 4; - fail_unless_equals_int (gst_buffer_get_size (outbuffer), length); - gst_buffer_unref (outbuffer); - - /* second buffer */ - GST_DEBUG ("second buffer"); - inbuffer = gst_buffer_new_and_alloc (4); - - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - - fail_unless_equals_int (g_list_length (buffers), 1); - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - - /* the third output buffer is data */ - length = GST_DP_HEADER_LENGTH + 4; - fail_unless_equals_int (gst_buffer_get_size (outbuffer), length); - gst_buffer_unref (outbuffer); - - /* a third buffer without caps set explicitly; should work */ - GST_DEBUG ("Creating third buffer, no caps set"); - inbuffer = gst_buffer_new_and_alloc (4); - - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - - fail_unless_equals_int (g_list_length (buffers), 1); - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - - /* the fourth output buffer is data */ - length = GST_DP_HEADER_LENGTH + 4; - fail_unless_equals_int (gst_buffer_get_size (outbuffer), length); - gst_buffer_unref (outbuffer); - - - fail_unless (gst_element_set_state (gdppay, - GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); - - gst_caps_unref (caps); - g_free (caps_string); - g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); - g_list_free (buffers); - buffers = NULL; - ASSERT_OBJECT_REFCOUNT (gdppay, "gdppay", 1); - cleanup_gdppay (gdppay); -} - -GST_END_TEST; - -static GstStaticPadTemplate shsrctemplate = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("application/x-gst-test-streamheader") - ); - - -static GstElement * -setup_gdppay_streamheader (void) -{ - GstElement *gdppay; - - GST_DEBUG ("setup_gdppay"); - gdppay = gst_check_setup_element ("gdppay"); - myshsrcpad = gst_check_setup_src_pad (gdppay, &shsrctemplate); - mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate); - gst_pad_set_active (myshsrcpad, TRUE); - gst_pad_set_active (mysinkpad, TRUE); - - return gdppay; -} - -/* this test serializes a stream that already has a streamheader of its own. - * the streamheader should then be serialized and put on the GDP stream's - * streamheader */ -GST_START_TEST (test_streamheader) -{ - GstCaps *caps, *sinkcaps; - GstElement *gdppay; - GstBuffer *inbuffer, *outbuffer, *shbuffer; - GstSegment segment; - GstEvent *event; - gchar *caps_string; - gint length; - GstStructure *structure; - GValue array = { 0 }; - GValue value = { 0 }; - const GValue *sh; - GArray *shbuffers; - - - gdppay = setup_gdppay_streamheader (); - - fail_unless (gst_element_set_state (gdppay, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - GST_DEBUG ("new segment"); - gst_segment_init (&segment, GST_FORMAT_TIME); - segment.stop = GST_SECOND; - event = gst_event_new_segment (&segment); - fail_unless (gst_pad_push_event (myshsrcpad, event)); - - /* no buffer should be pushed yet, still waiting for caps */ - fail_unless_equals_int (g_list_length (buffers), 0); - - GST_DEBUG ("first buffer"); - inbuffer = gst_buffer_new_and_alloc (4); - gst_buffer_fill (inbuffer, 0, "head", 4); - caps = gst_caps_from_string ("application/x-gst-test-streamheader"); - structure = gst_caps_get_structure (caps, 0); - GST_BUFFER_FLAG_SET (inbuffer, GST_BUFFER_FLAG_HEADER); - g_value_init (&array, GST_TYPE_ARRAY); - g_value_init (&value, GST_TYPE_BUFFER); - shbuffer = gst_buffer_copy (inbuffer); - gst_value_set_buffer (&value, shbuffer); - gst_buffer_unref (shbuffer); - gst_value_array_append_value (&array, &value); - g_value_unset (&value); - gst_structure_set_value (structure, "streamheader", &array); - g_value_unset (&array); - caps_string = gst_caps_to_string (caps); - - gst_pad_set_caps (myshsrcpad, caps); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference */ - fail_unless (gst_pad_push (myshsrcpad, inbuffer) == GST_FLOW_OK); - - /* we should have three buffers now */ - fail_unless_equals_int (g_list_length (buffers), 3); - - /* our sink pad should now have GDP caps with a streamheader that includes - * GDP wrappings of our streamheader */ - sinkcaps = gst_pad_get_current_caps (mysinkpad); - structure = gst_caps_get_structure (sinkcaps, 0); - fail_unless_equals_string ((gchar *) gst_structure_get_name (structure), - "application/x-gdp"); - fail_unless (gst_structure_has_field (structure, "streamheader")); - sh = gst_structure_get_value (structure, "streamheader"); - fail_unless (G_VALUE_TYPE (sh) == GST_TYPE_ARRAY); - shbuffers = g_value_peek_pointer (sh); - /* a serialized new_segment, a serialized caps, and serialization of our - * incoming streamheader */ - fail_unless_equals_int (shbuffers->len, 3); - - gst_caps_unref (sinkcaps); - - /* first buffer is the serialized new_segment event; - * the element also holds a ref to it */ - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2); - gst_buffer_unref (outbuffer); - - /* second buffer is the serialized caps; - * the element also holds a ref to it */ - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2); - length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1); - fail_unless_equals_int (gst_buffer_get_size (outbuffer), length); - gst_buffer_unref (outbuffer); - - /* the third buffer is the GDP buffer for our pushed buffer */ - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - length = GST_DP_HEADER_LENGTH + 4; - fail_unless_equals_int (gst_buffer_get_size (outbuffer), length); - gst_buffer_unref (outbuffer); - - /* second buffer */ - GST_DEBUG ("second buffer"); - inbuffer = gst_buffer_new_and_alloc (4); - - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference */ - fail_unless (gst_pad_push (myshsrcpad, inbuffer) == GST_FLOW_OK); - - fail_unless_equals_int (g_list_length (buffers), 1); - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - - /* the third output buffer is data */ - length = GST_DP_HEADER_LENGTH + 4; - fail_unless_equals_int (gst_buffer_get_size (outbuffer), length); - gst_buffer_unref (outbuffer); - - /* a third buffer without caps set explicitly; should work */ - GST_DEBUG ("Creating third buffer, no caps set"); - inbuffer = gst_buffer_new_and_alloc (4); - - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference */ - fail_unless (gst_pad_push (myshsrcpad, inbuffer) == GST_FLOW_OK); - - fail_unless_equals_int (g_list_length (buffers), 1); - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - - /* the fourth output buffer is data */ - length = GST_DP_HEADER_LENGTH + 4; - fail_unless_equals_int (gst_buffer_get_size (outbuffer), length); - gst_buffer_unref (outbuffer); - - - fail_unless (gst_element_set_state (gdppay, - GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); - - gst_caps_unref (caps); - g_free (caps_string); - g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); - g_list_free (buffers); - buffers = NULL; - ASSERT_OBJECT_REFCOUNT (gdppay, "gdppay", 1); - cleanup_gdppay (gdppay); -} - -GST_END_TEST; - - -GST_START_TEST (test_first_no_caps) -{ - GstElement *gdppay; - GstBuffer *inbuffer; - - gdppay = setup_gdppay (); - - fail_unless (gst_element_set_state (gdppay, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - GST_DEBUG ("first buffer"); - inbuffer = gst_buffer_new_and_alloc (4); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing should trigger an error */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_NOT_NEGOTIATED); - - fail_unless_equals_int (g_list_length (buffers), 0); - - fail_unless (gst_element_set_state (gdppay, - GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); - - g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); - g_list_free (buffers); - buffers = NULL; - ASSERT_OBJECT_REFCOUNT (gdppay, "gdppay", 1); - cleanup_gdppay (gdppay); -} - -GST_END_TEST; - -/* element should still work if no new_segment is sent before the first - * buffer */ -GST_START_TEST (test_first_no_new_segment) -{ - GstElement *gdppay; - GstBuffer *inbuffer; - GstCaps *caps; - - gdppay = setup_gdppay (); - - fail_unless (gst_element_set_state (gdppay, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - GST_DEBUG ("first buffer"); - inbuffer = gst_buffer_new_and_alloc (4); - caps = gst_caps_from_string (AUDIO_CAPS_STRING); - gst_pad_set_caps (mysrcpad, caps); - gst_caps_unref (caps); - - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - - /* we should have three buffers now; - * one for an "invented" new segment, one for GDP caps, and one with our - * buffer */ - fail_unless_equals_int (g_list_length (buffers), 3); - - fail_unless (gst_element_set_state (gdppay, - GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); - - g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); - g_list_free (buffers); - buffers = NULL; - ASSERT_OBJECT_REFCOUNT (gdppay, "gdppay", 1); - cleanup_gdppay (gdppay); -} - -GST_END_TEST; - -GST_START_TEST (test_crc) -{ - GstCaps *caps; - GstElement *gdppay; - GstBuffer *inbuffer, *outbuffer; - GstSegment segment; - GstEvent *event; - gchar *caps_string; - gint length; - GstMapInfo map; - guint16 crc_calculated, crc_read; - - gdppay = setup_gdppay (); - g_object_set (gdppay, "crc-header", TRUE, NULL); - - fail_unless (gst_element_set_state (gdppay, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - GST_DEBUG ("new segment"); - gst_segment_init (&segment, GST_FORMAT_TIME); - event = gst_event_new_segment (&segment); - fail_unless (gst_pad_push_event (mysrcpad, event)); - - /* no buffer should be pushed yet, waiting for caps */ - fail_unless_equals_int (g_list_length (buffers), 0); - - GST_DEBUG ("first buffer"); - inbuffer = gst_buffer_new_and_alloc (4); - caps = gst_caps_from_string (AUDIO_CAPS_STRING); - gst_pad_set_caps (mysrcpad, caps); - caps_string = gst_caps_to_string (caps); - - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - - /* we should have three buffers now */ - fail_unless_equals_int (g_list_length (buffers), 3); - - /* first buffer is the serialized new_segment event; - * the element also holds a ref to it */ - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2); - - /* verify the header checksum */ - /* CRC's start at 58 in the header */ - outbuffer = gst_buffer_make_writable (outbuffer); - gst_buffer_map (outbuffer, &map, GST_MAP_READWRITE); - crc_calculated = gst_dp_crc (map.data, 58); - crc_read = GST_READ_UINT16_BE (map.data + 58); - fail_unless_equals_int (crc_calculated, crc_read); - - /* change a byte in the header and verify that the checksum now fails */ - map.data[0] = 0xff; - crc_calculated = gst_dp_crc (map.data, 58); - fail_if (crc_calculated == crc_read, - "Introducing a byte error in the header should make the checksum fail"); - - gst_buffer_unmap (outbuffer, &map); - gst_buffer_unref (outbuffer); - - /* second buffer is the serialized caps; - * the element also holds a ref to it */ - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2); - length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1); - fail_unless_equals_int (gst_buffer_get_size (outbuffer), length); - gst_buffer_unref (outbuffer); - - /* the third buffer is the GDP buffer for our pushed buffer */ - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - buffers = g_list_remove (buffers, outbuffer); - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - length = GST_DP_HEADER_LENGTH + 4; - fail_unless_equals_int (gst_buffer_get_size (outbuffer), length); - gst_buffer_unref (outbuffer); - - fail_unless (gst_element_set_state (gdppay, - GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); - - gst_caps_unref (caps); - g_free (caps_string); - g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); - g_list_free (buffers); - buffers = NULL; - ASSERT_OBJECT_REFCOUNT (gdppay, "gdppay", 1); - cleanup_gdppay (gdppay); -} - -GST_END_TEST; - - -static Suite * -gdppay_suite (void) -{ - Suite *s = suite_create ("gdppay"); - TCase *tc_chain = tcase_create ("general"); - - suite_add_tcase (s, tc_chain); - tcase_add_test (tc_chain, test_audio); - tcase_add_test (tc_chain, test_first_no_caps); - tcase_add_test (tc_chain, test_first_no_new_segment); - tcase_add_test (tc_chain, test_streamheader); - tcase_add_test (tc_chain, test_crc); - - return s; -} - -GST_CHECK_MAIN (gdppay); diff --git a/tests/check/pipelines/.gitignore b/tests/check/pipelines/.gitignore index 7a5eb34..6219548 100644 --- a/tests/check/pipelines/.gitignore +++ b/tests/check/pipelines/.gitignore @@ -7,4 +7,3 @@ theoraenc vorbisdec vorbisenc oggmux -streamheader diff --git a/tests/check/pipelines/streamheader.c b/tests/check/pipelines/streamheader.c deleted file mode 100644 index be03e04..0000000 --- a/tests/check/pipelines/streamheader.c +++ /dev/null @@ -1,269 +0,0 @@ -/* GStreamer - * - * unit test for streamheader handling - * - * Copyright (C) 2007 Thomas Vander Stichele - * - * 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 - -#include -#include -#include - -#ifndef GST_DISABLE_PARSE - -/* this tests a gdp-serialized tag from audiotestsrc being sent only once - * to clients of multifdsink */ - -static int n_tags = 0; - -static GstPadProbeReturn -tag_event_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) -{ - GMainLoop *loop = user_data; - GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info); - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_TAG: - { - ++n_tags; - fail_if (n_tags > 1, "More than 1 tag received"); - break; - } - case GST_EVENT_EOS: - { - g_main_loop_quit (loop); - break; - } - default: - break; - } - - return GST_PAD_PROBE_OK; -} - -GST_START_TEST (test_multifdsink_gdp_tag) -{ - GstElement *p1, *p2; - GstElement *src, *sink, *depay; - GstPad *pad; - GMainLoop *loop; - int pfd[2]; - - loop = g_main_loop_new (NULL, FALSE); - - p1 = gst_parse_launch ("audiotestsrc num-buffers=10 ! gdppay" - " ! multifdsink name=p1sink", NULL); - fail_if (p1 == NULL); - p2 = gst_parse_launch ("fdsrc name=p2src ! gdpdepay name=depay" - " ! fakesink name=p2sink signal-handoffs=True", NULL); - fail_if (p2 == NULL); - - fail_if (pipe (pfd) == -1); - - gst_element_set_state (p1, GST_STATE_READY); - - sink = gst_bin_get_by_name (GST_BIN (p1), "p1sink"); - g_signal_emit_by_name (sink, "add", pfd[1], NULL); ///s[1] - gst_object_unref (sink); - - src = gst_bin_get_by_name (GST_BIN (p2), "p2src"); - g_object_set (G_OBJECT (src), "fd", pfd[0], NULL); - gst_object_unref (src); - - depay = gst_bin_get_by_name (GST_BIN (p2), "depay"); - fail_if (depay == NULL); - - pad = gst_element_get_static_pad (depay, "src"); - fail_unless (pad != NULL, "Could not get pad out of depay"); - gst_object_unref (depay); - - gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, - tag_event_probe_cb, loop, NULL); - - gst_element_set_state (p1, GST_STATE_PLAYING); - gst_element_set_state (p2, GST_STATE_PLAYING); - - g_main_loop_run (loop); - - assert_equals_int (n_tags, 1); - - gst_element_set_state (p1, GST_STATE_NULL); - gst_object_unref (p1); - gst_element_set_state (p2, GST_STATE_NULL); - gst_object_unref (p2); -} - -GST_END_TEST; - -#ifdef HAVE_VORBIS -/* this tests gdp-serialized Vorbis header pages being sent only once - * to clients of multifdsink; the gdp depayloader should deserialize - * exactly three in_caps buffers for the three header packets */ - -static int n_in_caps = 0; - -static GstPadProbeReturn -buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) -{ - GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info); - GstMapInfo map; - - gst_buffer_map (buffer, &map, GST_MAP_READ); - - if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_HEADER)) { - GstCaps *caps; - GstStructure *s; - const GValue *sh; - GArray *buffers; - GstBuffer *buf; - int i; - gboolean found = FALSE; - - n_in_caps++; - - caps = gst_pad_get_current_caps (pad); - s = gst_caps_get_structure (caps, 0); - fail_unless (gst_structure_has_field (s, "streamheader")); - sh = gst_structure_get_value (s, "streamheader"); - buffers = g_value_peek_pointer (sh); - assert_equals_int (buffers->len, 3); - - for (i = 0; i < 3; ++i) { - GValue *val; - GstMapInfo map2; - - val = &g_array_index (buffers, GValue, i); - buf = g_value_peek_pointer (val); - fail_unless (GST_IS_BUFFER (buf)); - - gst_buffer_map (buf, &map2, GST_MAP_READ); - if (map2.size == map.size) { - if (memcmp (map2.data, map.data, map.size) == 0) { - found = TRUE; - } - } - gst_buffer_unmap (buf, &map2); - } - fail_unless (found, "Did not find incoming HEADER buffer %p on caps", - buffer); - - gst_caps_unref (caps); - } - gst_buffer_unmap (buffer, &map); - - return TRUE; -} - -GST_START_TEST (test_multifdsink_gdp_vorbisenc) -{ - GstElement *p1, *p2; - GstElement *src, *sink, *depay; - GstPad *pad; - GMainLoop *loop; - int pfd[2]; - - loop = g_main_loop_new (NULL, FALSE); - - p1 = gst_parse_launch ("audiotestsrc num-buffers=10 ! audioconvert " - " ! vorbisenc ! gdppay ! multifdsink name=p1sink", NULL); - fail_if (p1 == NULL); - p2 = gst_parse_launch ("fdsrc name=p2src ! gdpdepay name=depay" - " ! fakesink name=p2sink signal-handoffs=True", NULL); - fail_if (p2 == NULL); - - fail_if (pipe (pfd) == -1); - - gst_element_set_state (p1, GST_STATE_READY); - - sink = gst_bin_get_by_name (GST_BIN (p1), "p1sink"); - g_signal_emit_by_name (sink, "add", pfd[1], NULL); - gst_object_unref (sink); - - src = gst_bin_get_by_name (GST_BIN (p2), "p2src"); - g_object_set (G_OBJECT (src), "fd", pfd[0], NULL); - gst_object_unref (src); - - depay = gst_bin_get_by_name (GST_BIN (p2), "depay"); - fail_if (depay == NULL); - - pad = gst_element_get_static_pad (depay, "src"); - fail_unless (pad != NULL, "Could not get pad out of depay"); - gst_object_unref (depay); - - gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, - tag_event_probe_cb, loop, NULL); - gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, buffer_probe_cb, NULL, - NULL); - - gst_element_set_state (p1, GST_STATE_PLAYING); - gst_element_set_state (p2, GST_STATE_PLAYING); - - g_main_loop_run (loop); - - assert_equals_int (n_in_caps, 3); - - gst_element_set_state (p1, GST_STATE_NULL); - gst_object_unref (p1); - gst_element_set_state (p2, GST_STATE_NULL); - gst_object_unref (p2); -} - -GST_END_TEST; -#endif /* HAVE_VORBIS */ - -#endif /* #ifndef GST_DISABLE_PARSE */ - -static Suite * -streamheader_suite (void) -{ - Suite *s = suite_create ("streamheader"); - TCase *tc_chain = tcase_create ("general"); - - suite_add_tcase (s, tc_chain); -#ifndef GST_DISABLE_PARSE - tcase_add_test (tc_chain, test_multifdsink_gdp_tag); -#ifdef HAVE_VORBIS - tcase_add_test (tc_chain, test_multifdsink_gdp_vorbisenc); -#endif -#endif - - return s; -} - -int -main (int argc, char **argv) -{ - int nf; - - Suite *s = streamheader_suite (); - SRunner *sr = srunner_create (s); - - gst_check_init (&argc, &argv); - - srunner_run_all (sr, CK_NORMAL); - nf = srunner_ntests_failed (sr); - srunner_free (sr); - - return nf; -} -- 2.7.4