/// <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 following the header in the MPEG2 section.</param>
        public override void Process(byte[] byteData, int index)
        {
            lastIndex = index;

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

                blockSize  = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex += 2;

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

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

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

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

                compatibilityDescriptorLength = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex += 2;

                if (compatibilityDescriptorLength != 0)
                {
                    compatibilityDescriptor = new DSMCCCompatibilityDescriptor();
                    compatibilityDescriptor.Process(byteData, lastIndex);
                    lastIndex = compatibilityDescriptor.Index;
                }

                numberOfModules = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex      += 2;

                if (numberOfModules != 0)
                {
                    moduleList = new Collection <DSMCCDownloadInfoIndicationModule>();

                    while (moduleList.Count < numberOfModules)
                    {
                        DSMCCDownloadInfoIndicationModule module = new DSMCCDownloadInfoIndicationModule();
                        module.Process(byteData, lastIndex);
                        moduleList.Add(module);

                        lastIndex = module.Index;
                    }
                }

                privateDataLength = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex        += 2;

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

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The DSMCC DownloadInfo Indication message is short"));
            }
        }
Beispiel #2
0
 private void checkRemoveModule(DSMCCDownloadInfoIndicationModule module)
 {
     foreach (DSMCCModule existingModule in modules)
     {
         if (existingModule.ModuleID == module.ModuleID)
         {
             modules.Remove(existingModule);
             return;
         }
     }
 }
        /// <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 following the header in the MPEG2 section.</param>
        public override void Process(byte[] byteData, int index)
        {
            lastIndex = index;

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

                blockSize = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex += 2;

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

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

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

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

                compatibilityDescriptorLength = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex += 2;

                if (compatibilityDescriptorLength != 0)
                {
                    compatibilityDescriptor = new DSMCCCompatibilityDescriptor();
                    compatibilityDescriptor.Process(byteData, lastIndex);
                    lastIndex = compatibilityDescriptor.Index;
                }

                numberOfModules = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex += 2;

                if (numberOfModules != 0)
                {
                    moduleList = new Collection<DSMCCDownloadInfoIndicationModule>();

                    while (moduleList.Count < numberOfModules)
                    {
                        DSMCCDownloadInfoIndicationModule module = new DSMCCDownloadInfoIndicationModule();
                        module.Process(byteData, lastIndex);
                        moduleList.Add(module);

                        lastIndex = module.Index;
                    }
                }

                privateDataLength = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex += 2;

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

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The DSMCC DownloadInfo Indication message is short"));
            }
        }
Beispiel #4
0
        private void checkAddModule(DSMCCDownloadInfoIndicationModule module)
        {
            foreach (DSMCCModule oldModule in modules)
            {
                if (oldModule.ModuleID == module.ModuleID)
                {
                    if (oldModule.Version == module.ModuleVersion)
                        return;
                    else
                    {
                        if (oldModule.Version != module.ModuleVersion)
                        {
                            int replaceIndex = modules.IndexOf(oldModule);
                            modules.Remove(oldModule);
                            DSMCCModule replaceModule = new DSMCCModule(module.ModuleID, module.ModuleVersion, module.ModuleSize, module.OriginalSize);
                            if (replaceIndex != modules.Count)
                                modules.Insert(replaceIndex, replaceModule);
                            else
                                modules.Add(replaceModule);
                            return;
                        }
                    }
                }
                else
                {
                    if (oldModule.ModuleID > module.ModuleID)
                    {
                        DSMCCModule insertModule = new DSMCCModule(module.ModuleID, module.ModuleVersion, module.ModuleSize, module.OriginalSize);
                        modules.Insert(modules.IndexOf(oldModule), insertModule);
                        return;
                    }
                }
            }

            DSMCCModule newModule = new DSMCCModule(module.ModuleID, module.ModuleVersion, module.ModuleSize, module.OriginalSize);
            modules.Add(newModule);
        }