예제 #1
0
        /// <summary>
        /// Create an instance of a DSMCC message.
        /// </summary>
        /// <param name="dsmccHeader">The header of the message.</param>
        /// <param name="byteData">The MPEG2 data block that contains the message.</param>
        /// <returns>An instance of the appropriate DSMCC message class.</returns>
        public static DSMCCMessage CreateInstance(DSMCCHeader dsmccHeader, byte[] byteData)
        {
            DSMCCMessage dsmccMessage;

            switch (dsmccHeader.MessageID)
            {
            case DSMCCDownloadDataBlock.MessageIDDownloadDataBlock:
                dsmccMessage = new DSMCCDownloadDataBlock(dsmccHeader);
                break;

            case DSMCCDownloadInfoIndication.MessageIDDownloadInfoIndication:
                dsmccMessage = new DSMCCDownloadInfoIndication(dsmccHeader);
                break;

            case DSMCCDownloadServerInitiate.MessageIDDownloadServerInitiate:
                dsmccMessage = new DSMCCDownloadServerInitiate(dsmccHeader);
                break;

            case DSMCCDownloadCancel.MessageIDDownloadCancel:
                dsmccMessage = new DSMCCDownloadCancel(dsmccHeader);
                break;

            default:
                throw (new ArgumentException("The DSMCC message ID is out of range"));
            }

            dsmccMessage.Process(byteData, dsmccHeader.Index);

            return(dsmccMessage);
        }
예제 #2
0
        /// <summary>
        /// Add a download data block to the module.
        /// </summary>
        /// <param name="newBlock">The block to be added.</param>
        /// <returns>True if the block has been added; false otherwise.</returns>
        public bool AddBlock(DSMCCDownloadDataBlock newBlock)
        {
            foreach (DSMCCDownloadDataBlock oldBlock in blocks)
            {
                if (oldBlock.BlockNumber == newBlock.BlockNumber)
                {
                    return(false);
                }

                if (oldBlock.BlockNumber > newBlock.BlockNumber)
                {
                    blocks.Insert(blocks.IndexOf(oldBlock), newBlock);
                    try
                    {
                        complete = checkComplete();
                        return(true);
                    }
                    catch (InvalidOperationException)
                    {
                        blocks.Clear();
                        return(false);
                    }
                }
            }

            blocks.Add(newBlock);

            try
            {
                complete = checkComplete();
                return(true);
            }
            catch (InvalidOperationException)
            {
                blocks.Clear();
                return(false);
            }
        }
예제 #3
0
        /// <summary>
        /// Add a download data block to the module.
        /// </summary>
        /// <param name="newBlock">The block to be added.</param>
        /// <returns>True if the block has been added; false otherwise.</returns>
        public bool AddBlock(DSMCCDownloadDataBlock newBlock)
        {
            foreach (DSMCCDownloadDataBlock oldBlock in blocks)
            {
                if (oldBlock.BlockNumber == newBlock.BlockNumber)
                    return (false);

                if (oldBlock.BlockNumber > newBlock.BlockNumber)
                {
                    blocks.Insert(blocks.IndexOf(oldBlock), newBlock);
                    try
                    {
                        complete = checkComplete();
                        return (true);
                    }
                    catch (InvalidOperationException)
                    {
                        blocks.Clear();
                        return (false);
                    }
                }
            }

            blocks.Add(newBlock);

            try
            {
                complete = checkComplete();
                return (true);
            }
            catch (InvalidOperationException)
            {
                blocks.Clear();
                return (false);
            }
        }
예제 #4
0
        /// <summary>
        /// Create an instance of a DSMCC message.
        /// </summary>
        /// <param name="dsmccHeader">The header of the message.</param>
        /// <param name="byteData">The MPEG2 data block that contains the message.</param>
        /// <returns>An instance of the appropriate DSMCC message class.</returns>
        public static DSMCCMessage CreateInstance(DSMCCHeader dsmccHeader, byte[] byteData)
        {
            DSMCCMessage dsmccMessage;

            switch (dsmccHeader.MessageID)
            {
                case DSMCCDownloadDataBlock.MessageIDDownloadDataBlock:
                    dsmccMessage = new DSMCCDownloadDataBlock(dsmccHeader);
                    break;
                case DSMCCDownloadInfoIndication.MessageIDDownloadInfoIndication:
                    dsmccMessage = new DSMCCDownloadInfoIndication(dsmccHeader);
                    break;
                case DSMCCDownloadServerInitiate.MessageIDDownloadServerInitiate:
                    dsmccMessage = new DSMCCDownloadServerInitiate(dsmccHeader);
                    break;
                case DSMCCDownloadCancel.MessageIDDownloadCancel:
                    dsmccMessage = new DSMCCDownloadCancel(dsmccHeader);
                    break;
                default:
                    throw (new ArgumentException("The DSMCC message ID is out of range"));
            }

            dsmccMessage.Process(byteData, dsmccHeader.Index);

            return (dsmccMessage);
        }
예제 #5
0
        private bool addDDBMessage(DSMCCDownloadDataBlock downloadDataBlock)
        {
            downloadDataBlock.LogMessage();

            foreach (DSMCCModule module in modules)
            {
                if (module.ModuleID == downloadDataBlock.ModuleID && module.Version == downloadDataBlock.ModuleVersion)
                    return (module.AddBlock(downloadDataBlock));
            }

            return (false);
        }