queue2: Fix merging of ranges
queue2: Fix merging of ranges

Make a method to get the seeking threshold. If data is further away from
this threshold we want to perform a seek upstream.
When the current downloaded range can merge with the next range,
actually include the data of the next range into the current range
instead of discarding it. Also decide if we seek to the write position
of the merged range or continue reading.

jpxiong/gstreamer,jpakkane/gstreamer,shelsonjava/gstreamer,mparis/gstreamer,cfoch/gstreamer,cfoch/gstreamer,surround-io/gstreamer,StreamUtils/gstreamer,surround-io/gstreamer,cfoch/gstreamer,krichter722/gstreamer,jpakkane/gstreamer,cablelabs/gstreamer,cablelabs/gstreamer,shelsonjava/gstreamer,centricular/gstreamer,StreamUtils/gstreamer,jpakkane/gstreamer,Lachann/gstreamer,krichter722/gstreamer,jpxiong/gstreamer,StreamUtils/gstreamer,cablelabs/gstreamer,krichter722/gstreamer,cfoch/gstreamer,centricular/gstreamer,centricular/gstreamer,centricular/gstreamer,jpxiong/gstreamer,Lachann/gstreamer,shelsonjava/gstreamer,Lachann/gstreamer,surround-io/gstreamer,centricular/gstreamer,surround-io/gstreamer,shelsonjava/gstreamer,surround-io/gstreamer,krichter722/gstreamer,cfoch/gstreamer,StreamUtils/gstreamer,Lachann/gstreamer,mparis/gstreamer,mparis/gstreamer,mparis/gstreamer,jpxiong/gstreamer,StreamUtils/gstreamer,krichter722/gstreamer,shelsonjava/gstreamer,jpxiong/gstreamer,cablelabs/gstreamer,mparis/gstreamer,cablelabs/gstreamer,Lachann/gstreamer,jpakkane/gstreamer,jpakkane/gstreamer