Exemplo n.º 1
0
        /// <summary>
        /// Acquire and process EIT data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            EITProgramContent.Load();
            CustomProgramCategory.Load();

            MultiTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary FreeSat T1.cfg"), Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary FreeSat T2.cfg"));

            /*GetStationData(dataProvider, worker, new int[] { 0xbba, 0xc1e, 0xf01 });*/
            GetStationData(dataProvider, worker, new int[] { 0xbba });
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            if (RunParameters.Instance.ChannelBouquet != -1 ||
                RunParameters.Instance.Options.Contains("USECHANNELID") ||
                RunParameters.Instance.Options.Contains("USELCN") ||
                RunParameters.Instance.Options.Contains("CREATEBRCHANNELS") ||
                RunParameters.Instance.Options.Contains("CREATEARCHANNELS"))
            {
                /*GetBouquetSections(dataProvider, worker, new int[] { 0xbba, oxc1e, oxf01 } );*/
                GetBouquetSections(dataProvider, worker, new int[] { 0xbba });
                if (worker.CancellationPending)
                {
                    return(CollectorReply.Cancelled);
                }
            }

            getFreeSatSections(dataProvider, worker);

            return(CollectorReply.OK);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Acquire and process EIT data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            EITProgramContent.Load();
            CustomProgramCategory.Load();
            ParentalRating.Load();

            if (RunParameters.Instance.Options.Contains("USEFREESATTABLES"))
            {
                MultiTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary FreeSat T1.cfg"), Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary FreeSat T2.cfg"));
            }

            GetStationData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            bool bouquetNeeded = checkBouquetNeeded();

            if (RunParameters.Instance.ChannelBouquet != -1 ||
                RunParameters.Instance.Options.Contains("USECHANNELID") ||
                RunParameters.Instance.Options.Contains("USELCN") ||
                RunParameters.Instance.Options.Contains("CREATEBRCHANNELS") ||
                RunParameters.Instance.Options.Contains("CREATEARCHANNELS"))
            {
                GetBouquetSections(dataProvider, worker);

                string bouquetType;

                if (eitChannels > 0)
                {
                    bouquetType = "Freeview";
                }
                else
                {
                    bouquetType = "OpenTV";
                }

                Logger.Instance.Write("Used " + bouquetType + " channel descriptors");

                if (worker.CancellationPending)
                {
                    return(CollectorReply.Cancelled);
                }
            }

            getEITSections(dataProvider, worker);

            return(CollectorReply.OK);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Acquire and process ATSC PSIP Info data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            AtscPsipProgramCategory.Load();
            CustomProgramCategory.Load();

            bool referenceTablesLoaded = MultiTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary ATSC PSIP T1.cfg"), Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary ATSC PSIP T2.cfg"));

            if (!referenceTablesLoaded)
            {
                return(CollectorReply.ReferenceDataError);
            }

            getMasterGuideData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getVirtualChannelData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            /*getRatingRegionData(dataProvider, worker);
             * if (worker.CancellationPending)
             *  return (CollectorReply.Cancelled);*/

            getExtendedTextData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getEventInformationData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            OutputFile.UseUnicodeEncoding = MultipleString.UseUnicodeEncoding;

            return(CollectorReply.OK);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Convert a subset of an array of text bytes to a string.
        /// </summary>
        /// <param name="byteData">The array of bytes.</param>
        /// <param name="offset">The index of the first byte to be converted.</param>
        /// <param name="length">The number of bytes to be converted.</param>
        /// <param name="replace">True to replace non-Ascii bytes with a space; false to ignore them.</param>
        /// <returns>The converted string.</returns>
        public static string GetString(byte[] byteData, int offset, int length, bool replace)
        {
            if (length == 0)
            {
                return(string.Empty);
            }

            string isoTable  = null;
            int    startByte = 0;

            if (RunParameters.Instance.CharacterSet != null)
            {
                isoTable = RunParameters.Instance.CharacterSet;
                if (byteData[offset] < 0x20)
                {
                    startByte = 1;
                }
            }
            else
            {
                if (byteData[offset] >= 0x20)
                {
                    isoTable = "iso-8859-1";
                }
                else
                {
                    switch (byteData[offset])
                    {
                    case 0x01:
                    case 0x02:
                    case 0x03:
                    case 0x04:
                    case 0x05:
                    case 0x06:
                    case 0x07:
                    case 0x08:
                    case 0x09:
                    case 0x0a:
                    case 0x0b:
                        isoTable  = "iso-8859-" + (byteData[offset] + 4).ToString();
                        startByte = 1;
                        break;

                    case 0x10:
                        if (byteData[offset + 1] == 0x00)
                        {
                            if (byteData[offset + 2] != 0x00 && byteData[offset + 2] != 0x0c)
                            {
                                isoTable  = "iso-8859-" + ((int)byteData[offset + 2]).ToString();
                                startByte = 3;
                                break;
                            }
                            else
                            {
                                return("Invalid DVB text string: byte 3 is not a valid value");
                            }
                        }
                        else
                        {
                            return("Invalid DVB text string: byte 2 is not a valid value");
                        }

                    case 0x11:
                    case 0x15:
                        isoTable  = "utf-8";
                        startByte = 1;
                        break;

                    case 0x1f:
                        if (byteData[offset + 1] == 0x01 || byteData[offset + 1] == 0x02)
                        {
                            if (MultiTreeDictionaryEntry.Loaded)
                            {
                                return(MultiTreeDictionaryEntry.DecodeData(Utils.GetBytes(byteData, offset, length + 1)));
                            }
                            else
                            {
                                return("Huffman text: " + Utils.ConvertToHex(byteData, offset, length));
                            }
                        }
                        else
                        {
                            return("Invalid DVB text string: Custom text specifier is not recognized");
                        }

                    default:
                        return("Invalid DVB text string: byte 1 is not a valid value");
                    }
                }
            }

            byte[] editedBytes  = new byte[length];
            int    editedLength = 0;

            for (int index = startByte; index < length; index++)
            {
                if (byteData[offset + index] > 0x1f)
                {
                    if (byteData[offset + index] < 0x80 || byteData[offset + index] > 0x9f)
                    {
                        editedBytes[editedLength] = byteData[offset + index];
                        editedLength++;
                    }
                }
                else
                {
                    if (replace)
                    {
                        editedBytes[editedLength] = 0x20;
                        editedLength++;
                    }
                }
            }

            if (editedLength == 0)
            {
                return(string.Empty);
            }

            try
            {
                Encoding sourceEncoding = Encoding.GetEncoding(isoTable);
                if (sourceEncoding == null)
                {
                    sourceEncoding = Encoding.GetEncoding("iso-8859-1");
                }

                return(sourceEncoding.GetString(editedBytes, 0, editedLength));
            }
            catch (ArgumentException e)
            {
                Logger.Instance.Write("<E> A text string could not be decoded");
                Logger.Instance.Write("<E> String: " + Utils.ConvertToHex(byteData, offset, length));
                Logger.Instance.Write("<E> Error: " + e.Message);
                return("** ERROR DECODING STRING - SEE COLLECTION LOG **");
            }
        }
Exemplo n.º 5
0
 internal string processHuffmanData(int compressionType)
 {
     return(MultiTreeDictionaryEntry.DecodeData(compressionType, compressedString));
 }