mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 18:51:11 +00:00
audiorate: add skip-to-first property
API: GstAudioRate::skip-to-first
This commit is contained in:
parent
bb0dc56114
commit
d17c4c28d5
2 changed files with 31 additions and 1 deletions
|
@ -78,6 +78,7 @@ enum
|
||||||
|
|
||||||
#define DEFAULT_SILENT TRUE
|
#define DEFAULT_SILENT TRUE
|
||||||
#define DEFAULT_TOLERANCE 0
|
#define DEFAULT_TOLERANCE 0
|
||||||
|
#define DEFAULT_SKIP_TO_FIRST FALSE
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -88,7 +89,7 @@ enum
|
||||||
ARG_DROP,
|
ARG_DROP,
|
||||||
ARG_SILENT,
|
ARG_SILENT,
|
||||||
ARG_TOLERANCE,
|
ARG_TOLERANCE,
|
||||||
/* FILL ME */
|
ARG_SKIP_TO_FIRST
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_audio_rate_src_template =
|
static GstStaticPadTemplate gst_audio_rate_src_template =
|
||||||
|
@ -212,6 +213,18 @@ gst_audio_rate_class_init (GstAudioRateClass * klass)
|
||||||
0, G_MAXUINT64, DEFAULT_TOLERANCE,
|
0, G_MAXUINT64, DEFAULT_TOLERANCE,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstAudioRate:skip-to-first:
|
||||||
|
*
|
||||||
|
* Don't produce buffers before the first one we receive.
|
||||||
|
*
|
||||||
|
* Since: 0.10.33
|
||||||
|
**/
|
||||||
|
g_object_class_install_property (object_class, ARG_SKIP_TO_FIRST,
|
||||||
|
g_param_spec_boolean ("skip-to-first", "Skip to first buffer",
|
||||||
|
"Don't produce buffers before the first one we receive",
|
||||||
|
DEFAULT_SKIP_TO_FIRST, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
element_class->change_state = gst_audio_rate_change_state;
|
element_class->change_state = gst_audio_rate_change_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,6 +569,16 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
|
||||||
audiorate->next_offset = pos;
|
audiorate->next_offset = pos;
|
||||||
audiorate->next_ts = gst_util_uint64_scale_int (audiorate->next_offset,
|
audiorate->next_ts = gst_util_uint64_scale_int (audiorate->next_offset,
|
||||||
GST_SECOND, audiorate->rate);
|
GST_SECOND, audiorate->rate);
|
||||||
|
|
||||||
|
if (audiorate->skip_to_first && GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
|
||||||
|
GST_DEBUG_OBJECT (audiorate, "but skipping to first buffer instead");
|
||||||
|
pos = gst_util_uint64_scale_int (GST_BUFFER_TIMESTAMP (buf),
|
||||||
|
audiorate->rate, GST_SECOND);
|
||||||
|
GST_DEBUG_OBJECT (audiorate, "so resync to offset %" G_GINT64_FORMAT,
|
||||||
|
pos);
|
||||||
|
audiorate->next_offset = pos;
|
||||||
|
audiorate->next_ts = GST_BUFFER_TIMESTAMP (buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
audiorate->in++;
|
audiorate->in++;
|
||||||
|
@ -768,6 +791,9 @@ gst_audio_rate_set_property (GObject * object,
|
||||||
case ARG_TOLERANCE:
|
case ARG_TOLERANCE:
|
||||||
audiorate->tolerance = g_value_get_uint64 (value);
|
audiorate->tolerance = g_value_get_uint64 (value);
|
||||||
break;
|
break;
|
||||||
|
case ARG_SKIP_TO_FIRST:
|
||||||
|
audiorate->skip_to_first = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -799,6 +825,9 @@ gst_audio_rate_get_property (GObject * object,
|
||||||
case ARG_TOLERANCE:
|
case ARG_TOLERANCE:
|
||||||
g_value_set_uint64 (value, audiorate->tolerance);
|
g_value_set_uint64 (value, audiorate->tolerance);
|
||||||
break;
|
break;
|
||||||
|
case ARG_SKIP_TO_FIRST:
|
||||||
|
g_value_set_boolean (value, audiorate->skip_to_first);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -58,6 +58,7 @@ struct _GstAudioRate
|
||||||
guint64 in, out, add, drop;
|
guint64 in, out, add, drop;
|
||||||
gboolean silent;
|
gboolean silent;
|
||||||
guint64 tolerance;
|
guint64 tolerance;
|
||||||
|
gboolean skip_to_first;
|
||||||
|
|
||||||
/* audio state */
|
/* audio state */
|
||||||
guint64 next_offset;
|
guint64 next_offset;
|
||||||
|
|
Loading…
Reference in a new issue