/// <summary> /// Retreives all of the sections for the specified table. /// </summary> /// <param name="PID">packet ID</param> /// <param name="TID">table ID</param> /// <returns>a list of Sections. Or an empty list if an error occurs</returns> private List <Section> GetAllSections(short PID, byte TID) { lock (mpeg2Data) { ISectionList sectionList = null; List <Section> retreivedSections = new List <Section>(); try { sectionList = GetTableSectionList(PID, TID); short sectionCount; sectionList.GetNumberOfSections(out sectionCount); for (short i = 0; i < sectionCount; i++) { try { IntPtr pSection; int sectionSize; int hr = sectionList.GetSectionData(i, out sectionSize, out pSection); DsError.ThrowExceptionForHR(hr); Section section = new Section(pSection); if (section.SectionSyntaxIndicator) { section = new LongSection(pSection); } retreivedSections.Add(section); } catch (Exception ex) { Debug.WriteLine("Failed to retreive section:"); ErrorLogger.DumpToDebug(ex); } } return(retreivedSections); } catch (Exception ex) { ErrorLogger.DumpToDebug(ex); return(retreivedSections); } finally { if (sectionList != null) { Marshal.ReleaseComObject(sectionList); } } } }
/// <summary> /// Adds the data contained in a given section to the virtual channel table. /// </summary> /// <param name="s">a Virtual Channel Table section</param> private void AddSection(LongSection s) { if (s == null) { return; } byte protocol_version = s.Data[0]; byte num_channels_in_section = s.Data[1]; for (int i = 2, channel = 0; (i < s.Data.Length) && (channel < num_channels_in_section); channel++) { Entry cur = new VirtualChannelTable.Entry(); int bytesUsed; cur.ParseFromArray(s.Data, i, out bytesUsed); i += bytesUsed; this.Items.Add(cur); } }