Lots of patches to work with most recent python3/GTK/Gst
authorEinar Jørgen Haraldseid <einar@haraldseid.net>
Fri, 2 Jun 2017 20:09:04 +0000 (22:09 +0200)
committerEinar Jørgen Haraldseid <einar@haraldseid.net>
Fri, 2 Jun 2017 20:09:04 +0000 (22:09 +0200)
example1.py
example2+3.py
example2.py
example3.glade
example3.py

index c2e6e6e216f21a75d0c74e22844d2cfa2769500a..9c41425b736a0bdac760385a63becbca5a6c7f53 100755 (executable)
@@ -7,14 +7,15 @@
 # Info on porting python scripts to Gstreamer 1.0 can be found here:
 # https://wiki.ubuntu.com/Novacut/GStreamer1.0
 
-from gi.repository import Gst
-import gobject
+import gi
+gi.require_version('Gst', '1.0')
+from gi.repository import Gst, GObject
 
 class Main:
   def __init__(self):
     # Initiate the pipeline
     Gst.init(None)
-    self.pipeline = Gst.Pipeline("mypipeline")
+    self.pipeline = Gst.Pipeline()
 
     # Add an audiotestsrc element to the pipeline
     self.audiotestsrc = Gst.ElementFactory.make("audiotestsrc", "audio")
@@ -32,5 +33,5 @@ class Main:
 
 # Create the pipelie and enter main loop, quit with ctrl+c
 start = Main()
-mainloop = gobject.MainLoop()
+mainloop = GObject.MainLoop()
 mainloop.run()
index d203020205698866099d8f4e9e53218ee18e4684..44da53d1f009bd0240fd3a66f180978f5c264756 100755 (executable)
@@ -2,17 +2,21 @@
 # Let's see if we can get a viewport AND audio working, combining ex. 2 and 3
 
 # GdkX11 to get access to xid, GstVideo to get access to set_window_handle
+import gi
+gi.require_version('Gtk', '3.0')
+gi.require_version('Gst', '1.0')
+gi.require_version('GstVideo', '1.0')
 from gi.repository import Gtk, Gst, GdkX11, GstVideo
 import signal
 
 class Main:
     def __init__(self):
-        
+
         # Create gui bits and bobs
 
         self.mainwindow = Gtk.Builder()
         self.mainwindow.add_from_file("example3.glade")
