1
2
3 import pygtk
4 pygtk.require('2.0')
5
6 import gobject
7 gobject.threads_init()
8
9 import pygst
10 pygst.require('0.10')
11
12 import gst
13 import gst.interfaces
14 from elisa.core.utils import classinit, signal
15 from elisa.core.media_uri import MediaUri
16
17 from fluendo_dvd.PipePlayer import *
18
19 DVD_ACTION_BUTTON_ACTIVATE = "Return"
20 DVD_ACTION_BUTTON_LEFT = "Left";
21 DVD_ACTION_BUTTON_RIGHT = "Right"
22 DVD_ACTION_BUTTON_UP = "Up"
23 DVD_ACTION_BUTTON_DOWN = "Down"
24 DVD_ACTION_MENU_TITLE = "t"
25 DVD_ACTION_MENU_ANGLE = "a"
26 DVD_ACTION_MENU_PTT = "p"
27 DVD_ACTION_MENU_ROOT_OR_RESUME = "m"
28 DVD_ACTION_SEARCH_PREV_PG = "comma"
29 DVD_ACTION_SEARCH_NEXT_PG = "period"
30 DVD_ACTION_BUTTON_ANGLE_NEXT = "plus"
31 DVD_ACTION_BUTTON_ANGLE_PREV = "minus"
32 DVD_R = "r"
33
34
35
37
38
39 __metaclass__ = classinit.ClassInitMeta
40 __classinit__ = classinit.build_properties
41
42 in_menu = signal.Signal('in_menu', bool)
43
45
46 self._dvd_player = DVDPlayer(gpl=gpl)
47 self._imagesink = None
48 self.timeout = 250 * gst.MSECOND
49 self._is_menu = False
50 bus = self._dvd_player.pipeline.get_bus()
51 bus.connect('message', self.on_message)
52
55
57 state = self.get_state()
58
59 if state[1] == gst.STATE_READY and action == DVD_ACTION_MENU_ROOT_OR_RESUME:
60 return
61
62 if self._imagesink:
63 if self._imagesink:
64 s = gst.structure_from_string( "application/x-gst-navigation,event=key-release,key=%s" % action )
65 event = gst.event_new_navigation(s)
66 self._imagesink.send_event(event)
67
69 """ Video sink access
70
71 If we're using playbin, return the value of the 'video-sink'
72 property. Either find the element in the pipeline named
73 'video-sink'
74
75 @rtype: L{gst.BaseSink}
76 """
77
78 return self._dvd_player.vsink
79
81 """ Video sink setter
82
83 @type sink: L{gst.BaseSink}
84 """
85 self._dvd_player.vdecoder.unlink(self._dvd_player.vsink)
86 self._dvd_player.pipeline.remove(self._dvd_player.vsink)
87
88 self._imagesink = sink.get_by_name('pgm_sink')
89 self._dvd_player.vsink = sink
90 self._dvd_player.pipeline.add(sink)
91 self._dvd_player.vdecoder.link(sink)
92
93
95 vlm = self._dvd_player.pipeline.get_by_name('vlm')
96 return vlm
97
105
110
112 if message.structure is None:
113 return
114 """
115 if message.structure.get_name() == 'prepare-xwindow-id':
116 message.src.set_property('force-aspect-ratio', True)
117 """
118 if message.type == gst.MESSAGE_ELEMENT and message.structure.get_name() == 'application/x-gst-dvd':
119 self._is_menu = message.structure['in-menu']
120 self.in_menu.emit(self._is_menu)
121
123 freezefile = None
124
125 if isinstance(uri, MediaUri) and uri.scheme != 'dvd':
126 path = uri.path
127 else:
128 path = None
129
130 self._dvd_player.reader.set_location (path, freezefile)
131
132
134 """
135 Returns the duration of the currently playing context
136
137 @rtype: gst.FORMAT_TIME
138 """
139 if self._dvd_player.pipeline.get_state(self.timeout)[1] not in (gst.STATE_PLAYING, gst.STATE_PAUSED):
140 return gst.CLOCK_TIME_NONE
141
142 try:
143 duration, format = self._dvd_player.pipeline.query_duration(gst.FORMAT_TIME)
144 except:
145
146 duration = gst.CLOCK_TIME_NONE
147
148 return duration
149
151 """
152 Returns the duration of the currently playing context
153
154 @rtype: long in nanoseconds,
155 """
156 duration = self.gst_duration
157 if duration == gst.CLOCK_TIME_NONE:
158 duration = 0
159
160 return duration
161
163 """
164 Returns the position of the currently playing context
165
166 @rtype: gst.FORMAT_TIME
167 """
168
169 if self._dvd_player.pipeline.get_state(self.timeout)[1] not in (gst.STATE_PLAYING, gst.STATE_PAUSED):
170 return gst.CLOCK_TIME_NONE
171
172 try:
173 position, format = self._dvd_player.pipeline.query_position(gst.FORMAT_TIME)
174 except:
175
176 position = gst.CLOCK_TIME_NONE
177
178 return position
179
180
182 """
183 Returns the position of the currently playing context
184
185 @rtype: long in nanoseconds,
186 """
187 position = self.gst_position
188 if position == gst.CLOCK_TIME_NONE:
189 position = 0
190
191 return position
192
194 """
195 @param location: time to seek to, in nanoseconds
196 """
197 res = self._dvd_player.seek(location)
198
200 self._dvd_player.pause()
201
203 self._dvd_player.play()
204
206 self._dvd_player.stop()
207
210
212 return self._dvd_player
213