internal void RunQuickBuffering(MediaEngine m) { // We need to perform some packet reading and decoding MediaFrame frame; var main = MainMediaType; var auxiliaries = MediaTypes.Except(main); var mediaTypes = MediaTypes; var mainBlocks = m.Blocks[main]; // Read and decode blocks until the main component is half full while (m.ShouldReadMorePackets) { // Read some packets m.Container.Read(); // Decode frames and add the blocks foreach (var t in mediaTypes) { frame = this[t].ReceiveNextFrame(); m.Blocks[t].Add(frame, m.Container); } // Check if we have at least a half a buffer on main if (mainBlocks.CapacityPercent >= 0.5) { break; } } // Check if we have a valid range. If not, just set it what the main component is dictating if (mainBlocks.Count > 0 && mainBlocks.IsInRange(m.WallClock) == false) { m.ChangePosition(mainBlocks.RangeStartTime); } // Have the other components catch up foreach (var t in auxiliaries) { if (mainBlocks.Count <= 0) { break; } if (t != MediaType.Audio && t != MediaType.Video) { continue; } while (m.Blocks[t].RangeEndTime < mainBlocks.RangeEndTime) { if (m.ShouldReadMorePackets == false) { break; } // Read some packets m.Container.Read(); // Decode frames and add the blocks frame = this[t].ReceiveNextFrame(); m.Blocks[t].Add(frame, m.Container); } } }