diff --git a/gst/gstclock.c b/gst/gstclock.c index 89b00517e9..12a953426a 100644 --- a/gst/gstclock.c +++ b/gst/gstclock.c @@ -1416,6 +1416,44 @@ gst_clock_add_observation (GstClock * clock, GstClockTime slave, GstClockTime master, gdouble * r_squared) { GstClockTime m_num, m_denom, b, xbase; + + if (!gst_clock_add_observation_unapplied (clock, slave, master, r_squared, + &xbase, &b, &m_num, &m_denom)) + return FALSE; + + /* if we have a valid regression, adjust the clock */ + gst_clock_set_calibration (clock, xbase, b, m_num, m_denom); + + return TRUE; +} + +/** + * gst_clock_add_observation_unapplied: + * @clock: a #GstClock + * @slave: a time on the slave + * @master: a time on the master + * @r_squared: (out): a pointer to hold the result + * @internal: (out) (allow-none): a location to store the internal time + * @external: (out) (allow-none): a location to store the external time + * @rate_num: (out) (allow-none): a location to store the rate numerator + * @rate_denom: (out) (allow-none): a location to store the rate denominator + * + * Add a clock observation to the internal slaving algorithm the same as + * gst_clock_add_observation(), and return the result of the master clock + * estimation, without updating the internal calibration. + * + * The caller can then take the results and call gst_clock_set_calibration() + * with the values, or some modified version of them. + * + * Since: 1.6 + */ +gboolean +gst_clock_add_observation_unapplied (GstClock * clock, GstClockTime slave, + GstClockTime master, gdouble * r_squared, + GstClockTime * internal, GstClockTime * external, + GstClockTime * rate_num, GstClockTime * rate_denom) +{ + GstClockTime m_num, m_denom, b, xbase; GstClockPrivate *priv; g_return_val_if_fail (GST_IS_CLOCK (clock), FALSE); @@ -1450,8 +1488,14 @@ gst_clock_add_observation (GstClock * clock, GstClockTime slave, "adjusting clock to m=%" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT ", b=%" G_GUINT64_FORMAT " (rsquared=%g)", m_num, m_denom, b, *r_squared); - /* if we have a valid regression, adjust the clock */ - gst_clock_set_calibration (clock, xbase, b, m_num, m_denom); + if (internal) + *internal = xbase; + if (external) + *external = b; + if (rate_num) + *rate_num = m_num; + if (rate_denom) + *rate_denom = m_denom; return TRUE; diff --git a/gst/gstclock.h b/gst/gstclock.h index 005916bdc5..c2239e59a2 100644 --- a/gst/gstclock.h +++ b/gst/gstclock.h @@ -478,6 +478,12 @@ GstClockTime gst_clock_get_timeout (GstClock *clock); gboolean gst_clock_add_observation (GstClock *clock, GstClockTime slave, GstClockTime master, gdouble *r_squared); +gboolean gst_clock_add_observation_unapplied (GstClock *clock, GstClockTime slave, + GstClockTime master, gdouble *r_squared, + GstClockTime *internal, + GstClockTime *external, + GstClockTime *rate_num, + GstClockTime *rate_denom); /* getting and adjusting internal/external time */ GstClockTime gst_clock_get_internal_time (GstClock *clock); diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index d0a9f19777..d3e94c3012 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -298,6 +298,7 @@ EXPORTS gst_child_proxy_set_property gst_child_proxy_set_valist gst_clock_add_observation + gst_clock_add_observation_unapplied gst_clock_adjust_unlocked gst_clock_adjust_with_calibration gst_clock_entry_type_get_type