Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Gtk;
- using Gst;
- public class VideoSample : Window {
- private DrawingArea drawing_area;
- private Pipeline pipeline;
- private Element src;
- private Element demux;
- private Element decoder;
- private Element sink;
- private ulong xid;
- public VideoSample () {
- create_widgets ();
- setup_gst_pipeline ();
- }
- private void create_widgets () {
- var vbox = new Box (Orientation.VERTICAL, 0);
- drawing_area = new DrawingArea ();
- drawing_area.realize.connect(on_realize);
- vbox.pack_start (drawing_area, true, true, 0);
- var play_button = new Button.from_stock (Stock.MEDIA_PLAY);
- play_button.clicked.connect (on_play);
- var stop_button = new Button.from_stock (Stock.MEDIA_STOP);
- stop_button.clicked.connect (on_stop);
- var quit_button = new Button.from_stock (Stock.QUIT);
- quit_button.clicked.connect (Gtk.main_quit);
- var bb = new ButtonBox (Orientation.HORIZONTAL);
- bb.add (play_button);
- bb.add (stop_button);
- bb.add (quit_button);
- vbox.pack_start (bb, false, true, 0);
- add (vbox);
- resize(640,480);
- }
- private void setup_gst_pipeline () {
- pipeline = new Pipeline ("mypipeline");
- src = ElementFactory.make ("souphttpsrc", "video");
- src.set("location","http://admin:12345@192.168.1.100/nphMotionJpeg?Resolution=320x240&Quality=Standard&Framerate=1");
- src.set("do-timestamp",1);
- demux = ElementFactory.make ("multipartdemux","demuxer");
- decoder = ElementFactory.make ("jpegdec","jpg");
- sink = ElementFactory.make ("xvimagesink", "sink");
- pipeline.add_many (src, demux, decoder, sink);
- demux.pad_added.connect((ev, pad) => {
- pad.link(decoder.get_pad("sink"));
- });
- src.link (demux);
- decoder.link (sink);
- }
- private void on_realize() {
- xid = (ulong)Gdk.X11Window.get_xid(drawing_area.get_window());
- }
- private void on_play () {
- var xoverlay = sink as XOverlay;
- xoverlay.set_xwindow_id (xid);
- pipeline.set_state (State.PLAYING);
- }
- private void on_stop () {
- pipeline.set_state (State.READY);
- }
- public static int main (string[] args) {
- Gst.init (ref args);
- Gtk.init (ref args);
- var sample = new VideoSample ();
- sample.show_all ();
- Gtk.main ();
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement