public MediaUriPlayer() { LAVFilterDirectory = "./"; Splitter = new FilterName("LAV Splitter", ClassId.LAVFilter, "LAVSplitter.ax"); SplitterSource = new FilterName("LAV Splitter Source", ClassId.LAVFilterSource, "LAVSplitter.ax"); VideoDecoder = new FilterName("LAV Video Decoder", ClassId.LAVFilterVideo, "LAVVideo.ax"); AudioDecoder = new FilterName("LAV Audio Decoder", ClassId.LAVFilterAudio, "LAVAudio.ax"); }
public static IBaseFilter AddFilterToGraph(IGraphBuilder graphBuilder, FilterName filterName, string baseDir, Guid clsid) { if (String.IsNullOrEmpty(filterName.Name)) { return(null); } try { IBaseFilter NewFilter = null; // use local lib if (!String.IsNullOrEmpty(filterName.Filename) && filterName.CLSID != Guid.Empty) { string dllPath = Path.Combine(baseDir, filterName.Filename); NewFilter = FilterFromFile.LoadFilterFromDll(dllPath, filterName.CLSID, !Path.IsPathRooted(dllPath)); } // or try load from system if (NewFilter == null) { foreach (Filter filter in Filters.LegacyFilters) { if (String.Compare(filter.Name, filterName.Name, true) == 0 && (clsid == Guid.Empty || filter.CLSID == clsid)) { NewFilter = (IBaseFilter)Marshal.BindToMoniker(filter.MonikerString); } } } int hr = graphBuilder.AddFilter(NewFilter, filterName.Name); if (hr < 0) { log.Error("Unable to add filter: {0} to graph", filterName); NewFilter = null; } else { log.Debug("Added filter: {0} to graph", filterName); } if (NewFilter == null) { log.Error("Failed filter: {0} not found", filterName); } return(NewFilter); } catch (Exception ex) { log.Error(ex, "Error adding filter: {0} to graph", filterName); return(null); } }
public MediaUriPlayer() { LAVFilterDirectory = "./"; //we are going to use this source for playback because it does not lock the file AsyncFileSource = new FilterName("System AsyncFileSource", ClassId.FilesyncSource, "Not applicable"); //we are only using this source for determine if stream has video(bool HasVideo) NOT for playback // because this source locks the file SplitterSource = new FilterName("LAV Splitter Source", ClassId.LAVFilterSource, "LAVSplitter.ax"); Splitter = new FilterName("LAV Splitter", ClassId.LAVFilter, "LAVSplitter.ax"); VideoDecoder = new FilterName("LAV Video Decoder", ClassId.LAVFilterVideo, "LAVVideo.ax"); AudioDecoder = new FilterName("LAV Audio Decoder", ClassId.LAVFilterAudio, "LAVAudio.ax"); }
protected virtual void InsertAudioFilter(IBaseFilter sourceFilter, FilterName audioDecoder) { if (audioDecoder.CLSID == Guid.Empty) { return; } // Set Audio Codec // Remove Pin var audioPinFrom = DirectShowLib.DsFindPin.ByName(sourceFilter, "Audio"); IPin audioPinTo; if (audioPinFrom != null) { int hr = audioPinFrom.ConnectedTo(out audioPinTo); if (hr >= 0 && audioPinTo != null) { PinInfo pInfo; audioPinTo.QueryPinInfo(out pInfo); FilterInfo fInfo; pInfo.filter.QueryFilterInfo(out fInfo); DirectShowUtil.DisconnectAllPins(m_graph, pInfo.filter); m_graph.RemoveFilter(pInfo.filter); DsUtils.FreePinInfo(pInfo); Marshal.ReleaseComObject(fInfo.pGraph); Marshal.ReleaseComObject(audioPinTo); audioPinTo = null; } Marshal.ReleaseComObject(audioPinFrom); audioPinFrom = null; } DirectShowUtil.AddFilterToGraph(m_graph, audioDecoder, LAVFilterDirectory, Guid.Empty); }