示例#1
0
        /// <summary>
        /// Parse the service description.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the service description.</param>
        /// <param name="index">Index of the first byte of the service description in the MPEG2 section.</param>
        internal void Process(byte[] byteData, int index)
        {
            lastIndex = index;

            try
            {
                serviceID  = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex += 2;

                eitSchedule         = ((int)byteData[lastIndex] & 0x02) != 0;
                eitPresentFollowing = ((int)byteData[lastIndex] & 0x01) != 0;
                lastIndex++;

                runningStatus = (int)(byteData[lastIndex] >> 5);
                scrambled     = ((int)byteData[lastIndex] & 0x10) >> 4 == 1;

                int descriptorLoopLength = ((byteData[lastIndex] & 0x0f) * 256) + (int)byteData[lastIndex + 1];
                lastIndex += 2;

                while (descriptorLoopLength != 0)
                {
                    DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex, Scope.ServiceDescripton);

                    if (!descriptor.IsEmpty)
                    {
                        if (descriptor as DVBServiceDescriptor != null)
                        {
                            serviceDescriptor = descriptor as DVBServiceDescriptor;
                        }
                        else
                        {
                            if (descriptor as ServiceChannelDescriptor != null)
                            {
                                serviceChannelDescriptor = descriptor as ServiceChannelDescriptor;
                            }
                        }

                        lastIndex             = descriptor.Index;
                        descriptorLoopLength -= descriptor.TotalLength;
                    }
                    else
                    {
                        lastIndex            += DescriptorBase.MinimumDescriptorLength;
                        descriptorLoopLength -= DescriptorBase.MinimumDescriptorLength;
                    }
                }

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The DVB Service Description message is short"));
            }
        }
示例#2
0
        /// <summary>
        /// Create an instance of the descriptor class.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the descriptor.</param>
        /// <param name="index">The index of the tag byte of the descriptor.</param>
        /// <param name="scope">The current scope.</param>
        /// <returns>A descriptor instance.</returns>
        internal static DescriptorBase Instance(byte[] byteData, int index, Scope scope)
        {
            DescriptorBase descriptor;

            switch ((int)byteData[index])
            {
            case NetworkNameDescriptorTag:
                descriptor = new DVBNetworkNameDescriptor();
                break;

            case SatelliteDeliverySystemDescriptorTag:
                descriptor = new DVBSatelliteDeliverySystemDescriptor();
                break;

            case ServiceDescriptorTag:
                descriptor = new DVBServiceDescriptor();
                break;

            case ServiceListDescriptorTag:
                descriptor = new DVBServiceListDescriptor();
                break;

            case ShortEventDescriptorTag:
                descriptor = new DVBShortEventDescriptor();
                break;

            case ExtendedEventDescriptorTag:
                descriptor = new DVBExtendedEventDescriptor();
                break;

            case ComponentDescriptorTag:
                descriptor = new DVBComponentDescriptor();
                break;

            case ContentDescriptorTag:
                descriptor = new DVBContentDescriptor();
                break;

            case ParentalRatingDescriptorTag:
                descriptor = new DVBParentalRatingDescriptor();
                break;

            case BouquetNameDescriptorTag:
                descriptor = new DVBBouquetNameDescriptor();
                break;

            case LocalTimeOffsetDescriptorTag:
                descriptor = new DVBLocalTimeOffsetDescriptor();
                break;

            case OpenTVChannelInfoDescriptorTag:
                descriptor = new OpenTVChannelInfoDescriptor();
                break;

            case GenericChannelInfoDescriptorTag:
                switch (scope)
                {
                case Scope.Bouquet:
                    descriptor = new FreeviewChannelInfoDescriptor();
                    break;

                case Scope.ServiceDescripton:
                    descriptor = new ServiceChannelDescriptor();
                    break;

                default:
                    descriptor = new DescriptorBase();
                    break;
                }
                break;

            case FreeviewChannelInfoDescriptorTag:
            case TurkeyChannelInfoDescriptorTag:
            case E2ChannelInfoDescriptorTag:
                if (scope == Scope.Bouquet)
                {
                    descriptor = new FreeviewChannelInfoDescriptor();
                }
                else
                {
                    descriptor = new DescriptorBase();
                }
                break;

            case FreeSatChannelInfoDescriptorTag:
                descriptor = new FreeSatChannelInfoDescriptor();
                break;

            case ContentIdentifierDescriptorTag:
                descriptor = new DVBContentIdentifierDescriptor();
                break;

            default:
                descriptor = new DescriptorBase();
                break;
            }

            descriptor.tag = (int)byteData[index];
            index++;

            descriptor.length = (int)byteData[index];
            index++;

            if (descriptor.Length != 0)
            {
                descriptor.Process(byteData, index);
            }

            return(descriptor);
        }
