completed code for dynamicly resizing jitter buffer