rotrevrep

gstreamer-player-1.0 sample - glimagesink renderer

Jan 6th, 2016
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.30 KB | None | 0 0
  1. public class Renderer : Gst.PlayerVideoRenderer, GLib.Object {
  2.     Gst.Element glimagesink;
  3.    
  4.     construct {
  5.         glimagesink = Gst.ElementFactory.make ("glimagesink", null);
  6.     }
  7.    
  8.     public uint* window_handle {
  9.         set {
  10.             (glimagesink as Gst.Video.Overlay).set_window_handle (value);
  11.         }
  12.     }
  13.    
  14.     public Gst.Element create_video_sink (Gst.Player player) {
  15.         return glimagesink;
  16.     }
  17. }
  18.  
  19. public static void main (string[] args) {
  20.     X.init_threads();
  21.     Gtk.init (ref args);
  22.     Gst.init (ref args);
  23.     var window = new Gtk.Window();
  24.     var bar = new Gtk.HeaderBar();
  25.     bar.show_close_button = true;
  26.     bar.title = "Test GStreamer";
  27.     window.set_titlebar (bar);
  28.     var area = new Gtk.DrawingArea();
  29.     var renderer = new Renderer();
  30.     window.destroy.connect (Gtk.main_quit);
  31.     var player = new Gst.Player (renderer, null);
  32.     area.realize.connect (() => {
  33.         renderer.window_handle = (uint*)(area.get_window() as Gdk.X11.Window).get_xid();
  34.         player.play();
  35.     });
  36.     window.add (area);
  37.     player.media_info_updated.connect (info => {
  38.         print ("info : %s\n", info.get_title());
  39.     });
  40.     player.uri = "http://docs.gstreamer.com/media/sintel_trailer-480p.webm";
  41.     window.set_size_request (400, 300);
  42.     window.show_all();
  43.     Gtk.main();
  44. }
  45.  
  46. // valac sample.vala --pkg gtk+-3.0 --pkg gdk-x11-3.0 --pkg gstreamer-video-1.0 --pkg gstreamer-player-1.0
Add Comment
Please, Sign In to add comment