mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-29 19:50:40 +00:00
baseparse: add skip property
This commit is contained in:
parent
038821d30e
commit
ba3d5da1ee
1 changed files with 78 additions and 3 deletions
|
@ -266,6 +266,10 @@ struct _GstBaseParsePrivate
|
|||
gboolean exact_position;
|
||||
/* seek events are temporarily kept to match them with newsegments */
|
||||
GSList *pending_seeks;
|
||||
|
||||
/* property */
|
||||
/* number of initial frames to discard */
|
||||
gint skip;
|
||||
};
|
||||
|
||||
typedef struct _GstBaseParseSeek
|
||||
|
@ -276,6 +280,23 @@ typedef struct _GstBaseParseSeek
|
|||
GstClockTime start_ts;
|
||||
} GstBaseParseSeek;
|
||||
|
||||
/* signals and args */
|
||||
enum
|
||||
{
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_SKIP
|
||||
/* FILL ME */
|
||||
};
|
||||
|
||||
#define PROP_DEFAULT_SKIP 0
|
||||
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
static void gst_base_parse_class_init (GstBaseParseClass * klass);
|
||||
|
@ -314,6 +335,10 @@ static void gst_base_parse_reset (GstBaseParse * parse);
|
|||
|
||||
static void gst_base_parse_set_index (GstElement * element, GstIndex * index);
|
||||
static GstIndex *gst_base_parse_get_index (GstElement * element);
|
||||
static void gst_base_parse_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_base_parse_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
|
||||
static gboolean gst_base_parse_sink_activate (GstPad * sinkpad);
|
||||
static gboolean gst_base_parse_sink_activate_push (GstPad * pad,
|
||||
|
@ -403,6 +428,14 @@ gst_base_parse_class_init (GstBaseParseClass * klass)
|
|||
gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_base_parse_set_index);
|
||||
gstelement_class->get_index = GST_DEBUG_FUNCPTR (gst_base_parse_get_index);
|
||||
|
||||
gobject_class->set_property = gst_base_parse_set_property;
|
||||
gobject_class->get_property = gst_base_parse_get_property;
|
||||
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SKIP,
|
||||
g_param_spec_int ("skip", "skip", "Discard number of initial frames",
|
||||
0, G_MAXINT, PROP_DEFAULT_SKIP,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/* Default handlers */
|
||||
klass->check_valid_frame = gst_base_parse_check_frame;
|
||||
klass->parse_frame = gst_base_parse_parse_frame;
|
||||
|
@ -460,6 +493,7 @@ gst_base_parse_init (GstBaseParse * parse, GstBaseParseClass * bclass)
|
|||
parse->adapter = gst_adapter_new ();
|
||||
|
||||
parse->priv->pad_mode = GST_ACTIVATE_NONE;
|
||||
parse->priv->skip = PROP_DEFAULT_SKIP;
|
||||
|
||||
/* init state */
|
||||
gst_base_parse_reset (parse);
|
||||
|
@ -1501,9 +1535,15 @@ gst_base_parse_push_buffer (GstBaseParse * parse, GstBuffer * buffer)
|
|||
gst_buffer_unref (buffer);
|
||||
ret = GST_FLOW_OK;
|
||||
} else if (ret == GST_FLOW_OK) {
|
||||
ret = gst_pad_push (parse->srcpad, buffer);
|
||||
GST_LOG_OBJECT (parse, "frame (%d bytes) pushed: %s",
|
||||
GST_BUFFER_SIZE (buffer), gst_flow_get_name (ret));
|
||||
if (G_LIKELY (!parse->priv->skip)) {
|
||||
ret = gst_pad_push (parse->srcpad, buffer);
|
||||
GST_LOG_OBJECT (parse, "frame (%d bytes) pushed: %s",
|
||||
GST_BUFFER_SIZE (buffer), gst_flow_get_name (ret));
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (parse, "initial frame (%d bytes) discarded",
|
||||
GST_BUFFER_SIZE (buffer));
|
||||
parse->priv->skip--;
|
||||
}
|
||||
} else {
|
||||
gst_buffer_unref (buffer);
|
||||
GST_LOG_OBJECT (parse, "frame (%d bytes) not pushed: %s",
|
||||
|
@ -2871,6 +2911,41 @@ gst_base_parse_get_index (GstElement * element)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_base_parse_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstBaseParse *parse;
|
||||
|
||||
parse = GST_BASE_PARSE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SKIP:
|
||||
parse->priv->skip = g_value_get_int (value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_base_parse_get_property (GObject * object, guint prop_id, GValue * value,
|
||||
GParamSpec * pspec)
|
||||
{
|
||||
GstBaseParse *parse;
|
||||
|
||||
parse = GST_BASE_PARSE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SKIP:
|
||||
g_value_set_int (value, parse->priv->skip);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_base_parse_change_state (GstElement * element, GstStateChange transition)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue