示例#1
0
        /// <summary>
        /// Create a new instance of a BIOP descriptor.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the descriptor.</param>
        /// <param name="index">Index of the descriptor tag in the MPEG2 section.</param>
        /// <returns>A BIOP descriptor instance.</returns>
        public static BIOPDescriptor Create(byte[] byteData, int index)
        {
            BIOPDescriptor descriptor = null;

            switch (byteData[index])
            {
            case DVBCompressedModuleDescriptor.Tag:
                descriptor = new DVBCompressedModuleDescriptor();
                break;

            case MHPLabelDescriptor.Tag:
                descriptor = new MHPLabelDescriptor();
                break;

            case MHPCachingPriorityDescriptor.Tag:
                descriptor = new MHPCachingPriorityDescriptor();
                break;

            case MHPContentTypeDescriptor.Tag:
                descriptor = new MHPContentTypeDescriptor();
                break;

            default:
                throw (new InvalidOperationException("BIOPDescriptor: Tag not recognized - " + byteData[index]));
            }

            descriptor.Process(byteData, index);

            return(descriptor);
        }
示例#2
0
        /// <summary>
        /// Parse the module information.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the module information.</param>
        /// <param name="index">Index of the first byte of the module information in the MPEG2 section.</param>
        public void Process(byte[] byteData, int index)
        {
            lastIndex = index;

            try
            {
                moduleTimeout = Utils.Convert4BytesToInt(byteData, lastIndex);
                lastIndex    += 4;

                blockTimeout = Utils.Convert4BytesToInt(byteData, lastIndex);
                lastIndex   += 4;

                minimumBlockTime = Utils.Convert4BytesToInt(byteData, lastIndex);
                lastIndex       += 4;

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

                if (tapsCount != 0)
                {
                    taps = new Collection <BIOPTap>();

                    while (taps.Count < tapsCount)
                    {
                        BIOPTap tap = new BIOPTap();
                        tap.Process(byteData, lastIndex);
                        taps.Add(tap);

                        lastIndex = tap.Index;
                    }
                }

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

                if (userInfoLength != 0)
                {
                    descriptors = new Collection <BIOPDescriptor>();

                    while (userInfoLength > 0)
                    {
                        BIOPDescriptor descriptor = BIOPDescriptor.Create(byteData, lastIndex);
                        descriptors.Add(descriptor);

                        userInfoLength -= (descriptor.Index - lastIndex);
                        lastIndex       = descriptor.Index;
                    }
                }

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The BIOP Module Info message is short"));
            }
        }