gstreamer/gst/freeze/gstfreeze.c

390 lines
10 KiB
C
Raw Normal View History

/* gst-freeze -- Source freezer
* Copyright (C) 2005 Gergely Nagy <gergely.nagy@neteyes.hu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1, as published by the Free Software Foundation.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include "gstfreeze.h"
GST_DEBUG_CATEGORY_STATIC (freeze_debug);
#define GST_CAT_DEFAULT freeze_debug
enum
{
ARG_0,
ARG_MAX_BUFFERS,
};
Define GstElementDetails as const and also static (when defined as global) Original commit message from CVS: * ext/amrwb/gstamrwbdec.c: * ext/amrwb/gstamrwbenc.c: * ext/amrwb/gstamrwbparse.c: * ext/arts/gst_arts.c: * ext/artsd/gstartsdsink.c: * ext/audiofile/gstafparse.c: * ext/audiofile/gstafsink.c: * ext/audiofile/gstafsrc.c: * ext/audioresample/gstaudioresample.c: * ext/bz2/gstbz2dec.c: * ext/bz2/gstbz2enc.c: * ext/cdaudio/gstcdaudio.c: * ext/directfb/dfbvideosink.c: * ext/divx/gstdivxdec.c: * ext/divx/gstdivxenc.c: * ext/dts/gstdtsdec.c: (gst_dtsdec_base_init): * ext/faac/gstfaac.c: (gst_faac_base_init): * ext/faad/gstfaad.c: * ext/gsm/gstgsmdec.c: * ext/gsm/gstgsmenc.c: * ext/hermes/gsthermescolorspace.c: * ext/ivorbis/vorbisfile.c: * ext/lcs/gstcolorspace.c: * ext/libfame/gstlibfame.c: * ext/libmms/gstmms.c: (gst_mms_base_init): * ext/musepack/gstmusepackdec.c: (gst_musepackdec_base_init): * ext/musicbrainz/gsttrm.c: (gst_musicbrainz_base_init): * ext/nas/nassink.c: (gst_nassink_base_init): * ext/neon/gstneonhttpsrc.c: * ext/sdl/sdlaudiosink.c: * ext/sdl/sdlvideosink.c: * ext/shout/gstshout.c: * ext/snapshot/gstsnapshot.c: * ext/sndfile/gstsf.c: * ext/swfdec/gstswfdec.c: * ext/tarkin/gsttarkindec.c: * ext/tarkin/gsttarkinenc.c: * ext/theora/theoradec.c: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init): * ext/xvid/gstxviddec.c: * ext/xvid/gstxvidenc.c: * gst/cdxaparse/gstcdxaparse.c: (gst_cdxa_parse_base_init): * gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_base_init): * gst/chart/gstchart.c: * gst/colorspace/gstcolorspace.c: * gst/deinterlace/gstdeinterlace.c: * gst/equalizer/gstiirequalizer.c: (gst_iir_equalizer_base_init): * gst/festival/gstfestival.c: * gst/filter/gstbpwsinc.c: * gst/filter/gstiir.c: * gst/filter/gstlpwsinc.c: * gst/freeze/gstfreeze.c: * gst/games/gstpuzzle.c: (gst_puzzle_base_init): * gst/librfb/gstrfbsrc.c: * gst/mixmatrix/mixmatrix.c: * gst/mpeg1sys/gstmpeg1systemencode.c: * gst/mpeg1videoparse/gstmp1videoparse.c: * gst/mpeg2sub/gstmpeg2subt.c: * gst/mpegaudioparse/gstmpegaudioparse.c: * gst/multifilesink/gstmultifilesink.c: * gst/overlay/gstoverlay.c: * gst/passthrough/gstpassthrough.c: * gst/playondemand/gstplayondemand.c: * gst/qtdemux/qtdemux.c: * gst/rtjpeg/gstrtjpegdec.c: * gst/rtjpeg/gstrtjpegenc.c: * gst/smooth/gstsmooth.c: * gst/smoothwave/gstsmoothwave.c: * gst/spectrum/gstspectrum.c: * gst/speed/gstspeed.c: * gst/stereo/gststereo.c: * gst/switch/gstswitch.c: * gst/tta/gstttadec.c: (gst_tta_dec_base_init): * gst/tta/gstttaparse.c: (gst_tta_parse_base_init): * gst/vbidec/gstvbidec.c: * gst/videocrop/gstvideocrop.c: * gst/videodrop/gstvideodrop.c: * gst/virtualdub/gstxsharpen.c: * gst/xingheader/gstxingmux.c: (gst_xing_mux_base_init): * gst/y4m/gsty4mencode.c: * sys/cdrom/gstcdplayer.c: * sys/directdraw/gstdirectdrawsink.c: * sys/directsound/gstdirectsoundsink.c: * sys/glsink/glimagesink.c: * sys/qcam/gstqcamsrc.c: * sys/v4l2/gstv4l2src.c: * sys/vcd/vcdsrc.c: (gst_vcdsrc_base_init): * sys/ximagesrc/ximagesrc.c: Define GstElementDetails as const and also static (when defined as global)
2006-04-25 21:56:38 +00:00
static const GstElementDetails freeze_details =
GST_ELEMENT_DETAILS ("Stream freezer",
Unify the long descriptions in the plugin details (#337263). Original commit message from CVS: Patch by: j^ <j at bootlab dot org> * ext/amrwb/gstamrwbdec.c: * ext/amrwb/gstamrwbenc.c: * ext/amrwb/gstamrwbparse.c: * ext/arts/gst_arts.c: * ext/artsd/gstartsdsink.c: * ext/audiofile/gstafparse.c: * ext/audiofile/gstafsink.c: * ext/audiofile/gstafsrc.c: * ext/cdaudio/gstcdaudio.c: * ext/directfb/dfbvideosink.c: * ext/divx/gstdivxdec.c: * ext/divx/gstdivxenc.c: * ext/dts/gstdtsdec.c: (gst_dtsdec_base_init): * ext/faac/gstfaac.c: (gst_faac_base_init): * ext/faad/gstfaad.c: * ext/gsm/gstgsmdec.c: * ext/gsm/gstgsmenc.c: * ext/hermes/gsthermescolorspace.c: * ext/ivorbis/vorbisfile.c: * ext/lcs/gstcolorspace.c: * ext/libfame/gstlibfame.c: * ext/libmms/gstmms.c: (gst_mms_base_init): * ext/musicbrainz/gsttrm.c: (gst_musicbrainz_base_init): * ext/nas/nassink.c: (gst_nassink_base_init): * ext/neon/gstneonhttpsrc.c: * ext/polyp/polypsink.c: (gst_polypsink_base_init): * ext/sdl/sdlaudiosink.c: * ext/sdl/sdlvideosink.c: * ext/shout/gstshout.c: * ext/snapshot/gstsnapshot.c: * ext/sndfile/gstsf.c: * ext/tarkin/gsttarkindec.c: * ext/tarkin/gsttarkinenc.c: * ext/theora/theoradec.c: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init): * ext/xvid/gstxviddec.c: * ext/xvid/gstxvidenc.c: * gst/cdxaparse/gstcdxaparse.c: (gst_cdxa_parse_base_init): * gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_base_init): * gst/chart/gstchart.c: * gst/equalizer/gstiirequalizer.c: (gst_iir_equalizer_base_init): * gst/festival/gstfestival.c: * gst/filter/gstiir.c: * gst/filter/gstlpwsinc.c: * gst/freeze/gstfreeze.c: * gst/games/gstpuzzle.c: (gst_puzzle_base_init): * gst/mixmatrix/mixmatrix.c: * gst/mpeg1sys/gstmpeg1systemencode.c: * gst/mpeg1videoparse/gstmp1videoparse.c: * gst/mpeg2sub/gstmpeg2subt.c: * gst/mpegaudioparse/gstmpegaudioparse.c: * gst/multifilesink/gstmultifilesink.c: * gst/overlay/gstoverlay.c: * gst/passthrough/gstpassthrough.c: * gst/playondemand/gstplayondemand.c: * gst/qtdemux/qtdemux.c: * gst/rtjpeg/gstrtjpegdec.c: * gst/rtjpeg/gstrtjpegenc.c: * gst/smooth/gstsmooth.c: * gst/tta/gstttadec.c: (gst_tta_dec_base_init): * gst/tta/gstttaparse.c: (gst_tta_parse_base_init): * gst/videocrop/gstvideocrop.c: * gst/videodrop/gstvideodrop.c: * gst/virtualdub/gstxsharpen.c: * gst/xingheader/gstxingmux.c: (gst_xing_mux_base_init): * gst/y4m/gsty4mencode.c: Unify the long descriptions in the plugin details (#337263).
2006-04-06 11:35:26 +00:00
"Generic",
"Makes a stream from buffers of data",
"Gergely Nagy <gergely.nagy@neteyes.hu>,"
" Renato Filho <renato.filho@indt.org.br>");
static GstStaticPadTemplate gst_freeze_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate gst_freeze_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static void gst_freeze_class_init (GstFreezeClass * klass);
static void gst_freeze_dispose (GObject * object);
static void gst_freeze_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_freeze_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstFlowReturn gst_freeze_chain (GstPad * pad, GstBuffer * buffer);
static GstStateChangeReturn gst_freeze_change_state (GstElement * element,
GstStateChange transition);
static GstFlowReturn gst_freeze_play (GstPad * pad, GstBuffer * buff);
static void gst_freeze_loop (GstPad * pad);
static gboolean gst_freeze_sink_activate (GstPad * sinkpad);
static gboolean gst_freeze_sink_activate_pull (GstPad * sinkpad,
gboolean active);
static gboolean gst_freeze_sink_event (GstPad * pad, GstEvent * event);
static void gst_freeze_clear_buffer (GstFreeze * freeze);
static void gst_freeze_buffer_free (gpointer data, gpointer user_data);
GST_BOILERPLATE (GstFreeze, gst_freeze, GstElement, GST_TYPE_ELEMENT);
static void
gst_freeze_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_set_details (element_class, &freeze_details);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_freeze_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_freeze_src_template));
}
static void
gst_freeze_class_init (GstFreezeClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
element_class->change_state = gst_freeze_change_state;
object_class->set_property = gst_freeze_set_property;
object_class->get_property = gst_freeze_get_property;
g_object_class_install_property (object_class,
ARG_MAX_BUFFERS,
g_param_spec_uint ("max-buffers",
"max-buffers",
"Maximum number of buffers", 0, G_MAXUINT, 1, G_PARAM_READWRITE));
object_class->dispose = gst_freeze_dispose;
}
static void
gst_freeze_init (GstFreeze * freeze, GstFreezeClass * klass)
{
freeze->sinkpad =
Fix leaks. Original commit message from CVS: * ext/amrwb/gstamrwbdec.c: (gst_amrwbdec_init): * ext/amrwb/gstamrwbenc.c: (gst_amrwbenc_init): * ext/amrwb/gstamrwbparse.c: (gst_amrwbparse_init): * ext/audioresample/gstaudioresample.c: * ext/bz2/gstbz2dec.c: (gst_bz2dec_init): * ext/bz2/gstbz2enc.c: (gst_bz2enc_init): * ext/divx/gstdivxdec.c: (gst_divxdec_init): * ext/divx/gstdivxenc.c: (gst_divxenc_init): * ext/faac/gstfaac.c: (gst_faac_init): * ext/gsm/gstgsmdec.c: (gst_gsmdec_init): * ext/gsm/gstgsmenc.c: (gst_gsmenc_init): * ext/hermes/gsthermescolorspace.c: (gst_hermes_colorspace_init): * ext/lcs/gstcolorspace.c: (gst_colorspace_init): * ext/libfame/gstlibfame.c: (gst_fameenc_init): * ext/snapshot/gstsnapshot.c: (gst_snapshot_init): * ext/spc/gstspc.c: (gst_spc_dec_init): * ext/swfdec/gstswfdec.c: (gst_swfdec_init): * ext/xvid/gstxvidenc.c: (gst_xvidenc_init): * gst/cdxaparse/gstcdxaparse.c: (gst_cdxa_parse_init): * gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init): * gst/chart/gstchart.c: (gst_chart_init): * gst/colorspace/gstcolorspace.c: (gst_colorspace_init): * gst/festival/gstfestival.c: (gst_festival_init): * gst/freeze/gstfreeze.c: (gst_freeze_init): * gst/mixmatrix/mixmatrix.c: (gst_mixmatrix_request_new_pad): * gst/mpeg1sys/gstmpeg1systemencode.c: (gst_system_encode_init): * gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init): * gst/nsf/gstnsf.c: (gst_nsfdec_init): * gst/overlay/gstoverlay.c: (gst_overlay_init): * gst/passthrough/gstpassthrough.c: (passthrough_init): * gst/playondemand/gstplayondemand.c: (play_on_demand_init): * gst/smooth/gstsmooth.c: (gst_smooth_init): * gst/smoothwave/gstsmoothwave.c: (gst_smoothwave_init): * gst/speed/gstspeed.c: (speed_init): * gst/vbidec/gstvbidec.c: (gst_vbidec_init): * gst/videodrop/gstvideodrop.c: (gst_videodrop_init): * sys/dxr3/dxr3spusink.c: (dxr3spusink_init): * sys/dxr3/dxr3videosink.c: (dxr3videosink_init): * sys/qcam/gstqcamsrc.c: (gst_qcamsrc_init): Fix leaks.
2007-06-22 10:46:33 +00:00
gst_pad_new_from_static_template (&gst_freeze_sink_template, "sink");
gst_element_add_pad (GST_ELEMENT (freeze), freeze->sinkpad);
gst_pad_set_activate_function (freeze->sinkpad, gst_freeze_sink_activate);
gst_pad_set_activatepull_function (freeze->sinkpad,
gst_freeze_sink_activate_pull);
gst_pad_set_chain_function (freeze->sinkpad, gst_freeze_chain);
gst_pad_set_getcaps_function (freeze->sinkpad, gst_pad_proxy_getcaps);
gst_pad_set_event_function (freeze->sinkpad, gst_freeze_sink_event);
Fix leaks. Original commit message from CVS: * ext/amrwb/gstamrwbdec.c: (gst_amrwbdec_init): * ext/amrwb/gstamrwbenc.c: (gst_amrwbenc_init): * ext/amrwb/gstamrwbparse.c: (gst_amrwbparse_init): * ext/audioresample/gstaudioresample.c: * ext/bz2/gstbz2dec.c: (gst_bz2dec_init): * ext/bz2/gstbz2enc.c: (gst_bz2enc_init): * ext/divx/gstdivxdec.c: (gst_divxdec_init): * ext/divx/gstdivxenc.c: (gst_divxenc_init): * ext/faac/gstfaac.c: (gst_faac_init): * ext/gsm/gstgsmdec.c: (gst_gsmdec_init): * ext/gsm/gstgsmenc.c: (gst_gsmenc_init): * ext/hermes/gsthermescolorspace.c: (gst_hermes_colorspace_init): * ext/lcs/gstcolorspace.c: (gst_colorspace_init): * ext/libfame/gstlibfame.c: (gst_fameenc_init): * ext/snapshot/gstsnapshot.c: (gst_snapshot_init): * ext/spc/gstspc.c: (gst_spc_dec_init): * ext/swfdec/gstswfdec.c: (gst_swfdec_init): * ext/xvid/gstxvidenc.c: (gst_xvidenc_init): * gst/cdxaparse/gstcdxaparse.c: (gst_cdxa_parse_init): * gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init): * gst/chart/gstchart.c: (gst_chart_init): * gst/colorspace/gstcolorspace.c: (gst_colorspace_init): * gst/festival/gstfestival.c: (gst_festival_init): * gst/freeze/gstfreeze.c: (gst_freeze_init): * gst/mixmatrix/mixmatrix.c: (gst_mixmatrix_request_new_pad): * gst/mpeg1sys/gstmpeg1systemencode.c: (gst_system_encode_init): * gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init): * gst/nsf/gstnsf.c: (gst_nsfdec_init): * gst/overlay/gstoverlay.c: (gst_overlay_init): * gst/passthrough/gstpassthrough.c: (passthrough_init): * gst/playondemand/gstplayondemand.c: (play_on_demand_init): * gst/smooth/gstsmooth.c: (gst_smooth_init): * gst/smoothwave/gstsmoothwave.c: (gst_smoothwave_init): * gst/speed/gstspeed.c: (speed_init): * gst/vbidec/gstvbidec.c: (gst_vbidec_init): * gst/videodrop/gstvideodrop.c: (gst_videodrop_init): * sys/dxr3/dxr3spusink.c: (dxr3spusink_init): * sys/dxr3/dxr3videosink.c: (dxr3videosink_init): * sys/qcam/gstqcamsrc.c: (gst_qcamsrc_init): Fix leaks.
2007-06-22 10:46:33 +00:00
freeze->srcpad =
gst_pad_new_from_static_template (&gst_freeze_src_template, "src");
gst_element_add_pad (GST_ELEMENT (freeze), freeze->srcpad);
gst_pad_set_getcaps_function (freeze->srcpad, gst_pad_proxy_getcaps);
freeze->timestamp_offset = 0;
freeze->running_time = 0;
freeze->current = NULL;
freeze->max_buffers = 1;
freeze->on_flush = FALSE;
freeze->buffers = g_queue_new ();
}
static void
gst_freeze_dispose (GObject * object)
{
GstFreeze *freeze = GST_FREEZE (object);
gst_freeze_clear_buffer (freeze);
g_queue_free (freeze->buffers);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gst_freeze_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstFreeze *freeze = GST_FREEZE (object);
switch (prop_id) {
case ARG_MAX_BUFFERS:
freeze->max_buffers = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_freeze_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstFreeze *freeze = GST_FREEZE (object);
switch (prop_id) {
case ARG_MAX_BUFFERS:
g_value_set_uint (value, freeze->max_buffers);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GstFlowReturn
gst_freeze_chain (GstPad * pad, GstBuffer * buffer)
{
return gst_freeze_play (pad, buffer);
}
static GstStateChangeReturn
gst_freeze_change_state (GstElement * element, GstStateChange transition)
{
GstFreeze *freeze = GST_FREEZE (element);
GstStateChangeReturn return_val = GST_STATE_CHANGE_SUCCESS;
switch (transition) {
case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
case GST_STATE_CHANGE_NULL_TO_READY:
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
freeze->timestamp_offset = freeze->running_time = 0;
break;
default:
break;
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return_val =
GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
case GST_STATE_CHANGE_READY_TO_NULL:
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
freeze->timestamp_offset = freeze->running_time = 0;
break;
default:
break;
}
return return_val;
}
static GstFlowReturn
gst_freeze_play (GstPad * pad, GstBuffer * buff)
{
GstFreeze *freeze;
guint64 cur_offset;
GstFlowReturn ret = GST_FLOW_OK;
freeze = GST_FREEZE (gst_pad_get_parent (pad));
if (freeze->on_flush) {
g_object_unref (freeze);
return GST_FLOW_WRONG_STATE;
}
cur_offset = freeze->offset;
/* If it is working in push mode this function will be called by "_chain"
and buff will never be NULL. In pull mode this function will be called
by _loop and buff will be NULL */
if (!buff) {
ret =
gst_pad_pull_range (GST_PAD (freeze->sinkpad), freeze->offset, 4096,
&buff);
if (ret != GST_FLOW_OK) {
gst_object_unref (freeze);
return ret;
}
freeze->offset += GST_BUFFER_SIZE (buff);
}
if (g_queue_get_length (freeze->buffers) < freeze->max_buffers ||
freeze->max_buffers == 0) {
g_queue_push_tail (freeze->buffers, buff);
GST_DEBUG_OBJECT (freeze, "accepted buffer %u",
g_queue_get_length (freeze->buffers) - 1);
} else {
gst_buffer_unref (buff);
}
if (freeze->current != NULL) {
GST_DEBUG_OBJECT (freeze, "switching to next buffer");
freeze->current = g_queue_peek_nth (freeze->buffers,
g_queue_index (freeze->buffers, (gpointer) freeze->current) + 1);
}
if (freeze->current == NULL) {
if (freeze->max_buffers > 1)
GST_DEBUG_OBJECT (freeze, "restarting the loop");
freeze->current = g_queue_peek_head (freeze->buffers);
}
GST_BUFFER_TIMESTAMP (freeze->current) = freeze->timestamp_offset +
freeze->running_time;
freeze->running_time += GST_BUFFER_DURATION (freeze->current);
gst_buffer_ref (freeze->current);
ret = gst_pad_push (freeze->srcpad, freeze->current);
gst_object_unref (freeze);
return ret;
}
static void
gst_freeze_loop (GstPad * pad)
{
gst_freeze_play (pad, NULL);
}
static gboolean
gst_freeze_sink_activate (GstPad * sinkpad)
{
GstFreeze *freeze;
freeze = GST_FREEZE (GST_PAD_PARENT (sinkpad));
if (gst_pad_check_pull_range (sinkpad)) {
return gst_pad_activate_pull (sinkpad, TRUE);
} else {
return gst_pad_activate_push (sinkpad, TRUE);
}
}
static gboolean
gst_freeze_sink_activate_pull (GstPad * sinkpad, gboolean active)
{
gboolean result;
if (active) {
/* if we have a scheduler we can start the task */
result = gst_pad_start_task (sinkpad,
(GstTaskFunction) gst_freeze_loop, sinkpad);
} else {
result = gst_pad_stop_task (sinkpad);
}
return result;
}
static void
gst_freeze_buffer_free (gpointer data, gpointer user_data)
{
gst_buffer_unref (GST_BUFFER (data));
}
static void
gst_freeze_clear_buffer (GstFreeze * freeze)
{
if (freeze->buffers != NULL) {
g_queue_foreach (freeze->buffers, gst_freeze_buffer_free, NULL);
}
freeze->current = NULL;
freeze->running_time = 0;
}
static gboolean
gst_freeze_sink_event (GstPad * pad, GstEvent * event)
{
gboolean ret = TRUE;
GstFreeze *freeze = GST_FREEZE (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
GST_DEBUG_OBJECT (freeze, "EOS on sink pad %s",
gst_pad_get_name (GST_PAD (freeze->sinkpad)));
gst_event_unref (event);
break;
case GST_EVENT_NEWSEGMENT:
/* FALL TROUGH */
case GST_EVENT_FLUSH_STOP:
gst_freeze_clear_buffer (freeze);
/* FALL TROUGH */
default:
ret = gst_pad_event_default (GST_PAD (freeze->sinkpad), event);
break;
}
gst_object_unref (freeze);
return ret;
}
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (freeze_debug, "freeze", 0, "Stream freezer");
return gst_element_register (plugin, "freeze", GST_RANK_NONE,
GST_TYPE_FREEZE);
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"freeze",
"Stream freezer",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
/*
* Local variables:
* mode: c
* file-style: k&r
* c-basic-offset: 2
* arch-tag: fb0ee62b-cf74-46c0-8e62-93b58bacc0ed
* End:
*/