examples/play.py (GstPlayer.query_position)
authorAndy Wingo <wingo@pobox.com>
Fri, 10 Feb 2006 10:53:22 +0000 (10:53 +0000)
committerAndy Wingo <wingo@pobox.com>
Fri, 10 Feb 2006 10:53:22 +0000 (10:53 +0000)
Original commit message from CVS:
2006-02-10  Andy Wingo  <wingo@pobox.com>

* examples/play.py (GstPlayer.query_position)
(PlayerWindow.update_scale_cb): Only return position, duration
from query_position -- fixes a bugaboo.
(main): Add some input validation.

* examples/pipeline-tester (data): Add a pipeline to test software
scaling.

ChangeLog
examples/pipeline-tester
examples/play.py

index abdc384..82b4590 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-02-10  Andy Wingo  <wingo@pobox.com>
+
+       * examples/play.py (GstPlayer.query_position) 
+       (PlayerWindow.update_scale_cb): Only return position, duration
+       from query_position -- fixes a bugaboo.
+       (main): Add some input validation.
+
+       * examples/pipeline-tester (data): Add a pipeline to test software
+       scaling.
+
 2006-02-07  Edward Hervey  <edward@fluendo.com>
 
        * gst/gst.override:
index 5cd99d7..069d891 100755 (executable)
@@ -67,6 +67,12 @@ data = (('Video capture via V4L',
         ('Video test, RGB format',
          'videotestsrc \n'
          '    ! video/x-raw-rgb,red_mask=0xff00 \n'
+         '    ! ffmpegcolorspace \n'
+         '    ! ximagesink'),
+        ('Software scaling',
+         'videotestsrc \n'
+         '    ! video/x-raw-rgb,height=200,width=320 \n'
+         '    ! videoscale method=2 \n'
          '    ! ximagesink'),
         ('Reencode Vorbis to mulaw, play via ALSA',
          'filesrc location=cooldance.ogg \n'
index c3137e7..95f9f25 100644 (file)
@@ -29,20 +29,16 @@ class GstPlayer:
     def query_position(self):
         "Returns a (position, duration) tuple"
         try:
-            ret = self.player.query_position(gst.FORMAT_TIME)
+            position, format = self.player.query_position(gst.FORMAT_TIME)
         except:
             position = gst.CLOCK_TIME_NONE
-        else:
-            position = ret[0]
 
         try:
-            ret = self.player.query_duration(gst.FORMAT_TIME)
+            duration, format = self.player.query_duration(gst.FORMAT_TIME)
         except:
             duration = gst.CLOCK_TIME_NONE
-        else:
-            duration = ret[0]
 
-        return (position, duration, ret[1])
+        return (position, duration)
 
     def seek(self, location):
         """
@@ -222,7 +218,7 @@ class PlayerWindow(gtk.Window):
                 self.update_scale_cb)
 
     def update_scale_cb(self):
-        self.p_position, self.p_duration, format = self.player.query_position()
+        self.p_position, self.p_duration = self.player.query_position()
         if self.p_position != gst.CLOCK_TIME_NONE:
             value = self.p_position * 100.0 / self.p_duration
             self.adjustment.set_value(value)
@@ -260,7 +256,19 @@ class PlayerWindow(gtk.Window):
         self.adjustment.set_value(0.0)
 
 def main(args):
+    def usage():
+        sys.stderr.write("usage: %s URI-OF-MEDIA-FILE\n" % args[0])
+        sys.exit(1)
+
     w = PlayerWindow()
+
+    if len(args) != 2:
+        usage()
+
+    if not gst.uri_is_valid(args[1]):
+        sys.stderr.write("Error: Invalid URI: %s\n" % args[1])
+        sys.exit(1)
+
     w.load_file(args[1])
     w.show_all()