summaryrefslogtreecommitdiffstats
path: root/gajim/gajim-port-to-farstream.patch
blob: 5608862a91ff08f68ae9f7979e82135bedc08ae7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
diff -r 0a5aa768f117 src/chat_control.py
--- a/src/chat_control.py	Wed Feb 22 15:36:35 2012 +0100
+++ b/src/chat_control.py	Wed Feb 22 19:26:03 2012 -0500
@@ -1648,15 +1648,15 @@
         self.restore_conversation()
         self.msg_textview.grab_focus()
 
-        # change tooltip text for audio and video buttons if python-farsight is
+        # change tooltip text for audio and video buttons if python-farstream is
         # not installed
-        if not gajim.HAVE_FARSIGHT:
+        if not gajim.HAVE_FARSTREAM:
             tooltip_text = self._audio_button.get_tooltip_text()
             self._audio_button.set_tooltip_text(
-                '%s\n%s' % (tooltip_text, _('Requires python-farsight.')))
+                '%s\n%s' % (tooltip_text, _('Requires python-farstream.')))
             tooltip_text = self._video_button.get_tooltip_text()
             self._video_button.set_tooltip_text(
-                '%s\n%s' % (tooltip_text, _('Requires python-farsight.')))
+                '%s\n%s' % (tooltip_text, _('Requires python-farstream.')))
 
         gajim.ged.register_event_handler('pep-received', ged.GUI1,
             self._nec_pep_received)
@@ -1704,7 +1704,7 @@
 
         # Jingle detection
         if self.contact.supports(NS_JINGLE_ICE_UDP) and \
-        gajim.HAVE_FARSIGHT and self.contact.resource:
+        gajim.HAVE_FARSTREAM and self.contact.resource:
             self.audio_available = self.contact.supports(NS_JINGLE_RTP_AUDIO)
             self.video_available = self.contact.supports(NS_JINGLE_RTP_VIDEO)
         else:
diff -r 0a5aa768f117 src/common/gajim.py
--- a/src/common/gajim.py	Wed Feb 22 15:36:35 2012 +0100
+++ b/src/common/gajim.py	Wed Feb 22 19:26:03 2012 -0500
@@ -169,21 +169,21 @@
 # read.
 HAVE_LATEX = False
 
-HAVE_FARSIGHT = True
+HAVE_FARSTREAM = True
 try:
-    farsight = __import__('farsight')
+    farstream = __import__('farstream')
     import gst
     import glib
     try:
         conference = gst.element_factory_make('fsrtpconference')
-        session = conference.new_session(farsight.MEDIA_TYPE_AUDIO)
+        session = conference.new_session(farstream.MEDIA_TYPE_AUDIO)
         del session
         del conference
     except glib.GError:
-        HAVE_FARSIGHT = False
+        HAVE_FARSTREAM = False
 
 except ImportError:
-    HAVE_FARSIGHT = False
+    HAVE_FARSTREAM = False
 
 HAVE_UPNP_IGD = True
 try:
diff -r 0a5aa768f117 src/common/helpers.py
--- a/src/common/helpers.py	Wed Feb 22 15:36:35 2012 +0100
+++ b/src/common/helpers.py	Wed Feb 22 19:26:03 2012 -0500
@@ -1330,7 +1330,7 @@
             gajim.gajim_optional_features[a].append(xmpp.NS_ESESSION)
         if gajim.config.get_per('accounts', a, 'answer_receipts'):
             gajim.gajim_optional_features[a].append(xmpp.NS_RECEIPTS)
-        if gajim.HAVE_FARSIGHT:
+        if gajim.HAVE_FARSTREAM:
             gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE)
             gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE_RTP)
             gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE_RTP_AUDIO)
diff -r 0a5aa768f117 src/common/jingle.py
--- a/src/common/jingle.py	Wed Feb 22 15:36:35 2012 +0100
+++ b/src/common/jingle.py	Wed Feb 22 19:26:03 2012 -0500
@@ -35,7 +35,7 @@
 import gajim
 
 from jingle_session import JingleSession, JingleStates
-if gajim.HAVE_FARSIGHT:
+if gajim.HAVE_FARSTREAM:
     from jingle_rtp import JingleAudio, JingleVideo
 
 
diff -r 0a5aa768f117 src/common/jingle_rtp.py
--- a/src/common/jingle_rtp.py	Wed Feb 22 15:36:35 2012 +0100
+++ b/src/common/jingle_rtp.py	Wed Feb 22 19:26:03 2012 -0500
@@ -21,7 +21,7 @@
 import socket
 
 import xmpp
-import farsight, gst
+import farstream, gst
 from glib import GError
 
 import gajim
