/// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="index">The index of the first byte of the data portion.</param>
        /// <returns>True if the section is an MHW2 category section; false otherwise.</returns>
        internal bool Process(byte[] byteData, int index)
        {
            lastIndex = index;

            if (byteData[lastIndex] != 0x01)
            {
                return(false);
            }

            lastIndex++;

            categoryCount = (int)byteData[lastIndex];
            lastIndex++;

            try
            {
                int p1 = 0;
                int p2 = 0;

                string themeName = null;

                for (int themeIndex = 0; themeIndex < categoryCount; themeIndex++)
                {
                    p1 = ((byteData[lastIndex + (themeIndex * 2)] << 8) | byteData[lastIndex + 1 + (themeIndex * 2)]) + 3;

                    for (int descriptionIndex = 0; descriptionIndex <= (byteData[p1] & 0x3f); descriptionIndex++)
                    {
                        p2 = ((byteData[p1 + 1 + (descriptionIndex * 2)] << 8) | byteData[p1 + 2 + (descriptionIndex * 2)] + 3);

                        MediaHighwayCategoryEntry categoryEntry = new MediaHighwayCategoryEntry();

                        categoryEntry.Number = ((themeIndex & 0x3f) << 6) | (descriptionIndex & 0x3f);
                        if (descriptionIndex == 0)
                        {
                            themeName = Utils.GetString(byteData, p2 + 1, byteData[p2] & 0x1f, true).Trim();
                            categoryEntry.Description = themeName;
                        }
                        else
                        {
                            categoryEntry.Description = themeName + " " + Utils.GetString(byteData, p2 + 1, byteData[p2] & 0x1f, true).Trim();
                        }

                        Categories.Add(categoryEntry);
                    }
                }
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The MediaHighway2 Category Section message is short"));
            }

            Validate();

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="index">The index of the first byte of the data portion.</param>
        internal void Process(byte[] byteData, int index)
        {
            int descriptionIndex = index + 16;
            int categoryNumber   = 0;

            int categoryIndex = 0;
            int categoryID    = 0;

            try
            {
                while (descriptionIndex < byteData.Length)
                {
                    MediaHighwayCategoryEntry categoryEntry = new MediaHighwayCategoryEntry();

                    if (byteData[categoryID + 3] == categoryIndex)
                    {
                        categoryNumber = categoryID * 16;
                        categoryID++;
                    }

                    categoryEntry.Number      = categoryNumber;
                    categoryEntry.Description = Utils.GetString(byteData, descriptionIndex, 15, true).Trim();
                    Categories.Add(categoryEntry);

                    descriptionIndex += 15;
                    categoryNumber++;
                    categoryIndex++;
                }
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The MediaHighway1 Category Section message is short"));
            }

            Validate();
        }
        /// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="index">The index of the first byte of the data portion.</param>
        internal void Process(byte[] byteData, int index)
        {
            int descriptionIndex = index + 16;
            int categoryNumber = 0;

            int categoryIndex = 0;
            int categoryID = 0;

            try
            {
                while (descriptionIndex < byteData.Length)
                {
                    MediaHighwayCategoryEntry categoryEntry = new MediaHighwayCategoryEntry();

                    if (byteData[categoryID + 3] == categoryIndex)
                    {
                        categoryNumber = categoryID * 16;
                        categoryID++;
                    }

                    categoryEntry.Number = categoryNumber;
                    categoryEntry.Description = Utils.GetString(byteData, descriptionIndex, 15, true).Trim();
                    Categories.Add(categoryEntry);

                    descriptionIndex += 15;
                    categoryNumber++;
                    categoryIndex++;
                }
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The MediaHighway1 Category Section message is short"));
            }

            Validate();
        }
        /// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="index">The index of the first byte of the data portion.</param>
        /// <returns>True if the section is an MHW2 category section; false otherwise.</returns>
        internal bool Process(byte[] byteData, int index)
        {
            lastIndex = index;

            if (byteData[lastIndex] != 0x01)
                return (false);

            lastIndex++;

            categoryCount = (int)byteData[lastIndex];
            lastIndex++;

            try
            {
                int p1 = 0;
                int p2 = 0;

                string themeName = null;

                for (int themeIndex = 0; themeIndex < categoryCount; themeIndex++)
                {
                    p1 = ((byteData[lastIndex + (themeIndex * 2)] << 8) | byteData[lastIndex + 1 + (themeIndex * 2)]) + 3;

                    for (int descriptionIndex = 0; descriptionIndex <= (byteData[p1] & 0x3f); descriptionIndex++)
                    {
                        p2 = ((byteData[p1 + 1 + (descriptionIndex * 2)] << 8) | byteData[p1 + 2 + (descriptionIndex * 2)] + 3);

                        MediaHighwayCategoryEntry categoryEntry = new MediaHighwayCategoryEntry();

                        categoryEntry.Number = ((themeIndex & 0x3f) << 6) | (descriptionIndex & 0x3f);
                        if (descriptionIndex == 0)
                        {
                            themeName = Utils.GetString(byteData, p2 + 1, byteData[p2] & 0x1f, true).Trim();
                            categoryEntry.Description = themeName;
                        }
                        else
                            categoryEntry.Description = themeName + " " + Utils.GetString(byteData, p2 + 1, byteData[p2] & 0x1f, true).Trim();

                        Categories.Add(categoryEntry);
                    }
                }
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The MediaHighway2 Category Section message is short"));
            }

            Validate();

            return (true);
        }