projects
/
experiments
/
gstreamer.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
5fc6659
)
gst-trick-mode.py: port to GStreamer 1.0
author
Antonio Ospite <ao2@ao2.it>
Wed, 17 Sep 2014 10:54:56 +0000
(12:54 +0200)
committer
Antonio Ospite <ao2@ao2.it>
Wed, 17 Sep 2014 11:44:02 +0000
(13:44 +0200)
python/gst-trick-mode.py
patch
|
blob
|
history
diff --git
a/python/gst-trick-mode.py
b/python/gst-trick-mode.py
index
a4e063f
..
e50e252
100755
(executable)
--- a/
python/gst-trick-mode.py
+++ b/
python/gst-trick-mode.py
@@
-5,10
+5,13
@@
import sys
import sys
-import gobject
-gobject.threads_init()
+import gi
+gi.require_version('Gst', '1.0')
+from gi.repository import Gst
+Gst.init(None)
-import gst
+from gi.repository import GObject
+GObject.threads_init()
class Player:
class Player:
@@
-16,7
+19,7
@@
class Player:
self._filename = filename
self._rate = rate
self._filename = filename
self._rate = rate
- self._player =
gst.element_factory_make("playbin2
", "player")
+ self._player =
Gst.ElementFactory.make("playbin
", "player")
self._player.set_property("uri", filename)
bus = self._player.get_bus()
self._player.set_property("uri", filename)
bus = self._player.get_bus()
@@
-24,8
+27,8
@@
class Player:
bus.connect('message::state-changed', self.on_state_changed)
def run(self):
bus.connect('message::state-changed', self.on_state_changed)
def run(self):
- self._player.set_state(
gst.STATE_
PLAYING)
- loop =
go
bject.MainLoop()
+ self._player.set_state(
Gst.State.
PLAYING)
+ loop =
GO
bject.MainLoop()
loop.run()
def on_state_changed(self, bus, msg):
loop.run()
def on_state_changed(self, bus, msg):
@@
-35,35
+38,35
@@
class Player:
print 'on_state_changed'
old_state, new_state, pending = msg.parse_state_changed()
print "%s -> %s" % (old_state, new_state)
print 'on_state_changed'
old_state, new_state, pending = msg.parse_state_changed()
print "%s -> %s" % (old_state, new_state)
- if old_state ==
gst.STATE_READY and new_state == gst.STATE_
PAUSED:
+ if old_state ==
Gst.State.READY and new_state == Gst.State.
PAUSED:
self.set_rate(self._rate)
def set_rate(self, rate):
self._rate = rate
try:
self.set_rate(self._rate)
def set_rate(self, rate):
self._rate = rate
try:
- position, f
ormat = self._player.query_position(gst.FORMAT_
TIME)
+ position, f
mt = self._player.query_position(Gst.Format.
TIME)
except:
position = 0
# Create the seek event
if rate > 0:
except:
position = 0
# Create the seek event
if rate > 0:
- seek_event =
gst.event_
new_seek(rate,
-
gst.FORMAT_
TIME,
-
gst.SEEK_FLAG_FLUSH | gst.SEEK_FLAG_
ACCURATE,
-
gst.SEEK_TYPE_
SET, position,
-
gst.SEEK_TYPE_
NONE, 0)
+ seek_event =
Gst.Event.
new_seek(rate,
+
Gst.Format.
TIME,
+
Gst.SeekFlags.FLUSH | Gst.SeekFlags.
ACCURATE,
+
Gst.SeekType.
SET, position,
+
Gst.SeekType.
NONE, 0)
else:
else:
- seek_event =
gst.event_
new_seek(rate,
-
gst.FORMAT_
TIME,
-
gst.SEEK_FLAG_FLUSH | gst.SEEK_FLAG_
ACCURATE,
-
gst.SEEK_TYPE_
SET, 0,
-
gst.SEEK_TYPE_
SET, position)
+ seek_event =
Gst.Event.
new_seek(rate,
+
Gst.Format.
TIME,
+
Gst.SeekFlags.FLUSH | Gst.SeekFlags.
ACCURATE,
+
Gst.SeekType.
SET, 0,
+
Gst.SeekType.
SET, position)
if seek_event:
self._player.send_event(seek_event)
if seek_event:
self._player.send_event(seek_event)
-
g
st.info("rate set to %s" % rate)
+
G
st.info("rate set to %s" % rate)
else:
else:
-
g
st.warining("change rate failed")
+
G
st.warining("change rate failed")
def main(args):
def main(args):
@@
-74,7
+77,7
@@
def main(args):
usage()
sys.exit(1)
usage()
sys.exit(1)
- if not
g
st.uri_is_valid(args[1]):
+ if not
G
st.uri_is_valid(args[1]):
sys.stderr.write("Error: Invalid URI: %s\n" % args[1])
sys.exit(1)
sys.stderr.write("Error: Invalid URI: %s\n" % args[1])
sys.exit(1)