For some cases, maybe the timestamp of gap event is smaller than
segment start value or larger than segment stop value in playback.
And the timestamp plus duration may exceed segment boundary. Need
check and clip the timestamp or duration before recalculating.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8517>