示例#1
0
 public SectionReceivedEventArgs(DvbStpHeader header, SegmentAssembler assembler)
     : base(header)
 {
     ReceivedSections  = assembler.ReceivedSections;
     RemainingSections = assembler.RemainingSections;
     ReceivedBytes     = assembler.ReceivedBytes;
     RemainingBytes    = header.TotalSegmentSize - ReceivedBytes;
 } // constructor
示例#2
0
        } // OnSegmentStarted

        private void OnSectionReceived(DvbStpHeader header, SegmentAssembler assembler)
        {
            if (SectionReceived == null)
            {
                return;
            }

            var args = new PayloadStorage.SectionReceivedEventArgs(header, assembler);

            SectionReceived(this, args);
        } // OnSectionReceived
示例#3
0
        } // 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
示例#4
0
        } // 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
示例#5
0
        } // 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
示例#6
0
        }     // 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
示例#7
0
 public SegmentReceivedEventArgs(SegmentAssembler assembler)
 {
     SegmentIdentity = assembler.SegmentIdentity;
     SectionCount    = assembler.ReceivedSections;
 } // constructor
示例#8
0
 public SegmentPayloadReceivedEventArgs(SegmentAssembler assembler)
     : base(assembler)
 {
     Payload = assembler.GetPayload();
 } // constructor
示例#9
0
 public SegmentDownloadCompletedEventArgs(SegmentAssembler segmentData)
 {
     SegmentData = segmentData;
 } // constructor
示例#10
0
        } // StoreSectionData

        private void Clean()
        {
            SegmentData = null;
        } // Clean