Exemplo n.º 1
0
        protected override bool EnumerateStreams(bool forceRefresh)
        {
            //FIXME: TSReader only offers Audio in IAMStreamSelect, it would be cleaner to expose subs as well.
            bool refreshed = base.EnumerateStreams(forceRefresh);

            if (refreshed)
            {
                // If base class has refreshed the stream infos, then update the subtitle streams.
                ISubtitleStream subtitleStream = _sourceFilter as ISubtitleStream;
                int             count          = 0;
                if (subtitleStream != null)
                {
                    _streamInfoSubtitles = new StreamInfoHandler();
                    subtitleStream.GetSubtitleStreamCount(ref count);
                    if (count > 0)
                    {
                        StreamInfo subStream = new StreamInfo(null, NO_STREAM_INDEX, NO_SUBTITLES, 0);
                        _streamInfoSubtitles.AddUnique(subStream);
                    }
                    for (int i = 0; i < count; ++i)
                    {
                        //FIXME: language should be passed back also as LCID
                        SubtitleLanguage language = new SubtitleLanguage();
                        subtitleStream.GetSubtitleStreamLanguage(i, ref language);
                        int lcid = LookupLcidFromName(language.lang);
                        // Note: the "type" is no longer considered in MP1 code as well, so I guess DVBSub3 only supports Bitmap subs at all.
                        string     name      = language.lang;
                        StreamInfo subStream = new StreamInfo(null, i, name, lcid);
                        _streamInfoSubtitles.AddUnique(subStream);
                    }
                }
            }
            return(refreshed);
        }
Exemplo n.º 2
0
        protected override bool EnumerateStreams(bool forceRefresh)
        {
            bool refreshed = base.EnumerateStreams(forceRefresh);

            if (refreshed)
            {
                ISubtitleStream subtitleStream      = _tsReader as ISubtitleStream;
                int             subtitleStreamCount = 0;
                subtitleStream?.GetSubtitleStreamCount(ref subtitleStreamCount);

                if (subtitleStreamCount >= 1)
                {
                    _streamInfoSubtitles = new TsReaderStreamInfoHandler(subtitleStream);
                    SetPreferredSubtitle();
                    return(true);
                }
                ITeletextSource teletextSource      = _tsReader as ITeletextSource;
                int             teletextStreamCount = 0;
                teletextSource?.GetTeletextStreamCount(ref teletextStreamCount);
                if (teletextStreamCount >= 1)
                {
                    _streamInfoSubtitles = new TsReaderTeletextInfoHandler(teletextSource);
                    SetPreferredSubtitle();
                    return(true);
                }
            }
            return(false);
        }
        public TsReaderStreamInfoHandler(ISubtitleStream subtitleStream)
        {
            if (subtitleStream == null)
            {
                return;
            }

            int count = 0;

            _subtitleStream = subtitleStream;
            subtitleStream.GetSubtitleStreamCount(ref count);
            if (count > 0)
            {
                StreamInfo subStream = new StreamInfo(null, NO_STREAM_INDEX, VideoPlayer.NO_SUBTITLES, 0);
                AddUnique(subStream);
            }
            for (int i = 0; i < count; ++i)
            {
                //FIXME: language should be passed back also as LCID
                SubtitleLanguage language = new SubtitleLanguage();
                subtitleStream.GetSubtitleStreamLanguage(i, ref language);
                int lcid = BaseDXPlayer.LookupLcidFromName(language.lang);
                // Note: the "type" is no longer considered in MP1 code as well, so I guess DVBSub3 only supports Bitmap subs at all.
                string     name      = language.lang;
                StreamInfo subStream = new StreamInfo(null, i, name, lcid);
                AddUnique(subStream);
            }
        }
