Skip to content

Commit 7a88da9

Browse files
committed
video player: make seek flags construction a bit more easier to follow
1 parent 8d0fe72 commit 7a88da9

File tree

1 file changed

+11
-4
lines changed
  • src/plugins/gstreamer_video_player

1 file changed

+11
-4
lines changed

src/plugins/gstreamer_video_player/player.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@ static int apply_playback_state(struct gstplayer *player) {
308308
}
309309
}
310310

311+
GstSeekFlags seek_flags = GST_SEEK_FLAG_FLUSH;
312+
if (player->do_fast_seeking) {
313+
seek_flags |= GST_SEEK_FLAG_KEY_UNIT | GST_SEEK_FLAG_SNAP_NEAREST;
314+
} else {
315+
seek_flags |= GST_SEEK_FLAG_ACCURATE;
316+
}
317+
311318
if (player->direction == kForward) {
312319
LOG_PLAYER_DEBUG(
313320
player,
@@ -316,12 +323,13 @@ static int apply_playback_state(struct gstplayer *player) {
316323
GST_TIME_ARGS(position),
317324
GST_TIME_ARGS(GST_CLOCK_TIME_NONE)
318325
);
326+
327+
319328
ok = gst_element_seek(
320329
GST_ELEMENT(player->playbin),
321330
desired_rate,
322331
GST_FORMAT_TIME,
323-
GST_SEEK_FLAG_FLUSH |
324-
(player->do_fast_seeking ? GST_SEEK_FLAG_KEY_UNIT | GST_SEEK_FLAG_SNAP_NEAREST : GST_SEEK_FLAG_ACCURATE),
332+
seek_flags,
325333
GST_SEEK_TYPE_SET,
326334
position,
327335
GST_SEEK_TYPE_SET,
@@ -348,8 +356,7 @@ static int apply_playback_state(struct gstplayer *player) {
348356
GST_ELEMENT(player->playbin),
349357
desired_rate,
350358
GST_FORMAT_TIME,
351-
GST_SEEK_FLAG_FLUSH |
352-
(player->do_fast_seeking ? GST_SEEK_FLAG_KEY_UNIT | GST_SEEK_FLAG_SNAP_NEAREST : GST_SEEK_FLAG_ACCURATE),
359+
seek_flags,
353360
GST_SEEK_TYPE_SET,
354361
0,
355362
GST_SEEK_TYPE_SET,

0 commit comments

Comments
 (0)