Skip to content
Permalink
Browse files

first draft

  • Loading branch information...
edoput committed Oct 16, 2015
0 parents commit 18c58faccca9e5171183fb655a17c53c75ba04fd
Showing with 280 additions and 0 deletions.
  1. +6 −0 Makefile
  2. +44 −0 notes.md
  3. +57 −0 src/application.vala
  4. +98 −0 src/main.vala
  5. +75 −0 src/window.vala
@@ -0,0 +1,6 @@
default:
valac src/*.vala --pkg gstreamer-1.0 --pkg gtk+-3.0
doc: notes.md
pandoc $< -s --highlight-style pygments -o notes.html
run: main
./main
@@ -0,0 +1,44 @@
# deps

writing a gstreamer plugin bind requires a handful of tools, the most notable are

- gstreamer1.0-tools, required for gst-inspect, a utility to inspect plugin installed on the system
- gstreamer1.0-plugin-good, the plugins required
- automake
- valadoc
- valac


## inspect for gstreamer plugins

To inspect your system and list the gstreamer plugins installed use `gst-inspect1.0` from the _gstreamer1.0-tools_ package

gst-inspect1.0 ximagesrc

you can find the sample output from my machine in [inspect.log](./inspect.log).


## inspect for gstreamer available plugins from Vala

Here it is a snippet of the code needed to retrieve the names of the plugins available with Gstreamer from Vala

// namespace
using Gst;

int main (string args[])
{
// init Gstreamer
Gst.init(ref args);
// retrieves the singleton of the plugin registry
Registry registry = Registry.get ();
// instantiae and retrieve the list of plugin available
List<Plugin> plugins = registry.get_plugin_list();
// print the name of each plugin
plugins.foreach ((entry)=>{
stdouts.puts (entry.get_name ());
stdouts.puts ("\n");
});
// end
return 0;
}

@@ -0,0 +1,57 @@
using Gst;
using GLib;

public class Lycheese.Application : Gtk.Application
{

private GLib.Settings settings;
static MainWindow main_window;

private void common_init ()
{
if (this.get_windows () == null)
{
// var gtk_settings = Gtk.Settings.get_default ();

// if (gtk_settings != null)
// {
// gtk_settings.Gtk_application_prefer_dark_theme = true;
// }

main_window = new Lycheese.MainWindow (this);

this.add_window (main_window);

}
}

public Application ()
{
GLib.Object(
application_id: "it.edoput.Lycheese",
flags: ApplicationFlags.FLAGS_NONE
);
}

/**
* main window should be a singleton
*/
protected override void activate ()
{
if (this.get_windows () != null)
{
main_window.present ();
}
else
{
common_init ();
}
}
/**
* Destroy the main window, close application
*/
private void on_quit ()
{
main_window.destroy ();
}
}
@@ -0,0 +1,98 @@
using Gst;

public int main(string args[])
{
// Gst.init(ref args);
// Gtk.init(ref args);

// if (!Gst.is_initialized ()) {
// stderr.puts ("Gstremer is not initialised\n");
// return -1;
// }

// Gst.Element screen = Gst.ElementFactory.make ("ximagesrc", "source");
// Gst.Element color_convert = Gst.ElementFactory.make ("videoconvert", "convert");
// Gst.Element encoder = Gst.ElementFactory.make ("x264enc","encoder");
// Gst.Element flv_muxer = Gst.ElementFactory.make ("flvmux", "muxer");
// Gst.Element file = Gst.ElementFactory.make ("filesink", "sink");

// if (screen == null || color_convert == null || encoder == null || flv_muxer == null || file == null) {
// stderr.puts ("Couldn't create a element:\n");

// if (screen == null) stderr.puts ("screen");
// if (color_convert == null) stderr.puts ("color converter\n");
// if (encoder == null) stderr.puts ("x264 encoder\n");
// if (flv_muxer== null) stderr.puts ("flv muxer\n");
// if (file == null) stderr.puts ("file sink\n");

// return -1;
// }


// // create a pipeline
// Pipeline pipe = new Gst.Pipeline ("test");
//
// pipe.add_many (
// screen,
// color_convert,
// encoder,
// flv_muxer,
// file
// );

// if (screen.link (color_convert) != true) {
// stderr.puts ("1");
// return -1;
// }
// if (color_convert.link (encoder) != true) {
// stderr.puts ("2");
// return -1;
// }
// if (encoder.link (flv_muxer) != true) {
// stderr.puts ("3");
// return -1;
// }
// if (flv_muxer.link (file) != true) {
// stderr.puts ("4");
// return -1;
// }


// // set parameters from ximagesrc
// file.set ("location", "./test.flv");

// Gst.StateChangeReturn ret = pipe.set_state (Gst.State.PLAYING);

// if (ret == Gst.StateChangeReturn.FAILURE) {
// stderr.puts ("Couldn't start pipeline\n");
// return -1;
// }
// else if ( ret == Gst.StateChangeReturn.SUCCESS)
// {
// stdout.puts ("Pipeline is playing\n");
// }

// get a bus before setting playing state
// Gst.Bus bus = pipe.get_bus ();

// Message msg = bus.timed_pop_filtered (Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS);

// if (msg != null)
// {
// switch (msg.type)
// {
// case Gst.MessageType.ERROR:
// break;
// case Gst.MessageType.EOS:
// stdout.puts ("Stream ended");
// break;
// default:
// assert_not_reached();
// }
// }

// free resources
// pipe.set_state (Gst.State.NULL);

return new Lycheese.Application ().run (args);
}
@@ -0,0 +1,75 @@

// int main (string[] args)
// {
// Gtk.init(ref args);
//
// var window = new Window();
// window.title = "Lycheese - a streaming solution";
// window.window_position = WindowPosition.CENTER;
// window.destroy.connect (Gtk.main_quit);
//
// var top_widget = new Gtk.Grid();
// var webcam_button = new Gtk.ToggleButton.with_label ("Webcam");
// var screen_button = new Gtk.ToggleButton.with_label ("Screen");
// var both_button = new Gtk.ToggleButton.with_label ("Both");
//
// top_widget.attach (webcam_button, 0, 0);
// top_widget.attach (screen_button, 1, 0);
// top_widget.attach (both_button, 2, 0);
//
// window.add (top_widget);
//
// window.show_all ();
// Gtk.main();
// return 0;
// }

using Gtk;

class Lycheese.MainWindow : Gtk.ApplicationWindow
{
private GLib.Settings settings;

// private Cheese.Camera camera;

private const GLib.ActionEntry ations[] = {
{"settings", show_settings}
};

public MainWindow (Gtk.Application application)
{
GLib.Object (application: application);

Gtk.Settings settings = Gtk.Settings.get_default ();
this.init_gui();
}

private void init_gui () {
this.title = "Lycheese";
this.window_position = WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);

var top_widget = new Gtk.Grid ();

var webcam_button = new Gtk.ToggleButton.with_label ("Webcam");
var screen_button = new Gtk.ToggleButton.with_label ("Screen");
var both_button = new Gtk.ToggleButton.with_label ("Both");
top_widget.attach (webcam_button, 0, 0);
top_widget.attach (screen_button, 1, 0);
top_widget.attach (both_button, 2, 0);

this.add (top_widget);

this.show_all ();
}

public void on_webcam_button_press_event ()
{
return;
}

public void show_settings ()
{
return;
}
}

0 comments on commit 18c58fa

Please sign in to comment.
You can’t perform that action at this time.