示例#3
0
        /// <summary>
        /// Create an instance of the descriptor class.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the descriptor.</param>
        /// <param name="index">The index of the tag byte of the descriptor.</param>
        /// <param name="scope">The current scope.</param>
        /// <returns>A descriptor instance.</returns>
        internal static DescriptorBase Instance(byte[] byteData, int index, Scope scope)
        {
            DescriptorBase descriptor;

            switch ((int)byteData[index])
            {
                case NetworkNameDescriptorTag:
                    descriptor = new DVBNetworkNameDescriptor();
                    break;
                case SatelliteDeliverySystemDescriptorTag:
                    descriptor = new DVBSatelliteDeliverySystemDescriptor();
                    break;
                case ServiceDescriptorTag:
                    descriptor = new DVBServiceDescriptor();
                    break;
                case ServiceListDescriptorTag:
                    descriptor = new DVBServiceListDescriptor();
                    break;
                case ShortEventDescriptorTag:
                    descriptor = new DVBShortEventDescriptor();
                    break;
                case ExtendedEventDescriptorTag:
                    descriptor = new DVBExtendedEventDescriptor();
                    break;
                case ComponentDescriptorTag:
                    descriptor = new DVBComponentDescriptor();
                    break;
                case ContentDescriptorTag:
                    descriptor = new DVBContentDescriptor();
                    break;
                case ParentalRatingDescriptorTag:
                    descriptor = new DVBParentalRatingDescriptor();
                    break;
                case BouquetNameDescriptorTag:
                    descriptor = new DVBBouquetNameDescriptor();
                    break;
                case LocalTimeOffsetDescriptorTag:
                    descriptor = new DVBLocalTimeOffsetDescriptor();
                    break;
                case OpenTVChannelInfoDescriptorTag:
                    descriptor = new OpenTVChannelInfoDescriptor();
                    break;
                case GenericChannelInfoDescriptorTag:
                    switch (scope)
                    {
                        case Scope.Bouquet:
                            descriptor = new FreeviewChannelInfoDescriptor();
                            break;
                        case Scope.ServiceDescripton:
                            descriptor = new ServiceChannelDescriptor();
                            break;
                        default:
                            descriptor = new DescriptorBase();
                            break;
                    }
                    break;
                case FreeviewChannelInfoDescriptorTag:
                case TurkeyChannelInfoDescriptorTag:
                case E2ChannelInfoDescriptorTag:
                    if (scope == Scope.Bouquet)
                        descriptor = new FreeviewChannelInfoDescriptor();
                    else
                        descriptor = new DescriptorBase();
                    break;
                case FreeSatChannelInfoDescriptorTag:
                    descriptor = new FreeSatChannelInfoDescriptor();
                    break;
                case ContentIdentifierDescriptorTag:
                    descriptor = new DVBContentIdentifierDescriptor();
                    break;
                default:
                    descriptor = new DescriptorBase();
                    break;
            }

            descriptor.tag = (int)byteData[index];
            index++;

            descriptor.length = (int)byteData[index];
            index++;

            if (descriptor.Length != 0)
                descriptor.Process(byteData, index);

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

            try
            {
                serviceID = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex += 2;

                eitSchedule = ((int)byteData[lastIndex] & 0x02) != 0;
                eitPresentFollowing = ((int)byteData[lastIndex] & 0x01) != 0;
                lastIndex++;

                runningStatus = (int)(byteData[lastIndex] >> 5);
                scrambled = ((int)byteData[lastIndex] & 0x10) >> 4 == 1;

                int descriptorLoopLength = ((byteData[lastIndex] & 0x0f) * 256) + (int)byteData[lastIndex + 1];
                lastIndex += 2;

                while (descriptorLoopLength != 0)
                {
                    DescriptorBase descriptor = DescriptorBase.Instance(byteData, lastIndex, Scope.ServiceDescripton);

                    if (!descriptor.IsEmpty)
                    {
                        if (descriptor as DVBServiceDescriptor != null)
                            serviceDescriptor = descriptor as DVBServiceDescriptor;
                        else
                        {
                            if (descriptor as ServiceChannelDescriptor != null)
                                serviceChannelDescriptor = descriptor as ServiceChannelDescriptor;
                        }

                        lastIndex = descriptor.Index;
                        descriptorLoopLength -= descriptor.TotalLength;
                    }
                    else
                    {
                        lastIndex += DescriptorBase.MinimumDescriptorLength;
                        descriptorLoopLength -= DescriptorBase.MinimumDescriptorLength;
                    }
                }

                Validate();
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The DVB Service Description message is short"));
            }
        }