<commit_before>/*
 * AppSrc.cs: example of using the appsrc element
 *
 * Authors:
 *   <NAME> <<EMAIL>>
 *
 * Copyright (C) 2009 <NAME>
 *
 */

using System;
using System.Runtime.InteropServices;
using GLib;
using Gst;
using Cairo;

public class AppSrcDemo
{
	static MainLoop loop;
	static Gst.App.AppSrc appsrc;
  static Pipeline pipeline;

	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
		appsrc.Caps = Gst.Video.VideoUtil.FormatNewCaps(Gst.Video.VideoFormat.BGRA, 640, 480, 4, 1, 1, 1);

		// Connect the handlers
		GLib.Signal.Lookup(appsrc, "need-data").AddDelegate(new EventHandler(PushAppData));
		pipeline.Bus.AddSignalWatch();
		pipeline.Bus.Message += MessageHandler;

		// Run, loop, run!
		pipeline.SetState(State.Playing);
		loop.Run();
	}

	static void PushAppData(object o, EventArgs e)
	{
		ulong mseconds = 0;
		if (appsrc.Clock != null)
			mseconds = appsrc.Clock.Time / Clock.MSecond;
		byte[] data = DrawData(mseconds);

		Gst.Buffer buffer = new Gst.Buffer(data);<commit_msg>Set pipeline to null state in the end and use the real NeedData event of appsrc<commit_after>/*
 * AppSrc.cs: example of using the appsrc element
 *
 * Authors:
 *   <NAME> <<EMAIL>>
 *
 * Copyright (C) 2009 <NAME>
 *
 */

using System;
using System.Runtime.InteropServices;
using GLib;
using Gst;
using Cairo;

public class AppSrcDemo
{
	static MainLoop loop;
	static Gst.App.AppSrc appsrc;
	static Pipeline pipeline;

	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
		appsrc.Caps = Gst.Video.VideoUtil.FormatNewCaps(Gst.Video.VideoFormat.BGRA, 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);
	}

	static void PushAppData(object o, Gst.App.NeedDataArgs args)
	{
		ulong mseconds = 0;
		if (appsrc.Clock != null)
			mseconds = appsrc.Clock.Time / Clock.MSecond;
		byte[] data = DrawData(mseconds);

		Gst.Buffer buffer = new Gst.Buffer(data);
{'fraction_non_alphanumeric': 0.12688098495212038, 'fraction_numerical': 0.015047879616963064, 'mean_word_length': 3.966044142614601, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7613795', 'n_tokens_mistral': 1105, 'n_tokens_neox': 987, 'n_words': 272}