/// <summary> /// Adds the subtitle filter to the graph. The caller need to call <see cref="Marshal.ReleaseComObject"/> on the /// returned instance when done. /// </summary> /// <param name="graphBuilder">The IGraphBuilder</param> /// <returns>DvbSub2(3) filter instance</returns> public IBaseFilter AddSubtitleFilter(IGraphBuilder graphBuilder) { try { _filter = FilterLoader.LoadFilterFromDll("DVBSub3.ax", CLSID_DVBSUB3, true); _subFilter = _filter as IDVBSubtitleSource; ServiceRegistration.Get <ILogger>().Debug("SubtitleRenderer: CreateFilter success: " + (_filter != null) + " & " + (_subFilter != null)); } catch (Exception e) { ServiceRegistration.Get <ILogger>().Error(e); } if (_subFilter != null) { graphBuilder.AddFilter(_filter, "MediaPortal DVBSub3"); _subFilter.StatusTest(111); _callBack = OnSubtitle; IntPtr pCallback = Marshal.GetFunctionPointerForDelegate(_callBack); _subFilter.SetBitmapCallback(pCallback); _subFilter.StatusTest(222); IntPtr pResetCallBack = Marshal.GetFunctionPointerForDelegate(_resetCallBack); _subFilter.SetResetCallback(pResetCallBack); IntPtr pUpdateTimeoutCallBack = Marshal.GetFunctionPointerForDelegate(_updateTimeoutCallBack); _subFilter.SetUpdateTimeoutCallback(pUpdateTimeoutCallBack); } return(_filter); }
protected override void AddSourceFilter() { var vsFilter = FilterLoader.LoadFilterFromDll(VSFILTER_FILENAME, new Guid(VSFILTER_CLSID), true); _graphBuilder.AddFilter(vsFilter, VSFILTER_NAME); base.AddSourceFilter(); }
/// <summary> /// Adds the file source filter to the graph. /// </summary> protected override void AddFileSource() { // Render the file _fileSource = FilterLoader.LoadFilterFromDll("TsReader.ax", typeof(TsReader).GUID, true); ITsReader tsReader = (ITsReader)_fileSource; tsReader.SetRelaxedMode(1); tsReader.SetTsReaderCallback(this); tsReader.SetRequestAudioChangeCallback(this); _graphBuilder.AddFilter(_fileSource, TSREADER_FILTER_NAME); _subtitleRenderer = new SubtitleRenderer(OnTextureInvalidated); _subtitleFilter = _subtitleRenderer.AddSubtitleFilter(_graphBuilder); if (_subtitleFilter != null) { _subtitleRenderer.RenderSubtitles = true; _subtitleRenderer.SetPlayer(this); } IFileSourceFilter f = (IFileSourceFilter)_fileSource; f.Load(SourcePathOrUrl, null); // Init GraphRebuilder _graphRebuilder = new GraphRebuilder(_graphBuilder, _fileSource, OnAfterGraphRebuild) { PlayerName = PlayerTitle }; }
/// <summary> /// Adds a source filter to the graph and sets the input. /// </summary> protected override void AddSourceFilter() { if (!_useTsReader) { base.AddSourceFilter(); return; } // Render the file _sourceFilter = FilterLoader.LoadFilterFromDll("TsReader.ax", typeof(TsReader).GUID, true); IFileSourceFilter fileSourceFilter = (IFileSourceFilter)_sourceFilter; ITsReader tsReader = (ITsReader)_sourceFilter; tsReader.SetRelaxedMode(1); tsReader.SetTsReaderCallback(this); tsReader.SetRequestAudioChangeCallback(this); _graphBuilder.AddFilter(_sourceFilter, TSREADER_FILTER_NAME); if (_resourceLocator.NativeResourcePath.IsNetworkResource) { // _resourceAccessor points to an rtsp:// stream or network file var sourcePathOrUrl = SourcePathOrUrl; if (sourcePathOrUrl == null) { throw new IllegalCallException("The LiveRadioPlayer can only play network resources of type INetworkResourceAccessor"); } ServiceRegistration.Get <ILogger>().Debug("{0}: Initializing for stream '{1}'", PlayerTitle, sourcePathOrUrl); IDisposable accessEnsurer = null; if (IsLocalFilesystemResource) { accessEnsurer = ((ILocalFsResourceAccessor)_resourceAccessor).EnsureLocalFileSystemAccess(); } using (accessEnsurer) { int hr = fileSourceFilter.Load(SourcePathOrUrl, null); new HRESULT(hr).Throw(); } } else { //_resourceAccessor points to a local .ts file var localFileSystemResourceAccessor = _resourceAccessor as ILocalFsResourceAccessor; if (localFileSystemResourceAccessor == null) { throw new IllegalCallException("The LiveRadioPlayer can only play file resources of type ILocalFsResourceAccessor"); } using (localFileSystemResourceAccessor.EnsureLocalFileSystemAccess()) { ServiceRegistration.Get <ILogger>().Debug("{0}: Initializing for stream '{1}'", PlayerTitle, localFileSystemResourceAccessor.LocalFileSystemPath); fileSourceFilter.Load(localFileSystemResourceAccessor.LocalFileSystemPath, null); } } }
protected override void AddSourceFilter() { string sourceFilterName = GetSourceFilterName(_resourceAccessor.ResourcePathName); if (!string.IsNullOrEmpty(sourceFilterName)) { IBaseFilter sourceFilter = null; try { if (sourceFilterName == MPUrlSourceFilter.Downloader.FilterName) { _filterWrapper = FilterLoader.LoadFilterFromDll( Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), @"MPUrlSourceSplitter\MPUrlSourceSplitter.ax"), new Guid(MPUrlSourceFilter.Downloader.FilterCLSID)); sourceFilter = _filterWrapper.GetFilter(); if (sourceFilter != null) { _graphBuilder.AddFilter(sourceFilter, MPUrlSourceFilter.Downloader.FilterName); } } else { sourceFilter = FilterGraphTools.AddFilterByName(_graphBuilder, FilterCategory.LegacyAmFilterCategory, sourceFilterName); } if (sourceFilter == null) { throw new OnlineVideosException(string.Format("Could not create instance of source filter: '{0}'", sourceFilterName)); } var filterStateEx = sourceFilter as MPUrlSourceFilter.IFilterStateEx; if (filterStateEx != null) { LoadAndWaitForMPUrlSourceFilter(filterStateEx); } else { var fileSourceFilter = sourceFilter as IFileSourceFilter; if (fileSourceFilter != null) { Marshal.ThrowExceptionForHR(fileSourceFilter.Load(_resourceAccessor.ResourcePathName, null)); } else { throw new OnlineVideosException(string.Format("'{0}' does not implement IFileSourceFilter", sourceFilterName)); } } FilterGraphTools.RenderOutputPins(_graphBuilder, sourceFilter); } finally { FilterGraphTools.TryRelease(ref sourceFilter); } } else { base.AddSourceFilter(); } }
/// <summary> /// Adds the TsReader filter to the graph. /// </summary> protected override void AddSourceFilter() { // Render the file _sourceFilter = FilterLoader.LoadFilterFromDll("TsReader.ax", typeof(TsReader).GUID, true); IFileSourceFilter fileSourceFilter = (IFileSourceFilter)_sourceFilter; ITsReader tsReader = (ITsReader)_sourceFilter; tsReader.SetRelaxedMode(1); tsReader.SetTsReaderCallback(this); tsReader.SetRequestAudioChangeCallback(this); _graphBuilder.AddFilter(_sourceFilter, TSREADER_FILTER_NAME); _subtitleRenderer = new SubtitleRenderer(OnTextureInvalidated); _subtitleFilter = _subtitleRenderer.AddSubtitleFilter(_graphBuilder); if (_subtitleFilter != null) { _subtitleRenderer.RenderSubtitles = true; _subtitleRenderer.SetPlayer(this); } if (_resourceLocator.NativeResourcePath.IsNetworkResource) { // _resourceAccessor points to an rtsp:// stream or network file var sourcePathOrUrl = SourcePathOrUrl; if (sourcePathOrUrl == null) { throw new IllegalCallException("The TsVideoPlayer can only play network resources of type INetworkResourceAccessor"); } ServiceRegistration.Get <ILogger>().Debug("{0}: Initializing for stream '{1}'", PlayerTitle, sourcePathOrUrl); int hr = fileSourceFilter.Load(SourcePathOrUrl, null); new HRESULT(hr).Throw(); } else { // _resourceAccessor points to a local or remote mapped .ts file _localFsRaHelper = new LocalFsResourceAccessorHelper(_resourceAccessor); var localFileSystemResourceAccessor = _localFsRaHelper.LocalFsResourceAccessor; if (localFileSystemResourceAccessor == null) { throw new IllegalCallException("The TsVideoPlayer can only play file resources of type ILocalFsResourceAccessor"); } ServiceRegistration.Get <ILogger>().Debug("{0}: Initializing for stream '{1}'", PlayerTitle, localFileSystemResourceAccessor.LocalFileSystemPath); int hr = fileSourceFilter.Load(localFileSystemResourceAccessor.LocalFileSystemPath, null); new HRESULT(hr).Throw(); } // Init GraphRebuilder _graphRebuilder = new GraphRebuilder(_graphBuilder, _sourceFilter, OnAfterGraphRebuild) { PlayerName = PlayerTitle }; }
protected override void AddSourceFilter() { //VideoSettings settings = ServiceRegistration.Get<ISettingsManager>().Load<VideoSettings>() ?? new VideoSettings(); //if (settings.EnableSubtitles) { var _vsFilter = FilterLoader.LoadFilterFromDll(VSFILTER_FILENAME, new Guid(VSFILTER_CLSID), true); _graphBuilder.AddFilter(_vsFilter, VSFILTER_NAME); } base.AddSourceFilter(); }
protected override void AddSubtitleFilter() { var vsFilter = FilterLoader.LoadFilterFromDll(VSFILTER_FILENAME, new Guid(VSFILTER_CLSID), true); if (vsFilter == null) { ServiceRegistration.Get <ILogger>().Warn("{0}: Failed to add {1} to graph", PlayerTitle, VSFILTER_NAME); return; } _graphBuilder.AddFilter(vsFilter, VSFILTER_NAME); }
public static void AddStreamSourceFilter(string sourceFilterName, IResourceAccessor resourceAccessor, IGraphBuilder graphBuilder, out FilterFileWrapper filterWrapper) { filterWrapper = null; IBaseFilter sourceFilter = null; try { if (sourceFilterName == Utils.FilterName) { var filterPath = FileUtils.BuildAssemblyRelativePath(@"MPUrlSourceSplitter\MPUrlSourceSplitter.ax"); filterWrapper = FilterLoader.LoadFilterFromDll(filterPath, new Guid(Utils.FilterCLSID)); sourceFilter = filterWrapper.GetFilter(); if (sourceFilter != null) { graphBuilder.AddFilter(sourceFilter, Utils.FilterName); } } else { sourceFilter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, sourceFilterName); } if (sourceFilter == null) { throw new UPnPRendererExceptions(string.Format("Could not create instance of source filter: '{0}'", sourceFilterName)); } string url = resourceAccessor.ResourcePathName; var filterStateEx = sourceFilter as OnlineVideos.MPUrlSourceFilter.IFilterStateEx; if (filterStateEx != null) { LoadAndWaitForMPUrlSourceFilter(url, filterStateEx); } else { var fileSourceFilter = sourceFilter as IFileSourceFilter; if (fileSourceFilter != null) { Marshal.ThrowExceptionForHR(fileSourceFilter.Load(resourceAccessor.ResourcePathName, null)); } else { throw new UPnPRendererExceptions(string.Format("'{0}' does not implement IFileSourceFilter", sourceFilterName)); } } FilterGraphTools.RenderOutputPins(graphBuilder, sourceFilter); } finally { FilterGraphTools.TryRelease(ref sourceFilter); } }
protected override void AddSourceFilter() { ServiceRegistration.Get <ILogger>().Debug("{0}: Initializing for WTV media item '{1}'", PlayerTitle, SourcePathOrUrl); var vsFilter = FilterLoader.LoadFilterFromDll(VSFILTER_FILENAME, new Guid(VSFILTER_CLSID), true); _graphBuilder.AddFilter(vsFilter, VSFILTER_NAME); // try to render the url and let DirectShow choose the source filter int hr = _graphBuilder.RenderFile(SourcePathOrUrl, null); new HRESULT(hr).Throw(); }
protected virtual void AddClosedCaptionsFilter() { VideoSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <VideoSettings>(); if (settings.EnableClosedCaption) { // ClosedCaptions filter var ccFilter = FilterLoader.LoadFilterFromDll(CCFILTER_FILENAME, new Guid(CCFILTER_CLSID), true); if (ccFilter == null) { ServiceRegistration.Get <ILogger>().Warn("{0}: Failed to add {1} to graph", PlayerTitle, CCFILTER_FILENAME); return; } _graphBuilder.AddFilter(ccFilter, CCFILTER_FILENAME); } }
public IBaseFilter AddClosedCaptionsFilter(IGraphBuilder graphBuilder) { FilterFileWrapper ccFilter = FilterLoader.LoadFilterFromDll(CCFILTER_FILENAME, new Guid(CCFILTER_CLSID), true); IBaseFilter baseFilter = ccFilter.GetFilter(); if (baseFilter != null) { graphBuilder.AddFilter(baseFilter, CCFILTER_NAME); } else { ccFilter.Dispose(); ServiceRegistration.Get <ILogger>().Warn("SubtitleRenderer: Failed to add {1} to graph", CCFILTER_FILENAME); } return(baseFilter); }
public IBaseFilter AddClosedCaptionsFilter(IGraphBuilder graphBuilder) { // ClosedCaptions filter var platform = IntPtr.Size > 4 ? "x64" : "x86"; FilterFileWrapper ccFilter = FilterLoader.LoadFilterFromDll($"{platform}\\{CCFILTER_FILENAME}", new Guid(CCFILTER_CLSID), true); IBaseFilter baseFilter = ccFilter.GetFilter(); if (baseFilter != null) { graphBuilder.AddFilter(baseFilter, CCFILTER_NAME); } else { ccFilter.Dispose(); ServiceRegistration.Get <ILogger>().Warn("SubtitleRenderer: Failed to add {1} to graph", CCFILTER_FILENAME); } return(baseFilter); }
/// <summary> /// Adds a source filter to the graph and sets the input. /// </summary> protected override void AddSourceFilter() { if (!_useTsReader) { base.AddSourceFilter(); return; } // Render the file // Notes Morpheus_xx, 2017-04-19: // In contrast to TV we need to use a relative path here, as the method is located inside the SlimTV assembly. // For TV part, the base class inside VideoPlayers is used and thus the correct path to TsReader.ax // The problem with different paths appears only inside RELEASE builds, but not DEBUG. Why this happens I don't know. var platform = IntPtr.Size > 4 ? "x64" : "x86"; _sourceFilter = FilterLoader.LoadFilterFromDll($"..\\VideoPlayers\\{platform}\\TsReader.ax", typeof(TsReader).GUID, true); var baseFilter = _sourceFilter.GetFilter(); IFileSourceFilter fileSourceFilter = (IFileSourceFilter)baseFilter; _tsReader = (ITsReader)baseFilter; _tsReader.SetRelaxedMode(1); _tsReader.SetTsReaderCallback(this); _tsReader.SetRequestAudioChangeCallback(this); _graphBuilder.AddFilter(baseFilter, TSREADER_FILTER_NAME); if (_resourceLocator.NativeResourcePath.IsNetworkResource) { // _resourceAccessor points to an rtsp:// stream or network file var sourcePathOrUrl = SourcePathOrUrl; if (sourcePathOrUrl == null) { throw new IllegalCallException("The LiveRadioPlayer can only play network resources of type INetworkResourceAccessor"); } ServiceRegistration.Get <ILogger>().Debug("{0}: Initializing for stream '{1}'", PlayerTitle, sourcePathOrUrl); IDisposable accessEnsurer = null; if (IsLocalFilesystemResource) { accessEnsurer = ((ILocalFsResourceAccessor)_resourceAccessor).EnsureLocalFileSystemAccess(); } using (accessEnsurer) { int hr = fileSourceFilter.Load(SourcePathOrUrl, null); new HRESULT(hr).Throw(); } } else { //_resourceAccessor points to a local .ts file var localFileSystemResourceAccessor = _resourceAccessor as ILocalFsResourceAccessor; if (localFileSystemResourceAccessor == null) { throw new IllegalCallException("The LiveRadioPlayer can only play file resources of type ILocalFsResourceAccessor"); } using (localFileSystemResourceAccessor.EnsureLocalFileSystemAccess()) { ServiceRegistration.Get <ILogger>().Debug("{0}: Initializing for stream '{1}'", PlayerTitle, localFileSystemResourceAccessor.LocalFileSystemPath); fileSourceFilter.Load(localFileSystemResourceAccessor.LocalFileSystemPath, null); } } }
/// <summary> /// Adds the file source filter to the graph. /// </summary> protected override void AddSourceFilter() { if (!IsLocalFilesystemResource) { throw new IllegalCallException("The BluRayPlayer can only play local file system resources"); } // Load source filter, assembly location must be determined here, otherwise LoadFilterFromDll would try to lookup the file relative to VideoPlayer! string filterPath = FilterLoader.BuildAssemblyRelativePath("BDReader.ax"); _fileSource = FilterLoader.LoadFilterFromDll(filterPath, typeof(BDReader).GUID); var baseFilter = _fileSource.GetFilter(); // Init BD Reader _bdReader = (IBDReader)baseFilter; LoadSettings(); _bdReader.SetD3DDevice(_device.NativePointer); _bdReader.SetBDReaderCallback(this); _graphBuilder.AddFilter(baseFilter, BluRayAPI.BDREADER_FILTER_NAME); // TODO: add the correct subtitle filter /* _subtitleRenderer = new SubtitleRenderer(OnTextureInvalidated); * _subtitleFilter = _subtitleRenderer.AddSubtitleFilter(_graphBuilder); * if (_subtitleFilter != null) * { * _subtitleRenderer.RenderSubtitles = true; * _subtitleRenderer.SetPlayer(this); * } */ // Prepare event handling _eventThread = new Thread(HandleBDEvent); _eventThread.Start(); // Render the file IFileSourceFilter f = (IFileSourceFilter)_fileSource; using (((ILocalFsResourceAccessor)_resourceAccessor).EnsureLocalFileSystemAccess()) { string strFile = Path.Combine(((ILocalFsResourceAccessor)_resourceAccessor).LocalFileSystemPath, @"BDMV\index.bdmv"); f.Load(strFile, null); // Init GraphRebuilder _graphRebuilder = new GraphRebuilder(_graphBuilder, baseFilter, OnAfterGraphRebuild) { PlayerName = PlayerTitle }; // Get the complete BD title information (including all streams, chapters...) _titleInfos = GetTitleInfoCollection(_bdReader); ulong duration = 0; uint maxIdx = 0; foreach (BluRayAPI.BDTitleInfo bdTitleInfo in _titleInfos) { if (bdTitleInfo.Duration > duration) { duration = bdTitleInfo.Duration; maxIdx = bdTitleInfo.Index; } } // TEST: play the longest title _forceTitle = false; if (_forceTitle) { _bdReader.ForceTitleBasedPlayback(true, maxIdx); _currentTitle = (int)maxIdx; } else { _bdReader.ForceTitleBasedPlayback(false, 0); } _bdReader.Start(); SetVideoDecoder(); } }
/// <summary> /// Adds the TsReader filter to the graph. /// </summary> protected override void AddSourceFilter() { var platform = IntPtr.Size > 4 ? "x64" : "x86"; _sourceFilter = FilterLoader.LoadFilterFromDll($"{platform}\\TsReader.ax", typeof(TsReader).GUID, true); var baseFilter = _sourceFilter.GetFilter(); IFileSourceFilter fileSourceFilter = (IFileSourceFilter)baseFilter; _tsReader = (ITsReader)baseFilter; _tsReader.SetRelaxedMode(1); _tsReader.SetTsReaderCallback(this); _tsReader.SetRequestAudioChangeCallback(this); _graphBuilder.AddFilter(baseFilter, TSREADER_FILTER_NAME); if (_resourceLocator.NativeResourcePath.IsNetworkResource) { // _resourceAccessor points to an rtsp:// stream or network file var sourcePathOrUrl = SourcePathOrUrl; if (sourcePathOrUrl == null) { throw new IllegalCallException("The TsVideoPlayer can only play network resources of type INetworkResourceAccessor"); } ServiceRegistration.Get <ILogger>().Debug("{0}: Initializing for stream '{1}'", PlayerTitle, sourcePathOrUrl); IDisposable accessEnsurer = null; if (IsLocalFilesystemResource) { accessEnsurer = ((ILocalFsResourceAccessor)_resourceAccessor).EnsureLocalFileSystemAccess(); } using (accessEnsurer) { int hr = fileSourceFilter.Load(SourcePathOrUrl, null); new HRESULT(hr).Throw(); } } else { // _resourceAccessor points to a local or remote mapped .ts file _localFsRaHelper = new LocalFsResourceAccessorHelper(_resourceAccessor); var localFileSystemResourceAccessor = _localFsRaHelper.LocalFsResourceAccessor; if (localFileSystemResourceAccessor == null) { throw new IllegalCallException("The TsVideoPlayer can only play file resources of type ILocalFsResourceAccessor"); } using (localFileSystemResourceAccessor.EnsureLocalFileSystemAccess()) { ServiceRegistration.Get <ILogger>().Debug("{0}: Initializing for stream '{1}'", PlayerTitle, localFileSystemResourceAccessor.LocalFileSystemPath); int hr = fileSourceFilter.Load(localFileSystemResourceAccessor.LocalFileSystemPath, null); new HRESULT(hr).Throw(); } } // Init GraphRebuilder _graphRebuilder = new GraphRebuilder(_graphBuilder, baseFilter, OnAfterGraphRebuild) { PlayerName = PlayerTitle }; }