internal void Initialize(TransportStreamParser tsParser, string fileName)
        {
            _programMapTableParser = new ProgramMapTableParser();
            _programMapTableParser.Parse(fileName); // get languages
            _tsParser = tsParser;
            _fileName = fileName;
            Text      = string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.Title, fileName);

            foreach (int id in tsParser.SubtitlePacketIds)
            {
                var language = _programMapTableParser.GetSubtitleLanguage(id);
                if (string.IsNullOrEmpty(language))
                {
                    language = "unknown";
                }

                listBoxTracks.Items.Add(new StreamTrackItem
                {
                    Text       = string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.PidLineImage, id, language, tsParser.GetDvbSubtitles(id).Count),
                    IsTeletext = false,
                    Pid        = id,
                    Language   = language
                });
            }

            foreach (var program in tsParser.TeletextSubtitlesLookup)
            {
                var language = _programMapTableParser.GetSubtitleLanguage(program.Key);
                if (string.IsNullOrEmpty(language))
                {
                    language = "unknown";
                }

                foreach (var kvp in program.Value)
                {
                    var subtitle = new Subtitle(kvp.Value);
                    subtitle.Renumber();
                    listBoxTracks.Items.Add(new StreamTrackItem
                    {
                        Text       = string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.PidLineTeletext, kvp.Key, program.Key, language, kvp.Value.Count),
                        IsTeletext = true,
                        Pid        = program.Key,
                        PageNumber = kvp.Key,
                        Srt        = new SubRip().ToText(subtitle, null)
                    });
                }
            }

            listBoxTracks.SelectedIndex = 0;
        }
        private string GetSelectedLanguage()
        {
            int idx = listBoxSubtitles.SelectedIndex;

            if (idx < 0)
            {
                return(null);
            }

            int pid = _tsParser.SubtitlePacketIds[listBoxTracks.SelectedIndex];

            return(_programMapTableParser.GetSubtitleLanguage(pid));
        }
Exemplo n.º 3
0
        public static string GetFileNameEnding(ProgramMapTableParser pmt, int pid)
        {
            var twoLetter   = pmt.GetSubtitleLanguageTwoLetter(pid);
            var threeLetter = pmt.GetSubtitleLanguage(pid);

            if (string.IsNullOrEmpty(twoLetter))
            {
                twoLetter = threeLetter;
            }
            if (string.IsNullOrEmpty(threeLetter))
            {
                twoLetter   = pid.ToString(CultureInfo.InvariantCulture);
                threeLetter = pid.ToString(CultureInfo.InvariantCulture);
            }

            return(Configuration.Settings.Tools.BatchConvertTsFileNameAppend
                   .Replace("{two-letter-country-code}", twoLetter)
                   .Replace("{two-letter-country-code-uppercase}", twoLetter.ToUpperInvariant())
                   .Replace("{three-letter-country-code}", threeLetter)
                   .Replace("{three-letter-country-code-uppercase}", threeLetter));
        }
Exemplo n.º 4
0
        internal void Initialize(TransportStreamParser tsParser, string fileName)
        {
            _programMapTableParser = new ProgramMapTableParser();
            _programMapTableParser.Parse(fileName); // get languages
            _tsParser = tsParser;
            _fileName = fileName;
            Text      = string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.Title, fileName);

            foreach (int id in tsParser.SubtitlePacketIds)
            {
                var language = _programMapTableParser.GetSubtitleLanguage(id);
                if (!string.IsNullOrEmpty(language))
                {
                    listBoxTracks.Items.Add(string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.PidLine, id + ", " + language, tsParser.GetDvbSubtitles(id).Count));
                }
                else
                {
                    listBoxTracks.Items.Add(string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.PidLine, id, tsParser.GetDvbSubtitles(id).Count));
                }
            }
            listBoxTracks.SelectedIndex = 0;
        }