Esempio n. 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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <summary>
        /// Parse the message.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the message.</param>
        /// <param name="index">Index of the first byte of the message in the MPEG2 section.</param>
        /// <param name="objectInfoLength">The length of the object information data.</param>
        public override void Process(byte[] byteData, int index, int objectInfoLength)
        {
            lastIndex = index;

            try
            {
                if (objectInfoLength != 0)
                {
                    fileContentSize = Utils.Convert8BytesToLong(byteData, lastIndex);
                    lastIndex      += 8;

                    if (objectInfoLength > 8)
                    {
                        contentTypeDescriptors = new Collection <MHPContentTypeDescriptor>();

                        int workingLength = objectInfoLength - 8;

                        while (workingLength != 0)
                        {
                            MHPContentTypeDescriptor descriptor = new MHPContentTypeDescriptor();
                            descriptor.Process(byteData, lastIndex);
                            contentTypeDescriptors.Add(descriptor);

                            workingLength = descriptor.Index - lastIndex;
                            lastIndex     = descriptor.Index;
                        }
                    }
                }

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

                if (serviceContextCount != 0)
                {
                    serviceContexts = new Collection <BIOPServiceContext>();

                    while (serviceContexts.Count != serviceContextCount)
                    {
                        BIOPServiceContext serviceContext = new BIOPServiceContext();
                        serviceContext.Process(byteData, lastIndex);
                        serviceContexts.Add(serviceContext);

                        lastIndex = serviceContext.Index;
                    }
                }

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

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

                if (contentLength != 0)
                {
                    contentData = Utils.GetBytes(byteData, lastIndex, contentLength);
                    lastIndex  += contentLength;
                }

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The BIOP File message is short"));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Parse the message.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the message.</param>
        /// <param name="index">Index of the first byte of the message in the MPEG2 section.</param>
        /// <param name="objectInfoLength">The length of the object information data.</param>
        public override void Process(byte[] byteData, int index, int objectInfoLength)
        {
            lastIndex = index;

            try
            {
                if (objectInfoLength != 0)
                {
                    fileContentSize = Utils.Convert8BytesToLong(byteData, lastIndex);
                    lastIndex += 8;

                    if (objectInfoLength > 8)
                    {
                        contentTypeDescriptors = new Collection<MHPContentTypeDescriptor>();

                        int workingLength = objectInfoLength - 8;

                        while (workingLength != 0)
                        {
                            MHPContentTypeDescriptor descriptor = new MHPContentTypeDescriptor();
                            descriptor.Process(byteData, lastIndex);
                            contentTypeDescriptors.Add(descriptor);

                            workingLength = descriptor.Index - lastIndex;
                            lastIndex = descriptor.Index;

                        }
                    }
                }

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

                if (serviceContextCount != 0)
                {
                    serviceContexts = new Collection<BIOPServiceContext>();

                    while (serviceContexts.Count != serviceContextCount)
                    {
                        BIOPServiceContext serviceContext = new BIOPServiceContext();
                        serviceContext.Process(byteData, lastIndex);
                        serviceContexts.Add(serviceContext);

                        lastIndex = serviceContext.Index;
                    }
                }

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

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

                if (contentLength != 0)
                {
                    contentData = Utils.GetBytes(byteData, lastIndex, contentLength);
                    lastIndex += contentLength;
                }

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