public void Should_apply_each_filter_in_order_added() { var pipeline = new Pipeline<int, string>(); pipeline.Add(new AddToInput(2)); pipeline.Add(new AppendToOutput("@")); pipeline.Finally(x => x + "!"); var output = pipeline.Execute(2); Assert.That(output, Is.EqualTo("4!@")); }
public void Should_throw_exception_when_chain_goes_too_far() { var pipeline = new Pipeline<int, string>(); pipeline.Add(new AddToInput(3)); Assert.Throws<EndOfChainException>(() => pipeline.Execute(2)); }
public void TestBufferOwnership () { MyTransformIp.Register (); Pipeline pipeline = new Pipeline (); Element src = ElementFactory.Make ("fakesrc"); src["num-buffers"] = 10; Element transform = new MyTransformIp (); Element sink = ElementFactory.Make ("fakesink"); pipeline.Add (src, transform, sink); Element.Link (src, transform, sink); Gst.GLib.MainLoop loop = new Gst.GLib.MainLoop (); pipeline.Bus.AddWatch (delegate (Bus bus, Message message) { switch (message.Type) { case MessageType.Error: Enum err; string msg; message.ParseError (out err, out msg); Assert.Fail (String.Format ("Error message: {0}", msg)); loop.Quit (); break; case MessageType.Eos: loop.Quit (); break; } return true; }); pipeline.SetState (State.Playing); loop.Run (); pipeline.SetState (State.Null); }
public static void Main (string[] args) { Application.Init(); loop = new MainLoop(); // Construct all the elements pipeline = new Pipeline(); appsrc = new Gst.App.AppSrc ("AppSrcDemo"); Element color = ElementFactory.Make ("ffmpegcolorspace"); Element sink = ElementFactory.Make ("autovideosink"); // Link the elements pipeline.Add (appsrc, color, sink); Element.Link (appsrc, color, sink); // Set the caps on the AppSrc to RGBA, 640x480, 4 fps, square pixels Gst.Video.VideoFormat fmt = (BitConverter.IsLittleEndian) ? Gst.Video.VideoFormat.BGRA : Gst.Video.VideoFormat.ARGB; appsrc.Caps = Gst.Video.VideoUtil.FormatNewCaps (fmt, 640, 480, 4, 1, 1, 1); // Connect the handlers appsrc.NeedData += PushAppData; pipeline.Bus.AddSignalWatch(); pipeline.Bus.Message += MessageHandler; // Run, loop, run! pipeline.SetState (State.Playing); loop.Run(); pipeline.SetState (State.Null); }
public void Should_not_require_final_function_when_chain_short_circuits() { var pipeline = new Pipeline<int, string>(); pipeline.Add(new ShortCircuit()); var output = pipeline.Execute(2); Assert.That(output, Is.EqualTo("2")); }
public void Filter_can_modify_output() { var pipeline = new Pipeline<int, string>(); pipeline.Add(new AppendToOutput("#")); pipeline.Finally(x => x + "!"); var output = pipeline.Execute(2); Assert.That(output, Is.EqualTo("2!#")); }
/// <summary> /// Extends the compiler pipeline with x86 compiler stages. /// </summary> /// <param name="pipeline">The pipeline to extend.</param> public override void ExtendCompilerPipeline(Pipeline <BaseCompilerStage> pipeline, CompilerOptions compilerOptions) { if (compilerOptions.MultibootSpecification == MultibootSpecification.V1) { pipeline.InsertAfterFirst <TypeInitializerStage>( new MultibootV1Stage() ); } pipeline.Add(new Intel.CompilerStages.StartUpStage()); }
private void InicializeChainAndContext(ISeedParams seedParams) { _seedContext = new DatabaseInitializer(seedParams); _chainOfResponsability = new Pipeline <DatabaseInitializer, bool>(); foreach (var seed in SeedFactory.CreateStepDefinitions()) { _chainOfResponsability.Add(seed); } _chainOfResponsability.Finally(p => p.EndedProcess); }
public void AfterExistingFunction() { var pipeline = new Pipeline(); pipeline.Add(Noop); pipeline.After(Noop, NopNop); Assert.Equal( new Pipeline.Function[] { Noop, NopNop }, pipeline.Process); }
public void RemoveNonExistingFunctionFromPipeline() { var pipeline = new Pipeline(); pipeline.Add(Noop); Assert.Single(pipeline.Process); pipeline.Remove(NopNop); Assert.Single(pipeline.Process); }
public void Filter_can_modify_output() { var pipeline = new Pipeline <int, string>(); pipeline.Add(new AppendToOutput("#")); pipeline.Finally(x => x + "!"); var output = pipeline.Execute(2); Assert.That(output, Is.EqualTo("2!#")); }
/// <summary> /// Extends the compiler pipeline with x86 compiler stages. /// </summary> /// <param name="pipeline">The pipeline to extend.</param> public override void ExtendCompilerPipeline(Pipeline <BaseCompilerStage> pipeline, CompilerSettings compilerSettings) { if (compilerSettings.Settings.GetValue("Multiboot.Version", string.Empty).ToLower() == "v1") { pipeline.InsertAfterFirst <TypeInitializerStage>( new MultibootV1Stage() ); } pipeline.Add(new Intel.CompilerStages.StartUpStage()); }
public async Task given_filters_when_executing_then_should_execute_in_order() { var input = "one"; var pipeline = new Pipeline <string>(); pipeline .Add(new Append(", two")) .Add(new Append(", three")); var result = await pipeline.ExecuteAsync(input); result.Should().Be("one, two, three"); }
public void ResetEmptiesTheStack() { var pipeline = new Pipeline(); pipeline.Add(Noop); Assert.Single(pipeline.Process); pipeline.Reset(); Assert.Empty(pipeline.Process); }
public async Task ExpandingTokensPassedToTheNextFunction() { var received = new List <string>(); Func <Token, Token> fn = t => { received.Add(t); return(t); }; var pipeline = new Pipeline(); pipeline.Add(ExpandTokenFun); pipeline.Add(fn.ToPipelineFunction()); var cancellationToken = new CancellationToken(); await pipeline.RunString("foo", cancellationToken) .ToList(cancellationToken); Assert.Equal(new[] { "foo", "FOO" }, received); }
public BpmDetector() { try { pipeline = new Pipeline("the pipeline"); filesrc = ElementFactory.Make("filesrc", "the filesrc"); var decodebin = ElementFactory.Make("decodebin", "the decodebin"); var audioconvert = Make("audioconvert"); var bpmdetect = Make("bpmdetect"); fakesink = ElementFactory.Make("fakesink", "the fakesink"); pipeline.Add(filesrc, decodebin, audioconvert, bpmdetect, fakesink); if (!filesrc.Link(decodebin)) { Log.Error("Could not link pipeline elements"); throw new Exception(); } // decodebin and audioconvert are linked dynamically when the decodebin creates a new pad decodebin.PadAdded += (o, args) => { var audiopad = audioconvert.GetStaticPad("sink"); if (audiopad.IsLinked) { return; } var caps = args.NewPad.QueryCaps(); if (caps == null) { return; } var str = caps[0]; if (!str.Name.Contains("audio")) { return; } args.NewPad.Link(audiopad); }; if (!Element.Link(audioconvert, bpmdetect, fakesink)) { Log.Error("Could not link pipeline elements"); throw new Exception(); } pipeline.Bus.AddWatch(OnBusMessage); } catch (Exception e) { Log.Error(e); throw new ApplicationException(Catalog.GetString("Could not create BPM detection driver."), e); } }
internal const double SignatureTimeout = 2.0; //*** Node at level 0 have max N second to transmit the signedTimestamps /// <summary> /// The node at level 1 received the signatures collected from the node at level 0. Check if everything is correct, remove the objects from stand by and start to distributing them /// </summary> /// <param name="signedTimestamps">The decentralized signature</param> /// <param name="fromIp">The IP of the node at level 0 that transmitted the signedTimestamps</param> /// <returns></returns> internal bool UnlockElementsInStandBy(ObjToNode.TimestampVector signedTimestamps, uint fromIp) { var timeLimit = _networkConnection.Now.AddSeconds(-SignatureTimeout).Ticks; // Node at level 0 have max N second to transmit the signedTimestamps bool result = true; lock (Pipeline) { var remove = new List <ObjToNode>(); var addList = new List <ElementPipeline>(); lock (_standByList) { foreach (var objFromNode in _standByList) { if (signedTimestamps.TryGetValue(objFromNode.ShortHash(), out var signature)) { remove.Add(objFromNode); if (objFromNode.Timestamp > timeLimit) // Prevents the node at level 0 from holding the data for a long time, then distributing it late and attempting dishonest distributions { objFromNode.TimestampSignature = signature; var check = objFromNode.CheckSignedTimestamp(_networkConnection, fromIp, true); if (check == ObjToNode.CheckSignedTimestampResult.Ok) { addList.Add(new ElementPipeline(objFromNode)); } else { result = false; Debugger.Break(); } } else { result = false; Debugger.Break(); } } else { result = false; Debugger.Break(); } } foreach (var item in remove) { _standByList.Remove(item); } } Pipeline.Add(addList); } return(result); }
public BpmDetector() { try { pipeline = new Pipeline(); filesrc = new FileSrc(); var decodebin = new DecodeBin2(); var audioconvert = Make("audioconvert"); var bpmdetect = Make("bpmdetect"); fakesink = new FakeSink(); pipeline.Add(filesrc, decodebin, audioconvert, bpmdetect, fakesink); if (!filesrc.Link(decodebin)) { Log.Error("Could not link pipeline elements"); throw new Exception(); } // decodebin and audioconvert are linked dynamically when the decodebin creates a new pad decodebin.NewDecodedPad += delegate(object o, DecodeBin2.NewDecodedPadArgs args) { var audiopad = audioconvert.GetStaticPad("sink"); if (audiopad.IsLinked) { return; } using (var caps = args.Pad.Caps) { using (var str = caps[0]) { if (!str.Name.Contains("audio")) { return; } } } args.Pad.Link(audiopad); }; if (!Element.Link(audioconvert, bpmdetect, fakesink)) { Log.Error("Could not link pipeline elements"); throw new Exception(); } pipeline.Bus.AddWatch(OnBusMessage); //gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (detector->pipeline)), bbd_pipeline_bus_callback, detector); } catch (Exception e) { Log.Exception(e); throw new ApplicationException(Catalog.GetString("Could not create BPM detection driver."), e); } }
private void CreatePipeline() { Log("Initializing Pipeline..", LogLevelFlags.Debug); _pipeline = new Pipeline("pipeline0"); _pipeline.Bus.EnableSyncMessageEmission(); _pipeline.Bus.AddSignalWatch(); _pipeline.Bus.Message += OnBusMessage; _pipeline.AutoFlushBus = true; _pipeline.Bus.Dispose(); if (!_enableOverlay) { _pipeline.Bus.SyncMessage += OnBusSyncMessage; } CreateElements(); if (_enableAudio) { _pipeline.Add(_uriDecodeBin, _audioConvert, _videoConvert, _audioSink, _videoSink); if (!_audioConvert.Link(_audioSink)) { Log("Audio sink could not be linked", LogLevelFlags.Error); return; } } else { _pipeline.Add(_uriDecodeBin, _videoConvert, _videoSink); } if (!_videoConvert.Link(_videoSink)) { Log("Video sink could not be linked", LogLevelFlags.FlagFatal); return; } }
/// <summary> /// Creates a vignette with a specified color /// </summary> private static void CreateVignette(string srcPath, Color color, string dstPath) { const float borderScale = 0.05f; const float blurRadiusScale = borderScale / 2.0f; using (var reader = ImageReader.Create(srcPath)) using (var gc = new GraphicsContainer(reader.Width, reader.Height, reader.DpiX, reader.DpiY)) using (var gr = gc.GetGraphics()) { int offset = (int)(reader.Width * borderScale); gr.FillEllipse(new SolidBrush(RgbColor.White), offset, offset, gc.Width - 2 * offset, gc.Height - 2 * offset); // One pipeline for generating an alpha channel var alphaPipeline = new Pipeline(); alphaPipeline.Add(new ImageGenerator(gc, PixelFormat.Format8bppGrayscale, RgbColor.Black)); alphaPipeline.Add(new Blur(reader.Width * blurRadiusScale)); // And another one for getting a final content var pipeline = new Pipeline(); pipeline.Add(reader); pipeline.Add(new ScaleAlpha(alphaPipeline)); pipeline.Add(new RemoveAlpha(color)); pipeline.Add(ImageWriter.Create(dstPath)); try { pipeline.Run(); } finally { pipeline.DisposeAllElements(); alphaPipeline.DisposeAllElements(); } } }
public async Task ExpandingTokensPassedToOutput() { var pipeline = new Pipeline(); pipeline.Add(ExpandTokenFun); var cancellationToken = new CancellationToken(); IList <string> output = await pipeline.RunString( "foo", cancellationToken) .ToList(cancellationToken); Assert.Equal(new[] { "foo", "FOO" }, output); }
public virtual void Draw(Bitmap bitmap) { var vObject = this as IPipelineExtender; if (vObject != null && vObject.CanExtendPipeline) { var addAlpha = false; if (!bitmap.PixelFormat.HasAlpha) { bitmap.Channels.SetAlpha(1); addAlpha = true; } IEnumerable <IDisposable> deps; var pipeline = new Pipeline(bitmap); var scale = bitmap.DpiX / TargetDpi ?? 1; vObject.ExtendPipeline(pipeline, bitmap, GetColorManagement(), scale, out deps); using (var newBitmap = new Bitmap()) { pipeline.Add(newBitmap); pipeline.Run(); pipeline.Remove(bitmap); Pipeline.Run(newBitmap + bitmap); } if (addAlpha) { bitmap.Channels.RemoveAlpha(ColorManagement.GetTransparentColor(bitmap.PixelFormat)); } pipeline.DisposeAllElements(); if (deps != null) { foreach (var dep in deps) { dep.Dispose(); } } } else { using (var graphics = bitmap.GetAdvancedGraphics()) { Draw(graphics, bitmap, GetColorManagement()); } } }
public async Task break_pipe() { var sp = new Mock <IServiceProvider>(); var pipeline = new Pipeline(sp.Object); pipeline.Add <Pipe1>(); pipeline.Add <Pipe2>(); pipeline.Add <Break>(); pipeline.Add <Pipe3>(); var result = await pipeline.Execute(CancellationToken.None); result.GetAll().Should().HaveCount(3); result.GetOptional <Pipe1>().Should().NotBeNull(); result.GetOptional <Pipe2>().Should().NotBeNull(); result.GetOptional <Break>().Should().NotBeNull(); result.GetOptional <Pipe3>().Should().BeNull(); var logic = new Action(() => { result.Get <Pipe3>(); }); logic.Should().ThrowExactly <MissingDataFromPipelineResultException>(); }
/// <summary> /// Initializes a new instance of the <see cref="ExplorerMethodCompiler" /> class. /// </summary> /// <param name="compiler">The compiler.</param> /// <param name="method">The method.</param> /// <param name="basicBlocks">The basic blocks.</param> /// <param name="threadID">The thread identifier.</param> public ExplorerMethodCompiler(ExplorerCompiler compiler, MosaMethod method, BasicBlocks basicBlocks, int threadID) : base(compiler, method, basicBlocks, threadID) { var compilerOptions = Compiler.CompilerOptions; // Populate the pipeline Pipeline.Add(new IMethodCompilerStage[] { new CILDecodingStage(), new ExceptionPrologueStage(), new OperandAssignmentStage(), new StackSetupStage(), new CILProtectedRegionStage(), new ExceptionStage(), new StaticAllocationResolutionStage(), new CILTransformationStage(), new UnboxValueTypeStage(), (compilerOptions.EnableInlinedMethods) ? new InlineStage() : null, (compilerOptions.EnableSSA) ? new EdgeSplitStage() : null, (compilerOptions.EnableSSA) ? new PhiPlacementStage() : null, (compilerOptions.EnableSSA) ? new EnterSSAStage() : null, (compilerOptions.EnableSparseConditionalConstantPropagation && compilerOptions.EnableSSA) ? new SparseConditionalConstantPropagationStage() : null, (compilerOptions.EnableIROptimizations) ? new IROptimizationStage() : null, //(compilerOptions.TwoPassOptimizationStages && compilerOptions.EnableOptimizations && compilerOptions.EnableSparseConditionalConstantPropagation && compilerOptions.EnableSSA) ? new SparseConditionalConstantPropagationStage() : null, //(compilerOptions.TwoPassOptimizationStages && compilerOptions.EnableOptimizations && compilerOptions.EnableSparseConditionalConstantPropagation && compilerOptions.EnableSSA) ? new IROptimizationStage() : null, (compilerOptions.EnableSSA) ? new LeaveSSA() : null, new IRCleanupStage(), (compilerOptions.EnableInlinedMethods) ? new InlineEvaluationStage() : null, //new StopStage(), new PlatformStubStage(), new PlatformEdgeSplitStage(), new VirtualRegisterRenameStage(), new GreedyRegisterAllocatorStage(), new StackLayoutStage(), new EmptyBlockRemovalStage(), new BlockOrderingStage(), new CodeGenerationStage(compilerOptions.EmitBinary), new GraphVizStage(), (compilerOptions.EmitBinary) ? new ProtectedRegionLayoutStage() : null, (compilerOptions.EmitBinary) ? new DisassemblyStage() : null }); }
private void StartPipeline() { pipeline = new Pipeline(); Element src = ElementFactory.Make("filesrc", "source"), decoder = ElementFactory.Make("decodebin", "decoder"), chroma_print = ElementFactory.Make("chromaprint", "processor"), sink = ElementFactory.Make("fakesink", "sink"); pipeline.Bus.AddSignalWatch(); pipeline.Bus.Message += MsgHandler; if (src == null || decoder == null || chroma_print == null || sink == null) { Console.WriteLine("cannot find necessary gstreamer element (filesrc, decodebin, chromaprint or fakesink)!"); pipeline = null; return; } sink ["sync"] = 0; src ["location"] = filename; pipeline.Add(src); pipeline.Add(decoder); pipeline.Add(chroma_print); pipeline.Add(sink); src.Link(decoder); chroma_print.Link(sink); decoder.PadAdded += (o, args) => { args.NewPad.Link(chroma_print.GetStaticPad("sink")); }; pipeline.SetState(State.Playing); }
private string SavePreviewImage() { if (!_previewImageEnabled) { return(""); } var fileName = _fileCache.GetPublicTempFileName(".jpg"); var width = (int)(Math.Max(SourceImageParams.Width * ActualSizeHorizontalScale / _previewImageResizeRatio, 1)); var height = (int)(Math.Max(SourceImageParams.Height * ActualSizeVerticalScale / _previewImageResizeRatio, 1)); var pipeline = new Pipeline { ImageReader.Create(_fileCache.GetAbsolutePrivateCachePath(SourceCacheFilename)), new Resize(width, height, ResizeInterpolationMode.Anisotropic9) }; if ((SourceImageParams.ColorProfile != null && SourceImageParams.PixelFormat.ColorSpace != ColorSpace.Rgb) || SourceImageParams.PixelFormat.HasAlpha) { var cc = new Transforms.ColorConverter(PixelFormat.Format24bppRgb) { ColorManagementEngine = ColorManagementEngine.LittleCms, DestinationProfile = ColorProfile.FromSrgb() }; pipeline.Add(cc); } pipeline.Add(new JpegWriter(_fileCache.GetAbsolutePublicCachePath(fileName), 60)); pipeline.Run(); pipeline.DisposeAllElements(); return(_fileCache.GetRelativePublicCachePath(fileName)); }
public static Pipeline <T, TOut> AddAssembly <T, TOut>( this Pipeline <T, TOut> pipeline, Assembly assembly, Func <Type, bool> predicate) { var filterTypes = assembly .GetTypes() .Where(t => typeof(IFilter <T, TOut>).IsAssignableFrom(t)); foreach (var filterType in filterTypes.Where(predicate)) { pipeline.Add(filterType); } return(pipeline); }
public async Task RunPassesEntireTokenArrayToPipelineFunction() { _hasRun = false; var pipeline = new Pipeline(); pipeline.Add(ChecksTokenArray); var cancellationToken = new CancellationToken(); await foreach (string resultToken in pipeline.Run( new[] { new Token("foo") }.ToAsyncEnumerable(cancellationToken), cancellationToken)) { Assert.False(true, "Function fn is supposed to eat tokens."); } Assert.True(_hasRun); }
public static void Run(string[] args) { // Initialize GStreamer Gst.Application.Init(ref args); GtkSharp.GstreamerSharp.ObjectManager.Initialize(); string fileName = @"U:/Video/test.avi"; _pipeline = new Pipeline(); _src = ElementFactory.Make("filesrc"); _dbin = ElementFactory.Make("decodebin"); _conv = ElementFactory.Make("videoconvert"); _tee = ElementFactory.Make("tee"); if (new[] { _pipeline, _src, _dbin, _conv, _tee }.Any(e => e == null)) { "Failed to create elements".PrintErr(); return; } _src["location"] = fileName; _pipeline.Add(_src, _dbin, _conv, _tee); if (!Element.Link(_src, _dbin) || !Element.Link(_conv, _tee)) { "Failed to link elements".PrintErr(); return; } _dbin.PadAdded += PadAddedCb; _loop = new GLib.MainLoop(); var bus = _pipeline.Bus; bus.AddSignalWatch(); bus.Message += MessageCb; if (_pipeline.SetState(State.Playing) == StateChangeReturn.Failure) { "Failed to go into PLAYING state".PrintErr(); return; } _loop.Run(); _pipeline.SetState(State.Null); _pipeline.Dispose(); }
/// <summary> /// Initializes a new instance of the <see cref="AotMethodCompiler" /> class. /// </summary> /// <param name="compiler">The compiler.</param> /// <param name="method">The method.</param> /// <param name="basicBlocks">The basic blocks.</param> /// <param name="threadID">The thread identifier.</param> public AotMethodCompiler(BaseCompiler compiler, MosaMethod method, BasicBlocks basicBlocks, int threadID) : base(compiler, method, basicBlocks, threadID) { var compilerOptions = compiler.CompilerOptions; // Populate the pipeline Pipeline.Add(new IMethodCompilerStage[] { new CILDecodingStage(), new ExceptionPrologueStage(), new OperandAssignmentStage(), new StackSetupStage(), new CILProtectedRegionStage(), new ExceptionStage(), new StaticAllocationResolutionStage(), new CILTransformationStage(), new UnboxValueTypeStage(), (compilerOptions.EnableInlinedMethods) ? new InlineStage() : null, (compilerOptions.EnableSSA) ? new EdgeSplitStage() : null, (compilerOptions.EnableSSA) ? new EnterSSAStage() : null, (compilerOptions.EnableSparseConditionalConstantPropagation && compilerOptions.EnableSSA) ? new SparseConditionalConstantPropagationStage() : null, (compilerOptions.EnableIROptimizations) ? new IROptimizationStage() : null, new LowerIRStage(), (compilerOptions.IRLongExpansion && compiler.Architecture.NativePointerSize == 4) ? new IRLongExpansionStage() : null, (compilerOptions.TwoPassOptimizations && compilerOptions.EnableIROptimizations && compilerOptions.EnableSparseConditionalConstantPropagation && compilerOptions.EnableSSA) ? new SparseConditionalConstantPropagationStage() : null, (compilerOptions.TwoPassOptimizations && compilerOptions.EnableIROptimizations && compilerOptions.EnableSparseConditionalConstantPropagation && compilerOptions.EnableSSA) ? new IROptimizationStage() : null, (compilerOptions.EnableSSA) ? new LeaveSSAStage() : null, new IRCleanupStage(), (compilerOptions.EnableInlinedMethods) ? new InlineEvaluationStage() : null, new DevirtualizeCallStage(), new CallStage(), new PlatformStubStage(), new PlatformEdgeSplitStage(), new VirtualRegisterRenameStage(), new GreedyRegisterAllocatorStage(), new StackLayoutStage(), new EmptyBlockRemovalStage(), new BlockOrderingStage(), new CodeGenerationStage(), new PreciseGCStage(), new ProtectedRegionLayoutStage(), }); }
public void TestBufferOwnershipNIp() { MyTransformNIp.Register(); Pipeline pipeline = new Pipeline(); Element src = ElementFactory.Make("fakesrc"); src["sizetype"] = 2; Element capsfilter = ElementFactory.Make("capsfilter"); capsfilter["caps"] = Caps.FromString("foo/bar"); src["num-buffers"] = 10; MyTransformNIp transform = new MyTransformNIp(); Element sink = ElementFactory.Make("fakesink"); pipeline.Add(src, capsfilter, transform, sink); Element.Link(src, capsfilter, transform, sink); GLib.MainLoop loop = new GLib.MainLoop(); pipeline.Bus.AddWatch(delegate(Bus bus, Message message) { switch (message.Type) { case MessageType.Error: Enum err; string msg; message.ParseError(out err, out msg); Assert.Fail(String.Format("Error message: {0}", msg)); loop.Quit(); break; case MessageType.Eos: loop.Quit(); break; } return(true); }); pipeline.SetState(State.Playing); loop.Run(); Assert.IsTrue(transform.transformed); pipeline.SetState(State.Null); }
static void Main(string[] args) { Pipeline PL = new Pipeline(); for (int i = 0; i < 3; i++) { PL.Add(new TestPipe()); } for (int j = 0; j < 5; j++) { PL.Receive(j); RandomEffect(PL); } Console.ReadLine(); PL.Dispose(); }
public static void Run(ref string[] args, string source, string sourceOptions = "") { Console.WriteLine($"Playing video and audio from {source}"); Application.Init(ref args); Pipeline = new Gst.Pipeline("simplepipeline"); VideoSink = new AppSink("videoSink"); Playbin = ElementFactory.Make("playbin", "playbin"); Playbin["uri"] = source; Playbin["video-sink"] = VideoSink; VideoSink["caps"] = Caps.FromString("video/x-raw,format=RGBA"); VideoSink.EmitSignals = true; VideoSink.NewSample += NewVideoSample; VideoSink.Drop = true; VideoSink.Sync = true; VideoSink.Qos = true; Pipeline.Add(Playbin); MainLoop = new GLib.MainLoop(); Pipeline.Bus.AddSignalWatch(); Pipeline.Bus.Message += OnMessage; var ret = Pipeline.SetState(State.Playing); if (ret == StateChangeReturn.Failure) { Console.WriteLine("Unable to set the pipeline to the playing state."); return; } else if (ret == StateChangeReturn.NoPreroll) { IsLive = true; Console.WriteLine("Playing a live stream."); } MainLoop.Run(); Pipeline.SetState(State.Null); }
private void ConstructPipeline() { pipeline = new Pipeline("pipeline"); filesrc = ElementFactory.Make("filesrc", "filesrc") as FileSrc; filesink = ElementFactory.Make("filesink", "filesink") as FileSink; audioconvert = ElementFactory.Make("audioconvert", "audioconvert"); encoder = ElementFactory.Make("wavenc", "wavenc"); decodebin = ElementFactory.Make("decodebin2", "decodebin") as DecodeBin2; decodebin.NewDecodedPad += OnNewDecodedPad; pipeline.Add(filesrc, decodebin, audioconvert, encoder, filesink); filesrc.Link(decodebin); audioconvert.Link(encoder); encoder.Link(filesink); pipeline.Bus.AddWatch(new BusFunc(OnBusMessage)); }
public async Task Post_Dispose_Or_TearDown_Call_Accept_Throws_DisposedError() { var consumers = new IConsumer <object> [1]; consumers[0] = Substitute.For <IConsumer <object> >(); var instance = new Pipeline <object, object>(consumers, IdentityAwaitableAdapter <object> .Default, CancellationToken.None, 1); using (instance) { } Assert.Throws <ObjectDisposedException>(() => instance.Add(new object(), CancellationToken.None)); instance = new Pipeline <object, object>(consumers, IdentityAwaitableAdapter <object> .Default, CancellationToken.None, 1); await instance.TearDown().ConfigureAwait(false); Assert.Throws <ObjectDisposedException>(() => instance.Add(new object(), CancellationToken.None)); }
static void Main(string[] args) { Gst.Application.Init(); TransformSample.Register(); Pipeline pipeline = new Pipeline(); Element videotestsrc = ElementFactory.Make("videotestsrc"); Element transform = new TransformSample(); Element ffmpegcolorspace = ElementFactory.Make("ffmpegcolorspace"); Element videosink = ElementFactory.Make("autovideosink"); pipeline.Add(videotestsrc, transform, ffmpegcolorspace, videosink); Element.Link(videotestsrc, transform, ffmpegcolorspace, videosink); GLib.MainLoop loop = new GLib.MainLoop(); pipeline.Bus.AddSignalWatch(); pipeline.Bus.Message += delegate(object sender, MessageArgs margs) { Message message = margs.Message; switch (message.Type) { case MessageType.Error: Enum err; string msg; message.ParseError(out err, out msg); System.Console.WriteLine(String.Format("Error message: {0}", msg)); loop.Quit(); break; case MessageType.Eos: loop.Quit(); break; } }; pipeline.SetState(State.Playing); loop.Run(); pipeline.SetState(State.Null); }
public static void Main (string [] args) { Application.Init(); Pipeline pipeline = new Pipeline ("pipeline"); FileSrc source = FileSrc.Make ("source"); typefind = TypeFindElement.Make ("typefind"); FakeSink sink = FakeSink.Make ("sink"); source.Location = args[0]; typefind.HaveType += OnHaveType; pipeline.Add (source, typefind, sink); source.Link (typefind); typefind.Link (sink); pipeline.SetState (State.Paused); pipeline.SetState (State.Null); pipeline.Dispose(); }
private void ConstructPipeline() { pipeline = new Pipeline ("pipeline"); filesrc = ElementFactory.Make ("filesrc", "filesrc") as FileSrc; filesink = ElementFactory.Make ("filesink", "filesink") as FileSink; audioconvert = ElementFactory.Make ("audioconvert", "audioconvert"); encoder = ElementFactory.Make ("wavenc", "wavenc"); decodebin = ElementFactory.Make ("decodebin2", "decodebin") as DecodeBin2; decodebin.NewDecodedPad += OnNewDecodedPad; pipeline.Add (filesrc, decodebin, audioconvert, encoder, filesink); filesrc.Link (decodebin); audioconvert.Link (encoder); encoder.Link (filesink); pipeline.Bus.AddWatch (new BusFunc (OnBusMessage)); }
public static void Run () { MySrc.Register (); MySink.Register (); MySrc mysrc = Gst.ElementFactory.Make ("mysrc") as MySrc; MySink mysink = Gst.ElementFactory.Make ("mysink") as MySink; Gst.Pipeline pipeline = new Pipeline ("pipeline"); pipeline.Add (mysrc, mysink); Assert.IsTrue (mysrc.Link (mysink)); loop = new MainLoop (); pipeline.Bus.AddWatch (new BusFunc (BusCb)); pipeline.SetState (Gst.State.Playing); loop.Run (); pipeline.SetState (Gst.State.Null); }
void ButtonOpenClicked(object sender, EventArgs args) { FileChooserDialog dialog = new FileChooserDialog ("Open", this, FileChooserAction.Open, new object[] { "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept }); dialog.SetCurrentFolder (Environment.GetFolderPath (Environment.SpecialFolder.Personal)); if (dialog.Run () == (int)ResponseType.Accept) { _pipelineOK = false; if (_pipeline != null) { _pipeline.SetState (Gst.State.Null); _pipeline.Dispose (); } _scale.Value = 0; _pipeline = new Pipeline (string.Empty); Element playbin = ElementFactory.Make ("playbin", "playbin"); XvImageSink sink = XvImageSink.Make ("sink"); if (_pipeline == null) Console.WriteLine ("Unable to create pipeline"); if (playbin == null) Console.WriteLine ("Unable to create element 'playbin'"); if (sink == null) Console.WriteLine ("Unable to create element 'sink'"); _pipeline.Add (playbin); XOverlayAdapter sinkadapter = new XOverlayAdapter (sink); sinkadapter.XwindowId = gdk_x11_drawable_get_xid (_da.GdkWindow.Handle); playbin.SetProperty ("video-sink", sink); playbin.SetProperty ("uri", "file://" + dialog.Filename); StateChangeReturn sret = _pipeline.SetState (Gst.State.Playing); if (sret == StateChangeReturn.Async) { State state, pending; sret = _pipeline.GetState (out state, out pending, Clock.Second * 5); } if (sret == StateChangeReturn.Success) _pipelineOK = true; else Console.WriteLine ("State change failed for {0} ({1})\n", dialog.Filename, sret); } dialog.Destroy (); }
static void Main (string[] args) { Gst.Application.Init (); TransformSample.Register (); Pipeline pipeline = new Pipeline (); Element videotestsrc = ElementFactory.Make ("videotestsrc"); Element transform = new TransformSample (); Element ffmpegcolorspace = ElementFactory.Make ("ffmpegcolorspace"); Element videosink = ElementFactory.Make ("autovideosink"); pipeline.Add (videotestsrc, transform, ffmpegcolorspace, videosink); Element.Link (videotestsrc, transform, ffmpegcolorspace, videosink); Gst.GLib.MainLoop loop = new Gst.GLib.MainLoop (); pipeline.Bus.AddSignalWatch(); pipeline.Bus.Message += delegate (object sender, MessageArgs margs) { Message message = margs.Message; switch (message.Type) { case MessageType.Error: Enum err; string msg; message.ParseError (out err, out msg); System.Console.WriteLine (String.Format ("Error message: {0}", msg)); loop.Quit (); break; case MessageType.Eos: loop.Quit (); break; } }; pipeline.SetState (State.Playing); loop.Run (); pipeline.SetState (State.Null); }