| Trees | Indices | Help |
|---|
|
|
1 # -*- Mode: Python -*-
2 # vi:si:et:sw=4:sts=4:ts=4
3
4 # Flumotion - a streaming media server
5 # Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L.
6 # Copyright (C) 2010,2011 Flumotion Services, S.A.
7 # All rights reserved.
8 #
9 # This file may be distributed and/or modified under the terms of
10 # the GNU Lesser General Public License version 2.1 as published by
11 # the Free Software Foundation.
12 # This file is distributed without any warranty; without even the implied
13 # warranty of merchantability or fitness for a particular purpose.
14 # See "LICENSE.LGPL" in the source distribution for more information.
15 #
16 # Headers in this file shall remain intact.
17
18 import gettext
19 import os
20
21 import gobject
22 import gtk
23
24 from zope.interface import implements
25
26 from flumotion.common import messages
27 from flumotion.common.i18n import N_, gettexter
28 from flumotion.admin.gtk.basesteps import AudioProducerStep, VideoProducerStep
29 from flumotion.admin.assistant.interfaces import IProducerPlugin
30 from flumotion.admin.assistant.models import AudioProducer, VideoProducer, \
31 AudioEncoder, VideoEncoder, VideoConverter
32 from flumotion.ui.fileselector import FileSelectorDialog
33
34 __pychecker__ = 'no-returnvalues'
35 __version__ = "$Rev: 6583 $"
36 _ = gettext.gettext
37 T_ = gettexter('flumotion')
38
39
41 componentType = 'loop-producer'
42
44 super(LoopProducer, self).__init__()
45 self.properties.location = None
46 self.properties.framerate = 5.0
47 self.properties.width = 320
48 self.properties.height = 240
49
51 if isinstance(component, AudioEncoder):
52 return 'audio'
53 elif isinstance(component, (VideoEncoder, VideoConverter)):
54 return 'video'
55 else:
56 raise AssertionError
57
58
60 icon = 'looper.png'
61 componentType = 'filesrc'
62 gladeFile = os.path.join(os.path.dirname(os.path.abspath(__file__)),
63 'wizard.glade')
64
65 _mimetype = 'application/ogg'
66 _audio_required = True
67 _video_required = True
68
72
76
79
82
84 self._blockNext[id] = True
85 if location is None or location == '':
86 self._verify()
87 return
88 self.wizard.waitForTask('looper location check')
89
90 def checkFileFinished(result):
91 validFile, properties = result
92 if not validFile:
93 message = messages.Warning(T_(N_(
94 "'%s' is not a valid file, "
95 "or is not readable on worker '%s'.")
96 % (location, self.worker)))
97 message.id = 'looper-'+id+'-check'
98 self.wizard.add_msg(message)
99 else:
100 self._updateFileProperties(properties)
101 self.wizard.clear_msg('looper-'+id+'-check')
102 self._blockNext[id] = False
103 self.wizard.taskFinished()
104 self._verify()
105 d = self.runInWorker('flumotion.worker.checks.check',
106 'checkMediaFile',
107 location,
108 self._mimetype,
109 self._audio_required,
110 self._video_required)
111 d.addCallback(checkFileFinished)
112
117
121
125
130
135
136 fs = FileSelectorDialog(self.wizard.window,
137 self.wizard.getAdminModel())
138
139 fs.connect('response', response_cb)
140 fs.connect('delete-event', deleteEvent)
141 fs.selector.setWorkerName(self.model.worker)
142 fs.selector.setOnlyDirectoriesMode(False)
143 if location:
144 directory = os.path.dirname(location)
145 else:
146 directory = '/'
147 fs.selector.setDirectory(directory)
148 fs.show_all()
149
152
154
155 def response(fs, response):
156 fs.hide()
157 if response == gtk.RESPONSE_OK:
158 self.model.properties.location = fs.getFilename()
159 self._proxy.update('location')
160 self._clearMessage('location')
161 self._runFileCheck(self.model.properties.location, 'location')
162
163 self._showFileSelector(response,
164 self.model.properties.location)
165
170
171
173 title = _('Loop Video')
174 name = 'Loop Video'
175
179
181 self._audio_required = False
182 self.location.data_type = str
183 self.width.data_type = int
184 self.height.data_type = int
185 self.framerate.data_type = float
186 self._proxy = self.add_proxy(self.model.properties,
187 ['width', 'height',
188 'framerate', 'location'])
189
191 self.model.properties.width = props.get('width',
192 self.model.properties.width)
193 self.model.properties.height = props.get('height',
194 self.model.properties.height)
195 self.model.properties.framerate = props.get('framerate',
196 self.model.properties.framerate)
197 self._proxy.update('width')
198 self._proxy.update('height')
199 self._proxy.update('framerate')
200
201
203 name = 'Loop audio'
204 title = _('Loop audio')
205
209
211 self._video_required = False
212 self.location.data_type = str
213 self._proxy = self.add_proxy(self.model.properties, ['location'])
214 self.video.hide()
215 videoProducer = self.wizard.getStep('Production').getVideoProducer()
216 if not videoProducer or videoProducer.componentType != 'loop-producer':
217 self.location_box.set_sensitive(True)
218 else:
219 self.location.set_text(videoProducer.properties.location)
220 self.location_box.set_sensitive(False)
221
224
225
227 implements(IProducerPlugin)
228
231
233 if type == 'audio':
234 return LoopAudioStep(self.wizard, LoopProducer())
235 elif type == 'video':
236 return LoopVideoStep(self.wizard, LoopProducer())
237
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Mon May 11 00:19:52 2015 | http://epydoc.sourceforge.net |