@@ -42,8 +42,8 @@
         JingleContent.__init__(self, session, transport)
         self.media = media
         self._dtmf_running = False
-        self.farsight_media = {'audio': farsight.MEDIA_TYPE_AUDIO,
-                                                        'video': farsight.MEDIA_TYPE_VIDEO}[media]
+        self.farstream_media = {'audio': farstream.MEDIA_TYPE_AUDIO,
+                                                        'video': farstream.MEDIA_TYPE_VIDEO}[media]
 
         self.pipeline = None
         self.src_bin = None
@@ -59,7 +59,7 @@
         self.callbacks['session-terminate'] += [self.__stop]
         self.callbacks['session-terminate-sent'] += [self.__stop]
 
-    def setup_stream(self):
+    def setup_stream(self, on_src_pad_added):
         # pipeline and bus
         self.pipeline = gst.Pipeline()
         bus = self.pipeline.get_bus()
@@ -68,13 +68,12 @@
 
         # conference
         self.conference = gst.element_factory_make('fsrtpconference')
-        self.conference.set_property('sdes-cname', self.session.ourjid)
         self.pipeline.add(self.conference)
         self.funnel = None
 
-        self.p2psession = self.conference.new_session(self.farsight_media)
+        self.p2psession = self.conference.new_session(self.farstream_media)
 
-        participant = self.conference.new_participant(self.session.peerjid)
+        participant = self.conference.new_participant()
         # FIXME: Consider a workaround, here...
         # pidgin and telepathy-gabble don't follow the XEP, and it won't work
         # due to bad controlling-mode
@@ -93,7 +92,9 @@
                     params['stun-ip'] = ip
 
         self.p2pstream = self.p2psession.new_stream(participant,
-                farsight.DIRECTION_RECV, 'nice', params)
+                farstream.DIRECTION_RECV)
+        self.p2pstream.connect('src-pad-added', on_src_pad_added)
+        self.p2pstream.set_transmitter('nice', params)
 
     def is_ready(self):
         return (JingleContent.is_ready(self) and self.candidates_ready)
@@ -117,7 +118,7 @@
         # FIXME: connectivity should not be etablished yet
         # Instead, it should be etablished after session-accept!
         if self.sent:
-            self.p2pstream.set_remote_candidates(candidates)
+            self.p2pstream.add_remote_candidates(candidates)
 
     def batch_dtmf(self, events):
         """
@@ -140,15 +141,14 @@
 
     def _start_dtmf(self, event):
         if event in ('*', '#'):
-            event = {'*': farsight.DTMF_EVENT_STAR,
-                    '#': farsight.DTMF_EVENT_POUND}[event]
+            event = {'*': farstream.DTMF_EVENT_STAR,
+                    '#': farstream.DTMF_EVENT_POUND}[event]
         else:
             event = int(event)
-        self.p2psession.start_telephony_event(event, 2,
-                farsight.DTMF_METHOD_RTP_RFC4733)
+        self.p2psession.start_telephony_event(event, 2)
 
     def _stop_dtmf(self):
-        self.p2psession.stop_telephony_event(farsight.DTMF_METHOD_RTP_RFC4733)
+        self.p2psession.stop_telephony_event()
 
     def _fill_content(self, content):
         content.addChild(xmpp.NS_JINGLE_RTP + ' description',
@@ -170,34 +170,33 @@
         if message.type == gst.MESSAGE_ELEMENT:
             name = message.structure.get_name()
             log.debug('gst element message: %s: %s' % (name, message))
-            if name == 'farsight-new-active-candidate-pair':
+            if name == 'farstream-new-active-candidate-pair':
                 pass
-            elif name == 'farsight-recv-codecs-changed':
+            elif name == 'farstream-recv-codecs-changed':
                 pass
-            elif name == 'farsight-codecs-changed':
-                if self.sent and self.p2psession.get_property('codecs-ready'):
+            elif name == 'farstream-codecs-changed':
+                if self.sent and self.p2psession.get_property('codecs'):
                     self.send_description_info()
-            elif name == 'farsight-local-candidates-prepared':
+            elif name == 'farstream-local-candidates-prepared':
                 self.candidates_ready = True
                 if self.is_ready():
                     self.session.on_session_state_changed(self)
-            elif name == 'farsight-new-local-candidate':
+            elif name == 'farstream-new-local-candidate':
                 candidate = message.structure['candidate']
                 self.transport.candidates.append(candidate)
                 if self.sent:
                     # FIXME: Is this case even possible?
                     self.send_candidate(candidate)
-            elif name == 'farsight-component-state-changed':
+            elif name == 'farstream-component-state-changed':
                 state = message.structure['state']
-                if state == farsight.STREAM_STATE_FAILED:
+                if state == farstream.STREAM_STATE_FAILED:
                     reason = xmpp.Node('reason')
                     reason.setTag('failed-transport')
                     self.session.remove_content(self.creator, self.name, reason)
-            elif name == 'farsight-error':
-                log.error('Farsight error #%d!\nMessage: %s\nDebug: %s' % (
+            elif name == 'farstream-error':
+                log.error('Farstream error #%d!\nMessage: %s' % (
                     message.structure['error-no'],
-                    message.structure['error-msg'],
-                    message.structure['debug-msg']))
+                    message.structure['error-msg']))
         elif message.type == gst.MESSAGE_ERROR:
             # TODO: Fix it to fallback to videotestsrc anytime an error occur,
             # or raise an error, Jingle way
@@ -236,10 +235,10 @@
     def on_negotiated(self):
         if self.accepted:
             if self.transport.remote_candidates:
-                self.p2pstream.set_remote_candidates(self.transport.remote_candidates)
+                self.p2pstream.add_remote_candidates(self.transport.remote_candidates)
                 self.transport.remote_candidates = []
-            # TODO: farsight.DIRECTION_BOTH only if senders='both'
-            self.p2pstream.set_property('direction', farsight.DIRECTION_BOTH)
+            # TODO: farstream.DIRECTION_BOTH only if senders='both'
+            self.p2pstream.set_property('direction', farstream.DIRECTION_BOTH)
         JingleContent.on_negotiated(self)
 
     def __on_remote_codecs(self, stanza, content, error, action):
@@ -252,8 +251,8 @@
             if not codec['id'] or not codec['name'] or not codec['clockrate']:
                 # ignore invalid payload-types
                 continue
-            c = farsight.Codec(int(codec['id']), codec['name'],
-                    self.farsight_media, int(codec['clockrate']))
+            c = farstream.Codec(int(codec['id']), codec['name'],
+                    self.farstream_media, int(codec['clockrate']))
             if 'channels' in codec:
                 c.channels = int(codec['channels'])
             else:
@@ -318,7 +317,7 @@
         self.out_volume.set_property('volume', vol)
 
     def setup_stream(self):
-        JingleRTPContent.setup_stream(self)
+        JingleRTPContent.setup_stream(self, self._on_src_pad_added)
 
         # Configure SPEEX
         # Workaround for psi (not needed since rev
@@ -326,10 +325,10 @@
         #  place 16kHz before 8kHz, as buggy psi versions will take in
         #  account only the first codec
 
-        codecs = [farsight.Codec(farsight.CODEC_ID_ANY, 'SPEEX',
-                farsight.MEDIA_TYPE_AUDIO, 16000),
-                farsight.Codec(farsight.CODEC_ID_ANY, 'SPEEX',
-                farsight.MEDIA_TYPE_AUDIO, 8000)]
+        codecs = [farstream.Codec(farstream.CODEC_ID_ANY, 'SPEEX',
+                farstream.MEDIA_TYPE_AUDIO, 16000),
+                farstream.Codec(farstream.CODEC_ID_ANY, 'SPEEX',
+                farstream.MEDIA_TYPE_AUDIO, 8000)]
         self.p2psession.set_codec_preferences(codecs)
 
         # the local parts
@@ -348,9 +347,8 @@
 
         self.src_bin.get_pad('src').link(self.p2psession.get_property(
                 'sink-pad'))
-        self.p2pstream.connect('src-pad-added', self._on_src_pad_added)
 
-        # The following is needed for farsight to process ICE requests:
+        # The following is needed for farstream to process ICE requests:
         self.pipeline.set_state(gst.STATE_PLAYING)
 
 
@@ -363,7 +361,7 @@
         # TODO: Everything is not working properly:
         # sometimes, one window won't show up,
         # sometimes it'll freeze...
-        JingleRTPContent.setup_stream(self)
+        JingleRTPContent.setup_stream(self, self._on_src_pad_added)
 
         # the local parts
         if gajim.config.get('video_framerate'):
@@ -395,9 +393,8 @@
 
         self.src_bin.get_pad('src').link(self.p2psession.get_property(
             'sink-pad'))
-        self.p2pstream.connect('src-pad-added', self._on_src_pad_added)
 
-        # The following is needed for farsight to process ICE requests:
+        # The following is needed for farstream to process ICE requests:
         self.pipeline.set_state(gst.STATE_PLAYING)
 
     def get_fallback_src(self):
diff -r 0a5aa768f117 src/common/jingle_transport.py
--- a/src/common/jingle_transport.py	Wed Feb 22 15:36:35 2012 +0100
+++ b/src/common/jingle_transport.py	Wed Feb 22 19:26:03 2012 -0500
@@ -73,7 +73,7 @@
 
 
 try:
-    import farsight
+    import farstream
 except Exception:
     pass
 
@@ -82,11 +82,11 @@
         JingleTransport.__init__(self, TransportType.datagram)
 
     def make_candidate(self, candidate):
-        types = {farsight.CANDIDATE_TYPE_HOST: 'host',
-                farsight.CANDIDATE_TYPE_SRFLX: 'srflx',
-                farsight.CANDIDATE_TYPE_PRFLX: 'prflx',
-                farsight.CANDIDATE_TYPE_RELAY: 'relay',
-                farsight.CANDIDATE_TYPE_MULTICAST: 'multicast'}
+        types = {farstream.CANDIDATE_TYPE_HOST: 'host',
+                farstream.CANDIDATE_TYPE_SRFLX: 'srflx',
+                farstream.CANDIDATE_TYPE_PRFLX: 'prflx',
+                farstream.CANDIDATE_TYPE_RELAY: 'relay',
+                farstream.CANDIDATE_TYPE_MULTICAST: 'multicast'}
         attrs = {
                 'component': candidate.component_id,
                 'foundation': '1', # hack
@@ -98,7 +98,7 @@
         }
         if candidate.type in types:
             attrs['type'] = types[candidate.type]
-        if candidate.proto == farsight.NETWORK_PROTOCOL_UDP:
+        if candidate.proto == farstream.NETWORK_PROTOCOL_UDP:
             attrs['protocol'] = 'udp'
         else:
             # we actually don't handle properly different tcp options in jingle
@@ -117,29 +117,29 @@
     def parse_transport_stanza(self, transport):
         candidates = []
         for candidate in transport.iterTags('candidate'):
-            cand = farsight.Candidate()
+            cand = farstream.Candidate()
             cand.component_id = int(candidate['component'])
             cand.ip = str(candidate['ip'])
             cand.port = int(candidate['port'])
             cand.foundation = str(candidate['foundation'])
-            #cand.type = farsight.CANDIDATE_TYPE_LOCAL
+            #cand.type = farstream.CANDIDATE_TYPE_LOCAL
             cand.priority = int(candidate['priority'])
 
             if candidate['protocol'] == 'udp':
-                cand.proto = farsight.NETWORK_PROTOCOL_UDP
+                cand.proto = farstream.NETWORK_PROTOCOL_UDP
             else:
                 # we actually don't handle properly different tcp options in jingle
-                cand.proto = farsight.NETWORK_PROTOCOL_TCP
+                cand.proto = farstream.NETWORK_PROTOCOL_TCP
 
             cand.username = str(transport['ufrag'])
             cand.password = str(transport['pwd'])
 
             #FIXME: huh?
-            types = {'host': farsight.CANDIDATE_TYPE_HOST,
-                                    'srflx': farsight.CANDIDATE_TYPE_SRFLX,
-                                    'prflx': farsight.CANDIDATE_TYPE_PRFLX,
-                                    'relay': farsight.CANDIDATE_TYPE_RELAY,
-                                    'multicast': farsight.CANDIDATE_TYPE_MULTICAST}
+            types = {'host': farstream.CANDIDATE_TYPE_HOST,
+                                    'srflx': farstream.CANDIDATE_TYPE_SRFLX,
+                                    'prflx': farstream.CANDIDATE_TYPE_PRFLX,
+                                    'relay': farstream.CANDIDATE_TYPE_RELAY,
+                                    'multicast': farstream.CANDIDATE_TYPE_MULTICAST}
             if 'type' in candidate and candidate['type'] in types:
                 cand.type = types[candidate['type']]
             else:
diff -r 0a5aa768f117 src/features_window.py
--- a/src/features_window.py	Wed Feb 22 15:36:35 2012 +0100
+++ b/src/features_window.py	Wed Feb 22 19:26:03 2012 -0500
@@ -103,9 +103,9 @@
                 _('Generate XHTML output from RST code (see http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html).'),
                 _('Requires python-docutils.'),
                 _('Requires python-docutils.')),
-            _('Audio / Video'): (self.farsight_available,
+            _('Audio / Video'): (self.farstream_available,
                 _('Ability to start audio and video chat.'),
-                _('Requires python-farsight and gstreamer-plugins-bad.'),
+                _('Requires python-farstream and gstreamer-plugins-bad.'),
                 _('Feature not available under Windows.')),
             _('UPnP-IGD'): (self.gupnp_igd_available,
                 _('Ability to request your router to forward port for file transfer.'),
@@ -258,8 +258,8 @@
             return False
         return True
 
-    def farsight_available(self):
-        return gajim.HAVE_FARSIGHT
+    def farstream_available(self):
+        return gajim.HAVE_FARSTREAM
 
     def gupnp_igd_available(self):
         return gajim.HAVE_UPNP_IGD