-        
+
         signals = {
             "on_play_clicked" : self.OnPlay,
             "on_stop_clicked" : self.OnStop,
@@ -25,18 +29,18 @@ class Main:
 
         # Initiate the pipeline
         Gst.init(None)
-        self.pipeline = Gst.Pipeline("mypipeline")
+        self.pipeline = Gst.Pipeline()
 
         # Add a videotestsrc element to the pipeline, set it to pattern "snow."
         self.videotestsrc = Gst.ElementFactory.make("videotestsrc", "videosource")
         self.videotestsrc.set_property("pattern", "snow")
         self.pipeline.add(self.videotestsrc)
-        
+
         # Add a capsfilter that we want to apply to our videotestsrc
         self.videotestcaps = Gst.ElementFactory.make("capsfilter", "videotestcaps")
         self.videotestcaps.set_property("caps",Gst.Caps.from_string("video/x-raw,width=640,height=480"))
         self.pipeline.add(self.videotestcaps)
-        
+
         # Link the capsfilter to the videotestsrc
         self.videotestsrc.link(self.videotestcaps)
 
@@ -58,17 +62,17 @@ class Main:
 
         # Link the two elements together
         self.audiotestsrc.link(self.pulsesink)
-        
+
         # Set up a bus to our pipeline to get notified when the video is ready
         self.bus = self.pipeline.get_bus()
         self.bus.enable_sync_message_emission()
         self.bus.connect("sync-message::element", self.OnSyncElement)
-        
+
         # Summon the window and connect the window's close button to quit
         self.window = self.mainwindow.get_object("mainwindow")
         self.window.connect("delete-event", Gtk.main_quit)
         self.window.show_all()
-        
+
         # Get window ID of the viewport widget from the GUI
         self.win_id = self.mainwindow.get_object("viewport").get_window().get_xid()
 
@@ -87,7 +91,7 @@ class Main:
     def OnStop(self, widget):
         print "stop"
         self.pipeline.set_state(Gst.State.READY)
-        
+
     def OnQuit(self, widget):
         print "quit"
         Gtk.main_quit()
index 90b846337a1ea2f82ce64a73098d54f5a876376d..1c8c17ec01abb5996cbee87040584dcf56fa2bb3 100755 (executable)
@@ -6,6 +6,9 @@
 # Info on porting python scripts to GStreamer 1.0 can be found here:
 # https://wiki.ubuntu.com/Novacut/GStreamer1.0
 
+import gi
+gi.require_version('Gtk', '3.0')
+gi.require_version('Gst', '1.0')
 from gi.repository import Gtk, Gst
 import signal
 
@@ -15,7 +18,7 @@ class Main:
         # Create gui bits and bobs
 
         self.wTree = Gtk.Builder()
-        self.wTree.add_from_file("example2_2.glade")
+        self.wTree.add_from_file("example2.glade")
         
         signals = {
             "on_play_clicked" : self.OnPlay,
@@ -29,7 +32,7 @@ class Main:
 
         # Initiate the pipeline
         Gst.init(None)
-        self.pipeline = Gst.Pipeline("mypipeline")
+        self.pipeline = Gst.Pipeline()
 
         # Add an audiotestsrc element to the pipeline
         self.audiotestsrc = Gst.ElementFactory.make("audiotestsrc", "audio")
index 8a73a3b8832a2683c2c4088103b311b068741b12..14ff7ba7bd3bbe557fbe950e88fbd2fb6b6b6562 100644 (file)
@@ -7,7 +7,7 @@
     <property name="title" translatable="yes">GStreamer video test</property>
     <property name="icon_name">video-display</property>
     <child>
-      <object class="GtkBox" id="box1">
+      <object class="GtkVBox" id="box1">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
@@ -47,7 +47,7 @@
             <property name="margin_bottom">8</property>
             <property name="yalign">1</property>
             <child>
-              <object class="GtkButtonBox" id="buttonbox1">
+              <object class="GtkHButtonBox" id="buttonbox1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="spacing">8</property>
index dd99993b96d8ee0318eb381ab7ce2c1f58157e6f..f5af59b29b05e6d6915fa254bb72e1deac1a9cce 100755 (executable)
@@ -4,6 +4,10 @@
 # http://bazaar.launchpad.net/~jderose/+junk/gst-examples/view/head:/video-player-1.0
 
 # GdkX11 to get access to xid, GstVideo to get access to set_window_handle
+import gi
+gi.require_version('Gtk', '3.0')
+gi.require_version('Gst', '1.0')
+gi.require_version('GstVideo', '1.0')
 from gi.repository import Gtk, Gst, GdkX11, GstVideo
 import signal
 
@@ -27,7 +31,7 @@ class Main:
 
         # Initiate the pipeline
         Gst.init(None)
-        self.pipeline = Gst.Pipeline("mypipeline")
+        self.pipeline = Gst.Pipeline()
 
         # Add a videotestsrc element to the pipeline, set it to pattern "snow."
         self.videotestsrc = Gst.ElementFactory.make("videotestsrc", "videosource")
@@ -63,23 +67,23 @@ class Main:
         self.win_id = self.mainwindow.get_object("viewport").get_window().get_xid()
 
 
-    # When we get a message that video is ready to display, set the 
+    # When we get a message that video is ready to display, set the
     # correct window id to hook it to our viewport
     def OnSyncElement(self, bus, message):
         if message.get_structure().get_name() == "prepare-window-handle":
-            print "prepare-window-handle"
+            print("prepare-window-handle")
             message.src.set_window_handle(self.win_id)
 
     def OnPlay(self, widget):
-        print "play"
+        print("play")
         self.pipeline.set_state(Gst.State.PLAYING)
 
     def OnStop(self, widget):
-        print "stop"
+        print("stop")
         self.pipeline.set_state(Gst.State.READY)
         
     def OnQuit(self, widget):
-        print "quit"
+        print("quit")
         Gtk.main_quit()
 
     # Workaround to get Ctrl+C to terminate from command line