Exemplo n.º 4
0
        protected override void AddSubtitleFilter(bool isSourceFilterPresent)
        {
            VideoSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <VideoSettings>() ?? new VideoSettings();

            ISubtitleStream subtitleStream      = _tsReader as ISubtitleStream;
            int             subtitleStreamCount = 0;

            subtitleStream?.GetSubtitleStreamCount(ref subtitleStreamCount);

            ITeletextSource teletextSource      = _tsReader as ITeletextSource;
            int             teletextStreamCount = 0;

            teletextSource?.GetTeletextStreamCount(ref teletextStreamCount);

            bool shouldAddDvbFilter            = isSourceFilterPresent && subtitleStreamCount >= 1 && settings.EnableDvbSubtitles;
            bool shouldRenderTeletextSubtitles = isSourceFilterPresent && teletextStreamCount >= 1 && settings.EnableTeletextSubtitles;
            bool shouldAddClosedCaptionsFilter = settings.EnableAtscClosedCaptions && (subtitleStreamCount == 0 && teletextStreamCount == 0);

            if (shouldAddDvbFilter)
            {
                _subtitleRenderer.SetPlayer(this);
                _subtitleFilter = _subtitleRenderer.AddDvbSubtitleFilter(_graphBuilder);
                if (_subtitleFilter != null)
                {
                    _subtitleRenderer.RenderSubtitles = true;
                }
            }
            else if (shouldRenderTeletextSubtitles)
            {
                _subtitleRenderer.AddTeletextSubtitleDecoder(teletextSource);
                _subtitleRenderer.SetPlayer(this);
                _subtitleRenderer.RenderSubtitles = true;
            }
            else if (shouldAddClosedCaptionsFilter)
            {
                _subtitleRenderer.AddClosedCaptionsFilter(_graphBuilder);
            }
            ServiceRegistration.Get <ILogger>().Debug("TsVideoPlayer.AddSubtitleFilter: shouldAddDvbFilter: {0},  shouldRenderTeletextSubtitles: {1}, " +
                                                      "shouldAddClosedCaptionsFilter: {2}, RenderSubtitles is: {3}, subtitleStreamCount: {4}, teletextStreamCount: {5}",
                                                      shouldAddDvbFilter.ToString(), shouldRenderTeletextSubtitles.ToString(), shouldAddClosedCaptionsFilter.ToString(), _subtitleRenderer.RenderSubtitles.ToString(),
                                                      subtitleStreamCount.ToString(), teletextStreamCount.ToString());
        }
Exemplo n.º 5
0
        protected override bool EnumerateStreams(bool forceRefresh)
        {
            //FIXME: TSReader only offers Audio in IAMStreamSelect, it would be cleaner to expose subs as well.
            bool refreshed = base.EnumerateStreams(forceRefresh);

            if (refreshed)
            {
                // If base class has refreshed the stream infos, then update the subtitle streams.
                ISubtitleStream subtitleStream = _fileSource as ISubtitleStream;
                int             count          = 0;
                if (subtitleStream != null)
                {
                    _streamInfoSubtitles = new StreamInfoHandler();
                    subtitleStream.GetSubtitleStreamCount(ref count);
                    if (count > 0)
                    {
                        StreamInfo subStream = new StreamInfo(null, NO_STREAM_INDEX, NO_SUBTITLES, 0);
                        _streamInfoSubtitles.AddUnique(subStream);
                    }
                    for (int i = 0; i < count; ++i)
                    {
                        //FIXME: language should be passed back also as LCID
                        SubtitleLanguage language = new SubtitleLanguage();
                        int type = 0;
                        subtitleStream.GetSubtitleStreamLanguage(i, ref language);
                        subtitleStream.GetSubtitleStreamType(i, ref type);
                        int    lcid = LookupLcidFromName(language.lang);
                        string name = type == 0
                            ? String.Format("{0} (DVB)", language.lang)
                            : String.Format("{0} (Teletext)", language.lang);
                        StreamInfo subStream = new StreamInfo(null, i, name, lcid);
                        _streamInfoSubtitles.AddUnique(subStream);
                    }
                }
            }
            return(refreshed);
        }