2007-08-14 13:50:43 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2007 Nokia Corporation (contact <stefan.kost@nokia.com>)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2007-08-14 13:50:43 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* SECTION:element-rndbuffersize
|
2018-10-22 09:39:24 +00:00
|
|
|
* @title: rndbuffersize
|
2007-08-14 13:50:43 +00:00
|
|
|
*
|
|
|
|
* This element pulls buffers with random sizes from the source.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2012-05-08 17:45:34 +00:00
|
|
|
#include "config.h"
|
2007-08-14 13:50:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2012-06-28 19:03:05 +00:00
|
|
|
#include <gst/base/gstadapter.h>
|
2007-08-14 13:50:43 +00:00
|
|
|
|
2021-02-15 13:55:15 +00:00
|
|
|
#include "gstdebugutilselements.h"
|
|
|
|
|
2007-08-14 13:50:43 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_rnd_buffer_size_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_rnd_buffer_size_debug
|
|
|
|
|
|
|
|
#define GST_TYPE_RND_BUFFER_SIZE (gst_rnd_buffer_size_get_type())
|
|
|
|
#define GST_RND_BUFFER_SIZE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RND_BUFFER_SIZE,GstRndBufferSize))
|
|
|
|
#define GST_RND_BUFFER_SIZE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RND_BUFFER_SIZE,GstRndBufferSizeClass))
|
|
|
|
#define GST_IS_RND_BUFFER_SIZE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RND_BUFFER_SIZE))
|
|
|
|
#define GST_IS_RND_BUFFER_SIZE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RND_BUFFER_SIZE))
|
|
|
|
|
|
|
|
typedef struct _GstRndBufferSize GstRndBufferSize;
|
|
|
|
typedef struct _GstRndBufferSizeClass GstRndBufferSizeClass;
|
|
|
|
|
|
|
|
struct _GstRndBufferSize
|
|
|
|
{
|
|
|
|
GstElement parent;
|
|
|
|
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
/*< private > */
|
2007-08-14 13:50:43 +00:00
|
|
|
GRand *rand;
|
2012-06-09 15:53:54 +00:00
|
|
|
guint seed;
|
|
|
|
gint min, max;
|
2007-08-14 13:50:43 +00:00
|
|
|
|
|
|
|
GstPad *sinkpad, *srcpad;
|
|
|
|
guint64 offset;
|
2012-05-08 17:45:34 +00:00
|
|
|
|
|
|
|
gboolean need_newsegment;
|
2012-06-28 19:03:05 +00:00
|
|
|
|
|
|
|
GstAdapter *adapter;
|
2007-08-14 13:50:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstRndBufferSizeClass
|
|
|
|
{
|
|
|
|
GstElementClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2015-04-27 10:22:11 +00:00
|
|
|
PROP_SEED = 1,
|
|
|
|
PROP_MINIMUM,
|
|
|
|
PROP_MAXIMUM
|
2007-08-14 13:50:43 +00:00
|
|
|
};
|
|
|
|
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
#define DEFAULT_SEED 0
|
|
|
|
#define DEFAULT_MIN 1
|
|
|
|
#define DEFAULT_MAX (8*1024)
|
|
|
|
|
|
|
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
2007-08-14 13:50:43 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
2007-08-14 13:50:43 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
2007-08-16 07:40:48 +00:00
|
|
|
static void gst_rnd_buffer_size_finalize (GObject * object);
|
2007-08-14 13:50:43 +00:00
|
|
|
static void gst_rnd_buffer_size_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_rnd_buffer_size_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
2011-11-18 12:57:20 +00:00
|
|
|
static gboolean gst_rnd_buffer_size_activate (GstPad * pad, GstObject * parent);
|
2011-11-21 12:37:01 +00:00
|
|
|
static gboolean gst_rnd_buffer_size_activate_mode (GstPad * pad,
|
|
|
|
GstObject * parent, GstPadMode mode, gboolean active);
|
2007-08-14 13:50:43 +00:00
|
|
|
static void gst_rnd_buffer_size_loop (GstRndBufferSize * self);
|
|
|
|
static GstStateChangeReturn gst_rnd_buffer_size_change_state (GstElement *
|
|
|
|
element, GstStateChange transition);
|
2012-05-09 10:15:21 +00:00
|
|
|
static gboolean gst_rnd_buffer_size_src_event (GstPad * pad,
|
|
|
|
GstObject * parent, GstEvent * event);
|
2012-06-28 19:03:05 +00:00
|
|
|
static gboolean gst_rnd_buffer_size_sink_event (GstPad * pad,
|
|
|
|
GstObject * parent, GstEvent * event);
|
|
|
|
static GstFlowReturn gst_rnd_buffer_size_chain (GstPad * pad,
|
|
|
|
GstObject * parent, GstBuffer * buffer);
|
2007-08-14 13:50:43 +00:00
|
|
|
|
2010-03-17 17:23:00 +00:00
|
|
|
GType gst_rnd_buffer_size_get_type (void);
|
2011-06-07 10:06:08 +00:00
|
|
|
#define gst_rnd_buffer_size_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE (GstRndBufferSize, gst_rnd_buffer_size, GST_TYPE_ELEMENT);
|
2021-02-15 13:55:15 +00:00
|
|
|
GST_ELEMENT_REGISTER_DEFINE (rndbuffersize, "rndbuffersize",
|
|
|
|
GST_RANK_NONE, gst_rnd_buffer_size_get_type ());
|
2007-08-14 13:50:43 +00:00
|
|
|
|
|
|
|
static void
|
2011-06-07 10:06:08 +00:00
|
|
|
gst_rnd_buffer_size_class_init (GstRndBufferSizeClass * klass)
|
2007-08-14 13:50:43 +00:00
|
|
|
{
|
2011-06-07 10:06:08 +00:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_rnd_buffer_size_debug, "rndbuffersize", 0,
|
|
|
|
"rndbuffersize element");
|
|
|
|
|
|
|
|
gobject_class->set_property = gst_rnd_buffer_size_set_property;
|
|
|
|
gobject_class->get_property = gst_rnd_buffer_size_get_property;
|
|
|
|
gobject_class->finalize = gst_rnd_buffer_size_finalize;
|
2007-08-14 13:50:43 +00:00
|
|
|
|
2016-03-04 01:30:12 +00:00
|
|
|
gst_element_class_add_static_pad_template (gstelement_class, &sink_template);
|
|
|
|
gst_element_class_add_static_pad_template (gstelement_class, &src_template);
|
2007-08-14 13:50:43 +00:00
|
|
|
|
2012-04-09 23:51:41 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class, "Random buffer size",
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
"Testing", "pull random sized buffers",
|
2011-04-28 12:37:40 +00:00
|
|
|
"Stefan Kost <stefan.kost@nokia.com>");
|
2007-08-14 13:50:43 +00:00
|
|
|
|
|
|
|
gstelement_class->change_state =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_change_state);
|
|
|
|
|
2015-04-27 10:22:11 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_SEED,
|
2012-06-09 15:53:54 +00:00
|
|
|
g_param_spec_uint ("seed", "random number seed",
|
2007-08-14 13:50:43 +00:00
|
|
|
"seed for randomness (initialized when going from READY to PAUSED)",
|
2010-10-13 14:21:23 +00:00
|
|
|
0, G_MAXUINT32, DEFAULT_SEED,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2015-04-27 10:22:11 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_MINIMUM,
|
2019-09-02 12:27:35 +00:00
|
|
|
g_param_spec_int ("min", "minimum", "minimum buffer size",
|
2010-10-13 14:21:23 +00:00
|
|
|
0, G_MAXINT32, DEFAULT_MIN,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2015-04-27 10:22:11 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_MAXIMUM,
|
2012-06-09 15:53:54 +00:00
|
|
|
g_param_spec_int ("max", "maximum", "maximum buffer size",
|
2010-10-13 14:21:23 +00:00
|
|
|
1, G_MAXINT32, DEFAULT_MAX,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2007-08-14 13:50:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-06-07 10:06:08 +00:00
|
|
|
gst_rnd_buffer_size_init (GstRndBufferSize * self)
|
2007-08-14 13:50:43 +00:00
|
|
|
{
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
self->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
|
2007-08-14 13:50:43 +00:00
|
|
|
gst_pad_set_activate_function (self->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate));
|
2011-11-21 12:37:01 +00:00
|
|
|
gst_pad_set_activatemode_function (self->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate_mode));
|
2012-06-28 19:03:05 +00:00
|
|
|
gst_pad_set_event_function (self->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_sink_event));
|
|
|
|
gst_pad_set_chain_function (self->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_chain));
|
2013-12-24 13:40:25 +00:00
|
|
|
GST_OBJECT_FLAG_SET (self->sinkpad, GST_PAD_FLAG_PROXY_CAPS);
|
|
|
|
GST_OBJECT_FLAG_SET (self->sinkpad, GST_PAD_FLAG_PROXY_ALLOCATION);
|
|
|
|
GST_OBJECT_FLAG_SET (self->sinkpad, GST_PAD_FLAG_PROXY_SCHEDULING);
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
|
2007-08-14 13:50:43 +00:00
|
|
|
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
self->srcpad = gst_pad_new_from_static_template (&src_template, "src");
|
2012-05-08 18:07:04 +00:00
|
|
|
gst_pad_set_event_function (self->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_src_event));
|
2013-12-24 13:40:25 +00:00
|
|
|
GST_OBJECT_FLAG_SET (self->srcpad, GST_PAD_FLAG_PROXY_CAPS);
|
|
|
|
GST_OBJECT_FLAG_SET (self->srcpad, GST_PAD_FLAG_PROXY_ALLOCATION);
|
|
|
|
GST_OBJECT_FLAG_SET (self->srcpad, GST_PAD_FLAG_PROXY_SCHEDULING);
|
2007-08-14 13:50:43 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-16 07:40:48 +00:00
|
|
|
static void
|
|
|
|
gst_rnd_buffer_size_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstRndBufferSize *self = GST_RND_BUFFER_SIZE (object);
|
|
|
|
|
|
|
|
if (self->rand) {
|
|
|
|
g_rand_free (self->rand);
|
|
|
|
self->rand = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-14 13:50:43 +00:00
|
|
|
static void
|
|
|
|
gst_rnd_buffer_size_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstRndBufferSize *self = GST_RND_BUFFER_SIZE (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2015-04-27 10:22:11 +00:00
|
|
|
case PROP_SEED:
|
2012-06-09 15:53:54 +00:00
|
|
|
self->seed = g_value_get_uint (value);
|
2007-08-14 13:50:43 +00:00
|
|
|
break;
|
2015-04-27 10:22:11 +00:00
|
|
|
case PROP_MINIMUM:
|
2012-06-09 15:53:54 +00:00
|
|
|
self->min = g_value_get_int (value);
|
2007-08-14 13:50:43 +00:00
|
|
|
break;
|
2015-04-27 10:22:11 +00:00
|
|
|
case PROP_MAXIMUM:
|
2012-06-09 15:53:54 +00:00
|
|
|
self->max = g_value_get_int (value);
|
2007-08-14 13:50:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rnd_buffer_size_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstRndBufferSize *self = GST_RND_BUFFER_SIZE (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2015-04-27 10:22:11 +00:00
|
|
|
case PROP_SEED:
|
2012-06-09 15:53:54 +00:00
|
|
|
g_value_set_uint (value, self->seed);
|
2007-08-14 13:50:43 +00:00
|
|
|
break;
|
2015-04-27 10:22:11 +00:00
|
|
|
case PROP_MINIMUM:
|
2012-06-09 15:53:54 +00:00
|
|
|
g_value_set_int (value, self->min);
|
2007-08-14 13:50:43 +00:00
|
|
|
break;
|
2015-04-27 10:22:11 +00:00
|
|
|
case PROP_MAXIMUM:
|
2012-06-09 15:53:54 +00:00
|
|
|
g_value_set_int (value, self->max);
|
2007-08-14 13:50:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-18 12:57:20 +00:00
|
|
|
gst_rnd_buffer_size_activate (GstPad * pad, GstObject * parent)
|
2007-08-14 13:50:43 +00:00
|
|
|
{
|
2011-07-10 09:40:40 +00:00
|
|
|
GstQuery *query;
|
|
|
|
gboolean pull_mode;
|
|
|
|
|
|
|
|
query = gst_query_new_scheduling ();
|
|
|
|
|
2012-06-28 19:03:05 +00:00
|
|
|
if (gst_pad_peer_query (pad, query))
|
2012-09-11 15:36:51 +00:00
|
|
|
pull_mode = gst_query_has_scheduling_mode_with_flags (query,
|
|
|
|
GST_PAD_MODE_PULL, GST_SCHEDULING_FLAG_SEEKABLE);
|
2012-06-28 19:03:05 +00:00
|
|
|
else
|
|
|
|
pull_mode = FALSE;
|
2011-07-10 09:40:40 +00:00
|
|
|
|
2011-11-18 16:59:16 +00:00
|
|
|
gst_query_unref (query);
|
2011-07-10 09:40:40 +00:00
|
|
|
|
2012-06-28 19:03:05 +00:00
|
|
|
if (pull_mode) {
|
|
|
|
GST_DEBUG_OBJECT (pad, "activating pull");
|
|
|
|
return gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (pad, "activating push");
|
|
|
|
return gst_pad_activate_mode (pad, GST_PAD_MODE_PUSH, TRUE);
|
2007-08-14 13:50:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-21 12:37:01 +00:00
|
|
|
gst_rnd_buffer_size_activate_mode (GstPad * pad, GstObject * parent,
|
|
|
|
GstPadMode mode, gboolean active)
|
2007-08-14 13:50:43 +00:00
|
|
|
{
|
2011-11-21 12:37:01 +00:00
|
|
|
gboolean res;
|
2011-11-18 12:57:20 +00:00
|
|
|
GstRndBufferSize *self = GST_RND_BUFFER_SIZE (parent);
|
2007-08-14 13:50:43 +00:00
|
|
|
|
2011-11-21 12:37:01 +00:00
|
|
|
switch (mode) {
|
|
|
|
case GST_PAD_MODE_PULL:
|
|
|
|
if (active) {
|
|
|
|
GST_INFO_OBJECT (self, "starting pull");
|
|
|
|
res =
|
|
|
|
gst_pad_start_task (pad, (GstTaskFunction) gst_rnd_buffer_size_loop,
|
2012-06-20 08:33:42 +00:00
|
|
|
self, NULL);
|
2012-05-08 17:45:34 +00:00
|
|
|
self->need_newsegment = TRUE;
|
2011-11-21 12:37:01 +00:00
|
|
|
} else {
|
|
|
|
GST_INFO_OBJECT (self, "stopping pull");
|
|
|
|
res = gst_pad_stop_task (pad);
|
|
|
|
}
|
|
|
|
break;
|
2012-06-28 19:03:05 +00:00
|
|
|
case GST_PAD_MODE_PUSH:
|
|
|
|
GST_INFO_OBJECT (self, "%sactivating in push mode", (active) ? "" : "de");
|
|
|
|
res = TRUE;
|
|
|
|
break;
|
2011-11-21 12:37:01 +00:00
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
2007-08-14 13:50:43 +00:00
|
|
|
}
|
2011-11-21 12:37:01 +00:00
|
|
|
return res;
|
2007-08-14 13:50:43 +00:00
|
|
|
}
|
|
|
|
|
2012-05-08 18:07:04 +00:00
|
|
|
static gboolean
|
2012-05-09 10:15:21 +00:00
|
|
|
gst_rnd_buffer_size_src_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event)
|
2012-05-08 18:07:04 +00:00
|
|
|
{
|
|
|
|
GstRndBufferSize *self;
|
|
|
|
GstSeekType start_type;
|
|
|
|
GstSeekFlags flags;
|
|
|
|
GstFormat format;
|
|
|
|
gint64 start;
|
|
|
|
|
|
|
|
if (GST_EVENT_TYPE (event) != GST_EVENT_SEEK) {
|
2013-12-24 13:40:25 +00:00
|
|
|
return gst_pad_event_default (pad, parent, event);
|
2012-05-08 18:07:04 +00:00
|
|
|
}
|
|
|
|
|
2012-05-09 10:15:21 +00:00
|
|
|
self = GST_RND_BUFFER_SIZE (parent);
|
2012-05-08 18:07:04 +00:00
|
|
|
gst_event_parse_seek (event, NULL, &format, &flags, &start_type, &start,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
if (format != GST_FORMAT_BYTES) {
|
|
|
|
GST_WARNING_OBJECT (pad, "only BYTE format supported");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (start_type != GST_SEEK_TYPE_SET) {
|
|
|
|
GST_WARNING_OBJECT (pad, "only SEEK_TYPE_SET supported");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((flags & GST_SEEK_FLAG_FLUSH)) {
|
|
|
|
gst_pad_push_event (self->srcpad, gst_event_new_flush_start ());
|
|
|
|
gst_pad_push_event (self->sinkpad, gst_event_new_flush_start ());
|
|
|
|
} else {
|
|
|
|
gst_pad_pause_task (self->sinkpad);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_PAD_STREAM_LOCK (self->sinkpad);
|
|
|
|
|
2012-05-09 14:14:55 +00:00
|
|
|
if ((flags & GST_SEEK_FLAG_FLUSH)) {
|
|
|
|
gst_pad_push_event (self->srcpad, gst_event_new_flush_stop (TRUE));
|
|
|
|
gst_pad_push_event (self->sinkpad, gst_event_new_flush_stop (TRUE));
|
|
|
|
}
|
2012-05-09 11:24:37 +00:00
|
|
|
|
2012-05-08 18:07:04 +00:00
|
|
|
GST_INFO_OBJECT (pad, "seeking to offset %" G_GINT64_FORMAT, start);
|
|
|
|
|
|
|
|
self->offset = start;
|
|
|
|
self->need_newsegment = TRUE;
|
|
|
|
|
|
|
|
gst_pad_start_task (self->sinkpad, (GstTaskFunction) gst_rnd_buffer_size_loop,
|
2012-06-20 08:33:42 +00:00
|
|
|
self, NULL);
|
2012-05-08 18:07:04 +00:00
|
|
|
|
|
|
|
GST_PAD_STREAM_UNLOCK (self->sinkpad);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2007-08-14 13:50:43 +00:00
|
|
|
|
2012-06-28 19:03:05 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_rnd_buffer_size_drain_adapter (GstRndBufferSize * self, gboolean eos)
|
|
|
|
{
|
|
|
|
GstFlowReturn flow;
|
|
|
|
GstBuffer *buf;
|
|
|
|
guint num_bytes, avail;
|
|
|
|
|
|
|
|
flow = GST_FLOW_OK;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (self->min > self->max))
|
|
|
|
goto bogus_minmax;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (self->min != self->max) {
|
|
|
|
num_bytes = g_rand_int_range (self->rand, self->min, self->max);
|
|
|
|
} else {
|
|
|
|
num_bytes = self->min;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (self, "pulling %u bytes out of adapter", num_bytes);
|
|
|
|
|
|
|
|
buf = gst_adapter_take_buffer (self->adapter, num_bytes);
|
|
|
|
|
|
|
|
if (buf == NULL) {
|
|
|
|
if (!eos) {
|
|
|
|
GST_LOG_OBJECT (self, "not enough bytes in adapter");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
avail = gst_adapter_available (self->adapter);
|
|
|
|
|
|
|
|
if (avail == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (avail < self->min) {
|
|
|
|
GST_WARNING_OBJECT (self, "discarding %u bytes at end (min=%u)",
|
|
|
|
avail, self->min);
|
|
|
|
gst_adapter_clear (self->adapter);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
buf = gst_adapter_take_buffer (self->adapter, avail);
|
|
|
|
g_assert (buf != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
flow = gst_pad_push (self->srcpad, buf);
|
|
|
|
}
|
|
|
|
while (flow == GST_FLOW_OK);
|
|
|
|
|
|
|
|
return flow;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
bogus_minmax:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (self, LIBRARY, SETTINGS,
|
|
|
|
("The minimum buffer size is smaller than the maximum buffer size."),
|
|
|
|
("buffer sizes: max=%d, min=%d", self->min, self->max));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_rnd_buffer_size_sink_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event)
|
|
|
|
{
|
|
|
|
GstRndBufferSize *rnd = GST_RND_BUFFER_SIZE (parent);
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
gst_rnd_buffer_size_drain_adapter (rnd, TRUE);
|
|
|
|
break;
|
|
|
|
case GST_EVENT_FLUSH_STOP:
|
|
|
|
if (rnd->adapter != NULL)
|
|
|
|
gst_adapter_clear (rnd->adapter);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-12-24 13:40:25 +00:00
|
|
|
return gst_pad_event_default (pad, parent, event);
|
2012-06-28 19:03:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_rnd_buffer_size_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
GstRndBufferSize *rnd = GST_RND_BUFFER_SIZE (parent);
|
|
|
|
GstFlowReturn flow;
|
|
|
|
|
|
|
|
if (rnd->adapter == NULL)
|
|
|
|
rnd->adapter = gst_adapter_new ();
|
|
|
|
|
|
|
|
gst_adapter_push (rnd->adapter, buf);
|
|
|
|
|
|
|
|
flow = gst_rnd_buffer_size_drain_adapter (rnd, FALSE);
|
|
|
|
|
|
|
|
if (flow != GST_FLOW_OK)
|
|
|
|
GST_INFO_OBJECT (rnd, "flow: %s", gst_flow_get_name (flow));
|
|
|
|
|
|
|
|
return flow;
|
|
|
|
}
|
|
|
|
|
2007-08-14 13:50:43 +00:00
|
|
|
static void
|
|
|
|
gst_rnd_buffer_size_loop (GstRndBufferSize * self)
|
|
|
|
{
|
|
|
|
GstBuffer *buf = NULL;
|
|
|
|
GstFlowReturn ret;
|
2011-07-10 09:40:40 +00:00
|
|
|
guint num_bytes, size;
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
|
|
|
|
if (G_UNLIKELY (self->min > self->max))
|
|
|
|
goto bogus_minmax;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (self->min != self->max)) {
|
|
|
|
num_bytes = g_rand_int_range (self->rand, self->min, self->max);
|
|
|
|
} else {
|
|
|
|
num_bytes = self->min;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (self, "pulling %u bytes at offset %" G_GUINT64_FORMAT,
|
|
|
|
num_bytes, self->offset);
|
2007-08-14 13:50:43 +00:00
|
|
|
|
|
|
|
ret = gst_pad_pull_range (self->sinkpad, self->offset, num_bytes, &buf);
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto pull_failed;
|
|
|
|
|
2011-07-10 09:40:40 +00:00
|
|
|
size = gst_buffer_get_size (buf);
|
|
|
|
|
|
|
|
if (size < num_bytes) {
|
|
|
|
GST_WARNING_OBJECT (self, "short buffer: %u bytes", size);
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
}
|
|
|
|
|
2012-05-08 17:45:34 +00:00
|
|
|
if (self->need_newsegment) {
|
|
|
|
GstSegment segment;
|
|
|
|
|
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
|
|
|
segment.start = self->offset;
|
|
|
|
gst_pad_push_event (self->srcpad, gst_event_new_segment (&segment));
|
|
|
|
self->need_newsegment = FALSE;
|
|
|
|
}
|
|
|
|
|
2011-07-10 09:40:40 +00:00
|
|
|
self->offset += size;
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
|
|
|
|
ret = gst_pad_push (self->srcpad, buf);
|
|
|
|
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto push_failed;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
pause_task:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (self, "pausing task");
|
|
|
|
gst_pad_pause_task (self->sinkpad);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pull_failed:
|
|
|
|
{
|
2012-01-03 14:26:21 +00:00
|
|
|
if (ret == GST_FLOW_EOS) {
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "eos");
|
|
|
|
gst_pad_push_event (self->srcpad, gst_event_new_eos ());
|
2007-08-14 13:50:43 +00:00
|
|
|
} else {
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
GST_WARNING_OBJECT (self, "pull_range flow: %s", gst_flow_get_name (ret));
|
2007-08-14 13:50:43 +00:00
|
|
|
}
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
goto pause_task;
|
|
|
|
}
|
2007-08-14 13:50:43 +00:00
|
|
|
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
push_failed:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (self, "push flow: %s", gst_flow_get_name (ret));
|
2012-01-03 14:26:21 +00:00
|
|
|
if (ret == GST_FLOW_EOS) {
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "eos");
|
2007-08-14 13:50:43 +00:00
|
|
|
gst_pad_push_event (self->srcpad, gst_event_new_eos ());
|
2012-01-03 14:26:21 +00:00
|
|
|
} else if (ret < GST_FLOW_EOS || ret == GST_FLOW_NOT_LINKED) {
|
2016-08-19 18:11:03 +00:00
|
|
|
GST_ELEMENT_FLOW_ERROR (self, ret);
|
2007-08-14 13:50:43 +00:00
|
|
|
}
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
goto pause_task;
|
|
|
|
}
|
|
|
|
|
|
|
|
bogus_minmax:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (self, LIBRARY, SETTINGS,
|
|
|
|
("The minimum buffer size is smaller than the maximum buffer size."),
|
2012-06-11 10:20:18 +00:00
|
|
|
("buffer sizes: max=%d, min=%d", self->min, self->max));
|
gst/debug/rndbuffersize.c: Bring rndbuffersize element into a state that doesn't require us to move it to -bad immedi...
Original commit message from CVS:
* gst/debug/rndbuffersize.c: (DEFAULT_SEED), (DEFAULT_MIN),
(DEFAULT_MAX), (src_template), (sink_template),
(gst_rnd_buffer_size_base_init), (gst_rnd_buffer_size_class_init),
(gst_rnd_buffer_size_init), (gst_rnd_buffer_size_activate),
(gst_rnd_buffer_size_loop), (gst_rnd_buffer_size_plugin_init):
Bring rndbuffersize element into a state that doesn't require us
to move it to -bad immediately. For one, fix up default min/max
values so that the element actuall works using the default values.
Also, don't ignore flow return values and do some kind of minimal
eos logic. Allow min=max to pull fixed-sized buffers. Bunch of
other gratuitious clean-ups.
2008-04-25 19:34:31 +00:00
|
|
|
goto pause_task;
|
2007-08-14 13:50:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_rnd_buffer_size_change_state (GstElement * element,
|
|
|
|
GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstRndBufferSize *self = GST_RND_BUFFER_SIZE (element);
|
|
|
|
GstStateChangeReturn ret;
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
|
|
|
self->offset = 0;
|
2007-08-16 07:40:48 +00:00
|
|
|
if (!self->rand) {
|
|
|
|
self->rand = g_rand_new_with_seed (self->seed);
|
|
|
|
}
|
2007-08-14 13:50:43 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2007-08-16 07:40:48 +00:00
|
|
|
if (self->rand) {
|
|
|
|
g_rand_free (self->rand);
|
|
|
|
self->rand = NULL;
|
|
|
|
}
|
2007-08-14 13:50:43 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
2012-06-28 19:03:05 +00:00
|
|
|
if (self->adapter) {
|
|
|
|
g_object_unref (self->adapter);
|
|
|
|
self->adapter = NULL;
|
|
|
|
}
|
2007-08-14 13:50:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|