protected void ClearPageData() { streamSerialNumber = 0; pages = new List <OggPage>(); //new ArrayList (); firstPageHeader = null; lastPageHeader = null; packetToPageMap = new List <IntCollection>(); //new ArrayList(); dirtyPackets = new Dictionary <uint, ByteVector>(); //new Hashtable (); dirtyPages = new IntCollection(); currentPage = null; currentPacketPage = null; currentPackets = null; }
private void WritePageGroup(IntCollection page_group) { if (page_group.IsEmpty) { return; } ByteVectorCollection packets = new ByteVectorCollection(); // If the first page of the group isn'type dirty, append its partial content here. if (!dirtyPages.Contains(((OggPage)this.pages[page_group[0]]).FirstPacketIndex)) { packets.Add(((OggPage)this.pages[page_group[0]]).Packets[0]); } int previous_packet = -1; int original_size = 0; for (int i = 0; i < page_group.Count; i++) { int page = page_group[i]; uint first_packet = (uint)((OggPage)this.pages[page]).FirstPacketIndex; uint last_packet = first_packet + ((OggPage)this.pages[page]).PacketCount - 1; for (uint j = first_packet; j <= last_packet; j++) { if (i == page_group.Count - 1 && j == last_packet && !dirtyPages.Contains((int)j)) { packets.Add(((OggPage)this.pages[page]).Packets[((OggPage)this.pages[page]).Packets.Count - 1]); } else if ((int)j != previous_packet) { previous_packet = (int)j; packets.Add(GetPacket(j)); } } original_size += ((OggPage)this.pages[page]).Size; } bool continued = ((OggPage)this.pages[page_group[0]]).Header.FirstPacketContinued; bool completed = ((OggPage)this.pages[page_group[page_group.Count - 1]]).Header.LastPacketCompleted; // TODO: This pagination method isn'type accurate for what'field being done here. // This should account for real possibilities like non-aligned packets and such. OggPage[] pages = OggPage.Paginate(packets, PaginationStrategy.SinglePagePerGroup, streamSerialNumber, page_group[0], continued, completed); ByteVector data = new ByteVector(); foreach (OggPage p in pages) { data.Add(p.Render()); } // The insertion algorithms could also be improve to queue and prioritize data // on the way out. Currently it requires rewriting the file for every page // group rather than just once; however, for tagging applications there will // generally only be one page group, so it'field not worth the time for the // optimization at the moment. Insert(data, ((OggPage)this.pages[page_group[0]]).FileOffset, original_size); // Update the page index to include the pages we just created and to delete the // old pages. foreach (OggPage p in pages) { int index = p.Header.PageSequenceNumber; this.pages[index] = p; } }
public IntCollection(IntCollection numbers) { Add(numbers); }