Example #1
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);
        }
Example #2
0
        private void processDescriptor(DescriptorBase descriptor)
        {
            switch (descriptor.Tag)
            {
            case DescriptorBase.ShortEventDescriptorTag:
                DVBShortEventDescriptor shortEventDescriptor = descriptor as DVBShortEventDescriptor;
                if (eventName == null)
                {
                    processShortEventDescriptor(shortEventDescriptor);
                }
                else
                {
                    if (RunParameters.Instance.InputLanguage == null)
                    {
                        processShortEventDescriptor(shortEventDescriptor);
                    }
                    else
                    {
                        if (shortEventDescriptor.LanguageCode == RunParameters.Instance.InputLanguage)
                        {
                            processShortEventDescriptor(shortEventDescriptor);
                        }
                        else
                        {
                            if (shortEventDescriptor.LanguageCode == "eng")
                            {
                                processShortEventDescriptor(shortEventDescriptor);
                            }
                        }
                    }
                }
                LanguageCode.RegisterUsage(shortEventDescriptor.LanguageCode);
                break;

            case DescriptorBase.ExtendedEventDescriptorTag:
                DVBExtendedEventDescriptor extendedEventDescriptor = descriptor as DVBExtendedEventDescriptor;
                if (extendedDescription == null)
                {
                    processExtendedEventDescriptor(extendedEventDescriptor);
                }
                else
                {
                    if (RunParameters.Instance.InputLanguage == null)
                    {
                        processExtendedEventDescriptor(extendedEventDescriptor);
                    }
                    else
                    {
                        if (extendedEventDescriptor.LanguageCode == RunParameters.Instance.InputLanguage)
                        {
                            processExtendedEventDescriptor(extendedEventDescriptor);
                        }
                        else
                        {
                            if (extendedEventDescriptor.LanguageCode == "eng")
                            {
                                processExtendedEventDescriptor(extendedEventDescriptor);
                            }
                        }
                    }
                }
                LanguageCode.RegisterUsage(extendedEventDescriptor.LanguageCode);
                break;

            case DescriptorBase.ComponentDescriptorTag:
                if ((descriptor as DVBComponentDescriptor).ComponentTypeVideo != -1)
                {
                    componentTypeVideo = (descriptor as DVBComponentDescriptor).ComponentTypeVideo;
                }
                if ((descriptor as DVBComponentDescriptor).ComponentTypeAudio != -1)
                {
                    componentTypeAudio = (descriptor as DVBComponentDescriptor).ComponentTypeAudio;
                }
                if ((descriptor as DVBComponentDescriptor).ComponentTypeSubtitles != -1)
                {
                    componentTypeSubtitles = (descriptor as DVBComponentDescriptor).ComponentTypeSubtitles;
                }
                break;

            case DescriptorBase.ContentDescriptorTag:
                contentType    = (descriptor as DVBContentDescriptor).ContentType[0];
                contentSubType = (descriptor as DVBContentDescriptor).ContentSubType[0];
                break;

            case DescriptorBase.ParentalRatingDescriptorTag:
                DVBParentalRatingDescriptor parentalRatingDescriptor = descriptor as DVBParentalRatingDescriptor;
                if (parentalRatingDescriptor.ParentalRatings != null)
                {
                    parentalRating = (descriptor as DVBParentalRatingDescriptor).ParentalRatings[0];
                }
                break;

            case DescriptorBase.ContentIdentifierDescriptorTag:
                DVBContentIdentifierDescriptor contentIdentifierDescriptor = descriptor as DVBContentIdentifierDescriptor;
                if (contentIdentifierDescriptor.IsSeriesLink)
                {
                    seriesID = contentIdentifierDescriptor.ContentReference;
                }
                else
                {
                    if (contentIdentifierDescriptor.IsEpisodeLink)
                    {
                        episodeID = contentIdentifierDescriptor.ContentReference;
                    }
                }
                break;

            default:
                if (RunParameters.Instance.DebugIDs.Contains("UNKNOWNDESCRIPTORS"))
                {
                    Logger.Instance.Write("Unprocessed EIT descriptor: 0x" + descriptor.Tag.ToString("X"));
                    if (RunParameters.Instance.DebugIDs.Contains("LOGDESCRIPTORDATA"))
                    {
                        Logger.Instance.Dump("Descriptor Data", descriptor.Data, descriptor.Data.Length);
                    }
                }
                break;
            }
        }