Changeset 8489 for branches/jingle/src
- Timestamp:
- 08/11/07 23:47:53 (17 months ago)
- Location:
- branches/jingle/src/common
- Files:
-
- 2 modified
-
farsight/farsight.override (modified) (1 diff)
-
jingle.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/jingle/src/common/farsight/farsight.override
r8486 r8489 82 82 } 83 83 // g_list_free(list); (a const list, we don't free it?) 84 return ret; 85 } 86 %% 87 override farsight_stream_get_native_candidate kwargs 88 static PyObject* _wrap_farsight_stream_get_native_candidate(PyGObject *self, 89 PyObject *args, 90 PyObject *kwargs) 91 { 92 static char* kwlist[] = {"candidate_id", NULL}; 93 char* candidate_id; 94 GList* list; 95 FarsightTransportInfo* data; 96 PyObject* ret; 97 PyObject* item; 98 99 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &candidate_id)) 100 return NULL; 101 102 list = farsight_stream_get_native_candidate(FARSIGHT_STREAM(self->obj), candidate_id); 103 data = list->data; 104 105 ret = PyDict_New(); 106 107 PyDict_SetItemString(ret, "candidate_id", item=PyString_FromString(data->candidate_id)); 108 Py_DECREF(item); 109 110 PyDict_SetItemString(ret, "component", item=PyInt_FromLong(data->component)); 111 Py_DECREF(item); 112 113 PyDict_SetItemString(ret, "ip", item=PyString_FromString(data->ip)); 114 Py_DECREF(item); 115 116 PyDict_SetItemString(ret, "port", item=PyInt_FromLong(data->port)); 117 Py_DECREF(item); 118 119 PyDict_SetItemString(ret, "proto", item=PyInt_FromLong(data->proto)); 120 Py_DECREF(item); 121 122 PyDict_SetItemString(ret, "proto_subtype", item=PyString_FromString(data->proto_subtype)); 123 Py_DECREF(item); 124 125 PyDict_SetItemString(ret, "proto_profile", item=PyString_FromString(data->proto_profile)); 126 Py_DECREF(item); 127 128 PyDict_SetItemString(ret, "preference", item=PyFloat_FromDouble(data->preference)); 129 Py_DECREF(item); 130 131 PyDict_SetItemString(ret, "type", item=PyInt_FromLong(data->type)); 132 Py_DECREF(item); 133 134 PyDict_SetItemString(ret, "username", item=PyString_FromString(data->username)); 135 Py_DECREF(item); 136 137 PyDict_SetItemString(ret, "password", item=PyString_FromString(data->password)); 138 Py_DECREF(item); 139 140 g_list_free(list); 141 84 142 return ret; 85 143 } -
branches/jingle/src/common/jingle.py
r8467 r8489 15 15 import gajim 16 16 import xmpp 17 18 # ugly hack 19 import sys, dl, gst 20 sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL) 21 import farsight 22 sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_LOCAL) 23 FARSIGHT_MEDIA_TYPE_AUDIO=0 24 FARSIGHT_STREAM_DIRECTION_BOTH=3 25 FARSIGHT_NETWORK_PROTOCOL_UDP=0 26 FARSIGHT_CANDIDATE_TYPE_LOCAL=0 17 27 18 28 import meta … … 69 79 } 70 80 81 # for making streams using farsight 82 self.p2psession = farsight.farsight_session_factory_make('rtp') 83 self.p2psession.connect('error', self.on_p2psession_error) 84 71 85 ''' Middle-level functions to manage contents. Handle local content 72 86 cache and send change notifications. ''' … … 147 161 148 162 149 def sessionInitiateCB(self, stanza):163 def __sessionInitiateCB(self, stanza, jingle, error): 150 164 ''' We got a jingle session request from other entity, 151 165 therefore we are the receiver... Unpack the data. ''' 152 jingle = stanza.getTag('jingle')153 166 self.initiator = jingle['initiator'] 154 167 self.responder = self.ourjid … … 173 186 174 187 self.state = JingleStates.pending 188 189 def on_p2psession_error(self, *anything): 190 print "Farsight session error!" 175 191 176 192 ''' Methods that make/send proper pieces of XML. They check if the session … … 359 375 def __init__(self, session, node=None): 360 376 self.session = session 361 362 if node is None: 363 self.audio = JingleAudioSession(self) 364 else: 365 self.audio = JingleAudioSession(self, node.getTag('content')) 366 self.transport = JingleICEUDPSession(self) 377 self.codecs = None 378 379 #if node is None: 380 # self.audio = JingleAudioSession(self) 381 #else: 382 # self.audio = JingleAudioSession(self, node.getTag('content')) 383 #self.transport = JingleICEUDPSession(self) 384 self.setupStream() 367 385 368 386 def toXML(self): … … 370 388 return xmpp.Node('content', 371 389 attrs={'name': self.name, 'creator': self.creator, 'profile': 'RTP/AVP'}, 372 payload=[self.audio.toXML(), self.transport.toXML()]) 390 payload=[ 391 xmpp.Node(xmpp.NS_JINGLE_AUDIO+' description', payload=self.getCodecs()), 392 xmpp.Node(xmpp.NS_JINGLE_ICE_UDP+' transport') 393 ]) 394 395 def setupStream(self): 396 self.p2pstream = self.session.p2psession.create_stream(FARSIGHT_MEDIA_TYPE_AUDIO, FARSIGHT_STREAM_DIRECTION_BOTH) 397 self.p2pstream.set_property('transmitter', 'libjingle') 398 self.p2pstream.connect('error', self.on_p2pstream_error) 399 self.p2pstream.connect('new-active-candidate-pair', self.on_p2pstream_new_active_candidate_pair) 400 self.p2pstream.connect('codec-changed', self.on_p2pstream_codec_changed) 401 self.p2pstream.connect('native-candidates-prepared', self.on_p2pstream_native_candidates_prepared) 402 self.p2pstream.connect('state-changed', self.on_p2pstream_state_changed) 403 self.p2pstream.connect('new-native-candidate', self.on_p2pstream_new_native_candidate) 404 self.p2pstream.prepare_transports() 405 406 def on_p2pstream_error(self, *whatever): pass 407 def on_p2pstream_new_active_candidate_pair(self, *whatever): pass 408 def on_p2pstream_codec_changed(self, *whatever): pass 409 def on_p2pstream_native_candidates_prepared(self, *whatever): pass 410 def on_p2pstream_state_changed(self, *whatever): pass 411 def on_p2pstream_new_native_candidate(self, *whatever): pass 412 def getCodecs(self): 413 codecs=self.p2pstream.get_local_codecs() 414 return (xmpp.Node('payload', attrs=a) for a in codecs) 373 415 374 416 class ConnectionJingle(object): … … 429 471 jingle = JingleSession(self, weinitiate=True, jid=jid) 430 472 self.addJingle(jingle) 431 jingle.addContent('voice', JingleVoiP( ))473 jingle.addContent('voice', JingleVoiP(jingle)) 432 474 jingle.startSession()
