Advertisement
rotrevrep

Untitled

Oct 17th, 2013
1,122
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public struct Picture
  2.     {
  3.         public int width;
  4.         public int height;
  5.         public uint8[] data;
  6.     }
  7. /***/
  8.     public Picture current_picture {
  9.             owned get {
  10.                 Picture pic = Picture();
  11.                 var caps = Gst.Caps.from_string("video/x-raw, format=(string)RGB, pixel-aspect-ratio=(fraction)1/1");
  12.                 Gst.Sample sample;
  13.                 Signal.emit_by_name(playbin, "convert-sample", caps, out sample);
  14.                 if(sample == null)
  15.                     return pic;
  16.                 var sample_caps = sample.get_caps ();
  17.                 if(sample_caps == null)
  18.                     return pic;
  19.                 var structure = sample_caps.get_structure(0).copy ();
  20.                 pic.width = (int)structure.get_value ("width");
  21.                 pic.height = (int)structure.get_value ("height");
  22.                 var memory = sample.get_buffer ().get_memory (0);
  23.                 Gst.MapInfo info;
  24.                 memory.map (out info, Gst.MapFlags.READ);
  25.                 pic.data = info.data;
  26.                 return pic;
  27.             }
  28.         }
Advertisement
RAW Paste Data Copied
Advertisement