Merge lp:~stolowski/unity-lens-video/unity-lens-videos.use-preview-player into lp:unity-lens-video

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 88
Merged at revision: 87
Proposed branch: lp:~stolowski/unity-lens-video/unity-lens-videos.use-preview-player
Merge into: lp:unity-lens-video
Diff against target: 90 lines (+21/-22)
1 file modified
src/unity-lens-video (+21/-22)
To merge this branch: bzr merge lp:~stolowski/unity-lens-video/unity-lens-videos.use-preview-player
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Łukasz Zemczak Pending
Review via email: mp+121040@code.launchpad.net

Commit message

Use preview-player video_properties() DBus call instead of gstreamer-0.11 (1.0).

Description of the change

Use preview-player video_properties() DBus call instead of gstreamer-0.11 (1.0).

To post a comment you must log in.
88. By Paweł Stołowski

Preview: call dbus via dbus.Interface(...) method name rather then a callable method object.

Revision history for this message
Michal Hruby (mhr3) wrote :

Works well with latest preview player.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-lens-video'
2--- src/unity-lens-video 2012-08-14 12:44:20 +0000
3+++ src/unity-lens-video 2012-08-23 16:22:25 +0000
4@@ -26,10 +26,7 @@
5 from zeitgeist import client, datamodel
6 import time
7 import fractions
8-
9-import gi
10-gi.require_version("Gst", "1.0")
11-gi.require_version("GstPbutils", "1.0")
12+import dbus
13
14 #pylint: disable=E0611
15 from gi.repository import (
16@@ -37,9 +34,7 @@
17 GObject,
18 Gio,
19 Unity,
20- Dee,
21- Gst,
22- GstPbutils
23+ Dee
24 )
25 #pylint: enable=E0611
26
27@@ -71,6 +66,10 @@
28 except:
29 raise SystemExit(1)
30
31+PREVIEW_PLAYER_DBUS_NAME = "com.canonical.Unity.Lens.Music.PreviewPlayer"
32+PREVIEW_PLAYER_DBUS_PATH = "/com/canonical/Unity/Lens/Music/PreviewPlayer"
33+PREVIEW_PLAYER_DBUS_IFACE = PREVIEW_PLAYER_DBUS_NAME
34+
35 # pylint: disable=R0903
36 class Daemon:
37
38@@ -104,6 +103,7 @@
39 filters = []
40 self._lens.props.filters = filters
41
42+ self.bus = dbus.SessionBus()
43
44 # Create the scope
45 self._scope = Unity.Scope.new("/net/launchpad/lens/video/main")
46@@ -142,23 +142,23 @@
47 subtitle = time.strftime("%x, %X", time.localtime(os.path.getmtime(GLib.filename_from_uri(uri, None))))
48 desc = model.get_string(iter, 5);
49 preview = Unity.MoviePreview.new(title, subtitle, desc, None)
50+
51 # we may get remote uris from zeitgeist - fetch details for local files only
52 if uri.startswith("file://"):
53 preview.props.image_source_uri = uri
54- try:
55- discoverer = GstPbutils.Discoverer.new(2 * 1000000000) #2 seconds
56- discoverer_info = discoverer.discover_uri(uri)
57- video_streams = discoverer_info.get_video_streams()
58- # note: the container may have multiple video and audio streams, we just get properties of the first one
59- if video_streams and len(video_streams) > 0:
60- vstream = video_streams[0]
61- dimensions = str(vstream.get_width()) + "*" + str(vstream.get_height())
62- if vstream.get_width() > 0 and vstream.get_height() > 0:
63- gcd = fractions.gcd(vstream.get_width(), vstream.get_height())
64- dimensions += ", " + str(vstream.get_width() / gcd) + ":" + str(vstream.get_height() / gcd)
65- preview.add_info(Unity.InfoHint.new("format", _("Format"), None, GstPbutils.pb_utils_get_codec_description(vstream.get_caps())))
66- preview.add_info(Unity.InfoHint.new("dimensions", _("Dimensions"), None, dimensions))
67- preview.add_info(Unity.InfoHint.new("size", _("Size"), None, GLib.format_size(os.path.getsize(GLib.filename_from_uri(uri, None)))))
68+ try:
69+ player = self.bus.get_object (PREVIEW_PLAYER_DBUS_NAME, PREVIEW_PLAYER_DBUS_PATH)
70+ props = dbus.Interface (player, PREVIEW_PLAYER_DBUS_IFACE).VideoProperties(uri)
71+ width = props['width']
72+ height = props['height']
73+ codec = props['codec']
74+ dimensions = str(width) + "*" + str(height)
75+ if width > 0 and height > 0:
76+ gcd = fractions.gcd(width, height)
77+ dimensions += ", " + str(width / gcd) + ":" + str(height / gcd)
78+ preview.add_info(Unity.InfoHint.new("format", _("Format"), None, codec))
79+ preview.add_info(Unity.InfoHint.new("dimensions", _("Dimensions"), None, dimensions))
80+ preview.add_info(Unity.InfoHint.new("size", _("Size"), None, GLib.format_size(os.path.getsize(GLib.filename_from_uri(uri, None)))))
81 except Exception as e:
82 print "Couldn't get video details", e
83 show_folder = Unity.PreviewAction.new("show-in-folder", _("Show in Folder"), None)
84@@ -498,7 +498,6 @@
85 except:
86 raise SystemExit(1)
87
88- Gst.init(sys.argv)
89 daemon = Daemon()
90 GObject.MainLoop().run()
91

Subscribers

People subscribed via source and target branches