Commit 157a65b1 authored by Wim Taymans's avatar Wim Taymans

Expose methods for some object properties so that subclasses can more easily configure them.

Original commit message from CVS:
* docs/libs/gst-plugins-base-libs-sections.txt:
* gst-libs/gst/audio/gstbaseaudiosink.c: (slave_method_get_type),
(gst_base_audio_sink_set_provide_clock),
(gst_base_audio_sink_get_provide_clock),
(gst_base_audio_sink_set_slave_method),
(gst_base_audio_sink_get_slave_method),
(gst_base_audio_sink_set_property),
(gst_base_audio_sink_get_property), (gst_base_audio_sink_drain),
(gst_base_audio_sink_none_slaving),
(gst_base_audio_sink_handle_slaving):
* gst-libs/gst/audio/gstbaseaudiosink.h:
Expose methods for some object properties so that subclasses can more
easily configure them.
Added slave method none, that completely disables slaving to the
internal clock.
API: gst_base_audio_sink_set_provide_clock()
API: gst_base_audio_sink_get_provide_clock()
API: gst_base_audio_sink_set_slave_method()
API: gst_base_audio_sink_get_slave_method()
* gst-libs/gst/audio/gstbaseaudiosrc.c:
(gst_base_audio_src_set_provide_clock),
(gst_base_audio_src_get_provide_clock),
(gst_base_audio_src_set_property),
(gst_base_audio_src_get_property), (gst_base_audio_src_create):
* gst-libs/gst/audio/gstbaseaudiosrc.h:
Expose methods for some object properties so that subclasses can more
easily configure them.
API: gst_base_audio_src_set_provide_clock()
API: gst_base_audio_src_get_provide_clock()
parent d834d1cb
2007-11-21 Wim Taymans <wim.taymans@gmail.com>
* docs/libs/gst-plugins-base-libs-sections.txt:
* gst-libs/gst/audio/gstbaseaudiosink.c: (slave_method_get_type),
(gst_base_audio_sink_set_provide_clock),
(gst_base_audio_sink_get_provide_clock),
(gst_base_audio_sink_set_slave_method),
(gst_base_audio_sink_get_slave_method),
(gst_base_audio_sink_set_property),
(gst_base_audio_sink_get_property), (gst_base_audio_sink_drain),
(gst_base_audio_sink_none_slaving),
(gst_base_audio_sink_handle_slaving):
* gst-libs/gst/audio/gstbaseaudiosink.h:
Expose methods for some object properties so that subclasses can more
easily configure them.
Added slave method none, that completely disables slaving to the
internal clock.
API: gst_base_audio_sink_set_provide_clock()
API: gst_base_audio_sink_get_provide_clock()
API: gst_base_audio_sink_set_slave_method()
API: gst_base_audio_sink_get_slave_method()
* gst-libs/gst/audio/gstbaseaudiosrc.c:
(gst_base_audio_src_set_provide_clock),
(gst_base_audio_src_get_provide_clock),
(gst_base_audio_src_set_property),
(gst_base_audio_src_get_property), (gst_base_audio_src_create):
* gst-libs/gst/audio/gstbaseaudiosrc.h:
Expose methods for some object properties so that subclasses can more
easily configure them.
API: gst_base_audio_src_set_provide_clock()
API: gst_base_audio_src_get_provide_clock()
2007-11-20 Wim Taymans <wim.taymans@gmail.com>
Patch by: Joe Peterson <lavajoe at gentoo dot org>
......@@ -98,6 +98,10 @@ GstBaseAudioSinkSlaveMethod
GST_BASE_AUDIO_SINK_CLOCK
GST_BASE_AUDIO_SINK_PAD
gst_base_audio_sink_create_ringbuffer
gst_base_audio_sink_set_provide_clock
gst_base_audio_sink_get_provide_clock
gst_base_audio_sink_set_slave_method
gst_base_audio_sink_get_slave_method
<SUBSECTION Standard>
GST_BASE_AUDIO_SINK
GST_IS_BASE_AUDIO_SINK
......@@ -118,6 +122,8 @@ GstBaseAudioSrcClass
GST_BASE_AUDIO_SRC_CLOCK
GST_BASE_AUDIO_SRC_PAD
gst_base_audio_src_create_ringbuffer
gst_base_audio_src_set_provide_clock
gst_base_audio_src_get_provide_clock
<SUBSECTION Standard>
GST_BASE_AUDIO_SRC
GST_IS_BASE_AUDIO_SRC
......
......@@ -94,6 +94,7 @@ slave_method_get_type (void)
static const GEnumValue slave_method[] = {
{GST_BASE_AUDIO_SINK_SLAVE_RESAMPLE, "Resampling slaving", "resample"},
{GST_BASE_AUDIO_SINK_SLAVE_SKEW, "Skew slaving", "skew"},
{GST_BASE_AUDIO_SINK_SLAVE_NONE, "No slaving", "none"},
{0, NULL, NULL},
};
......@@ -395,6 +396,97 @@ gst_base_audio_sink_get_time (GstClock * clock, GstBaseAudioSink * sink)
return result;
}
/**
* gst_base_audio_sink_set_provide_clock:
* @sink: a #GstBaseAudioSink
* @provide: new state
*
* Controls whether @sink will provide a clock or not. If @provide is %TRUE,
* gst_element_provide_clock() will return a clock that reflects the datarate
* of @sink. If @provide is %FALSE, gst_element_provide_clock() will return NULL.
*
* Since: 0.10.16
*/
void
gst_base_audio_sink_set_provide_clock (GstBaseAudioSink * sink,
gboolean provide)
{
g_return_if_fail (GST_IS_BASE_AUDIO_SINK (sink));
GST_OBJECT_LOCK (sink);
sink->provide_clock = provide;
GST_OBJECT_UNLOCK (sink);
}
/**
* gst_base_audio_sink_get_provide_clock:
* @sink: a #GstBaseAudioSink
*
* Queries whether @sink will provide a clock or not. See also
* gst_base_audio_sink_set_provide_clock.
*
* Returns: %TRUE if @sink will provide a clock.
*
* Since: 0.10.16
*/
gboolean
gst_base_audio_sink_get_provide_clock (GstBaseAudioSink * sink)
{
gboolean result;
g_return_val_if_fail (GST_IS_BASE_AUDIO_SINK (sink), FALSE);
GST_OBJECT_LOCK (sink);
result = sink->provide_clock;
GST_OBJECT_UNLOCK (sink);
return result;
}
/**
* gst_base_audio_sink_set_slave_method:
* @sink: a #GstBaseAudioSink
* @method: the new slave method
*
* Controls how clock slaving will be performed in @sink.
*
* Since: 0.10.16
*/
void
gst_base_audio_sink_set_slave_method (GstBaseAudioSink * sink,
GstBaseAudioSinkSlaveMethod method)
{
g_return_if_fail (GST_IS_BASE_AUDIO_SINK (sink));
GST_OBJECT_LOCK (sink);
sink->priv->slave_method = method;
GST_OBJECT_UNLOCK (sink);
}
/**
* gst_base_audio_sink_get_slave_method:
* @sink: a #GstBaseAudioSink
*
* Get the current slave method used by @sink.
*
* Returns: The current slave method used by @sink.
*
* Since: 0.10.16
*/
GstBaseAudioSinkSlaveMethod
gst_base_audio_sink_get_slave_method (GstBaseAudioSink * sink)
{
GstBaseAudioSinkSlaveMethod result;
g_return_val_if_fail (GST_IS_BASE_AUDIO_SINK (sink), -1);
GST_OBJECT_LOCK (sink);
result = sink->priv->slave_method;
GST_OBJECT_UNLOCK (sink);
return result;
}
static void
gst_base_audio_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
......@@ -411,12 +503,10 @@ gst_base_audio_sink_set_property (GObject * object, guint prop_id,
sink->latency_time = g_value_get_int64 (value);
break;
case PROP_PROVIDE_CLOCK:
GST_OBJECT_LOCK (sink);
sink->provide_clock = g_value_get_boolean (value);
GST_OBJECT_UNLOCK (sink);
gst_base_audio_sink_set_provide_clock (sink, g_value_get_boolean (value));
break;
case PROP_SLAVE_METHOD:
sink->priv->slave_method = g_value_get_enum (value);
gst_base_audio_sink_set_slave_method (sink, g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -440,12 +530,10 @@ gst_base_audio_sink_get_property (GObject * object, guint prop_id,
g_value_set_int64 (value, sink->latency_time);
break;
case PROP_PROVIDE_CLOCK:
GST_OBJECT_LOCK (sink);
g_value_set_boolean (value, sink->provide_clock);
GST_OBJECT_UNLOCK (sink);
g_value_set_boolean (value, gst_base_audio_sink_get_provide_clock (sink));
break;
case PROP_SLAVE_METHOD:
g_value_set_enum (value, sink->priv->slave_method);
g_value_set_enum (value, gst_base_audio_sink_get_slave_method (sink));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -842,6 +930,28 @@ gst_base_audio_sink_skew_slaving (GstBaseAudioSink * sink,
*srender_stop = render_stop;
}
/* apply the clock offset but do no slaving otherwise */
static void
gst_base_audio_sink_none_slaving (GstBaseAudioSink * sink,
GstClockTime render_start, GstClockTime render_stop,
GstClockTime * srender_start, GstClockTime * srender_stop)
{
GstClockTime cinternal, cexternal, crate_num, crate_denom;
/* get calibration parameters to compensate for offsets */
gst_clock_get_calibration (sink->provided_clock, &cinternal, &cexternal,
&crate_num, &crate_denom);
/* convert, ignoring speed */
render_start = clock_convert_external (render_start, cinternal, cexternal,
crate_num, crate_denom, sink->priv->us_latency);
render_stop = clock_convert_external (render_stop, cinternal, cexternal,
crate_num, crate_denom, sink->priv->us_latency);
*srender_start = render_start;
*srender_stop = render_stop;
}
/* converts render_start and render_stop to their slaved values */
static void
gst_base_audio_sink_handle_slaving (GstBaseAudioSink * sink,
......@@ -857,6 +967,10 @@ gst_base_audio_sink_handle_slaving (GstBaseAudioSink * sink,
gst_base_audio_sink_skew_slaving (sink, render_start, render_stop,
srender_start, srender_stop);
break;
case GST_BASE_AUDIO_SINK_SLAVE_NONE:
gst_base_audio_sink_none_slaving (sink, render_start, render_stop,
srender_start, srender_stop);
break;
default:
g_warning ("unknown slaving method %d", sink->priv->slave_method);
break;
......
......@@ -83,6 +83,7 @@ G_BEGIN_DECLS
* @GST_BASE_AUDIO_SINK_SLAVE_RESAMPLE: Resample to match the master clock
* @GST_BASE_AUDIO_SINK_SLAVE_SKEW: Adjust playout pointer when master clock
* drifts too much.
* @GST_BASE_AUDIO_SINK_SLAVE_NONE: No adjustment is done.
*
* Different possible clock slaving algorithms
*/
......@@ -90,6 +91,7 @@ typedef enum
{
GST_BASE_AUDIO_SINK_SLAVE_RESAMPLE,
GST_BASE_AUDIO_SINK_SLAVE_SKEW,
GST_BASE_AUDIO_SINK_SLAVE_NONE
} GstBaseAudioSinkSlaveMethod;
typedef struct _GstBaseAudioSink GstBaseAudioSink;
......@@ -147,6 +149,14 @@ GType gst_base_audio_sink_get_type(void);
GstRingBuffer *gst_base_audio_sink_create_ringbuffer (GstBaseAudioSink *sink);
void gst_base_audio_sink_set_provide_clock (GstBaseAudioSink *sink, gboolean provide);
gboolean gst_base_audio_sink_get_provide_clock (GstBaseAudioSink *sink);
void gst_base_audio_sink_set_slave_method (GstBaseAudioSink *sink,
GstBaseAudioSinkSlaveMethod method);
GstBaseAudioSinkSlaveMethod
gst_base_audio_sink_get_slave_method (GstBaseAudioSink *sink);
G_END_DECLS
#endif /* __GST_BASE_AUDIO_SINK_H__ */
......@@ -288,6 +288,52 @@ gst_base_audio_src_check_get_range (GstBaseSrc * bsrc)
return TRUE;
}
/**
* gst_base_audio_src_set_provide_clock:
* @src: a #GstBaseAudioSrc
* @provide: new state
*
* Controls whether @src will provide a clock or not. If @provide is %TRUE,
* gst_element_provide_clock() will return a clock that reflects the datarate
* of @src. If @provide is %FALSE, gst_element_provide_clock() will return NULL.
*
* Since: 0.10.16
*/
void
gst_base_audio_src_set_provide_clock (GstBaseAudioSrc * src, gboolean provide)
{
g_return_if_fail (GST_IS_BASE_AUDIO_SRC (src));
GST_OBJECT_LOCK (src);
src->priv->provide_clock = provide;
GST_OBJECT_UNLOCK (src);
}
/**
* gst_base_audio_src_get_provide_clock:
* @src: a #GstBaseAudioSrc
*
* Queries whether @src will provide a clock or not. See also
* gst_base_audio_src_set_provide_clock.
*
* Returns: %TRUE if @src will provide a clock.
*
* Since: 0.10.16
*/
gboolean
gst_base_audio_src_get_provide_clock (GstBaseAudioSrc * src)
{
gboolean result;
g_return_val_if_fail (GST_IS_BASE_AUDIO_SRC (src), FALSE);
GST_OBJECT_LOCK (src);
result = src->priv->provide_clock;
GST_OBJECT_UNLOCK (src);
return result;
}
static void
gst_base_audio_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
......@@ -304,9 +350,7 @@ gst_base_audio_src_set_property (GObject * object, guint prop_id,
src->latency_time = g_value_get_int64 (value);
break;
case PROP_PROVIDE_CLOCK:
GST_OBJECT_LOCK (src);
src->priv->provide_clock = g_value_get_boolean (value);
GST_OBJECT_UNLOCK (src);
gst_base_audio_src_set_provide_clock (src, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -330,9 +374,7 @@ gst_base_audio_src_get_property (GObject * object, guint prop_id,
g_value_set_int64 (value, src->latency_time);
break;
case PROP_PROVIDE_CLOCK:
GST_OBJECT_LOCK (src);
g_value_set_boolean (value, src->priv->provide_clock);
GST_OBJECT_UNLOCK (src);
g_value_set_boolean (value, gst_base_audio_src_get_provide_clock (src));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......
......@@ -109,6 +109,9 @@ GType gst_base_audio_src_get_type(void);
GstRingBuffer *gst_base_audio_src_create_ringbuffer (GstBaseAudioSrc *src);
void gst_base_audio_src_set_provide_clock (GstBaseAudioSrc *src, gboolean provide);
gboolean gst_base_audio_src_get_provide_clock (GstBaseAudioSrc *src);
G_END_DECLS
#endif /* __GST_BASE_AUDIO_SRC_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment