mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
API: Support seeking by offset
This commit is contained in:
25
lib/gst/clapper/gstclapper.c
vendored
25
lib/gst/clapper/gstclapper.c
vendored
@@ -1066,6 +1066,8 @@ tick_cb (gpointer user_data)
|
||||
position_updated_dispatch, data,
|
||||
(GDestroyNotify) position_updated_signal_data_free);
|
||||
}
|
||||
if (self->mpris)
|
||||
gst_clapper_mpris_set_position (self->mpris, position);
|
||||
}
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
@@ -3519,6 +3521,29 @@ gst_clapper_seek (GstClapper * self, GstClockTime position)
|
||||
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
|
||||
remove_seek_source (GstClapper * self)
|
||||
{
|
||||
|
3
lib/gst/clapper/gstclapper.h
vendored
3
lib/gst/clapper/gstclapper.h
vendored
@@ -172,6 +172,9 @@ void gst_clapper_stop (GstClapper *clapper
|
||||
GST_CLAPPER_API
|
||||
void gst_clapper_seek (GstClapper *clapper, GstClockTime position);
|
||||
|
||||
GST_CLAPPER_API
|
||||
void gst_clapper_seek_offset (GstClapper *clapper, GstClockTime offset);
|
||||
|
||||
GST_CLAPPER_API
|
||||
GstClapperState
|
||||
gst_clapper_get_state (GstClapper *clapper);
|
||||
|
Reference in New Issue
Block a user