Exemple #1
0
        /// <summary>
        /// Returns a section list for the entire specified table. Caller must dispose the resulting ISectionList
        /// </summary>
        /// <param name="PID">program ID</param>
        /// <param name="TID">table ID</param>
        /// <returns>returns the section list neccesary to read the whole table</returns>
        private ISectionList GetTableSectionList(short PID, byte TID)
        {
            ISectionList sectionList = null;
            int          hr          = mpeg2Data.GetTable(PID, TID, null, Parser.Timeout, out sectionList);

            DsError.ThrowExceptionForHR(hr);

            return(sectionList);
        }
Exemple #2
0
        /// <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);
                    }
                }
            }
        }