public SectionReceivedEventArgs(DvbStpHeader header, SegmentAssembler assembler) : base(header) { ReceivedSections = assembler.ReceivedSections; RemainingSections = assembler.RemainingSections; ReceivedBytes = assembler.ReceivedBytes; RemainingBytes = header.TotalSegmentSize - ReceivedBytes; } // constructor
} // OnSegmentStarted private void OnSectionReceived(DvbStpHeader header, SegmentAssembler assembler) { if (SectionReceived == null) { return; } var args = new PayloadStorage.SectionReceivedEventArgs(header, assembler); SectionReceived(this, args); } // OnSectionReceived
} // ProcessReceivedData private void InitSectionData() { // initialize segment data storage SegmentData = new SegmentAssembler(new DvbStpSegmentIdentity(Header), Header.LastSectionNumber); // notify start of download if (DownloadStarted != null) { OnDownloadStarted(); } // if } // InitSectionData
} // OnSectionReceived private void OnSegmentReceived(SegmentAssembler assembler) { if (SegmentReceived != null) { var args = new PayloadStorage.SegmentReceivedEventArgs(assembler); SegmentReceived(this, args); } // if if (SegmentPayloadReceived != null) { var args = new PayloadStorage.SegmentPayloadReceivedEventArgs(assembler); SegmentPayloadReceived(this, args); } // if } // OnSegmentReceived
} // constructor public bool AddSection(DvbStpHeader header, byte[] data, bool isRawData) { SegmentAssembler assembler; bool newSection; if (!Versions.TryGetValue(header.SegmentVersion, out assembler)) { assembler = new SegmentAssembler(new DvbStpSegmentIdentity(header), header.LastSectionNumber); Versions[header.SegmentVersion] = assembler; OnSegmentStarted(header); } // if if (SaveData) { if (isRawData) { newSection = assembler.AddSectionData(header.SectionNumber, data, header.PayloadOffset, header.PayloadSize); } else { newSection = assembler.AddSectionData(header.SectionNumber, data, 0, data.Length); } // if-else } else { newSection = assembler.AddSectionData(header.SectionNumber, PayloadStorage.EmptyData, 0, 0); } // if-else if (newSection) { OnSectionReceived(header, assembler); if (assembler.IsSegmentComplete) { OnSegmentReceived(assembler); // discard data assembler = null; Versions.Remove(header.SegmentVersion); } // if } // if return(newSection); } // AddSection
} // InitSectionData private void RestartSectionData() { // increment restart count DowloadRestartCount++; // avoid infinite restart loops if (DowloadRestartCount > MaxDowloadRestartCount) { throw new TimeoutException(); } // if // notify of download restart if (DownloadRestarted != null) { OnDowloadRestarted(); } // start over SegmentData = new SegmentAssembler(new DvbStpSegmentIdentity(Header), Header.LastSectionNumber); ResetNoDataTimeout(); } // RestartSectionData
public SegmentReceivedEventArgs(SegmentAssembler assembler) { SegmentIdentity = assembler.SegmentIdentity; SectionCount = assembler.ReceivedSections; } // constructor
public SegmentPayloadReceivedEventArgs(SegmentAssembler assembler) : base(assembler) { Payload = assembler.GetPayload(); } // constructor
public SegmentDownloadCompletedEventArgs(SegmentAssembler segmentData) { SegmentData = segmentData; } // constructor
} // StoreSectionData private void Clean() { SegmentData = null; } // Clean