gstreamer/gst/gdp/gstgdppay.c

872 lines
26 KiB
C
Raw Normal View History

/* GStreamer
* Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:element-gdppay
* @see_also: gdpdepay
*
* This element payloads GStreamer buffers and events using the
* GStreamer Data Protocol.
Cleanup Plugin docs. Link to signals and properties. Fix sub-section titles. Drop mentining that all our example pipe... Original commit message from CVS: * docs/plugins/gst-plugins-base-plugins-docs.sgml: * docs/plugins/gst-plugins-base-plugins-overrides.txt: * docs/plugins/gst-plugins-base-plugins-sections.txt: * docs/plugins/gst-plugins-base-plugins.args: * docs/plugins/gst-plugins-base-plugins.hierarchy: * docs/plugins/gst-plugins-base-plugins.interfaces: * docs/plugins/gst-plugins-base-plugins.prerequisites: * docs/plugins/gst-plugins-base-plugins.signals: * docs/plugins/inspect/plugin-adder.xml: * docs/plugins/inspect/plugin-alsa.xml: * docs/plugins/inspect/plugin-audioconvert.xml: * docs/plugins/inspect/plugin-audiorate.xml: * docs/plugins/inspect/plugin-audioresample.xml: * docs/plugins/inspect/plugin-audiotestsrc.xml: * docs/plugins/inspect/plugin-cdparanoia.xml: * docs/plugins/inspect/plugin-decodebin.xml: * docs/plugins/inspect/plugin-ffmpegcolorspace.xml: * docs/plugins/inspect/plugin-gdp.xml: * docs/plugins/inspect/plugin-gnomevfs.xml: * docs/plugins/inspect/plugin-libvisual.xml: * docs/plugins/inspect/plugin-ogg.xml: * docs/plugins/inspect/plugin-pango.xml: * docs/plugins/inspect/plugin-playback.xml: * docs/plugins/inspect/plugin-queue2.xml: * docs/plugins/inspect/plugin-subparse.xml: * docs/plugins/inspect/plugin-tcp.xml: * docs/plugins/inspect/plugin-theora.xml: * docs/plugins/inspect/plugin-typefindfunctions.xml: * docs/plugins/inspect/plugin-uridecodebin.xml: * docs/plugins/inspect/plugin-video4linux.xml: * docs/plugins/inspect/plugin-videorate.xml: * docs/plugins/inspect/plugin-videoscale.xml: * docs/plugins/inspect/plugin-videotestsrc.xml: * docs/plugins/inspect/plugin-volume.xml: * docs/plugins/inspect/plugin-vorbis.xml: * docs/plugins/inspect/plugin-ximagesink.xml: * docs/plugins/inspect/plugin-xvimagesink.xml: * ext/alsa/gstalsamixer.c: * ext/alsa/gstalsasink.c: * ext/alsa/gstalsasrc.c: * ext/gio/gstgiosink.c: * ext/gio/gstgiosrc.c: * ext/gio/gstgiostreamsink.c: * ext/gio/gstgiostreamsrc.c: * ext/gnomevfs/gstgnomevfssink.c: * ext/gnomevfs/gstgnomevfssrc.c: * ext/ogg/gstoggdemux.c: * ext/ogg/gstoggmux.c: * ext/pango/gstclockoverlay.c: * ext/pango/gsttextoverlay.c: * ext/pango/gsttextrender.c: * ext/pango/gsttimeoverlay.c: * ext/theora/theoradec.c: * ext/theora/theoraenc.c: * ext/theora/theoraparse.c: * ext/vorbis/vorbisdec.c: * ext/vorbis/vorbisenc.c: * ext/vorbis/vorbisparse.c: * ext/vorbis/vorbistag.c: * gst/adder/gstadder.c: * gst/audioconvert/gstaudioconvert.c: * gst/audioresample/gstaudioresample.c: * gst/audiotestsrc/gstaudiotestsrc.c: * gst/ffmpegcolorspace/gstffmpegcolorspace.c: * gst/gdp/gstgdpdepay.c: * gst/gdp/gstgdppay.c: * gst/playback/gstdecodebin2.c: * gst/playback/gstplaybin.c: * gst/playback/gstplaybin2.c: * gst/playback/gstqueue2.c: * gst/playback/gsturidecodebin.c: * gst/tcp/gstmultifdsink.c: * gst/tcp/gsttcpserversink.c: * gst/videorate/gstvideorate.c: * gst/videoscale/gstvideoscale.c: * gst/videotestsrc/gstvideotestsrc.c: * gst/volume/gstvolume.c: * sys/ximage/ximagesink.c: * sys/xvimage/xvimagesink.c: Cleanup Plugin docs. Link to signals and properties. Fix sub-section titles. Drop mentining that all our example pipelines are "simple" pipelines.
2008-07-10 21:06:06 +00:00
*
* <refsect2>
* |[
* gst-launch -v -m videotestsrc num-buffers=50 ! gdppay ! filesink location=test.gdp
Cleanup Plugin docs. Link to signals and properties. Fix sub-section titles. Drop mentining that all our example pipe... Original commit message from CVS: * docs/plugins/gst-plugins-base-plugins-docs.sgml: * docs/plugins/gst-plugins-base-plugins-overrides.txt: * docs/plugins/gst-plugins-base-plugins-sections.txt: * docs/plugins/gst-plugins-base-plugins.args: * docs/plugins/gst-plugins-base-plugins.hierarchy: * docs/plugins/gst-plugins-base-plugins.interfaces: * docs/plugins/gst-plugins-base-plugins.prerequisites: * docs/plugins/gst-plugins-base-plugins.signals: * docs/plugins/inspect/plugin-adder.xml: * docs/plugins/inspect/plugin-alsa.xml: * docs/plugins/inspect/plugin-audioconvert.xml: * docs/plugins/inspect/plugin-audiorate.xml: * docs/plugins/inspect/plugin-audioresample.xml: * docs/plugins/inspect/plugin-audiotestsrc.xml: * docs/plugins/inspect/plugin-cdparanoia.xml: * docs/plugins/inspect/plugin-decodebin.xml: * docs/plugins/inspect/plugin-ffmpegcolorspace.xml: * docs/plugins/inspect/plugin-gdp.xml: * docs/plugins/inspect/plugin-gnomevfs.xml: * docs/plugins/inspect/plugin-libvisual.xml: * docs/plugins/inspect/plugin-ogg.xml: * docs/plugins/inspect/plugin-pango.xml: * docs/plugins/inspect/plugin-playback.xml: * docs/plugins/inspect/plugin-queue2.xml: * docs/plugins/inspect/plugin-subparse.xml: * docs/plugins/inspect/plugin-tcp.xml: * docs/plugins/inspect/plugin-theora.xml: * docs/plugins/inspect/plugin-typefindfunctions.xml: * docs/plugins/inspect/plugin-uridecodebin.xml: * docs/plugins/inspect/plugin-video4linux.xml: * docs/plugins/inspect/plugin-videorate.xml: * docs/plugins/inspect/plugin-videoscale.xml: * docs/plugins/inspect/plugin-videotestsrc.xml: * docs/plugins/inspect/plugin-volume.xml: * docs/plugins/inspect/plugin-vorbis.xml: * docs/plugins/inspect/plugin-ximagesink.xml: * docs/plugins/inspect/plugin-xvimagesink.xml: * ext/alsa/gstalsamixer.c: * ext/alsa/gstalsasink.c: * ext/alsa/gstalsasrc.c: * ext/gio/gstgiosink.c: * ext/gio/gstgiosrc.c: * ext/gio/gstgiostreamsink.c: * ext/gio/gstgiostreamsrc.c: * ext/gnomevfs/gstgnomevfssink.c: * ext/gnomevfs/gstgnomevfssrc.c: * ext/ogg/gstoggdemux.c: * ext/ogg/gstoggmux.c: * ext/pango/gstclockoverlay.c: * ext/pango/gsttextoverlay.c: * ext/pango/gsttextrender.c: * ext/pango/gsttimeoverlay.c: * ext/theora/theoradec.c: * ext/theora/theoraenc.c: * ext/theora/theoraparse.c: * ext/vorbis/vorbisdec.c: * ext/vorbis/vorbisenc.c: * ext/vorbis/vorbisparse.c: * ext/vorbis/vorbistag.c: * gst/adder/gstadder.c: * gst/audioconvert/gstaudioconvert.c: * gst/audioresample/gstaudioresample.c: * gst/audiotestsrc/gstaudiotestsrc.c: * gst/ffmpegcolorspace/gstffmpegcolorspace.c: * gst/gdp/gstgdpdepay.c: * gst/gdp/gstgdppay.c: * gst/playback/gstdecodebin2.c: * gst/playback/gstplaybin.c: * gst/playback/gstplaybin2.c: * gst/playback/gstqueue2.c: * gst/playback/gsturidecodebin.c: * gst/tcp/gstmultifdsink.c: * gst/tcp/gsttcpserversink.c: * gst/videorate/gstvideorate.c: * gst/videoscale/gstvideoscale.c: * gst/videotestsrc/gstvideotestsrc.c: * gst/volume/gstvolume.c: * sys/ximage/ximagesink.c: * sys/xvimage/xvimagesink.c: Cleanup Plugin docs. Link to signals and properties. Fix sub-section titles. Drop mentining that all our example pipelines are "simple" pipelines.
2008-07-10 21:06:06 +00:00
* ]| This pipeline creates a serialized video stream that can be played back
* with the example shown in gdpdepay.
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/dataprotocol/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, GstBuffer * buffer);
static gboolean gst_gdp_pay_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event);
static GstStateChangeReturn gst_gdp_pay_change_state (GstElement *
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",
Use G_PARAM_STATIC_STRINGS everywhere for GParamSpecs that use static strings (i.e. all). This gives us less memory u... Original commit message from CVS: * configure.ac: * ext/alsa/gstalsamixerelement.c: (gst_alsa_mixer_element_class_init): * ext/alsa/gstalsasink.c: (gst_alsasink_class_init): * ext/alsa/gstalsasrc.c: (gst_alsasrc_class_init): * ext/cdparanoia/gstcdparanoiasrc.c: (gst_cd_paranoia_src_class_init): * ext/gio/gstgiosink.c: (gst_gio_sink_class_init): * ext/gio/gstgiosrc.c: (gst_gio_src_class_init): * ext/gio/gstgiostreamsink.c: (gst_gio_stream_sink_class_init): * ext/gio/gstgiostreamsrc.c: (gst_gio_stream_src_class_init): * ext/gnomevfs/gstgnomevfssink.c: (gst_gnome_vfs_sink_class_init): * ext/gnomevfs/gstgnomevfssrc.c: (gst_gnome_vfs_src_class_init): * ext/ogg/gstoggmux.c: (gst_ogg_mux_class_init): * ext/pango/gsttextoverlay.c: (gst_text_overlay_class_init): * ext/pango/gsttextrender.c: (gst_text_render_class_init): * ext/theora/theoradec.c: (gst_theora_dec_class_init): * ext/theora/theoraenc.c: (gst_theora_enc_class_init): * ext/theora/theoraparse.c: (gst_theora_parse_class_init): * ext/vorbis/vorbisenc.c: (gst_vorbis_enc_class_init): * gst-libs/gst/audio/gstaudiofiltertemplate.c: (gst_audio_filter_template_class_init): * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_class_init): * gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_class_init): * gst-libs/gst/cdda/gstcddabasesrc.c: (gst_cdda_base_src_class_init): * gst-libs/gst/interfaces/mixertrack.c: (gst_mixer_track_class_init): * gst-libs/gst/rtp/gstbasertpdepayload.c: (gst_base_rtp_depayload_class_init): * gst-libs/gst/rtp/gstbasertppayload.c: (gst_basertppayload_class_init): * gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_class_init): * gst/audiorate/gstaudiorate.c: (gst_audio_rate_class_init): * gst/audioresample/gstaudioresample.c: (gst_audioresample_class_init): * gst/audiotestsrc/gstaudiotestsrc.c: (gst_audio_test_src_class_init): * gst/gdp/gstgdppay.c: (gst_gdp_pay_class_init): * gst/playback/gstdecodebin2.c: (gst_decode_bin_class_init): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (preroll_unlinked): * gst/playback/gstplaybin.c: (gst_play_bin_class_init): * gst/playback/gstplaybin2.c: (gst_play_bin_class_init): * gst/playback/gstplaysink.c: (gst_play_sink_class_init): * gst/playback/gstqueue2.c: (gst_queue_class_init): * gst/playback/gststreaminfo.c: (gst_stream_info_class_init): * gst/playback/gststreamselector.c: (gst_selector_pad_class_init), (gst_stream_selector_class_init): * gst/playback/gsturidecodebin.c: (gst_uri_decode_bin_class_init): * gst/subparse/gstsubparse.c: (gst_sub_parse_class_init): * gst/tcp/gstmultifdsink.c: (gst_multi_fd_sink_class_init): * gst/tcp/gsttcpclientsink.c: (gst_tcp_client_sink_class_init): * gst/tcp/gsttcpclientsrc.c: (gst_tcp_client_src_class_init): * gst/tcp/gsttcpserversink.c: (gst_tcp_server_sink_class_init): * gst/tcp/gsttcpserversrc.c: (gst_tcp_server_src_class_init): * gst/videorate/gstvideorate.c: (gst_video_rate_class_init): * gst/videoscale/gstvideoscale.c: (gst_video_scale_class_init): * gst/videotestsrc/gstvideotestsrc.c: (gst_video_test_src_class_init): * gst/volume/gstvolume.c: (gst_volume_class_init): * sys/v4l/gstv4lelement.c: (gst_v4lelement_class_init): * sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_class_init): * sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_class_init): * sys/v4l/gstv4lsrc.c: (gst_v4lsrc_class_init): * sys/ximage/ximagesink.c: (gst_ximagesink_class_init): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_class_init): Use G_PARAM_STATIC_STRINGS everywhere for GParamSpecs that use static strings (i.e. all). This gives us less memory usage, fewer allocations and thus less memory defragmentation. Depend on core CVS for this. Fixes bug #523806.
2008-03-22 15:00:53 +00:00
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",
Use G_PARAM_STATIC_STRINGS everywhere for GParamSpecs that use static strings (i.e. all). This gives us less memory u... Original commit message from CVS: * configure.ac: * ext/alsa/gstalsamixerelement.c: (gst_alsa_mixer_element_class_init): * ext/alsa/gstalsasink.c: (gst_alsasink_class_init): * ext/alsa/gstalsasrc.c: (gst_alsasrc_class_init): * ext/cdparanoia/gstcdparanoiasrc.c: (gst_cd_paranoia_src_class_init): * ext/gio/gstgiosink.c: (gst_gio_sink_class_init): * ext/gio/gstgiosrc.c: (gst_gio_src_class_init): * ext/gio/gstgiostreamsink.c: (gst_gio_stream_sink_class_init): * ext/gio/gstgiostreamsrc.c: (gst_gio_stream_src_class_init): * ext/gnomevfs/gstgnomevfssink.c: (gst_gnome_vfs_sink_class_init): * ext/gnomevfs/gstgnomevfssrc.c: (gst_gnome_vfs_src_class_init): * ext/ogg/gstoggmux.c: (gst_ogg_mux_class_init): * ext/pango/gsttextoverlay.c: (gst_text_overlay_class_init): * ext/pango/gsttextrender.c: (gst_text_render_class_init): * ext/theora/theoradec.c: (gst_theora_dec_class_init): * ext/theora/theoraenc.c: (gst_theora_enc_class_init): * ext/theora/theoraparse.c: (gst_theora_parse_class_init): * ext/vorbis/vorbisenc.c: (gst_vorbis_enc_class_init): * gst-libs/gst/audio/gstaudiofiltertemplate.c: (gst_audio_filter_template_class_init): * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_class_init): * gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_class_init): * gst-libs/gst/cdda/gstcddabasesrc.c: (gst_cdda_base_src_class_init): * gst-libs/gst/interfaces/mixertrack.c: (gst_mixer_track_class_init): * gst-libs/gst/rtp/gstbasertpdepayload.c: (gst_base_rtp_depayload_class_init): * gst-libs/gst/rtp/gstbasertppayload.c: (gst_basertppayload_class_init): * gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_class_init): * gst/audiorate/gstaudiorate.c: (gst_audio_rate_class_init): * gst/audioresample/gstaudioresample.c: (gst_audioresample_class_init): * gst/audiotestsrc/gstaudiotestsrc.c: (gst_audio_test_src_class_init): * gst/gdp/gstgdppay.c: (gst_gdp_pay_class_init): * gst/playback/gstdecodebin2.c: (gst_decode_bin_class_init): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (preroll_unlinked): * gst/playback/gstplaybin.c: (gst_play_bin_class_init): * gst/playback/gstplaybin2.c: (gst_play_bin_class_init): * gst/playback/gstplaysink.c: (gst_play_sink_class_init): * gst/playback/gstqueue2.c: (gst_queue_class_init): * gst/playback/gststreaminfo.c: (gst_stream_info_class_init): * gst/playback/gststreamselector.c: (gst_selector_pad_class_init), (gst_stream_selector_class_init): * gst/playback/gsturidecodebin.c: (gst_uri_decode_bin_class_init): * gst/subparse/gstsubparse.c: (gst_sub_parse_class_init): * gst/tcp/gstmultifdsink.c: (gst_multi_fd_sink_class_init): * gst/tcp/gsttcpclientsink.c: (gst_tcp_client_sink_class_init): * gst/tcp/gsttcpclientsrc.c: (gst_tcp_client_src_class_init): * gst/tcp/gsttcpserversink.c: (gst_tcp_server_sink_class_init): * gst/tcp/gsttcpserversrc.c: (gst_tcp_server_src_class_init): * gst/videorate/gstvideorate.c: (gst_video_rate_class_init): * gst/videoscale/gstvideoscale.c: (gst_video_scale_class_init): * gst/videotestsrc/gstvideotestsrc.c: (gst_video_test_src_class_init): * gst/volume/gstvolume.c: (gst_volume_class_init): * sys/v4l/gstv4lelement.c: (gst_v4lelement_class_init): * sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_class_init): * sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_class_init): * sys/v4l/gstv4lsrc.c: (gst_v4lsrc_class_init): * sys/ximage/ximagesink.c: (gst_ximagesink_class_init): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_class_init): Use G_PARAM_STATIC_STRINGS everywhere for GParamSpecs that use static strings (i.e. all). This gives us less memory usage, fewer allocations and thus less memory defragmentation. Depend on core CVS for this. Fixes bug #523806.
2008-03-22 15:00:53 +00:00
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",
Use G_PARAM_STATIC_STRINGS everywhere for GParamSpecs that use static strings (i.e. all). This gives us less memory u... Original commit message from CVS: * configure.ac: * ext/alsa/gstalsamixerelement.c: (gst_alsa_mixer_element_class_init): * ext/alsa/gstalsasink.c: (gst_alsasink_class_init): * ext/alsa/gstalsasrc.c: (gst_alsasrc_class_init): * ext/cdparanoia/gstcdparanoiasrc.c: (gst_cd_paranoia_src_class_init): * ext/gio/gstgiosink.c: (gst_gio_sink_class_init): * ext/gio/gstgiosrc.c: (gst_gio_src_class_init): * ext/gio/gstgiostreamsink.c: (gst_gio_stream_sink_class_init): * ext/gio/gstgiostreamsrc.c: (gst_gio_stream_src_class_init): * ext/gnomevfs/gstgnomevfssink.c: (gst_gnome_vfs_sink_class_init): * ext/gnomevfs/gstgnomevfssrc.c: (gst_gnome_vfs_src_class_init): * ext/ogg/gstoggmux.c: (gst_ogg_mux_class_init): * ext/pango/gsttextoverlay.c: (gst_text_overlay_class_init): * ext/pango/gsttextrender.c: (gst_text_render_class_init): * ext/theora/theoradec.c: (gst_theora_dec_class_init): * ext/theora/theoraenc.c: (gst_theora_enc_class_init): * ext/theora/theoraparse.c: (gst_theora_parse_class_init): * ext/vorbis/vorbisenc.c: (gst_vorbis_enc_class_init): * gst-libs/gst/audio/gstaudiofiltertemplate.c: (gst_audio_filter_template_class_init): * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_class_init): * gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_class_init): * gst-libs/gst/cdda/gstcddabasesrc.c: (gst_cdda_base_src_class_init): * gst-libs/gst/interfaces/mixertrack.c: (gst_mixer_track_class_init): * gst-libs/gst/rtp/gstbasertpdepayload.c: (gst_base_rtp_depayload_class_init): * gst-libs/gst/rtp/gstbasertppayload.c: (gst_basertppayload_class_init): * gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_class_init): * gst/audiorate/gstaudiorate.c: (gst_audio_rate_class_init): * gst/audioresample/gstaudioresample.c: (gst_audioresample_class_init): * gst/audiotestsrc/gstaudiotestsrc.c: (gst_audio_test_src_class_init): * gst/gdp/gstgdppay.c: (gst_gdp_pay_class_init): * gst/playback/gstdecodebin2.c: (gst_decode_bin_class_init): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (preroll_unlinked): * gst/playback/gstplaybin.c: (gst_play_bin_class_init): * gst/playback/gstplaybin2.c: (gst_play_bin_class_init): * gst/playback/gstplaysink.c: (gst_play_sink_class_init): * gst/playback/gstqueue2.c: (gst_queue_class_init): * gst/playback/gststreaminfo.c: (gst_stream_info_class_init): * gst/playback/gststreamselector.c: (gst_selector_pad_class_init), (gst_stream_selector_class_init): * gst/playback/gsturidecodebin.c: (gst_uri_decode_bin_class_init): * gst/subparse/gstsubparse.c: (gst_sub_parse_class_init): * gst/tcp/gstmultifdsink.c: (gst_multi_fd_sink_class_init): * gst/tcp/gsttcpclientsink.c: (gst_tcp_client_sink_class_init): * gst/tcp/gsttcpclientsrc.c: (gst_tcp_client_src_class_init): * gst/tcp/gsttcpserversink.c: (gst_tcp_server_sink_class_init): * gst/tcp/gsttcpserversrc.c: (gst_tcp_server_src_class_init): * gst/videorate/gstvideorate.c: (gst_video_rate_class_init): * gst/videoscale/gstvideoscale.c: (gst_video_scale_class_init): * gst/videotestsrc/gstvideotestsrc.c: (gst_video_test_src_class_init): * gst/volume/gstvolume.c: (gst_volume_class_init): * sys/v4l/gstv4lelement.c: (gst_v4lelement_class_init): * sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_class_init): * sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_class_init): * sys/v4l/gstv4lsrc.c: (gst_v4lsrc_class_init): * sys/ximage/ximagesink.c: (gst_ximagesink_class_init): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_class_init): Use G_PARAM_STATIC_STRINGS everywhere for GParamSpecs that use static strings (i.e. all). This gives us less memory usage, fewer allocations and thus less memory defragmentation. Depend on core CVS for this. Fixes bug #523806.
2008-03-22 15:00:53 +00:00
GST_TYPE_DP_VERSION, DEFAULT_VERSION,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_set_details_simple (gstelement_class,
"GDP Payloader", "GDP/Payloader",
"Payloads GStreamer Data Protocol buffers",
"Thomas Vander Stichele <thomas at apestaart dot org>");
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);
}
#if 0
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 ();
gst_buffer_take_memory (headerbuf,
gst_memory_new_wrapped (0, header, g_free, len, 0, len));
payloadbuf = gst_buffer_new ();
plen = gst_dp_header_payload_length (header);
gst_buffer_take_memory (payloadbuf,
gst_memory_new_wrapped (0, payload, g_free, plen, 0, plen));
return gst_buffer_join (headerbuf, payloadbuf);
/* ERRORS */
packet_failed:
{
GST_WARNING_OBJECT (this, "could not create GDP header from caps");
return NULL;
}
}
#endif
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 ();
gst_buffer_take_memory (headerbuf,
gst_memory_new_wrapped (0, header, g_free, len, 0, len));
/* we do not want to lose the ref on the incoming buffer */
gst_buffer_ref (buffer);
return gst_buffer_join (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 ();
gst_buffer_take_memory (headerbuf,
gst_memory_new_wrapped (0, header, g_free, len, 0, len));
payloadbuf = gst_buffer_new ();
plen = gst_dp_header_payload_length (header);
2011-03-31 15:47:43 +00:00
if (plen && payload != NULL) {
gst_buffer_take_memory (payloadbuf,
gst_memory_new_wrapped (0, payload, g_free, plen, 0, plen));
}
return gst_buffer_join (headerbuf, payloadbuf);
/* 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 IN_CAPS, because it's a streamheader - otherwise it
is mixed with regular data buffers */
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_IN_CAPS);
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 IN_CAPS as other GDP event buffers */
GST_DEBUG_OBJECT (this,
"Setting IN_CAPS flag on outgoing buffer %" GST_PTR_FORMAT,
outbuffer);
GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_IN_CAPS);
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) {
2011-05-16 11:48:11 +00:00
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));
return GST_FLOW_OK;
}
static GstFlowReturn
gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer)
{
GstGDPPay *this;
#if 0
GstCaps *caps;
#endif
GstBuffer *outbuffer;
GstFlowReturn ret;
this = GST_GDP_PAY (gst_pad_get_parent (pad));
/* 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;
2011-05-16 11:48:11 +00:00
GstSegment segment;
GST_WARNING_OBJECT (this,
"did not receive new-segment before first buffer");
2011-05-16 11:48:11 +00:00
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_IN_CAPS);
GST_DEBUG_OBJECT (this, "Storing buffer %p as new_segment_buf",
outbuffer);
this->new_segment_buf = outbuffer;
}
}
#if 0
/* make sure we've received caps before */
caps = gst_buffer_get_caps (buffer);
if (!this->caps && !caps)
goto no_caps;
/* if the caps have changed, process caps first */
if (caps && !gst_caps_is_equal (this->caps, caps)) {
GST_LOG_OBJECT (this, "caps changed to %p, %" GST_PTR_FORMAT, caps, caps);
gst_caps_replace (&(this->caps), caps);
outbuffer = gst_gdp_buffer_from_caps (this, caps);
if (!outbuffer)
goto no_caps_buffer;
GST_BUFFER_TIMESTAMP (outbuffer) = GST_BUFFER_TIMESTAMP (buffer);
GST_BUFFER_DURATION (outbuffer) = 0;
GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_IN_CAPS);
if (this->caps_buf)
gst_buffer_unref (this->caps_buf);
this->caps_buf = outbuffer;
gst_gdp_pay_reset_streamheader (this);
}
if (caps)
gst_caps_unref (caps);
#endif
/* 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 IN_CAPS, 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_IN_CAPS)) {
GST_DEBUG_OBJECT (this, "Setting IN_CAPS flag on outgoing buffer %p",
outbuffer);
GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_IN_CAPS);
}
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);
gst_object_unref (this);
return ret;
/* ERRORS */
#if 0
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"));
if (caps)
gst_caps_unref (caps);
ret = GST_FLOW_NOT_NEGOTIATED;
goto done;
}
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, GstEvent * event)
{
GstBuffer *outbuffer;
GstGDPPay *this = GST_GDP_PAY (gst_pad_get_parent (pad));
GstFlowReturn flowret;
gboolean ret = TRUE;
GST_DEBUG_OBJECT (this, "received event %p of type %s (%d)",
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)) {
2011-05-16 11:48:11 +00:00
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_IN_CAPS);
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_IN_CAPS);
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);
gst_object_unref (this);
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;
}
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, GstEvent * event)
{
GstGDPPay *this;
gboolean res = TRUE;
this = GST_GDP_PAY (gst_pad_get_parent (pad));
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;
}
gst_object_unref (this);
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;
}