public override bool Build(DirectShowLib.IPin source, IBuild build) { bool result = false; if (Abstract.FindCaptureDeviceNameByIdentifier(this.device).NotNull()) { DirectShowLib.IBaseFilter filter = Abstract.FindCaptureDeviceByIdentifier(this.device, false); if (filter.NotNull() && this.SetFormat(filter)) { if (build.Graph.AddFilter(filter, "Capture") == 0) { foreach (Filters.Abstract candidate in this.Next) { if (result = candidate.Build(filter, 0, build)) { break; } } } else { Error.Log.Append(Error.Level.Debug, "Unable to open capture.", "DirectShow was unable to capture \"" + this.device + "\"."); Exception.GraphError.Check(build.Graph.RemoveFilter(filter)); } } } return(result); }
public override bool Build(DirectShowLib.IPin source, IBuild build) { bool result = false; DirectShowLib.IBaseFilter filter = this.Create(); if (filter.NotNull()) { Exception.GraphError.Check((filter as DirectShowLib.IFileSourceFilter).Load(this.file, new DirectShowLib.AMMediaType())); if (build.Graph.AddFilter(filter, "Asf Reader") == 0) { foreach (Abstract candidate in this.Next) { if (result = candidate.Build(filter, build)) { break; } } } else { Error.Log.Append(Error.Level.Debug, "Unable to open file.", "DirectShow was unable to open file \"" + this.file + "\"."); Exception.GraphError.Check(build.Graph.RemoveFilter(filter)); } } return(result); }
public override DirectShowLib.IBaseFilter Create() { DirectShowLib.IBaseFilter result = null; try { IntPtr handle = FromFile.LoadLibrary(this.path); IntPtr dllGetClassObjectPointer = FromFile.GetProcAddress(handle, "DllGetClassObject"); //Convert the function pointer to a .net delegate DllGetClassObject dllGetClassObject = (DllGetClassObject)System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(dllGetClassObjectPointer, typeof(DllGetClassObject)); System.Guid IClassFactoryGUID = new System.Guid("00000001-0000-0000-C000-000000000046"); //IClassFactory class id object classFactory; System.Guid identifier = this.Identifier; if (dllGetClassObject(ref identifier, ref IClassFactoryGUID, out classFactory) == 0) { System.Guid iBaseFilter = new System.Guid("56a86895-0ad4-11ce-b03a-0020af0ba770"); object filter; (classFactory as IClassFactory).CreateInstance(null, ref iBaseFilter, out filter); result = filter as DirectShowLib.IBaseFilter; } } catch (System.Exception e) { string message = "Filter \"" + this.Description + "\" could not find the file \"" + this.path.ToString() + "\"."; new DirectShow.Binding.Exception.FilterNotFound(Error.Level.Debug, message, e.Message).Throw(); } if (result.IsNull()) { result = base.Create(); } return(result); }
protected override Image Media(DirectShowLib.IBaseFilter filter) { return(new Image() { Type = DirectShowLib.MediaSubType.YUY2, Resolution = new Geometry2D.Integer.Size(720, 480) }); }
void SetOutputMedia(DirectShowLib.IBaseFilter filter, DirectShowLib.AMMediaType media) { DirectShowLib.IPin outPin = DirectShowLib.DsFindPin.ByDirection(filter, DirectShowLib.PinDirection.Output, 0); if (outPin is DirectShowLib.IAMStreamConfig) { Exception.GraphError.Check((outPin as DirectShowLib.IAMStreamConfig).SetFormat(media)); } }
public override DirectShowLib.IBaseFilter Create() { DirectShowLib.IBaseFilter result = base.Create(); if (result is DirectShowLib.IFileSourceFilter) { Binding.Exception.GraphError.Check((result as DirectShowLib.IFileSourceFilter).Load(this.url, new DirectShowLib.AMMediaType())); System.Threading.Thread.Sleep(500); } return(result); }
public override DirectShowLib.IBaseFilter Create() { DirectShowLib.IBaseFilter result = base.Create(); DirectShowLib.IPin pin = DirectShowLib.DsFindPin.ByDirection(result, DirectShowLib.PinDirection.Output, this.Output.Value); if (pin.NotNull() && pin is DirectShowLib.IAMVideoCompression) { Exception.GraphError.Check((pin as DirectShowLib.IAMVideoCompression).put_Quality(1.0)); } return(result); }
public override DirectShowLib.IBaseFilter Create() { this.Configure(new string[] { "Software", "Elecard", "Elecard MPEG Push Demultiplexer", System.IO.Path.GetFileName(System.Environment.GetCommandLineArgs()[0]) }, KeyValue.Create("Latency value for time adjustment", this.Latency) ); return this.filter = base.Create(); }
public virtual bool Build(DirectShowLib.IBaseFilter previous, int i, IBuild build) { bool result = false; DirectShowLib.IPin outPin = DirectShowLib.DsFindPin.ByDirection(previous, DirectShowLib.PinDirection.Output, i); if (outPin.NotNull()) { result = this.Build(outPin, build); } return(result); }
public override DirectShowLib.IBaseFilter Create() { this.Configure(new string[] { "Software", "Elecard", "Elecard MPEG Push Demultiplexer", System.IO.Path.GetFileName(System.Environment.GetCommandLineArgs()[0]) }, KeyValue.Create("Latency value for time adjustment", this.Latency) ); return(this.filter = base.Create()); }
public override DirectShowLib.IBaseFilter Create() { DirectShowLib.IBaseFilter result = base.Create(); if (result is DirectShowLib.IFileSinkFilter) { Binding.Exception.GraphError.Check((result as DirectShowLib.IFileSinkFilter).SetFileName(this.file, new DirectShowLib.AMMediaType() { majorType = DirectShowLib.MediaType.Stream, subType = DirectShowLib.MediaSubType.Mpeg2Program })); } return(result); }
public override bool Build(DirectShowLib.IPin source, IBuild build) { bool result = false; DirectShowLib.IBaseFilter filter = this.Create(); if (filter.NotNull() && build.Graph.AddFilter(filter, this.Description) == 0 && this.PreConfiguration(build)) { result = true; DirectShowLib.PinInfo pinInformation; Exception.GraphError.Check(source.QueryPinInfo(out pinInformation)); DirectShowLib.FilterInfo filterInformation; Exception.GraphError.Check(pinInformation.filter.QueryFilterInfo(out filterInformation)); switch (filterInformation.achName) { case "Capture": this.CreateSource(DirectShowLib.PinCategory.Capture, pinInformation.filter, filter, build); break; case "Source": this.CreateSource(null, pinInformation.filter, filter, build); break; default: if (!(result = (this.FuzzyMatch ? 0 <= build.Graph.Connect(source, DirectShowLib.DsFindPin.ByDirection(filter, DirectShowLib.PinDirection.Input, 0)) : 0 == build.Graph.ConnectDirect(source, DirectShowLib.DsFindPin.ByDirection(filter, DirectShowLib.PinDirection.Input, 0), new DirectShowLib.AMMediaType())))) { Error.Log.Append(Error.Level.Debug, "Unable to connect.", "DirectShow was unable to connect \"" + filterInformation.achName + "\" with \"" + this.Description + "\"."); Exception.GraphError.Check(source.Disconnect()); Exception.GraphError.Check(build.Graph.RemoveFilter(filter)); } break; } if (result &= this.PostConfiguration(build)) { if (this.WaitForOutput.Ticks > 0) { System.Threading.Thread.Sleep(this.WaitForOutput); } for (int i = 0; i < this.Followers.Length; i++) { foreach (Filters.Abstract candidate in this.Followers[i]) { if (result &= candidate.Build(filter, build)) { break; } } } } } return(result); }
public override DirectShowLib.IBaseFilter Create() { DirectShowLib.IBaseFilter result = base.Create(); if (result is DirectShowLib.IFileSinkFilter2) { Binding.Exception.GraphError.Check((result as DirectShowLib.IFileSinkFilter2).SetMode(DirectShowLib.AMFileSinkFlags.OverWrite)); Binding.Exception.GraphError.Check((result as DirectShowLib.IFileSinkFilter2).SetFileName(this.file, new DirectShowLib.AMMediaType() { majorType = DirectShowLib.MediaType.Stream, subType = DirectShowLib.MediaSubType.Mpeg2Transport })); } return(result); }
public override DirectShowLib.IBaseFilter Create() { DirectShowLib.AMMediaType sourceMedia = new DirectShowLib.AMMediaType() { majorType = DirectShowLib.MediaType.Video, subType = DirectShowLib.MediaSubType.H264, formatType = DirectShowLib.FormatType.Mpeg2Video }; // { majorType = DirectShowLib.MediaType.Stream, subType = new Guid("D607A0E7-BE64-4869-B70D-46F2E05D66D0") }; DirectShowLib.IBaseFilter result = base.Create(); if (result.NotNull()) { DirectShow.Binding.Exception.GraphError.Check((result as DirectShowLib.IFileSourceFilter).Load(this.url, sourceMedia)); } return(result); }
public override DirectShowLib.IBaseFilter Create() { DirectShowLib.AMMediaType sourceMedia = new DirectShowLib.AMMediaType() { majorType = DirectShowLib.MediaType.Stream, subType = DirectShowLib.MediaSubType.Mpeg2Transport }; DirectShowLib.IBaseFilter result = base.Create(); if (result.NotNull()) { DirectShow.Binding.Exception.GraphError.Check((result as DirectShowLib.IFileSourceFilter).Load(this.file, sourceMedia)); } return(result); }
public override DirectShowLib.IBaseFilter Create() { DirectShowLib.AMMediaType sourceMedia = new DirectShowLib.AMMediaType() { majorType = DirectShowLib.MediaType.Stream, subType = new Guid("555DC977-D6F1-4C2E-8D64-F58221A91234") }; DirectShowLib.IBaseFilter result = base.Create(); if (result.NotNull()) { DirectShow.Binding.Exception.GraphError.Check((result as DirectShowLib.IFileSourceFilter).Load(this.file, sourceMedia)); } return(result); }
/// <summary> build the capture graph for grabber. </summary> private void SetupGraph(string destFilename, string encoderName) { int hr; // Get the graphbuilder object captureGraphBuilder = new DirectShowLib.CaptureGraphBuilder2() as DirectShowLib.ICaptureGraphBuilder2; IFilterGraph2 filterGraph = new DirectShowLib.FilterGraph() as DirectShowLib.IFilterGraph2; mediaCtrl = filterGraph as DirectShowLib.IMediaControl; IMediaFilter mediaFilt = filterGraph as IMediaFilter; mediaEvent = filterGraph as IMediaEvent; captureGraphBuilder.SetFiltergraph(filterGraph); IBaseFilter aviMux; IFileSinkFilter fileSink = null; hr = captureGraphBuilder.SetOutputFileName(MediaSubType.Avi, destFilename, out aviMux, out fileSink); DsError.ThrowExceptionForHR(hr); DirectShowLib.IBaseFilter compressor = DirectShowUtils.GetVideoCompressor(encoderName); if (compressor == null) { throw new InvalidCodecException(encoderName); } hr = filterGraph.AddFilter(compressor, "compressor"); DsError.ThrowExceptionForHR(hr); // Our data source IBaseFilter source = (IBaseFilter) new GenericSampleSourceFilter(); // Get the pin from the filter so we can configure it IPin ipin = DsFindPin.ByDirection(source, PinDirection.Output, 0); try { // Configure the pin using the provided BitmapInfo ConfigurePusher((IGenericSampleConfig)ipin); } finally { Marshal.ReleaseComObject(ipin); } // Add the filter to the graph hr = filterGraph.AddFilter(source, "GenericSampleSourceFilter"); Marshal.ThrowExceptionForHR(hr); hr = filterGraph.AddFilter(source, "source"); DsError.ThrowExceptionForHR(hr); hr = captureGraphBuilder.RenderStream(null, null, source, compressor, aviMux); DsError.ThrowExceptionForHR(hr); IMediaPosition mediaPos = filterGraph as IMediaPosition; hr = mediaCtrl.Run(); DsError.ThrowExceptionForHR(hr); }
public override DirectShowLib.IBaseFilter Create() { DirectShowLib.IBaseFilter result = null; try { result = Activator.CreateInstance(Type.GetTypeFromCLSID(this.Identifier)) as DirectShowLib.IBaseFilter; } catch (System.Exception e) { string message = "Filter \"" + this.Description + "\" could not find the guid \"" + this.Identifier.ToString() + "\"."; new DirectShow.Binding.Exception.FilterNotFound(Error.Level.Debug, message, e.Message).Throw(); } return(result); }
public override DirectShowLib.IBaseFilter Create() { DirectShowLib.IBaseFilter result = null; try { result = System.Runtime.InteropServices.Marshal.BindToMoniker(this.moniker) as DirectShowLib.IBaseFilter; } catch (System.Exception e) { string message = "Filter \"" + this.Description + "\" could not find the moniker \"" + this.moniker + "\"."; new DirectShow.Binding.Exception.FilterNotFound(Error.Level.Debug, message, e.Message).Throw(); } return(result); }
public override DirectShowLib.IBaseFilter Create() { DirectShowLib.AMMediaType media = new DirectShowLib.AMMediaType() { majorType = DirectShowLib.MediaType.Stream, subType = DirectShowLib.MediaSubType.Mpeg2Program }; DirectShowLib.IBaseFilter result = base.Create(); if (result.NotNull()) { DirectShowLib.FilterInfo info; result.QueryFilterInfo(out info); string info2; result.QueryVendorInfo(out info2); DirectShow.Binding.Exception.GraphError.Check((result as DirectShowLib.IFileSinkFilter).SetFileName(this.filename, media)); } return(result); }
public virtual bool Build(DirectShowLib.IBaseFilter previous, IBuild build) { bool result = false; if (this.Output == -1) { for (int i = 0; i < 6 && !result; i++) { result = this.Build(previous, i, build); } } else { result = this.Build(previous, this.Output.Value, build); } return(result); }
bool SetFormat(DirectShowLib.IBaseFilter filter) { bool result = false; Format.Image wanted = this.Media(filter); if (wanted.NotNull()) { if (wanted.Resolution.NotNull()) { DirectShowLib.AMMediaType[] media = this.GetOutputMediaTypes(filter); if (media.NotNull()) { for (int i = 0; i < media.Length; i++) { DirectShowLib.VideoInfoHeader header = Abstract.GetHeader(media[i]); if (media[i].subType == wanted.Type && header.BmiHeader.Width == wanted.Resolution.Width) { if (header.BmiHeader.Height == wanted.Resolution.Height) { this.SetOutputMedia(filter, media[i]); result = true; break; } else if (wanted.ForceHeight) { header.BmiHeader.Height = wanted.Resolution.Height; header.BmiHeader.ImageSize = header.BmiHeader.Width * header.BmiHeader.Height * header.BmiHeader.BitCount / 8; header.BitRate = (int)((10000000 / header.AvgTimePerFrame) * header.BmiHeader.ImageSize * 8); Abstract.SetHeader(media[i], header); media[i].sampleSize = header.BmiHeader.ImageSize; this.SetOutputMedia(filter, media[i]); result = true; break; } } } } } else { result = true; } } return(result); }
DirectShowLib.AMMediaType[] GetOutputMediaTypes(DirectShowLib.IBaseFilter filter) { DirectShowLib.AMMediaType[] result = null; DirectShowLib.IPin outPin = DirectShowLib.DsFindPin.ByDirection(filter, DirectShowLib.PinDirection.Output, 0); if (outPin is DirectShowLib.IAMStreamConfig) { int count = 0; int size = 0; Exception.GraphError.Check((outPin as DirectShowLib.IAMStreamConfig).GetNumberOfCapabilities(out count, out size)); Buffer.Vector <byte> buffer = new Buffer.Vector <byte>(size); result = new DirectShowLib.AMMediaType[count]; for (int i = 0; i < count; i++) { Exception.GraphError.Check((outPin as DirectShowLib.IAMStreamConfig).GetStreamCaps(i, out result[i], buffer)); } } return(result); }
public override DirectShowLib.IBaseFilter Create() { this.Configure(new string[] { "Software", "Elecard", "Elecard File List Source", System.IO.Path.GetFileName(System.Environment.GetCommandLineArgs()[0]) }, KeyValue.Create("Dynamic length", 1) ); DirectShowLib.IBaseFilter result = base.Create(); if (result is DirectShowLib.IFileSourceFilter) { Binding.Exception.GraphError.Check((result as DirectShowLib.IFileSourceFilter).Load(this.file, new DirectShowLib.AMMediaType() { majorType = DirectShowLib.MediaType.Stream, subType = DirectShowLib.MediaSubType.Mpeg2Transport })); } return(result); }
protected override Image Media(DirectShowLib.IBaseFilter filter) { Image result = null; if (filter is DirectShowLib.IAMAnalogVideoDecoder) { DirectShowLib.AnalogVideoStandard standard; (filter as DirectShowLib.IAMAnalogVideoDecoder).get_TVFormat(out standard); if (standard >= DirectShowLib.AnalogVideoStandard.NTSC_M && standard <= DirectShowLib.AnalogVideoStandard.NTSCMask) { result = new Image() { Type = DirectShowLib.MediaSubType.YUY2, Resolution = new Geometry2D.Integer.Size(720, 480), ForceHeight = true } } ; } return(result); } }
public override DirectShowLib.IBaseFilter Create() { this.Configure(new string[] { "Software", "Elecard", "Elecard NWSource-Plus", System.IO.Path.GetFileName(System.Environment.GetCommandLineArgs()[0]) }, KeyValue.Create("[DS] Data Timeout", this.Timeout) ); DirectShowLib.IBaseFilter result = base.Create(); if (result is DirectShowLib.IFileSourceFilter) { Binding.Exception.GraphError.Check((result as DirectShowLib.IFileSourceFilter).Load(this.url, new DirectShowLib.AMMediaType() { majorType = DirectShowLib.MediaType.Stream, subType = DirectShowLib.MediaSubType.Mpeg2Transport })); System.Threading.Thread.Sleep(500); } return(result); }
public override bool Build(DirectShowLib.IPin source, Imint.Media.DirectShow.Binding.IBuild build) { bool result = false; DirectShowLib.IBaseFilter filter = this.Create(); if (filter.NotNull() && build.Graph.AddFilter(filter, this.Description) == 0) { foreach (DirectShow.Binding.Filters.Abstract candidate in this.Next) { if (result = candidate.Build(filter, build)) { break; } } } else { Error.Log.Append(Error.Level.Debug, "Unable to open file.", "DirectShow was unable to open file \"" + this.file + "\"."); Binding.Exception.GraphError.Check(build.Graph.RemoveFilter(filter)); } return(result); }
public override bool Build(DirectShowLib.IPin source, DirectShow.Binding.IBuild build) { bool result = false; DirectShowLib.IBaseFilter filter = this.Create(); if (build.Graph.AddFilter(filter, "VCS MPEG-4 File Source") == 0) { foreach (DirectShow.Binding.Filters.Abstract candidate in this.Next) { if (result = candidate.Build(filter, build)) { break; } } } else { Error.Log.Append(Error.Level.Debug, "Unable to open Hauppauge Transport Reader.", "VCS MPEG-4 File Source was unable to open file \"" + this.file + "\"."); DirectShow.Binding.Exception.GraphError.Check(build.Graph.RemoveFilter(filter)); } return(result); }
public override bool Build(DirectShowLib.IPin source, DirectShow.Binding.IBuild build) { bool result = false; DirectShowLib.IBaseFilter filter = this.Create(); if (build.Graph.AddFilter(filter, "Elecard NWSource-Plus") == 0) { foreach (DirectShow.Binding.Filters.Abstract candidate in this.Next) { if (result = candidate.Build(filter, build)) { break; } } } else { Error.Log.Append(Error.Level.Debug, "Unable to open Elecard NWSource-Plus Filter.", "Elecard NWSource-Plus Filter was unable to open url \"" + this.url + "\"."); DirectShow.Binding.Exception.GraphError.Check(build.Graph.RemoveFilter(filter)); } return(result); }
public override DirectShowLib.IBaseFilter Create() { return this.encoder = base.Create(); }
protected void CreateSource(DirectShowLib.DsGuid pinCategory, DirectShowLib.IBaseFilter source, DirectShowLib.IBaseFilter destination, IBuild build) { DirectShowLib.ICaptureGraphBuilder2 captureGraph = new DirectShowLib.CaptureGraphBuilder2() as DirectShowLib.ICaptureGraphBuilder2; Exception.GraphError.Check(captureGraph.SetFiltergraph(build.Graph)); Exception.GraphError.Check(captureGraph.RenderStream(pinCategory, DirectShowLib.MediaType.Video, source, null, destination)); }
protected virtual Format.Image Media(DirectShowLib.IBaseFilter filter) { return(new Format.Image()); }