API: Support seeking by offset

This commit is contained in:
Rafał Dzięgiel
2021-05-21 19:28:07 +02:00
parent 68d7205ead
commit f0475ee055
2 changed files with 28 additions and 0 deletions

View File

@@ -1066,6 +1066,8 @@ tick_cb (gpointer user_data)
position_updated_dispatch, data, position_updated_dispatch, data,
(GDestroyNotify) position_updated_signal_data_free); (GDestroyNotify) position_updated_signal_data_free);
} }
if (self->mpris)
gst_clapper_mpris_set_position (self->mpris, position);
} }
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
@@ -3519,6 +3521,29 @@ gst_clapper_seek (GstClapper * self, GstClockTime position)
g_mutex_unlock (&self->lock); g_mutex_unlock (&self->lock);
} }
/**
* gst_clapper_seek_offset:
* @clapper: #GstClapper instance
* @offset: offset from current position to seek to in nanoseconds
*
* Seeks the currently-playing stream to the @offset time
* in nanoseconds.
*/
void
gst_clapper_seek_offset (GstClapper * self, GstClockTime offset)
{
GstClockTime position;
g_return_if_fail (GST_IS_CLAPPER (self));
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (offset));
position = gst_clapper_get_position (self);
/* TODO: Prevent negative values */
gst_clapper_seek (self, position + offset);
}
static void static void
remove_seek_source (GstClapper * self) remove_seek_source (GstClapper * self)
{ {

View File

@@ -172,6 +172,9 @@ void gst_clapper_stop (GstClapper *clapper
GST_CLAPPER_API GST_CLAPPER_API
void gst_clapper_seek (GstClapper *clapper, GstClockTime position); void gst_clapper_seek (GstClapper *clapper, GstClockTime position);
GST_CLAPPER_API
void gst_clapper_seek_offset (GstClapper *clapper, GstClockTime offset);
GST_CLAPPER_API GST_CLAPPER_API
GstClapperState GstClapperState
gst_clapper_get_state (GstClapper *clapper); gst_clapper_get_state (GstClapper *clapper);